RE: [challenge] compressed folder obfuscation 04-18-2015, 12:10 AM
#13
(04-17-2015, 07:59 PM)Eclipse Wrote: I'm not quite sure what you mean.
For example with your code:
file1.zip -> file1.php
file2.rar -> file2.php
file3.exe -> file3.php
All three of these files now have the same extension.... What are you going to do to script them back to the original extension?
Then again, its probably not even worth thinking about as the end result is arguably worthless in terms of actual file hiding/obfuscation.
(04-17-2015, 08:08 PM)ring-1 Wrote: I figured this isn't the kind of thing you're looking for, but I made it anyway since the thread has the prefix of challenge in it. I assume it works on Windows, Unix, and Linux.
It also has a mode to obfuscate file contents too, since just changing the filename to a non-standard filetype doesn't stop the user from opening the file in a text editor or a simply just changing the filename, though it doesn't have a mode to deobfuscate the obfuscated contents.
It has a variable called blacklist_files, which will stop certain files from being obfuscated. Just add your own files into the list, example: blacklist_files = [current_file, "super secret porn accounts.txt", "credit bill.txt", "etc..."]
Code:import os import string import random cwd = os.path.dirname(os.path.realpath(__file__)) current_file = os.path.realpath(__file__) files = [ _ for _ in os.listdir(cwd) if os.path.isfile(os.path.join(cwd,_)) ] blacklist_files = [current_file] #enabling this will allow non-blacklisted file contents to become obfuscated along with the file names themself OBFUSCATE_FILE_CONTENTS = True def main(): for x in files: for _x in blacklist_files: if(x in _x): print("blacklisted file: {0} detected".format(x)) print("blacklisted file {0} not being obfuscated".format(x)) else: new_file_name = ''.join(random.choice(string.ascii_uppercase + string.ascii_lowercase + string.digits) for _ in range(12)) print("non-blacklisted file: {0} detected".format(x)) print("non-blacklisted file {0} being obufuscated".format(x)) os.rename(x, new_file_name) if OBFUSCATE_FILE_CONTENTS == True: old_file_c = open(new_file_name, "r") old_file_contents = list(old_file_c.read()) random.shuffle(old_file_contents) new_file_contents = ''.join(old_file_contents) _file = open(new_file_name, "w") _file.write(new_file_contents) old_file_c.close() _file.close() if __name__ == "__main__": main()
Correct me if I'm wrong..... But the file content shuffle is going to make your file unusable and/or non-recoverable. Why not use some actual symmetric/asymmetric encryption.... So you know... you can recover it.
(This post was last modified: 04-18-2015, 12:21 AM by Brawler.)


![[+]](https://sinister.li/images/modern/collapse_collapsed.png)