Created
April 10, 2019 22:15
-
-
Save Ge0rg3/fea57ae3785a2a7d22d39c09f5b311d9 to your computer and use it in GitHub Desktop.
Solving Sunshine CTF 2019's Time Warp challenge.
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
from socket import socket | |
nums = [] | |
def recv(sock): | |
try: data = sock.recv(1024).decode() | |
except: data = "" | |
print(data) | |
return data | |
while True: | |
sock = socket() | |
sock.settimeout(0.1) | |
try: | |
sock.connect(('archive.sunshinectf.org', 19004)) | |
except: | |
print("Could not connect... retrying") | |
sock.close() | |
continue | |
print(recv(sock)) | |
print(recv(sock)) | |
for index, num in enumerate(nums): | |
print(str(num)+", "+str(index)+"/"+str(len(nums))) | |
sock.send((num+"\n").encode('utf-8')) | |
congratsText = recv(sock) | |
congratsText += recv(sock) | |
sock.send("0\n".encode('utf-8')) | |
sock.settimeout(0.3) | |
resp = recv(sock) | |
sock.settimeout(0.1) | |
givenNum = resp.split("\n")[0] | |
if givenNum.isdigit(): | |
nums.append(resp.split("\n")[0]) | |
print("Current:"+', '.join(nums)) | |
else: | |
print("Error in response:"+givenNum) | |
sock.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment