forked from hugsy/stuff
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexploit_template.py
executable file
·38 lines (32 loc) · 1.03 KB
/
exploit_template.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
#!/usr/bin/env python2
from pwn import *
context.update(arch="amd64", # arch="i386", arch="mips", arch="arm",
endian="little", os="linux", log_level="debug",
terminal=["tmux", "split-window", "-v", "-p 85"],)
LOCAL, REMOTE, SSH = False, False, False
TARGET=os.path.realpath("./bof")
elf = ELF(TARGET)
def attach(r):
if LOCAL:
bkps = [elf.symbols["main"], ]
cmds = []
gdb.attach(r, '\n'.join(["break *{:#x}".format(x) for x in bkps] + cmds))
return
def exploit(r):
attach(r)
r.interactive()
return
if __name__ == "__main__":
if len(sys.argv)==6 and sys.argv[1]=="ssh":
SSH = True
sh = ssh(host=sys.argv[2], port=sys.argv[3], user=sys.argv[4], password=sys.argv[5])
sh.set_working_directory(os.path.dirname(TARGET))
r = sh.process([TARGET, ])
elif len(sys.argv)==3:
REMOTE = True
r = remote(sys.argv[1], int(sys.argv[2]))
else:
LOCAL = True
r = process([TARGET, ])
exploit(r)
sys.exit(0)