Create a gist now

Instantly share code, notes, and snippets.

@Newbrict /decode_pass.py Secret
Created Mar 19, 2015

Decodes the password for tw33tchainz binary
import sys
# get command line args
hexString = sys.argv[1]
# split it up by word size
splitSize = 8
words = [hexString[i:i+splitSize] for i in range(0, len(hexString), splitSize)]
# flip each word to account for little endian encoding
little_endian = []
splitSize = 2 # len of byte
for w in words:
splitByte = [w[i:i+2] for i in range(0, len(w), 2)]
splitByte = splitByte[::-1]
for byte in splitByte:
# convert to little endian and add to str
little_endian.append(int(byte,16))
# apply our changes to each byte
secret = []
for i in little_endian[:-1]:
if i % 2 == 0:
secret.append(((i+2) % 256))
else:
secret.append(i)
secret = ''.join([chr(c) for c in secret])
secret += chr(little_endian[-1])
sys.stdout.write(secret)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment