Skip to content

Instantly share code, notes, and snippets.

@zorix
Last active July 26, 2017 20:52
Show Gist options
  • Select an option

  • Save zorix/284330a8f423145a774780f94020667b to your computer and use it in GitHub Desktop.

Select an option

Save zorix/284330a8f423145a774780f94020667b to your computer and use it in GitHub Desktop.
import socket
import os
import sys
from time import sleep
def waitFor(s, msg):
got = ''
while msg not in got:
got += s.recv(4096)
return got
def send(s, msg):
s.send(msg + '\n')
def connect():
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect(('31.133.0.131', 9393))
waitFor(s, 'Enter shared secret mask you want to try:')
return s
"""
# finds length of SECERT1
msg = ''
while True:
msg += 'a'
s = connect()
send(s, msg)
sleep(0.2)
out = s.recv(4096)
if 'Mask too short.' not in out:
print msg
print out
break
print '.'
"""
passLen = 70 # 560 / 8
"""
# Display SECRET2
s = connect()
send(s, '00000001'*passLen)
sleep(0.1)
out = s.recv(4096)
print out
send(s, '0'*passLen)
sleep(0.1)
out = s.recv(4096)
print out
"""
def forceByte(i):
byte = ''
for b in range(8): #for each bit
s = connect()
checkingByteMask = ('0' * b) + '1' + ('0' * (8 - b - 1))
part1 = ('00000001' * i) + checkingByteMask + ('00000001' * (passLen - i - 1))
send(s, part1)
waitFor(s, 'Alright, now send in the bits:')
send(s, '0'*passLen)
out = waitFor(s, 'e')
if 'Access Granted' in out:
byte += '0'
else:
byte += '1'
sys.stdout.write(chr(int(byte[::-1], 2)))
sys.stdout.flush()
for i in range(passLen):
forceByte(i)
print ""
# This Crypto Is Absolutely Secure And There Will Be No Problem With It.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment