Skip to content

Instantly share code, notes, and snippets.

@yue82
Last active May 2, 2019 06:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yue82/07ade10c64f12afe56a671f05029b58d to your computer and use it in GitHub Desktop.
Save yue82/07ade10c64f12afe56a671f05029b58d to your computer and use it in GitHub Desktop.
reiwa ctf zero ha?
# -*- coding: utf-8 -*-
import socket
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect(('zerois-o-reiwa.seccon.jp', 23615))
for num in range(100):
data = ''
while data[:2] != '0=':
data = s.recv(1024)
if data[0] == 'W':
print(data)
exit()
q = data[2:-3].replace('?', '{}')
dic = {}
exec('a0={}'.format(q.format(0)), {}, dic)
exec('a1={}'.format(q.format(1)), {}, dic)
m = dic['a0'] - dic['a1']
if m == 0:
a = 0
else:
a = int(dic['a0'] / m)
print(num, q, dic, m, a)
s.send(b'{}'.format(a))
while True:
data = s.recv(1024)
if data:
print(data)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment