Description:
root@ubuntu:~# nc number.quals.seccon.jp 31337 3, 0 The maximum number? 3 3, 9, -7 The maximum number? 9 2, -9, -7, 2 The minimum number? -9 0, 2, 0, 1, -4 The minimum number? -4 -4, 3, -7, -9, 9, -9 The maximum number? 9 -2, 1, 5, 8, 1, 9, -7 The maximum number? Timeout, bye. root@ubuntu:~#Solution:
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
# Author: Kitwipat Towattana (@icheernoom) | |
import socket, re | |
def get_data(recv): | |
m = re.match("(.+)\nThe", recv) | |
return m | |
def get_num(m): | |
#num = re.split(", ",m.group(1)) | |
num = m.group(1).split(', ') | |
num = map(int, num) | |
return num | |
def min_max(recv): | |
print "===" | |
if "maximum" in recv: | |
print "maximum" | |
return max(get_num(get_data(recv))) | |
elif "minimum" in recv: | |
print "minimum" | |
return min(get_num(get_data(recv))) | |
else: | |
print recv | |
exit() | |
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | |
s.connect(('number.quals.seccon.jp', 31337)) | |
while(1): | |
recv = s.recv(2048) | |
data = min_max(recv) | |
print data | |
s.send(bytes(data)+"\r\n") | |
s.close |
Flag: SECCON{Programming is so fun!}
ไม่มีความคิดเห็น:
แสดงความคิดเห็น