Didactic XOR Cipher 2
-
- Posts: 8
- Joined: Sat Nov 01, 2008 2:49 pm
Didactic XOR Cipher 2
hey, guys. I solved it by trying XOR from 0 to 255 by programming. Anybody has a better solution?
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.
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.
-
- Posts: 61
- Joined: Wed Apr 30, 2008 3:31 am
-
- Posts: 61
- Joined: Wed Apr 30, 2008 3:31 am
Re: Didactic XOR Cipher 2
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.samuelandjw wrote:hey, guys. I solved it by trying XOR from 0 to 255 by programming. Anybody has a better solution?
-
- Posts: 144
- Joined: Fri Mar 28, 2008 11:29 pm
- Location: #hacker.org on Freenode
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.
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.
-
- Posts: 17
- Joined: Thu Apr 21, 2011 3:08 am
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.
<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.
And looked for something that made sense (previously converted the coded password into an int list)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
-----"""
Well, I chose the hard bruteforce way with C++.
Making simple things hard and complicated is what I always do .
Making simple things hard and complicated is what I always do .
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;
}
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
#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");
}
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");
}
-
- Posts: 2
- Joined: Fri May 20, 2016 7:56 pm
[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
Btw love this site/the challenges!! THANK YOU
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
Btw love this site/the challenges!! THANK YOU