Skip to content

Instantly share code, notes, and snippets.

@valhallasw
Created April 7, 2012 19:26
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 valhallasw/2331532 to your computer and use it in GitHub Desktop.
Save valhallasw/2331532 to your computer and use it in GitHub Desktop.
let_us_have_hex stitcher try
[submodule "4a65eadfbdc81b5eeb43"]
path = 4a65eadfbdc81b5eeb43
url = git@gist.github.com:4a65eadfbdc81b5eeb43.git
import sys
def dostitch():
first = "497a78705032357759326873634855675a43526c595341675044317a494852685a484a70636d39684c6e6c6f4b4434354369"
data = [line.strip() for line in open("4a65eadfbdc81b5eeb43/hexes").readlines()]
datastitch = first
i = 0
while (i < len(datastitch)):
i += 1
for line in data:
if line.startswith(datastitch[i:]):
overlap = len(datastitch[i:])
if overlap < 25:
return datastitch
data.remove(line)
print "match with overlap %i" % overlap
datastitch = datastitch[:i] + line
break
return datastitch
def toascii(data):
import binascii
return binascii.unhexlify(data)
def unbase64(data):
import binascii
length = len(data)
for takelen in [length, length-1, length-2]:
try:
return binascii.a2b_base64(data[:takelen])
except binascii.Error, e:
pass
raise e
def split(data):
c = ''.join(data[i] for i in range(0, len(data), 2))
php = ''.join(data[i] for i in range(1, len(data), 2))
return c, php
data = dostitch()
asciidata = toascii(data)
rawdata = unbase64(asciidata)
c, php = split(rawdata)
print "C code"
print "========"
print c
print ""
print "PHP code"
print "========"
print php
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment