Skip to content

Instantly share code, notes, and snippets.

@ahhh
Last active August 29, 2015 14:21
Show Gist options
  • Save ahhh/adbb6aec9fff668f9e24 to your computer and use it in GitHub Desktop.
Save ahhh/adbb6aec9fff668f9e24 to your computer and use it in GitHub Desktop.
DefCon CTF 2015 Quals: MathWhiz solution
import socket
HOST = 'mathwhiz_c951d46fed68687ad93a84e702800b7a.quals.shallweplayaga.me'
PORT = 21249
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((HOST, PORT))
while(1):
#print s.recv(1024)
problem = s.recv(1024).split('=')
problem = problem[0]
print problem
if '{' in problem:
problem = problem.replace("{", "(")
problem = problem.replace("}", ")")
if '[' in problem:
problem = problem.replace("[", "(")
problem = problem.replace("]", ")")
if 'ONE' in problem:
problem = problem.replace("ONE", "1")
if 'TWO' in problem:
problem = problem.replace("TWO", "2")
if 'THREE' in problem:
problem = problem.replace("THREE", "3")
if '^' in problem:
problem = problem.replace("^", "**")
answer = str(eval(problem))
print answer
s.send(answer)
#print "lolol"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment