Hello, fellow grey hat hackers and aspiring coders. I'm back again with another python tutorial. Just that this one is gonna be a lot cooler ;-). We gonna make an encryption program, that well you know encrypts all the files on your pendrive or hdd or whatever you want....Also lots of thanks to DrapsTV. They have helped me a lot with Python and making awesome programs. The video is here:
But don't watch it. Read my article...lol
StoryTime
So, I was watching Mr. Robot(Duh!!) and I was just impressed by how he encrypted his stuff with DeepSound and I have already seen OTW's tutorial on that, but I've been a script kiddie for too long and it's annoying that I can't go back even if I want to(lol!!). But anyway I wanted to make my own you know.
Besides imagine if you mess up real bad and the FBI comes knocking on your door and you know you got so much evidence on your computer and you going to jail...lol...you can just run this program and erase your hdd so even if forensics manages to pull your stuff back. It's encrypted and you might get away with it. ;-)
Also, I also wanted to do this because I wanted to make a ransomware(SHUT UP!! I'm grey hat I get bored sometimes). But I ain't gonna do it! ( or am i? muhahaha!!!)...lmao ok...now the code...hehehehe!!!!
Step 1: Import Modules
You know you gotta do this. Some of the modules, you gonna have to download it. So download pycrypto if you don't have it ok... :-)
Don't worry about the pkg-resources. That's just because I was converting it to exe with pyinstaller and it was giving me problems...but you can add it if you gonna convert it to exe as well...I guess....
Step 2: Create Encryption Part
Now this is the bomb...the encryption part I mean...this function is where all the encryption takes place...
So I'm gonna try and explain everything as best as I can.
We are using AES encryption so we will have to encrypt it in 64 bits( I think...I'm not sooo sure about the technicalities that's in the video)
But anyway you have to create an Initialization Vector(IV) that's for the encryption process and we will have to get the filesize so we can get rid of things in the file that are not needed during decryption...you will see when we get there....
Step 3: Now Decryption - FBI's Part
So you see we gonna need the IV that we stored in the file to add to our decryptor object so we can decrypt our stuff....so the truncate makes sure it gets the exact file(something like that....)
Step 4: The Main Program
This part just asks the user for the password, whether he wants to encrypt or decrypt and does the work ...
As you can see the allfiles function does a traverse of all the files in the current directory and stores it in an array which will be the files been encrypted. And also I made sure it doesn't encrypt twice and it doesn't encrypt the encryption program.(Ain't I sweet?) <3 <3 XD XD
The password will be converted to SHA256 because it will have a total of 16 characters and AES needs the number of characters of the key to be equivalent to 16 so there we go.
Same for decryption except we don't want to decrypt all the files(that's just stupid) so you can only decrypt one file at a time.....
Conclusion
That's it...This article was written in a rush. Besides I suck at writing articles so yeah....
I'm sorry if it sucks but I figured the site needed some fresh blood.(Literally, I'm a vampire...am kidding) But you know what I mean.
So that is the code, and you can have fun encrypting files on your drives. just put it in the root directory of your drive and run it....
WARNING: If you try and decrypt the file with a wrong password you will forever lose access to the file. So you might as well just delete it...lol
And the code is here on pastebin: http://pastebin.com/PthzX9Bf
Forget to leave you with something....
Matthew 6:33 - "But seek ye first the kingdom of God, and His righteousness and all these things shall be added unto you!!"
Comments
No Comments Exist
Be the first, drop a comment!