1.8 KiB
1.8 KiB
Difficulty
50/100
Category
Programming
How To Solve
Each of the 'friends' will give you harder and harder mathematical
puzzles to solve. Everytime you solve one you get to know a new friend.
Their names are always the first letter of the flag and then something
random. This is obvious because if you print them out the first couple
of friends are called I, G, C, T, F which spells IGCTF. The flag is
then the first names of all friends back to back IGCTFBR0M4NCE
.
To solve these math puzzles, you need to write a program because they have to be solved within 10 seconds. You can use a python module to do it afaik, but I wrote a dead simple script that uses eval and some string replacements.
from pwn import *
import time
def sin(exp): return math.sin(math.radians(eval(str(exp))))
def cos(exp): return math.cos(math.radians(eval(str(exp))))
def sqrt(exp): return math.sqrt(eval(str(exp)))
def solve(expression):
newexpr = ''
for i, c in enumerate(expression):
if c == '|' and expression[i-5:].startswith('sqrt'):
newexpr += "abs("
elif c == '|':
newexpr += ')'
else:
newexpr += c
#print(newexpr)
return str(eval(newexpr))
conn = remote('localhost', 3005)
#conn = process(['python3', './friend-generator.py'])
time.sleep(0.1)
print(conn.recv())
conn.send('yes\n'.encode())
time.sleep(0.1)
names = []
while True:
data = conn.recv().decode()
try:
name = data[data.index('name'):].split('\n')[0][8:].split(',')[0]
expression = data[data.index('first: '):].split('\n')[1]
except ValueError:
print(data)
exit(0)
solution = solve(expression)
#print(f"= {solution}")
print(name)
names.append(name)
conn.send((solution + "\n").encode())
time.sleep(0.1)
Hints
n/a
Flag
IGCTFBR0M4NCE