Home DEFCON CTF 2015 Quals -- mathwhiz
Post
Cancel

DEFCON CTF 2015 Quals -- mathwhiz

Category: Baby’s First
Points: 1

mathwhiz_c951d46fed68687ad93a84e702800b7a.quals.shallweplayaga.me:21249

The challenge’s pretty simple. The service will ask you a bunch of math problems(1000 actually), all you need to do is to answer all of them and you’ll get the flag. Notice that some of the questions contains some tricky input, like “ONE + TWO = ?”, “[1 + 2] + 4=?”……etc.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
from pwn import *
import string

HOST = "mathwhiz_c951d46fed68687ad93a84e702800b7a.quals.shallweplayaga.me"
PORT = 21249

r = remote(HOST, PORT)

LOG = True

d = dict()
d['{'] = '('
d['}'] = ')'
d['['] = '('
d[']'] = ')'

def my_recvuntil(delim):
    res = ""
    while delim not in res:
        c = r.recv(1)
        sys.stdout.write(c)
        res += c
    return res

cnt = 0
while True:
    print "Round:", cnt
    cnt += 1
    s = my_recvuntil("=\n")
    term = s[0:s.index('=\n'):]
    print "term:", term
    term_list = list(term)
    for index,c in enumerate(term_list):
        if c in d:
            term_list[index] = d[c]
    final_term = ''.join(x for x in term_list)
    
    final_term = final_term.replace("ONE", "1")
    final_term = final_term.replace("TWO", "2")
    final_term = final_term.replace("THREE", "3")
    final_term = final_term.replace("FOUR", "4")
    final_term = final_term.replace("FIVE", "5")
    final_term = final_term.replace("SIX", "6")
    final_term = final_term.replace("SEVEN", "7")
    final_term = final_term.replace("EIGHT", "8")
    final_term = final_term.replace("NINE", "9")
    final_term = final_term.replace("^", "**")
    
    print "Final:", final_term
    ans = eval(final_term)
    print "ans:", ans
    r.sendline(str(ans))
 

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

This post is licensed under CC BY-SA 4.0 by the author.

DEFCON CTF 2015 Quals -- r0pbaby

DEFCON CTF 2015 Quals -- catwestern

Comments powered by Disqus.