Skip to content

Batyrkajan/ransomeware

Repository files navigation

Simple Ransomware in Python Disclaimer: This script is for educational purposes only. Unauthorized access or modification of files without explicit permission is illegal and unethical. Use this code responsibly and only in controlled environments.

Overview This project demonstrates a simple implementation of ransomware in Python. It is intended to educate about how ransomware might operate, including file encryption and decryption processes.

Features File Encryption: Encrypts files in a specified directory using Base64 encoding. Ransom Message: Informs the user that their files have been encrypted and provides instructions. File Decryption: Allows decryption of files when the correct key is provided. How It Works Encryption Process:

The script scans the specified directory for files. It excludes certain files like README.md and the script itself to prevent self-encryption. Each file's content is read and encoded using Base64. The original file is overwritten with the encoded content. Ransom Notification:

After encryption, the script displays a message informing the user about the encryption. It requests a payment (simulated) to provide the decryption key. Decryption Process:

Prompts the user to enter a decryption key. If the key matches the predefined key in the script, it decodes the files. The original content is restored by overwriting the encoded files. Usage Prerequisites Python 3.x installed on your system. Basic understanding of running Python scripts. A test directory with sample files to encrypt and decrypt. Steps Setup:

Clone or download the script to a directory. Navigate to the directory containing the script. Running the Script:

bash

python3 ransomware.py

The script will encrypt all eligible files in the directory. A ransom message will be displayed. Decrypting Files:

When prompted, enter the decryption key. If the key is correct, the files will be decrypted. The correct key is hardcoded in the script as __ransomware_key.

Code Explanation Ransomware Class Purpose: Encapsulates all functionalities related to encryption, decryption, and user interaction.

Key Methods:

encrypt_file(filename): Encrypts a single file using Base64 encoding. decrypt_file(key, filename): Decrypts a file if the correct key is provided. get_files_in_folder(path): Retrieves a list of files to be processed. encrypt_files_in_folder(path): Encrypts all files in the specified folder. decrypt_files_in_folder(path): Decrypts all files in the specified folder after key verification. ransom_user(): Displays the ransom message to the user. obtain_key(): Prompts the user to enter the decryption key. Important Variables self._name: Stores the name of the ransomware instance. self.key: The hardcoded key used for encryption and decryption. Important Notes Educational Purposes Only: This script is designed to educate about ransomware behavior and should not be used maliciously. Base64 Encoding: The script uses Base64 encoding, which is not secure encryption. It's used here for simplicity. Ethical Considerations: Modifying or accessing files without permission is illegal. Always ensure you have the right to operate on the files and directories you target. Testing Environment: Use this script in a controlled environment with non-critical files to prevent data loss. Logging The script uses Python's logging module to output debug information. Logging level is set to DEBUG to provide detailed information about the script's execution flow. Logs include information about files being encrypted/decrypted and any errors encountered. Potential Issues and Solutions Permission Errors: You might encounter permission issues when accessing certain files or directories. Ensure you have the necessary permissions. Encoding Errors: The script assumes files are UTF-8 encoded. Non-text files or files with different encodings may cause errors. Error Handling: The script includes basic error handling to skip files that cause exceptions and logs the errors for review. Example Output vbnet Копировать код DEBUG:root:Encrypting file: /path/to/targetfile.txt Hi, all your files have been encrypted. Please send 0.1 USD on this address to get decryption key: XYZ. Number of encrypted files: 1 Please enter a key: __ransomware_key Files have been decrypted successfully.

License This project is licensed under the MIT License - see the LICENSE file for details.

Contact For questions or comments, please open an issue in the repository.

Warning: Potential Legal and Ethical Consequences:

The code implements a form of ransomware—a type of malicious software that encrypts files and can be used to demand payment for their decryption. Engaging with this code can lead to serious legal, ethical, and personal repercussions.

Potential Consequences

  1. Legal Issues Criminal Charges: Unauthorized access to or modification of computer systems and data is illegal under numerous national and international laws, including the Computer Fraud and Abuse Act (CFAA) in the United States and the Computer Misuse Act in the United Kingdom.

Prosecution for Cybercrime: Distributing or executing ransomware can lead to charges related to cyber extortion, hacking, and cyberterrorism.

Civil Liability: Victims of ransomware attacks may file civil lawsuits seeking damages, leading to significant financial penalties and restitution orders.

  1. Ethical Concerns Harm to Individuals and Organizations: Encrypting files without consent can cause loss of critical data, disrupt operations, and harm livelihoods.

Violation of Privacy: Unauthorized manipulation of data breaches ethical standards regarding privacy and consent.

  1. Personal Risks Reputational Damage: Involvement in cybercrime can permanently tarnish personal and professional reputations, affecting future employment and relationships.

Security Risks: Running such code, even in a controlled environment, may inadvertently expose your system to vulnerabilities or data loss.

Recommendations Do Not Execute or Distribute the Code: Avoid running this script on any system, including your own, as it may cause unintended damage or legal complications.

Use for Educational Purposes Only: If you are studying the code to understand how ransomware works, ensure it is done responsibly, ethically, and within the bounds of the law.

Consult Legal Professionals: Before engaging with code that has the potential for misuse, seek legal advice to understand the ramifications.

Focus on Ethical Cybersecurity Practices: Consider contributing positively by learning about cybersecurity defense mechanisms, ethical hacking (with proper authorization), or developing tools to combat malware.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages