-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdecrypt.py
More file actions
48 lines (42 loc) · 2.06 KB
/
Copy pathdecrypt.py
File metadata and controls
48 lines (42 loc) · 2.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# Activate virtual environment before running the script:
# source .venv/bin/activate --- for macOS/Linux
# .venv\Scripts\activate --- for Windows
import os
from cryptography.fernet import Fernet
# finding files
files = []
for file in os.listdir():
if file == "the_malware.py" or file == "thekey.key" or file == "decrypt.py" or file == "README.md" or file == "requirements.txt": # process every file except the script itself, the key file, the decryption script, the README file and the requirements file
continue
if os.path.isfile(file): # process only files
files.append(file)
print("Files encrypted:", files)
with open("thekey.key", "rb") as key:
secretkey = key.read()
secretphrase = "pratik"
user_phrase = input("Say my name: ")
if user_phrase == secretphrase:
for file in files:
with open(file, "rb") as thefile:
contents = thefile.read()
contents_decrypted = Fernet(secretkey).decrypt(contents)
with open(file, "wb") as thefile:
thefile.write(contents_decrypted)
print("\n" + "="*60)
print("✅ SUCCESS! YOUR FILES ARE SAFE! ✅")
print("="*60)
print("""
███████╗██████╗ ███████╗███████╗██████╗
██╔════╝██╔══██╗██╔════╝██╔════╝██╔══██╗
█████╗ ██████╔╝█████╗ █████╗ ██║ ██║
██╔══╝ ██╔══██╗██╔══╝ ██╔══╝ ██║ ██║
██║ ██║ ██║███████╗███████╗██████╔╝
╚═╝ ╚═╝ ╚═╝╚══════╝╚══════╝╚═════╝
""")
print("🎉 All files have been successfully decrypted! 🎉")
print("💚 Your data is now restored and safe!")
print("📁 Files recovered:", len(files), "files")
print("🔓 Encryption removed completely!")
print("="*60)
else:
print("Wrong name.")