I stated my reasoning behind this article series in the first article which can be found here.
To avoid redundancy please check out the preface over there and let’s get right into action!
note: If I write non sense in this and the next following articles please correct me for the sake of me and others not getting confused and mixed up with things .
Author Assigned Level: Wannabe
Community Assigned Level:
Since we’re starting at the beginning not much knowledge is required at the moment.
- ascii encoding
- basic knowledge about cryptography
These write ups are only my 2 cents on the challenges. So don’t take them too seriously.
HTS.org realistic challenges
Hello esteemed hacker, I hope you have some decent cryptography skills. I have some text I need decrypted.
I work for this company called ToxiCo Industrial Chemicals, which has recently come under fire because of the toxic chemicals we are dumping into the river nearby. Ecological inspectors have reported no problems, but it is widely speculated that they were paid off by ToxiCo management because the water pollution near the ToxiCo factory has always been a serious and widely publicized issue.
I have done some packet sniffing on my network and I have recovered this email that was sent from the CEO of the company to Chief Ecological Inspector Samuel Smith. However, it is encrypted and I cannot seem to decode it using any of my basic decryption tools. I have narrowed it down to the algorithm used to encrypt it, but it is beyond my scope. I was hoping you can take a look at it.
Please check it out.
If you can unscramble it and reply to this message with the original text, it would be much appreciated. Thank you.
What can we extract from the message?
- We have an encrypted email
- We have the used algorithm!
The algorithm site is just a simple two text box interface where you can type a message, choose a password and get the encrypted text of it. So we have to manually identify the underlying crypto mechanics…
Not much to see here this time around. Just some boring html code with a encrypt.php script, but nothing we can access or manipulate. So no posting of any source here. Won’t contribute anything to solving the challenge
The hack in this case is just trying to make sense of the encrypted message and figuring out how this algorithm works by testing the script itself which we have access to.
So we can try to encrypt as much clear text as we want.
I will not post all my tries to make sense out of it because I had my fair share of trouble decoding it. …
So let’s take a look:
Our single ‘d’ character is getting encrypted to .23.36.41 what do we get from this? Well it seems every character is converted to 3 chunks in the form of .XX.XX.XX
Let’s try again.
…Oopps. Our single ‘d’ character got encrypted to total different numbers…
Ugh… But wait?
Do they have something in common? Let’s take a look…
Oh they do! The numbers add up to ‘100’ in both times!
It’s time to recall basic character encoding techniques!
As we can look up at the link above a small ‘d’ corresponds to ‘100’ in ASCII!
We found out how a single character without choosing a password is encrypted!
But how does the password field make any sense now?
Let’s try encrypting our single ‘d’ with the password: d
And with some mad black magic skills we can see that our single encrypted ‘d’ still has the form of .XX.XX.XX, but this time the numbers add up to 200!
It’s spoiler time :
This behavior continues. Every character you put in the password field gets converted to its ASCII value and is added to each ASCII value from the characters of the clear text.
(the longer the password the higher the numbers in the end.)
So now it’s time to decrypt our message.
With this knowledge on board we’re almost ready to do this!
How do we get the password for decrypting??
This can be done through a frequency analysis.
We add up every ‘3 chunk’ and look at which element appears the most often.
Now some of you may think: “hey that’s simple, it’s English language so it’ll be the ‘e’.”
That’s incorrect in two areas tho:
- First: We still have to deal with a password
- Secondly: In general, when writing a message one uses more ‘space characters’ than ‘e’ characters.
→ space corresponds to the numerical value of 32 in ASCII
And that’s it. Subtracting the ASCII value for space from the added chunk with the most occurrences in the cipher results in the password key!
Now as a last step we can subtract this password key from every added chunk from before to get the clear text message.
For this to happen I wrote a quick little En-/Decrypter in Python. If anyone’s interested I can share it, but be warned it’s ugly, but still fully functional .
And that’s it. Challenge solved.
Thank you for looking the other way on the increased levels of toxic chemicals in the river running alongside our industrial facilities. You can pick up your payment of $20,000 in the mailbox at the mansion on the corner of 53 and St. Charles tomorrow between the hours of 3:00am and 5:00am.
ToxiCo Industrial Chemicals
In this case we had a kinda tricky but not that difficult task to solve. We had to combine our knowledge about cryptography and basic character en- and decoding to decrypt the cipher. The html code of the website didn’t reveal anything to us, so it we had to solve it on our own .
The next article of the series can be found here once it’s up!!