i created malware with Python (it's SCARY easy!!)
Based on NetworkChuck's video on YouTube. If you like this content, support the original creators by watching, liking and subscribing to their content.
The ransomware workflow is built from four steps: enumerate targets, encrypt file contents, write ciphertext back, and manage a persistent key for recovery.
Briefing
A hands-on Python walkthrough demonstrates that basic ransomware can be built with surprisingly little code: it encrypts files in a working directory, demands a “key” (framed as payment), and then uses a separate decryption script to restore data. The core takeaway is mechanical rather than theoretical—once a program can enumerate files, encrypt their contents, and write the ciphertext back, the rest is mostly bookkeeping (key generation, key storage, and excluding certain files so the process doesn’t destroy its own recovery path).
The build starts by setting up a safe, disposable Linux environment—explicitly recommending a cloud Linux instance that can be destroyed afterward. After creating a “ransomware” folder and generating a few sample text files, the walkthrough moves into a Python script (“Voldemort.py”). The script uses the OS library to list items in the current directory, filters out itself so it won’t encrypt the running program, and later adds a second filter to avoid encrypting directories (using os.path.is_file). Once the target list is correct, the encryption step relies on the cryptography library’s Fernet symmetric encryption. A fresh encryption key is generated with Fernet.generate_key(), saved to a local file (“key.key”) in binary form, and then used to encrypt each file’s contents.
To prevent the key file from being encrypted on subsequent runs, the script adds another exclusion rule for “key.key.” After encryption, the plaintext files become unreadable “gobbly cook” ciphertext, illustrating the practical impact of file encryption. A companion script (“decrypt.py”) reverses the process: it loads the saved key from key.key, decrypts each encrypted file back into plaintext, and also excludes decrypt.py itself so it doesn’t get overwritten during restoration. The walkthrough then adds “ransomware-like” theatrics—printing a demand message and requiring a user-entered secret phrase (hardcoded as “coffee”) before decryption proceeds.
The second half shifts from custom ransomware to learning from existing code. It clones a GitHub repository called malware showcase by Patrick (spelled as Patrick in the transcript), which contains Python-based examples of multiple malware categories—worms, Trojans, spyware, adware, ransomware, and file infection patterns. The setup instructions focus on installing Python dependencies via pip3 and a requirements.txt file, then navigating into individual example folders (such as file infection) to inspect and run scripts. The emphasis stays on educational use, with repeated warnings to use throwaway systems and ensure backups.
Overall, the transcript’s central message is that ransomware’s essential workflow—file discovery, encryption, key handling, and recovery gating—can be implemented in a straightforward way in Python, which is precisely why it’s framed as both “scary” and instructive.
Cornell Notes
The walkthrough builds a working ransomware/decryption pair in Python by combining file enumeration, Fernet symmetric encryption, and careful exclusions. It first creates a list of files in a directory, skips the ransomware script itself, and later skips directories and the saved key file (key.key) so recovery remains possible. Encryption writes ciphertext back into the same files, making them unreadable until the key is used. A separate decrypt.py script loads key.key, decrypts each file, and adds a secret-phrase gate (“coffee”) before restoring data. A second section then introduces malware showcase, a GitHub repository of Python examples for studying different malware behaviors.
How does the ransomware script decide which files to encrypt?
What encryption mechanism is used, and how is the key handled?
Why does the script need to exclude key.key from encryption?
How does decrypt.py restore files, and what prevents it from breaking itself?
What extra “ransomware-like” behavior is added beyond encryption/decryption?
What is malware showcase, and how is it set up for study?
Review Questions
- What specific checks does the ransomware script perform to avoid encrypting its own code, directories, and the key file?
- Describe the end-to-end flow from key generation to file encryption to key-based decryption in the two-script setup.
- How does the secret-phrase requirement change the behavior of decrypt.py compared with a plain “decrypt everything” utility?
Key Points
- 1
The ransomware workflow is built from four steps: enumerate targets, encrypt file contents, write ciphertext back, and manage a persistent key for recovery.
- 2
Correct target selection matters: excluding the ransomware script (Voldemort.py), skipping directories via os.path.is_file(), and excluding key.key prevents self-destruction and preserves decryptability.
- 3
Fernet symmetric encryption from the cryptography library is used to transform file bytes into ciphertext that cannot be read without the key.
- 4
The decryption script mirrors the encryption logic: it loads key.key, decrypts each encrypted file, and writes plaintext back to the same filenames.
- 5
A simple user gate (secret phrase “coffee”) is added to decrypt.py to mimic the coercive control seen in real ransomware.
- 6
A separate learning path uses the GitHub repository malware showcase to study Python implementations of multiple malware categories via cloned code and pip-installed dependencies.