-
-
Save stefan2904/8d14ca2eb0ec2fb38c23 to your computer and use it in GitHub Desktop.
via IRC
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
import socket | |
import random | |
host = "blackbox_ced7f267475a0299446fa86c26d77161.quals.shallweplayaga.me" | |
port = 18324 | |
inputs = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!\"#$%&'()*+,-./:;<=>?@[\]^_`{|}~ " | |
s = socket.socket() | |
s.connect((host, port)) | |
print s.recv(2048) | |
print s.recv(2048) | |
test = "ABab" | |
# Box 1 | |
s.sendall(test+"\n") | |
rec = s.recv(2048) | |
resp = rec[rec.index("[")+1:rec.index("\t")-1] | |
shift = inputs.index(resp[0]) | |
shift -= inputs.index(test[0]) | |
resp = rec[rec.index("Expected"):] | |
ans = resp[resp.index("[")+1:-2] | |
out = "" | |
for l in ans: | |
key = (inputs.index(l)-shift) % len(inputs) | |
out += inputs[key] | |
print out | |
s.sendall(out+"\n") | |
print s.recv(2048) | |
print s.recv(2048) | |
# Box 2 | |
test = "ABAAAAA" | |
s.sendall(test+"\n") | |
rec = s.recv(2048) | |
print rec | |
resp = rec[rec.index("Expected"):] | |
ans = resp[resp.index("[")+1:-2] | |
print repr(ans) | |
out = "" | |
shift = 0 | |
for l in ans: | |
key = inputs.index(l)-shift | |
shift += inputs.index(l) | |
shift = shift % len(inputs) | |
out += inputs[key] | |
print out | |
s.sendall(out+"\n") | |
print s.recv(2048) | |
print s.recv(2048) | |
test = "ABCDA" | |
s.sendall(test+"\n") | |
rec = s.recv(2048) | |
print rec | |
out = "" | |
resp = rec[rec.index("[")+1:rec.index("\t")-1] | |
shift = inputs.index(resp[0]) | |
shift -= inputs.index(test[0]) | |
print shift, resp[0], test[0] | |
resp = rec[rec.index("Expected"):] | |
ans = resp[resp.index("[")+1:-2] | |
print repr(ans) | |
for l in ans: | |
key = (inputs.index(l)-shift) % len(inputs) | |
out += inputs[key] | |
print out | |
out = out[::-1] | |
s.sendall(out+"\n") | |
print s.recv(2048) | |
print s.recv(2048) | |
s.sendall("A"*40+"\n") | |
rec = s.recv(2048) | |
key = rec[rec.index("[")+1:rec.index("\t")-1] | |
resp = rec[rec.index("Expected"):] | |
ans = resp[resp.index("[")+1:-2] | |
out = "" | |
for i in xrange(len(ans)): | |
shift = inputs.index(key[i]) | |
out += inputs[(inputs.index(ans[i]) - shift)%len(inputs)] | |
print out | |
s.sendall(out + "\n") | |
print s.recv(2048) | |
print s.recv(2048) | |
#box 5 | |
s.sendall("AAAA\n") | |
rec = s.recv(2048) | |
key = rec[rec.index("[")+1:rec.index("\t")-1] | |
resp = rec[rec.index("Expected"):] | |
ans = resp[resp.index("[")+1:-2] | |
shift = inputs.index(key[0]) | |
out = "" | |
print ans | |
for l in ans: | |
key = (inputs.index(l)-shift) % len(inputs) | |
shift += inputs.index(l) % len(inputs) | |
out += inputs[key] | |
s.sendall(out[::-1]+"\n") | |
print s.recv(2048) | |
print s.recv(2048) | |
s.sendall("A"*50+"\n") | |
rec = s.recv(2048) | |
key = rec[rec.index("[")+1:rec.index("\t")-1] | |
resp = rec[rec.index("Expected"):] | |
ans = resp[resp.index("[")+1:-2] | |
#ans = "".join([chr(0x41+(i%26)) for i in xrange(50)]) | |
off = inputs.index(key[i]) | |
print inputs | |
print key | |
out = "" | |
shift = 0 | |
for j in xrange(0,len(ans),4): | |
try: | |
i = j | |
out += inputs[(inputs.index(ans[i])-inputs.index(key[0])-shift)%len(inputs)] | |
shift += inputs.index(ans[i])+1 | |
i = j+1 | |
out += inputs[(inputs.index(ans[i])-inputs.index(key[0])-shift)%len(inputs)] | |
shift += inputs.index(ans[i])+1 | |
i = j+3 | |
out += inputs[(inputs.index(ans[i])-inputs.index(key[0])-shift)%len(inputs)] | |
shift += inputs.index(ans[i])+1 | |
i = j+2 | |
out += inputs[(inputs.index(ans[i])-inputs.index(key[0])-shift)%len(inputs)] | |
shift += inputs.index(ans[i])+1 | |
except: | |
pass | |
print ans | |
print out | |
s.sendall(out+"\n") | |
rec = s.recv(2048) | |
key = rec[rec.index("[")+1:rec.index("\t")-1] | |
resp = rec[rec.index("Expected"):] | |
print rec | |
print s.recv(2048) | |
print s.recv(2048) | |
print s.recv(2048) | |
print s.recv(2048) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The flag is: Gr3aT j0b! BlackBox Ma$Ter$@!!!%%