Defcon 2015 Quals - mathwhiz solution

Category: Baby's First Points: 1

The information given to us:

After connecting to it we can see it's giving us mathematical operations and he's waiting for the result. The solution is pretty easy. Get the data and pass it to python eval and return the result to the server.

#!/usr/bin/env python
# -*- coding: utf-8 -*-
import re
from pwn import *

r = remote("", 21249)

def ret_calc_level1(x):
    global r
    return'(.*).*=', x).group(1)

while True:
    data = r.recvdata()
    if "won" in data:
    data = data.replace("[", "(")
    data = data.replace("{", "(")
    data = data.replace("}", ")")
    data = data.replace("]", ")")
    data = data.replace("THREE", "3")
    data = data.replace("TWO", "2")
    data = data.replace("ONE", "1")
    data = data.replace("^", "**")
    print data
    data_1 = str(ret_calc_level1(data))
    res = eval(data_1)
    print "Res:", str(res)
    r.senddata("%d" % res)

The flag is:

Farva says you are a FickenChucker and you'd better watch Super Troopers 2