หน้าเว็บ

วันจันทร์ที่ 22 กุมภาพันธ์ พ.ศ. 2559

Internetwache CTF 2016: A numbers game (Code) Write-up


Description:
People either love or hate math. Do you love it? Prove it! You just need to solve a bunch of equations without a mistake.
Solution: 

#!/usr/bin/python
# Author: Kitwipat Towattana (@icheernoom)
from pwn import *
import sys
r = remote('188.166.133.53', 11027)
while True:
try:
result = r.recvline()
log.success(result)
problem = r.recvline()
question = problem.split(': ')[1]
log.info(problem)
x, cond, num1, eq, num2 = question.split(' ')
if "+" in cond:
ans = int(num2) - int(num1)
log.info("x = {0}".format(ans))
r.send("{0}\r\n".format(ans))
elif "-" in cond:
ans = int(num2) + int(num1)
log.info("x = {0}".format(ans))
r.send("{0}\r\n".format(ans))
elif "*" in cond:
ans = int(num2) / int(num1)
log.info("x = {0}".format(ans))
r.send("{0}\r\n".format(ans))
elif "/" in cond:
ans = int(num2) * int(num1)
log.info("x = {0}".format(ans))
r.send("{0}\r\n".format(ans))
except IndexError:
log.success("{0}".format(problem))
sys.exit()
'''
root@kali:~/Desktop# python code50.py
[+] Opening connection to 188.166.133.53 on port 11027: Done
[+] Hi, I heard that you're good in math. Prove it!
[*] Level 1.: x + 10 = 23
[*] x = 13
[+] Yay, that's right!
[*] Level 2.: x + 24 = 63
[*] x = 39
...[snip]...
[*] Level 98.: x + 1259 = 1878
[*] x = 619
[+] Yay, that's right!
[*] Level 99.: x * 1945 = 643795
[*] x = 331
[+] Yay, that's right!
[*] Level 100.: x * 639 = 341865
[*] x = 535
[+] Yay, that's right!
[+] IW{M4TH_1S_34SY}
[*] Closed connection to 188.166.133.53 port 11027
'''
view raw code50.py hosted with ❤ by GitHub

Flag: IW{M4TH_1S_34SY}

ไม่มีความคิดเห็น:

แสดงความคิดเห็น

264509