SECCON Beginners CTF 2018 - てけいさんえくすとりーむず
問題文
てけいさんのプロのために作りました。
えくすとりーむなので300秒でタイムアウトします。
$ nc tekeisan-ekusutoriim.chall.beginners.seccon.jp 8690
writeup
まずは接続してみる。
root@kali:~# nc tekeisan-ekusutoriim.chall.beginners.seccon.jp 8690 Welcome to TEKEISAN for Beginners -extreme edition- --------------------------------------------------------------- Please calculate. You need to answered 100 times. e.g. (Stage.1) 4 + 5 = 9 ... (Stage.99) 4 * 4 = 869 [!!] Wrong, see you. --------------------------------------------------------------- (Stage.1) 840 + 779 = 1619 (Stage.2) 505 + 756 = 1111 [!!] Wrong, see you.
延々と計算問題をこなしていくようだ。
100回も手動でやってられないので、スクリプトを書く。
式部分を抽出してevalで計算して送信する。
import socket import re s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.connect(('tekeisan-ekusutoriim.chall.beginners.seccon.jp', 8690)) while True: receivedata = s.recv(1024).decode('utf-8') print("[+]receivedata=",receivedata) splitreceivedata = receivedata.split("\n") formula = splitreceivedata[len(splitreceivedata)-1] pattern = '(.*) =' m = re.search(pattern, formula) if m: formula = m.group(1) print("[+]formula=",formula) senddata = str(eval(formula)) print("[+]senddata=",senddata) s.sendall((senddata+"\n").encode("utf-8"))
実行結果。
[+]receivedata= Welcome to TEKEISAN for Beginners -extreme edition- --------------------------------------------------------------- Please calculate. You need to answered 100 times. e.g. (Stage.1) 4 + 5 = 9 ... (Stage.99) 4 * 4 = 869 [!!] Wrong, see you. --------------------------------------------------------------- (Stage.1) 565 + 997 = [+]formula= 565 + 997 [+]senddata= 1562 [+]receivedata= (Stage.2) 559 - 527 = [+]formula= 559 - 527 [+]senddata= 32 (snip) [+]receivedata= (Stage.99) 624 * 588 = [+]formula= 624 * 588 [+]senddata= 366912 [+]receivedata= (Stage.100) 729 - 810 = [+]formula= 729 - 810 [+]senddata= -81 [+]receivedata= Congrats. Flag is: "ctf4b{ekusutori-mu>tekeisann>bigina-zu>2018}"
フラグゲット。
ctf4b{ekusutori-mu>tekeisann>bigina-zu>2018}