Skip to content

Commit dab7c6c

Browse files
committed
Updates reverse-engineering/67k-400-points.md
Auto commit by GitBook Editor
1 parent 67f83e2 commit dab7c6c

File tree

1 file changed

+7
-11
lines changed

1 file changed

+7
-11
lines changed

reverse-engineering/67k-400-points.md

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,9 @@
44

55
### Solution
66

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).
88

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.
1410

1511
I loaded 00000.exe into radare2 for some static analysis:
1612

@@ -19,17 +15,17 @@ I loaded 00000.exe into radare2 for some static analysis:
1915
`entry0` is where the program starts. This function basically breaks down to:
2016

2117
* 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`\)
2521

2622
Here's what `do_op()` looks like:
2723

2824
![](https://raw.githubusercontent.com/VulnHub/ctf-writeups/master/images/2017/easyctf/67k/02.png)
2925

3026
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:
3127

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\)
3329
* shift `z` by cl bits and store the result in eax
3430
* do a bitwise `and` on eax and print out the result
3531

@@ -130,7 +126,7 @@ if __name__ == "__main__":
130126
sys.stdout.write("%c" % (solve,))
131127
```
132128

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.
134130

135131
To demonstrate the script, I've copied a handful of the binaries to a sample directory and ran it:
136132

0 commit comments

Comments
 (0)