Page 1 of 2

Didactic XOR Cipher 2

Posted: Mon Nov 03, 2008 1:10 pm
by samuelandjw
hey, guys. I solved it by trying XOR from 0 to 255 by programming. Anybody has a better solution?

Posted: Mon Nov 03, 2008 1:36 pm
by W1zard
Well, I searched for patterns and bytes that occurred very often.
1. The byte used to XOR had to be in such a way that the first bit of every byte will be 0 (obvious if you look at the ASCII table).
2. The byte occurring most often will either be SPACE or e (if the text is without spaces).
So there are only two choices.

Posted: Mon Nov 03, 2008 3:24 pm
by the_impaler
I used the same brute force approach - let the computer do the work that it was designed to do.
Spit out the output and grep for common words like "is" .
While it was doing it I was working on other problems :wink:

Posted: Thu Nov 06, 2008 3:08 pm
by psycorama
the_impaler wrote:I used the same brute force approach - let the computer do the work that it was designed to do.
While it was doing it I was working on other problems :wink:
Well, my brute force attempt was finished, befor i could even blink....

Posted: Fri Nov 07, 2008 7:36 am
by the_impaler
And that is just enough to solve "Don't blink" challenge

Posted: Tue Dec 23, 2008 10:29 pm
by Belriel
Yes brute force was quick in this case and I filtered the results with a regular expression match to show me only those strings that contained only word characters, whites space characters, " and ', which gave me 3 results, the third was the one :).

Posted: Sun Apr 26, 2009 11:34 pm
by Meelo
I also wrote a little application. I didn't filter it (which, as I was just running a console application, made a lot of beeping noises), but it was fairly obvious when it came up through all the special characters. Although, filtering it does sound like a good idea.

Re: Didactic XOR Cipher 2

Posted: Thu Jul 09, 2009 7:34 pm
by hobbist
samuelandjw wrote:hey, guys. I solved it by trying XOR from 0 to 255 by programming. Anybody has a better solution?
Not better, as such...but I used the exact same code I used on the first XOR Cipher Challenge. Most of the work was already done, so like you I just looped it through the range 1,255.

Posted: Fri Jul 10, 2009 3:57 am
by therethinker
Here it makes sense to brute force it because of the small key size.

I *believe* that my solver threw out solutions w/ a character less than ' ' except \r & \n, or w/ characters greater than 'z'.
If I wanted to be anal, I could have picked out all the symbols inbetween, but this only returned a few answers.


Also, a nice program to use instead of grep is strings. You can set it to look for length 20 or something long if you know the answer will be there.

Posted: Mon May 30, 2011 3:45 am
by Millennium
I did this:

<html>
<body>
<?php

$array1=array(148, 136, 129, 133, 151, 129, 196, 151, 145, 134, 137, 141, 144, 196, 198, 140, 133, 135, 143, 133, 128, 139, 139, 128, 136, 129, 198, 196, 130, 139, 150, 196, 144, 140, 141, 151, 196, 135, 140, 133, 136, 136, 129, 138, 131, 129);
for ($i = 0; $i <= 200; $i++) {
for ($ii = 1; $ii <= count($array1); $ii++) {
echo chr($array1[$ii]^$i);
}
echo $ii."<br><br><br>";
}
?>
</body>
</html>

and hoped for the best. I searched for the words "Answer" and "submit" and found it.

Posted: Fri Jun 29, 2012 1:23 pm
by K-Lite
lista = [0x94, 0x88, 0x81, 0x85, 0x97, 0x81, 0xc4, 0x97, 0x91, 0x86, 0x89, 0x8d, 0x90, 0xc4, 0xc6, 0x8c, 0x85, 0x87, 0x8f, 0x85, 0x80, 0x8b, 0x8b, 0x80, 0x88, 0x81, 0xc6, 0xc4, 0x82, 0x8b, 0x96, 0xc4, 0x90, 0x8c, 0x8d, 0x97, 0xc4, 0x87, 0x8c, 0x85, 0x88, 0x88, 0x81, 0x8a, 0x83, 0x81]
for i in range(0,256):
for j in lista:
print chr(i^j)
print """-----
COMBINATION END
-----"""
And looked for something that made sense (previously converted the coded password into an int list)

Posted: Mon Feb 03, 2014 8:22 pm
by Sarithis
Well, I chose the hard bruteforce way with C++.
Making simple things hard and complicated is what I always do :oops:.


Code: Select all

#include <iostream>
#include <sstream>
#include <vector>
#include <fstream>

using namespace std;

vector <int> break_it_down(string hex_number);
void crack_it(vector<int> table);

int main(){
   string encrypted = "948881859781c4979186898d90c4c68c85878f85808b8b808881c6c4828b96c4908c8d97c4878c858888818a8381";
   vector<int> broken_table = break_it_down(encrypted);
   crack_it(broken_table);
   return 0;
}

void crack_it(vector<int> table){
   vector <vector <string> > XORed;
   string temp;
   XORed.resize(table.size());
   ofstream File;
   File.open("cracked");
   for (int j = 0; j < 256; j++) {
      for (int i = 0 ; i < table.size(); i++){
         temp = table[i]^j;
         XORed[j].push_back(temp);
         File << XORed[j][i];
      }
      File << endl;
   }
   File.close();
}

vector <int> break_it_down(string hex_number){
   vector<int> result;
   string STR;
   int INT;
   for (int i = 0, j=0; i < hex_number.length()/2; i++, j+=2){
      STR=("0x");
      STR+=hex_number[j];
      STR+=hex_number[j+1];
      stringstream ss;
      ss << hex << STR;
      ss >> INT;
      result.push_back(INT);
   }
   return result;
}

Posted: Fri Apr 25, 2014 9:37 pm
by Bo
one more c++ solution.

Code: Select all

FILE *f =  fopen("output.txt","w");
	string s = "948881859781c4979186898d90c4c68c85878f85808b8b808881c6c4828b96c4908c8d97c4878c858888818a8381";
	for(int KEY = 0x10; KEY<=0xff; KEY++)
	{
		for(int i = 0; i< s.size();i+=2)
		{
			stringstream str;
			string byte = s.substr(i,2);
			str << byte;
			int num(0);
			str >> std::hex >> num;
			fprintf(f,"%c",(num^KEY));
		}
		fprintf(f,"\n");
	}

Posted: Fri May 06, 2016 12:29 pm
by greyslim
#include <iostream>
using namespace std;
int pro(char l)
{
if (l=='0') return 0;
if (l=='1') return 1;
if (l=='2') return 2;
if (l=='3') return 3;
if (l=='4') return 4;
if (l=='5') return 5;
if (l=='6') return 6;
if (l=='7') return 7;
if (l=='8') return 8;
if (l=='9') return 9;
if (l=='a') return 10;
if (l=='b') return 11;
if (l=='c') return 12;
if (l=='d') return 13;
if (l=='e') return 14;
if (l=='f') return 15;
}
void main()
{
char m[]="948881859781c4979186898d90c4c68c85878f85808b8b808881c6c4828b96c4908c8d97c4878c858888818a8381";
int k,k1,k2;
for(int j=79;j<=255;j++)
{
for(int i=0;i<=90;i+=2)
{
k1=pro(m);
k2=pro(m[i+1]);
k=k1*16+k2;
k^=j;
cout<<(char)k;
}
cout<<endl;
}
system("pause");
}

Posted: Tue Jun 07, 2016 4:11 pm
by tankman175
[quote="Sarithis"]Well, I chose the hard bruteforce way with C++.
Making simple things hard and complicated is what I always do
[/quote]

Oh Yeah! I used java and tried to not use any prewritten methods so i sat there for like 3 hours programming hex-to-dez-to-bin and then xor it, and then i converted it into ascii charachters manually... it was probably amazingly unneccesary complicated, but i had a lot of fun doing it :D

Btw love this site/the challenges!! THANK YOU :D