The force is with those who read the source.

Internetwache CTF 2016: A numbers game (code 50)

2016-03-03

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.

Exploit

In this challenge, we need to solve 100 equations to get the flag. The equations are in the following form.

Level 1.: x * 14 = 238

Level 2.: x + 35 = 43

There is no special technique. Just parse the equations and solve it.

solve.pydownload
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
from pwnlib.tubes.remote import remote

r = remote('188.166.133.53', 11027)

while True:
lines = r.recvlines(2)
print '\n'.join(lines)
sp = lines[1].split()

# sp[3] is the operator
# sp[4] is the operand on the left side
# sp[6] is the operand on the right side
if sp[3] == '+':
x = int(sp[6]) - int(sp[4])
elif sp[3] == '-':
x = int(sp[6]) + int(sp[4])
elif sp[3] == '*':
x = int(sp[6]) / int(sp[4])
elif sp[3] == '/':
x = int(sp[6]) * int(sp[4])

print x
r.sendline(str(x))

Flag: IW{M4TH_1S_34SY}


Blog comments powered by Disqus