Skip to content

Commit c640e97

Browse files
author
Zetsubou Clown
committed
Reverse 100
1 parent 5387048 commit c640e97

File tree

5 files changed

+95
-0
lines changed

5 files changed

+95
-0
lines changed

IDontEven/create/Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
all:
2+
gcc -m32 -o rev100 rev100.c
3+
strip rev100

IDontEven/create/check

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
gdb rev100 <<END
2+
b *0x80485bd
3+
r
4+
call 0x8048541(1)
5+
x/s 0x804a0c4
6+
q
7+
y
8+
END

IDontEven/create/rev100.c

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
#include <stdio.h>
2+
#include <string.h>
3+
#include <stdlib.h>
4+
5+
int dumb_hash(char* input, int length){
6+
int result = 1, i;
7+
for(i = 1; i < length; ++i){
8+
result *= (((input[i] << 2) + 123456 - input[i-1]) * 3 + 2254) % 5557;
9+
}
10+
return result % 5557;
11+
}
12+
13+
char strings[5][100] = {"\xaa\xa1\x41\x34\xc4\xcb\xb1\xa7\xe9\x73\x43\x3\xa9\x83\x3a\x17\x1c\xa3\xfa\x93\x85\x40\x66\x50\xae\x32\x3a\x79\x7f\xc6",
14+
"\xa4\x8a\x1a\x7b\xd0\xc6\xa4\xb3\xe1\x73\x7e\x18\xec\x91\x39\x1d\x49\xfd\xef\x9c\x94\x52\x6c\xb\xed\x77\x6a\x7e\x34\x90\xb7\xc3\x42\x8c\x7b\x15\x5d\x3f\x9f\x4\x58\x75\xfa\x4a\xd4\xd6\x89\x70\xd3\xea\x9\xc6\xc4\x41\x9e\xcc\x3a\x3a\xf6\x75\x8f\x1e\x6c\x24\x8\xf5\x13\xfd\x82\x17\xad\x73\xeb\x2c\x51\x25\x25\xbe\x58\x7e\x3a\xd3\xb0\x26\xaf\xc5",
15+
"\xa7\xa1\x5f\x36",
16+
"\xbe\xa1\x58\x7f\x96\xde\xad\xb5\xbc\x74\x64\x4b\xad\xcd\x7c\x12\x13\xb0\xbf\x88\x93\x13\x7c\x56\xb4\x75\x72\x75\x69\xc6\xee\xda\x51\xdc\x3c\x53\x49\x60\x93",
17+
"\xbd\xa6\x4e\x27\x91\xd9\xe5\xbe\xbd\x20\x63\x4b\xbf\xd7\x29\xb\x14\xa0"
18+
};
19+
20+
void decrypt(int n){
21+
srand(1337);
22+
int i, len = strlen(strings[n]);
23+
for(i = 0; i < len; ++i)
24+
strings[n][i] ^= rand() % 256;
25+
}
26+
27+
int main(int argc, char* argv[]){
28+
int i;
29+
int hashes[5];
30+
if(argc != 5){
31+
decrypt(2);
32+
puts(strings[2]);
33+
return 1;
34+
}
35+
for(i = 0; i < argc; ++i){
36+
int len = strlen(argv[i]);
37+
if(len < 8){
38+
decrypt(2);
39+
puts(strings[2]);
40+
return 1;
41+
}
42+
hashes[i] = dumb_hash(argv[i], len);
43+
}
44+
if(hashes[0] < 13 && hashes[5] > 6000){
45+
decrypt(0);
46+
puts(strings[0]);
47+
} else if(hashes[2] % 123 == 44 || hashes[4] == 0){
48+
decrypt(4);
49+
puts(strings[4]);
50+
} else if(hashes[1] > hashes[0] * 5 && hashes[3] - hashes[2] > 5001){
51+
decrypt(1);
52+
puts(strings[1]);
53+
} else if(hashes[4] * hashes[1] < hashes[3] / hashes[4]){
54+
decrypt(3);
55+
puts(strings[3]);
56+
} else {
57+
decrypt(2);
58+
puts(strings[2]);
59+
}
60+
return 0;
61+
}

IDontEven/solution/solution.html

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
Сам код довольно прост. У Игрока есть два варианта: подбирать строки так, чтобы соблюдались написанные условия (некоторые из них невыполнимы), и получить все строки в расшифрованном виде, либо расшифровать вручную, что куда проще.
2+
3+
Для расшифровки вручную можно запустить всё это дело в каком-нибудь gdb и там вызвать нужную функцию нужное число раз.
4+
Пример сессии gdb для расшифровки полезной строки:
5+
gdb rev100 <<END
6+
b *0x80485bd
7+
r
8+
call 0x8048541(1)
9+
x/s 0x804a0c4
10+
q
11+
y
12+
END
13+
14+
Это выдаст строку "MD5(flag) is 2ef495fb2d47e8b9385322241c59ffdb. Don't worry, it's all lowercase letters".
15+
2ef495fb2d47e8b9385322241c59ffdb = MD5('STCTF#aaaaad#'), так что много времени занять не должно.

IDontEven/summary.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
answer_regex: STCTF#aaaaad#
3+
author: ZetsubouClown
4+
category: reverse
5+
description: |
6+
7+
name: I Don't Even
8+
price: 100

0 commit comments

Comments
 (0)