Skip to content

Instantly share code, notes, and snippets.

@hasherezade

hasherezade/first_xor.py Secret

Created Jul 13, 2015
Embed
What would you like to do?
Bunitu Proxy - decoding scripts
#!/usr/bin/python
FILENAME = "dalookerzmeoajrhja144"
KEY = "dalookerzmeoajrhja144"
MAX_KEY_LEN = 0xA
def decode1(data, key, max_key):
l = len(key)
j = 0 #key index
decoded = bytearray()
for i in range(0, len(data)):
decoded.append(data[i] ^ key[j % l])
if (i > 0):
j += 1
if (j == max_key):
j = 0
return decoded
data = bytearray(open(FILENAME, 'rb').read())
key = bytearray(KEY)
print decode1(data, key, MAX_KEY_LEN)
#!/usr/bin/python
FILENAME = "UncryptedStub._ini"
KEY = "9JKjPZSpEL8uHmkHNlXhwhDc9jRTGN"
MAX_KEY_LEN = 0x1E
def decode2(data, key, max_key):
j = 0 #key index
prev_j = 0
decoded = bytearray()
for i in range(0, len(data)):
val = data[i] + prev_j
val = ((val ^ key[j]) ^ key[prev_j]) % 256
decoded.append(val)
prev_j = j
j = j + 1
if (j == max_key):
j = 0
return decoded
data = bytearray(open(FILENAME, 'rb').read())
key = bytearray(KEY)
print decode2(data, key, MAX_KEY_LEN)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment