Sinisterly
[challenge] compressed folder obfuscation - Printable Version

+- Sinisterly (https://sinister.ly)
+-- Forum: Coding (https://sinister.ly/Forum-Coding)
+--- Forum: Coding (https://sinister.ly/Forum-Coding--71)
+--- Thread: [challenge] compressed folder obfuscation (/Thread-challenge-compressed-folder-obfuscation)

Pages: 1 2 3


[challenge] compressed folder obfuscation - Inori - 04-17-2015

Recently, I found out that it's possible to change the extension of any compressed folder (.zip, .rar, even .exe) to .txt or your choice of text file to make it unusable, then change it back when needed to use it.

My challenge is to find a way to do this automatically, using minimal user input. I tired it yesterday and failed pretty hard so good luck to anyone who tries.


RE: [challenge] folder encryption - Master - 04-17-2015

Bulk Rename Utility is a free file renaming software for Windows. Bulk Rename Utility allows you to easily rename files and entire folders based upon extremely flexible criteria.
[Image: bulk-rename-utility.jpg]

Hope this help.


RE: [challenge] folder encryption - Inori - 04-17-2015

(04-17-2015, 01:14 PM)Master Wrote: Bulk Rename Utility is a free file renaming software for Windows. Bulk Rename Utility allows you to easily rename files and entire folders based upon extremely flexible criteria.

-snip-

Hope this help.

I have BRU but the point of the challenge is to code a system that does the renaming from scratch.


RE: [challenge] folder encryption - Eclipse - 04-17-2015

What do you mean my automatically? Seems vague.

By the way, this isn't encryption. Just sayin'.


RE: [challenge] folder encryption - Inori - 04-17-2015

(04-17-2015, 01:41 PM)Eclipse Wrote: What do you mean my automatically? Seems vague.

By the way, this isn't encryption. Just sayin'.

By automatic, I mean after the file name is inputted, the written program would go through the process of changing the extension without any manual intervention.

(And yeah ik it's not encryption but I couldn't think of a better term)


RE: [challenge] folder encryption - Brawler - 04-17-2015

(04-17-2015, 04:41 PM)Touka Wrote: By automatic, I mean after the file name is inputted, the written program would go through the process of changing the extension without any manual intervention.

(And yeah ik it's not encryption but I couldn't think of a better term)

Obfuscation! That's the word you were looking for Smile

Here is a PowerShell 1 liner for renaming .txt to .obscure for all files within the current directory.

Code:
Get-ChildItem *.txt | foreach {Rename-Item $_ ($_.basename + ".obscure")}



RE: [challenge] folder encryption - Eclipse - 04-17-2015

(04-17-2015, 04:41 PM)Touka Wrote: By automatic, I mean after the file name is inputted, the written program would go through the process of changing the extension without any manual intervention.

(And yeah ik it's not encryption but I couldn't think of a better term)

Well, for that you'd need to have a program that runs in the background constantly and monitors all the filenames that you change. I mean, what would be the use of such a program? It'd be much better to just change the filenames of certain files in a given directory. Like so:

Code:
import os path = r'/path/to/file' os.chdir(path) exts = ['.exe', '.rar', '.zip'] for item in os.listdir('.'): if os.path.isfile(item): for ext in exts: if os.path.splittext(path)[1] == ext: os.rename(path, os.path.splittext(path)[0] + '.php')

I'll add a recursive function later but this'll have to do for now. I'm currently on a phone with shitty signal and it's a bumpy ride. Sorry for any mistakes, it's untested.


RE: [challenge] folder encryption - Brawler - 04-17-2015

(04-17-2015, 07:37 PM)Eclipse Wrote: Well, for that you'd need to have a program that runs in the background constantly and monitors all the filenames that you change. I mean, what would be the use of such a program? It'd be much better to just change the filenames of certain files in a given directory. Like so:

Code:
import os path = r'/path/to/file' os.chdir(path) exts = ['.exe', '.rar', '.zip'] for item in os.listdir('.'): if os.path.isfile(item): for ext in exts: if os.path.splittext(path)[1] == ext: os.rename(path, os.path.splittext(path)[0] + '.php')

I'll add a recursive function later but this'll have to do for now. I'm currently on a phone with shitty signal and it's a bumpy ride. Sorry for any mistakes, it's untested.

How are we going to keep the extensions straight for returning them?

Just my two cents.


RE: [challenge] folder encryption - Eclipse - 04-17-2015

(04-17-2015, 07:57 PM)Brawler Wrote: How are we going to keep the extensions straight for returning them?

Just my two cents.

I'm not quite sure what you mean.


RE: [challenge] folder encryption - ring-1 - 04-17-2015

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()