My own little Ransomware
Here's how I made a small demo ransomware.
Ok let's start making our ransomware
First we open Visual Studio Code and add python extensions. Make a python file named ransomware.py. Then we import os and cryptography Fernet.
To import cryptography Fernet we need to install cryprography from vs code terminal. Type pip install cryptography.
Then we need to look into the files in a folder so we create an array of file. Then we use for loop to look for files and save into file array.
Then we have to create a key to encrypt all the files. So we make a new variable key and generate a key using Fernet.generate_key().
Then we open a file in write mode named thekey as thekey.key file. Then using for loop we store all the files of file array in new variable contents and open it in read mode. And encrypt the contents using Fernet(key).encrypt(contents). Also we type in a small messsage too.
So here's our small ransomware ready to execute. But we also need to decrypt the files later on so we write decrypt code. So we make a new file decrypt.py and copy the code of ransomware.py. Since we need to make only a little changes.
First the few lines are same.
Now we need to open the thekey file that contains the key that we use it to decrypt the files. Remeber we have if condition to leave some of the files from being encrypted. So we open thekey file in read mode and create a secretkey ro read the key. Then we create a secret phrase to encrypt the files.
Now we neeed to see if the secret phrase is equal to the generated key or not.And the open the files and decrypt the files using Fernet(secretkey).decrypt(contents), we have our encrypted files in the contents.
So we have successfully encrypted and decrypted files using our code in python. We need to enter our secret phrase "perpendicular" to encrypt the files. And we also have our message printed.
You can download the ransomware.py file here. Also you can download decrypt.py file here.