Skip to content

Commit 9a2ebed

Browse files
committed
Defkthon Rev300
1 parent b6e2e56 commit 9a2ebed

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

defkthon-ctf/reversing-300/README.md

+25-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,31 @@
66
77
## Write-up
88

9-
(TODO)
9+
So `file 300.exe` says that it's an ordinary PE32 windows executable. When opening it in IDA and viewing all the strings referenced by the program, we see a lot of Python API functions that are dynamically loaded. It turns out the executable is also a valid ZIP file, and this zip file contains the `hashlib` python module. This is an open source module, suggesting that the program somehow uses this module to check the password entered by the user.
10+
11+
We want to extract the embedded python code. One string located close to the python API function names is `_MEIPASS2`. This string is an environment variable used by [PyInstaller](http://www.pyinstaller.org/export/develop/project/doc/Manual.html). Lucky for us, PyInstaller has a tool called ArchiveViewer to extract python code from a created executable. Using ArchiveViewer.py we extract the python file `challenge1`:
12+
13+
#AJIN ABRAHAM | OPENSECURITY.IN
14+
from passlib.hash import cisco_pix as pix
15+
import sys,base64
16+
user=""
17+
xx=""
18+
if(len(sys.argv)>1):
19+
x=sys.argv[1]
20+
hashus = pix.encrypt("DEFCON14-CTF-IS", user=x)
21+
z=[89,86,69,121,100,82,69,103,98,47,48,103,80,71,77,121]
22+
for zz in z:
23+
xx+= chr(zz+(275*100001-275*1000-27225274))
24+
hashgen = pix.encrypt("DEFCON14-CTF-IS", user=base64.decodestring(xx))
25+
if(hashgen==hashus):
26+
print "Oh Man You got it! But :( ===> " + str(base64.encodestring(base64.decodestring(xx)))
27+
else:
28+
print "Naaaaaaa !! You are screweD"
29+
else:
30+
print "Password !!"
31+
32+
33+
As you can see, it stores the password in obfuscated form. Then it uses the key DEFCON14-CTF-IS to encrypt both the stored password, and the password entered by the user. We can easily find the password by including the line `print base64.decodestring(xx)`. This returns easy!asMa@ss.
1034

1135
## Other write-ups
1236

0 commit comments

Comments
 (0)