Decrypt the whole file by XORing each byte with a Key
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
#!/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