Last active
May 2, 2019 06:16
-
-
Save yue82/07ade10c64f12afe56a671f05029b58d to your computer and use it in GitHub Desktop.
reiwa ctf zero ha?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- 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