Skip to content

Instantly share code, notes, and snippets.

@ulexec
Last active January 18, 2016 11:15
Show Gist options
  • Save ulexec/6dc8e82cc90e40bd674f to your computer and use it in GitHub Desktop.
Save ulexec/6dc8e82cc90e40bd674f to your computer and use it in GitHub Desktop.
Bring-the-Noise( crypto 200 ) Insomnihack teaser CTF 2016
#amn3s1a team: soez, n4x
from amnesia import *
import hashlib
import itertools
def learn_with_vibrations(lista):
q, n, eqs = 8, 6, 40
num = "01234567"
l = itertools.product(num, repeat=6)
while True:
c = "".join(l.next())
solution = []
for j in c:
solution.append(j)
print "[*] possible solution: %s" % solution
cont = 0
for coefs in lista:
ultimo = int(coefs[len(coefs)-1])
for k in range(-1, 3):
result = sum([int(solution[i])*int(coefs[i]) for i in range(n)]) % q
vibration = k
result = (result + q + vibration) % q
if result == ultimo:
cont += 1
break
if cont == eqs:
break
return solution
s = amnesiaSocket("bringthenoise.insomnihack.ch", 1111)
val = s.readLine()[-6:-1]
print "[*] finding appropitate seed for " + val
for i in range(0xffffff):
hash_object = hashlib.md5(str(i)).hexdigest()
if hash_object[:5] == val:
print "[+] coincidence founded : %d " % i
s.writeLine(str(i))
break
lista = []
for i in range(40):
e = s.readLine()[:-1].split(", ")
lista.append(e)
solution = learn_with_vibrations(lista)
string = ""
for j in solution:
string += j + ", "
print "[+] Solution: %s" % string[:-2]
print "[+] Aqui va el flag :)"
print s.readLine()
s.writeLine(string[:-2])
print s.readLine()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment