A ransomware is a piece of code that encrypts files and denies user access. The files can only be decrypted with the key used while encryption.
In this project, Python's Fernet
module is used to generate keys, encrypt, and decrypt files.
encrypt.py first generates a key (key.key file). This is being done by Fernet.generate_key()
. The key.key file stores the key which will be used to encrypt and further decrypt files. encrypt.py
recursively iterates and encrypts all the files present in the root_dir
. During encryption, we need to make sure that we are not encrypting the keys or the script used for encryption, or else that might have not end up well.
decrypt.py iterates through files similar to encrypt.py. Just the difference is that instead of encrypting, it decrypts all the files using same key which was generated during encryption. Without that key, decryption wouldn't work.
For recursively iterating files during encryption and decryption, FileLister is being used, which is just simple recursive way of listing all the files in a given directory.
Usage
For encryption, either give no arguments to run throughout test_dir
or give specific path:
For specific set of files:
Decryption:
For specific set of files:
Project link: https://github.com/chhajedji/ransomware
Top comments (1)
just created one in NodeJS github.com/uzair004/nodejs-ransome...