To fully understand this article, you would need to have working knowledge of C++.
Solving Mission 6 can be broken down into two parts. The first is figuring out how the encryption algorithm works, and the second, writing a programming to implement the knowledge from part one and decrypt the entire message.
Part 1: The XECryption Algorithm
You can skip this part if you have figured out how the algorithm works.
You are given the encrypted message and a working version of the encryptor. So, obviously to decrypt the message you need to figure out how the algorithm encrypted it, and that is mostly logic.
You are given two fields, one for the text to be encrypted and the other for the password. First, try entering some simple input, such as a single character to see what happens. You get three numbers. Try encoding 2 characters now. You get six numbers. From this you can assume that each character produces 3 numbers, and further, you can assume that the three numbers are related.
Go back to inputing one character without a password and try to figure out the relationship between the numbers. If you know anything about "hacking" or programming, you should be pretty familiar with the relationship between characters and numbers. Taking the most obvious arithmetic procedure, addition, you should be able to observe that the sum of the three numbers that appear per character is in fact that character's ASCII code. For example, entering "a" as the text, with a blank password, you get a sum of 97.
Now it's time to figure out how the password works. You can use a similar approach by passing in simple input and simple passwords and then finding out the differences of the outputted message. At the end you get that the ASCII from the password string gets added to the ASCII of each character, thus the increase of each character's summed number is constant.
And now we are ready to use that knowledge to write a C++ program to decrypt the entire message.
Part2: Decryption Using C++
I used the STL container to simplify some of the code, but it shouldn't be too difficult to avoid using it, if it was so wished. For those unfamiliar with the vector container, it allows you to have resizable arrays, i.e. you don't have to know the final size of the array at creation.
First things first, save the encrypted message into a text file in the directory you're compiling your code. I saved my encrypted message as "text.txt".
Next, write a list of the steps the program should follow:
1. Load "text.txt"
2. Read every three numbers and sum them up
3. Figure out the most common number/character
4. Figure out the password (the number added, not the inputed string)
5. Subtract the password from the summed numbers to get the original ascii
6. Typecast the ascii into characters and save it into("text2.txt")
So to start, include the headers we are using as well the namespace:
CODE :
#include
#include // for file input/output
#include // for the vector container
using namespace std;
Then, in the main() function we want to load "text.txt"
CODE :
Followed by reading the file, summing the numbers and saving them into the vector container:
CODE :
char ch; // used to read the dots
int num; // used to read the numbers
vector sums; // vector container for ints;
int counter=0; // used for .... counting
while(!fin.eof()) // while we haven't
//reached the eof (end of file)
{
sums.push_back(0); // add a new element to the vector
// with initial value 0
for(int i=0;i<3;i++) // go through the three numbers
{
fin >> ch >> num; // load the dot and then the
// number
sums[counter]+=num; // add the three numbers
}
counter++; // increase the counter
}
fin.close(); // remember to close the file
Next is finding which summed number comes up the most. This is important to figuring out the password, because if we know the mode of the most common number, it will correspond to the most common character. So if we knew the most common character, we can find it's ascii value and then find the differential between the one encrypted and the actual one. The differential would be the password. To clear that up, say the most common number (from the summed numbers) is 767 and we assume that the most common character from the original message is 'e' which has an ascii of 101. Then the password would be 768-101=666 and we can use that to decrypt the rest of the message.
The way I do this might be kind of sloppy, but it works:
CODE :
1: I assume that the difference between the highest number and the lowest number is no greater than 500. That is a pretty safe bet considering standard ascii is only from 0 to 255. Then I create an array which will hold the number of times each number comes up, hence called frequency.
2: Set all values in the array to 0.
3: Create an iterator. Iterators are used with the vector container.
4: .begin() and .end() are vector methods which return the number of the first element and the last element respectively. You need to use an iterator with them.
5: Since the actual range of the numbers is between 500 and 999, I subtract 500 to make it fit with the array restraints(0-499). Each time the number comes up, add one to its frequency.
6: Create an int for the mode with a default value of 0.
7: Go through all 500 frequencies and figure out which one is higher.
8: Since we subtracted 500, we add it back here to get the original number.
And for the end, we make a new file and output the answer:
CODE :
// getting the proper ascii
ofstream fout("text2.txt");
int subtract=mode-??; // subtract = the password
for(int i=0;i
{
sums[i]-=subtract; // get proper ascii numbers
cout << sums[i]; // print out message
fout << sums[i]; // save message to a text file
}
fout.close(); // close the file
return 0;
}
There two "mistakes" with the above section of the code, reasons being, first to make you think (referring to the ?? part), and second to stop someone without much knowledge in c++ from copy and pasting to get the answer. If you understood most of the program, you would know what should go in the ??. As a side note, you might have to make several educated guesses for that value. Or you could iterate through all the possibilities :p
Well that's it, hope it helped.
Cast your vote on this article *Note: the order of the votes has been reversed.
By: TheMindRapist - 04:09 pm Thursday April 03rd, 2008
Too many spoilers, although you explain things you still give away the answers. "first to make you think (referring to the ?? part)" But you put a comment right there telling the reader what to think....
Please don't think I'm just trying to bash you, my article has way too many spoilers also.
By: Damascus2k8 - 04:16 pm Thursday April 03rd, 2008
Great article! 10/10
i wrote mine in C and it's nowhere near as clean as that lol :)
The article does have a decent bit of spoilers, however the reason I let it get by is he purposely breaks the code. I do admit though that it is formated nicely and had no spelling/grammatical errors that I picked up. 8/10
Yes Maven, pm me or any of the other moderators with a revised version, saying you'd like the article edited.
If you would just prefer a brand new version with score wiped and everything, then send a pm to a moderator asking to delete it and then resubmit the article again.
i have found the original message,
but i don't find how to send it to ToxiCo_Watch
it seems that ToxiCo_Watch doesn't exist.
can someone give me a hint?
Re:i have found the original message,
but i don't find how to send it to ToxiCo_Watch
it seems that ToxiCo_Watch doesn't exist.
can someone give me a hint?
Send it By HTS Messages Center BUT Do Not Enter Anything In Subject Or It Will Not Work.
basfreak, I have not tried this but I would assume you put the headers that are for your related system, i.e <iostream> would most likely be the first line.
Nice Article, I may just script this instead but this was a nice guide to get you thinking of ways to crack this type of message. (semi spoilerish) 9/10
Edit:
It was going to take too much effort to write a way to calculate the mode in TCL, so I just printed out the summed values, and put them into an online one. the same goes for how i converted back to text
By: shanebane363 - 01:28 pm Friday June 06th, 2008
Nice Article, I Dont Have Much Knowledge on C++ or Programming, just a small amount, but what i understood of this was very good.
Does anybody Know where i Can get any better C++ knowledge online? i feel like im not retaining what im reading as well as i should be. . .Any Idea's How to improve?
By: shanebane363 - 01:33 pm Friday June 06th, 2008
you can do the exact same thing with a simple for loop and some knowlage about char
This site is the collective work of the
HackThisSite staff. Please don't reproduce in part or whole without permission.
Page Generated: Fri, 25 Jul 2008 07:35:40 -0500 Exec:
118