Skip to content

Instantly share code, notes, and snippets.

@0xbahaa 0xbahaa/xor_decryptor.py
Last active Feb 5, 2019

Embed
What would you like to do?
Decrypt the whole file by XORing each byte with a Key
#!/usr/bin/env python3
"""
__author__ = "Ahmad Bahaa"
__email__ = "0xbahaa@patch8.com"
Thanks to SalusLab for this challenge :)
"""
filename = 'encryped.zip'
out_filename = 'aaa.zip'
xor_key = 0xEE
bytes_list = []
#reading the file byte-by-byte into our list
# Source:https://stackoverflow.com/a/2872397
with open(filename, 'rb') as f:
while 1:
byte_s = f.read(1)
if not byte_s:
break
byte = byte_s[0]
bytes_list.append(byte)
#XORing each byte with our key (0xEE) and saving all in a new list
bytes_list_2 = []
for i in bytes_list:
ii = i ^ xor_key
bytes_list_2.append(ii)
#write the result into a zip-file
#print(bytes(bytes_list_2))
with open(out_filename,'wb') as f:
f.write(bytes(bytes_list_2))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.