Last active
July 19, 2017 21:18
-
-
Save dloss/ba2ec6ad7bf0a9735323f1d5f516faeb to your computer and use it in GitHub Desktop.
Swizzle extraction toolkit (Python 2.7)
This file contains 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 sys | |
import binascii | |
chunklen = 32 | |
maxbyte = 31 | |
data = sys.stdin.read() | |
all_bytes_once_ascending = [chr(i) for i in range(chunklen)] | |
start = 0 | |
while start < len(data)-chunklen: | |
chunk = data[start:start+chunklen] | |
lastchar = chunk[chunklen-1] | |
if ord(lastchar) > maxbyte: | |
# skip whole chunk, because it cannot match | |
start += chunklen | |
else: | |
if sorted(chunk) == all_bytes_once_ascending: | |
print "Found at 0x%02x: %s" % (start, binascii.hexlify(chunk)) | |
p = ["0x%02x, " % ord(c) for c in chunk] | |
for line in range(4): | |
print " " + "".join(p[line*8:line*8+8]) | |
start += 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment