-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathdecrypt.py
More file actions
66 lines (49 loc) · 1.92 KB
/
Copy pathdecrypt.py
File metadata and controls
66 lines (49 loc) · 1.92 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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
from Crypto.Cipher import AES
from Crypto.Util.Padding import unpad
import binascii
import os
import psutil
def get_all_disk_partitions():
partitions = []
for partition in psutil.disk_partitions(all=True):
if partition.fstype:
partitions.append(partition.device)
return partitions
def aes_ecb_decrypt(ciphertext):
cipher = AES.new(key, AES.MODE_ECB)
decrypted = cipher.decrypt(ciphertext)
return unpad(decrypted, AES.block_size)
def decrypt_file(input_file, output_file):
with open(input_file, 'rb') as f:
ciphertext = f.read()
decrypted_data = aes_ecb_decrypt(ciphertext)
with open(output_file, 'wb') as f:
f.write(decrypted_data)
print("[!] Decrypted file saved as " + output_file)
def read_file(file_walk):
for root, dirs, files in os.walk(file_walk):
for file in files:
# Get file extension
ext = os.path.splitext(file)[1]
# Check if in allowed list
if ext == ".love":
filename=os.path.join(root, file)
newfile = os.path.dirname(filename)+'\\'+os.path.basename(filename).replace('.love','')
try:
decrypt_file(filename,newfile)
os.remove(filename)
except Exception as e:
print("[!] Error decrypting file: " + filename)
print("[!] Error: str(e)" + str(e))
if "Padding is incorrect" in str(e):
print("[!] 秘钥错误!")
sys.exit(1)
if __name__ == "__main__":
import sys
keys = sys.argv[1]
key = binascii.unhexlify(keys)
# decrypt_file(input_file, output_file)
disk_partitions = get_all_disk_partitions()
for partition in disk_partitions:
read_file(partition)
print("文件解密完成。")