Skip to content

Instantly share code, notes, and snippets.

@dloss
Last active July 19, 2017 21:18
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 dloss/ba2ec6ad7bf0a9735323f1d5f516faeb to your computer and use it in GitHub Desktop.
Save dloss/ba2ec6ad7bf0a9735323f1d5f516faeb to your computer and use it in GitHub Desktop.
Swizzle extraction toolkit (Python 2.7)
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