Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
#!/usr/bin/env python3
# Solver for Sakebomb's Digerati’s Atlas Programming3 challenge @ Thotcon 0xA
import socket
HOST = 'irc.thotcon.org' # The server's hostname or IP address
PORT = 10000 # The port used by the server
def is_english(string):
words = ['the', 'there', 'some', 'use', 'her', 'than', 'and', 'this', 'would', 'first', 'have', 'each', 'make', 'water', 'from', 'which', 'like', 'been', 'she', 'him', 'call', 'one', 'into', 'who', 'you', 'had', 'how', 'time', 'oil', 'that', 'their', 'has', 'its', 'word', 'look', 'now', 'but', 'will', 'two', 'find', 'was', 'not', 'more', 'long', 'for', 'what', 'other', 'write', 'down', 'all', 'about', 'day', 'are', 'were', 'out', 'see', 'did', 'many', 'number', 'get', 'with', 'when', 'then', 'come', 'his', 'your', 'them', 'way', 'made', 'they', 'can', 'these', 'could', 'may', 'said', 'people', 'part']
for word in words:
if ' '+word+' ' in string:
return True
return False
def shift(message, key):
key = -key
translated = ""
for symbols in message:
if symbols.isalpha():
num = ord(symbols)
num += key
if symbols.isupper():
if num > ord('Z'):
num -= 26
elif num < ord('A'):
num += 26
elif symbols.islower():
if num > ord('z'):
num -= 26
elif num < ord('a'):
num += 26
translated += chr(num)
else:
translated += symbols
return translated
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
s.connect((HOST, PORT))
# s.sendall(b'yes')
data = s.recv(1024)
print('Received', repr(data))
if (data == b'Would you like to play a game?\n'):
s.sendall(b'yes')
data = s.recv(1024)
print('Received', repr(data))
s.sendall(b'\n')
data = s.recv(1024)
print('Received', repr(data))
# s.sendall(b'\n')
for y in range(5):
author = ""
for x in range(1, 25):
print("attempt: " + repr(x))
shifted = shift(data.decode('utf-8').strip(), x)
if (is_english(shifted)):
author = shifted.split('-')[-1] + '\n'
print(repr(author))
print('.......\n')
break
s.sendall(author.encode('utf-8'))
data = s.recv(1024)
data = s.recv(1024)
print('Recieved', repr(data))
data = s.recv(1024)
print('Recieved', repr(data))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.