Didactic XOR Cipher 2

Discussion of challenges you have already solved
samuelandjw
Posts: 8
Joined: Sat Nov 01, 2008 2:49 pm

Didactic XOR Cipher 2

Post by samuelandjw »

hey, guys. I solved it by trying XOR from 0 to 255 by programming. Anybody has a better solution?
W1zard
Posts: 8
Joined: Sat Oct 25, 2008 6:29 pm

Post 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.
the_impaler
Posts: 61
Joined: Wed Apr 30, 2008 3:31 am

Post 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:
psycorama
Posts: 1
Joined: Mon Oct 27, 2008 6:32 pm

Post 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....
the_impaler
Posts: 61
Joined: Wed Apr 30, 2008 3:31 am

Post by the_impaler »

And that is just enough to solve "Don't blink" challenge
Belriel
Posts: 16
Joined: Sat Dec 20, 2008 2:55 pm

Post 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 :).
Meelo
Posts: 9
Joined: Sat Apr 25, 2009 11:10 pm

Post 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.
hobbist
Posts: 5
Joined: Sun Jun 28, 2009 4:02 pm

Re: Didactic XOR Cipher 2

Post 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.
therethinker
Posts: 144
Joined: Fri Mar 28, 2008 11:29 pm
Location: #hacker.org on Freenode

Post 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.
Millennium
Posts: 17
Joined: Thu Apr 21, 2011 3:08 am

Post 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.
K-Lite
Posts: 1
Joined: Tue Jun 26, 2012 11:58 am

Post 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)
Sarithis
Posts: 1
Joined: Mon Feb 03, 2014 3:39 pm

Post 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;
}
Bo
Posts: 3
Joined: Wed Apr 23, 2014 10:02 am

Post 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");
	}
allons-y
greyslim
Posts: 1
Joined: Fri May 06, 2016 10:18 am

Post 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");
}
tankman175
Posts: 2
Joined: Fri May 20, 2016 7:56 pm

Post 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
Post Reply