forked from emilytouchingcomputers/CTFium
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvm_adventure.py
34 lines (30 loc) · 956 Bytes
/
vm_adventure.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/usr/bin/python
import string
import random
import _7amebox
from hashlib import sha1
# proof of work
print """
------------------------------------------------------------------------------------
if not (answer.startswith(prefix) and sha1(answer).hexdigest().endswith('000000')):
print 'nope'
exit(-1)
------------------------------------------------------------------------------------
"""
prefix = ''.join(random.sample(string.letters + string.digits, 6))
print 'prefix : {}'.format(prefix)
answer = raw_input('answer : ')
if not (answer.startswith(prefix) and sha1(answer).hexdigest().endswith('000000')):
print 'nope'
exit(-1)
firmware = 'pwn_adventure.firm'
emu = _7amebox.EMU()
emu.filesystem.load_file('flag')
for i in range(0, 8):
emu.filesystem.load_file('stage_{}.map'.format(i))
emu.register.init_register()
emu.init_pipeline()
emu.load_firmware(firmware)
emu.set_mitigation(nx=True)
emu.set_timeout(360)
emu.execute()