Skip to content

Instantly share code, notes, and snippets.

@yohanes
Created October 26, 2014 12:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yohanes/2e31463a5412d43bd6df to your computer and use it in GitHub Desktop.
Save yohanes/2e31463a5412d43bd6df to your computer and use it in GitHub Desktop.
pwnium2014
import Image
import base64
import socket
import os
def process():
im = [None] * 10
im[0] = Image.open("x.png").rotate(90)
for i in range(1, 10):
w,h = im[i-1].size
im[i] = im[i-1].crop((10, 10, w-10, h-10)).rotate(180)
im[i].save("X-"+str(i) + ".png")
new_im = Image.new('RGB', (200,200))
for i in range(0, 10):
new_im.paste(im[i], (i*10, i*10))
t1 = new_im.getpixel((100, 2))
t2 = new_im.getpixel((100, 198))
t3 = new_im.getpixel((2, 100))
t4 = new_im.getpixel((198, 100))
if (t3==(255,255,0)):
print "ROTATE1"
new_im = new_im.rotate(180)
new_im.save("A.png")
os.system("/usr/bin/tesseract A.png abc")
with open("abc.txt", "r") as f:
l = f.read()
l = l.strip()
print "RESULT", l
return l
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.settimeout(10)
s.connect(('41.231.53.40', 9090))
data = ''
while True:
data += s.recv(1)
print data
if (data.find("Answer")>=0):
print "processing\n"
d,e = data.split("\n")
dd = base64.b64decode(d)
with open("x.png", "w") as f:
f.write(dd)
res = process()
s.send(res+"\n")
data = ''
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment