Building a ransomware in Python (for educational purposes)

See repository

The Ransomware project explores cybersecurity threats, analyzing behavior, propagation techniques, and mitigation strategies. By understanding this type of script's inner workings, it aids in combating cyber threats and safeguarding digital assets.

def generate_key(password, salt_size=16, load_existing_salt=False, save_salt=True):
    if load_existing_salt:
        salt = load_salt()
    elif save_salt:
        salt = generate_salt(salt_size)
        with open("salt.salt", "wb") as salt_file:
            salt_file.write(salt)
    derived_key = derive_key(salt, password)
    return base64.urlsafe_b64encode(derived_key)

Steps :

  1. Necessary modules are imported.
  2. Key-related functions defined.
  3. Functions for encrypting files/folders.
  4. Functions for decrypting files/folders.