You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: reverse-engineering/67k-400-points.md
+7-11Lines changed: 7 additions & 11 deletions
Original file line number
Diff line number
Diff line change
@@ -4,13 +4,9 @@
4
4
5
5
### Solution
6
6
7
-
This was a 400 point reverse engineering challenge from [EasyCTF 2017](https://www.easyctf.com/). We're given a zip file containing 67,139 small programs starting from 00000.exe to 10642.exe. The idea is to solve each one in order and to join their output. The end result would lead to the flag. Here's the challenge description:
7
+
This was a 400 point reverse engineering challenge from [EasyCTF 2017](https://www.easyctf.com/). We're given a zip file containing 67,139 small programs starting from 00000.exe to 10642.exe. The idea is to solve each one in order and to join their output. The end result would lead to the flag. There are probably a hundred ways to solve this challenge, but I decided to give it a go using radare2's [r2pipe](https://github.com/radare/radare2-r2pipe).
8
8
9
-
> Here are 67k binaries, well more accurately 67,139 binaries. Solve every single one, append the results together in order (shouldn't be too difficult as the binaries are numbered) and then from there I'm sure you can figure it out.
10
-
11
-
There are probably a hundred ways to solve this challenge, but I decided to give it a go using radare2's [r2pipe](https://github.com/radare/radare2-r2pipe).
12
-
13
-
Disclaimer: This was the first time I'd used r2pipe, so I apologize for the noobness. After much Googling and fiddling, I ended up with a hacky script that solved the challenge. The script can definitely be improved upon, and I'd love to hear suggestions from those who are more experienced with r2pipe or radare2 scripting.
9
+
Disclaimer: This was the first time I'd used r2pipe, so I apologize for the noobness. After much Googling and fiddling, I ended up with a hacky script that solved the challenge. The script can definitely be improved upon, and I'd love to hear suggestions from those who are more experienced with r2pipe or radare2 scripting.
14
10
15
11
I loaded 00000.exe into radare2 for some static analysis:
16
12
@@ -19,17 +15,17 @@ I loaded 00000.exe into radare2 for some static analysis:
19
15
`entry0` is where the program starts. This function basically breaks down to:
20
16
21
17
* get a number from the user
22
-
* set eax to a value stored at an address (in this case 0x403000). I'll call this value `x`
23
-
* set ecx to a constant value (in this case 0xa1a8a7ed). I'll call this value `y`
24
-
* call a function, I'll call it `do_op()`, that returns the result of an operation (in this case `eax-ecx`)
18
+
* set eax to a value stored at an address \(in this case 0x403000\). I'll call this value `x`
19
+
* set ecx to a constant value \(in this case 0xa1a8a7ed\). I'll call this value `y`
20
+
* call a function, I'll call it `do_op()`, that returns the result of an operation \(in this case `eax-ecx`\)
The return value of this function, I'll call it `z`, is compared against the user's input. If they are identical it follows a branch that does the following:
31
27
32
-
* set cl to a value stored at an address (in this case 0x403007)
28
+
* set cl to a value stored at an address \(in this case 0x403007\)
33
29
* shift `z` by cl bits and store the result in eax
34
30
* do a bitwise `and` on eax and print out the result
35
31
@@ -130,7 +126,7 @@ if __name__ == "__main__":
130
126
sys.stdout.write("%c" % (solve,))
131
127
```
132
128
133
-
The script is commented so hopefully it makes sense, It basically figures out what the expected input is and what the binary's output will be.
129
+
The script is commented so hopefully it makes sense, It basically figures out what the expected input is and what the binary's output will be.
134
130
135
131
To demonstrate the script, I've copied a handful of the binaries to a sample directory and ran it:
0 commit comments