public
Created

let_us_have_hex stitcher try

  • Download Gist
.gitmodules
1 2 3
[submodule "4a65eadfbdc81b5eeb43"]
path = 4a65eadfbdc81b5eeb43
url = git@gist.github.com:4a65eadfbdc81b5eeb43.git
stitch.py
Python
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
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

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.