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


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

(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:
-snip-

I still haven't had my coffee so I only understood about half of it but from what I got, that sounds like it'd do the job.


RE: [challenge] compressed folder obfuscation - Eclipse - 04-17-2015

(04-17-2015, 09:12 PM)Touka Wrote: I still haven't had my coffee so I only understood about half of it but from what I got, that sounds like it'd do the job.

It's not 'automatic', but apart from that, it's pretty much what you're looking for


RE: [challenge] compressed folder obfuscation - Brawler - 04-18-2015

(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. Tongue


RE: [challenge] compressed folder obfuscation - Inori - 04-18-2015

(04-18-2015, 12:10 AM)Brawler Wrote: 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. Tongue

Actually, that doesn't sound half bad if you're dead set on destroying a file. Even overwriting isn't absolute so I guess this could help.


RE: [challenge] compressed folder obfuscation - Brawler - 04-18-2015

(04-18-2015, 12:47 AM)Touka Wrote: Actually, that doesn't sound half bad if you're dead set on destroying a file. Even overwriting isn't absolute so I guess this could help.

If that is your intent you should just zero it out.


RE: [challenge] compressed folder obfuscation - ring-1 - 04-18-2015

(04-18-2015, 01:02 AM)Brawler Wrote: If that is your intent you should just zero it out.

Pretty much this.
If you're using my script to remove data completely then you're going the wrong way about it, though the idea was to obfuscate the file, not erase it.

(04-17-2015, 09:46 PM)Eclipse Wrote: It's not 'automatic', but apart from that, it's pretty much what you're looking for

wat
In what way is my script not automatic? The fact that you have to change two, or possibly zero settings?


RE: [challenge] compressed folder obfuscation - Eclipse - 04-18-2015

(04-18-2015, 02:28 AM)ring-1 Wrote: wat
In what way is my script not automatic? The fact that you have to change two, or possibly zero settings?

There was some weird and, in my opinion, useless requirement for the script to run constantly in the background and rename every file that the user changes, 'automatically'.

(04-18-2015, 12:10 AM)Brawler Wrote: 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.

Well, if you really wanted to, you could save it to a log file somewhere and read from it.

Agreed.


RE: [challenge] compressed folder obfuscation - 0xDEAD10CC - 04-18-2015

(04-17-2015, 01:06 PM)Touka Wrote: 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.

I'm confused. Changing the file extension does not make it unusable, it just changes the default program used to open the file; on windows, default programs for the "open" verb for instance depend on the default program assigned to a file extension. Other than that, I can load an executable with a .txt or .jpeg file extension into memory no problem, because the file bytes will never change just by changing the file extension. What point are you trying to get across here?

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

So parsing the file signature and determining the original filetype by that, and renaming the file to it's proper extension automatically? It's as simple as that.

"MZ" - .exe
"PK" - .zip
etc...

Otherwise I don't understand... It's easy to just call the rename() function and change the filename + extension to anything at random.


RE: [challenge] compressed folder obfuscation - Eclipse - 04-18-2015

(04-18-2015, 07:15 PM)0xDEAD10CC Wrote: I'm confused. Changing the file extension does not make it unusable, it just changes the default program used to open the file; on windows, default programs for the "open" verb for instance depend on the default program assigned to a file extension. Other than that, I can load an executable with a .txt or .jpeg file extension into memory no problem, because the file bytes will never change just by changing the file extension. What point are you trying to get across here?

It'd be pretty effective at confusing a skiddy.

EDIT: That's pretty much the only use...


RE: [challenge] compressed folder obfuscation - ring-1 - 04-19-2015

(04-18-2015, 07:11 AM)Eclipse Wrote: There was some weird and, in my opinion, useless requirement for the script to run constantly in the background and rename every file that the user changes, 'automatically'.

That makes no sense. I'm not even being condescending. There is no requirement for the script to run constantly at all, you throw it in a directory, execute the script and ta-dah, all of your files are obfuscated. If you're implying that the output of the script is somehow... "constantly running," then just fork the Python process so that it isn't piped into the parent process. The script also doesn't require any manual interactions, so if anything, it's 100% automatic.