A reverse shell makes the victim machine start the connection back to the attacker, instead of waiting for incoming connections like a bind shell. It is the standard technique after exploiting a service, because it usually gets through firewalls and NAT that block inbound ports but allow outbound traffic. This cheatsheet gathers the most-used one-liners by language and the tools to catch them.
There is no universal one-liner: what works depends on which interpreters exist on the victim and on which shell/bin/sh actually is. The /dev/tcp trick is a Bash feature, not POSIX sh, so it fails on systems where /bin/sh is dash. And since netcat's -e flag is missing from almost every modern build, the real field pattern is the mkfifo one. That is why it pays to keep several alternatives at hand.
Always start the listener (nc -lvnp 4444) before firing the payload: if the victim connects and nothing is listening, the shell is lost.
The /dev/tcp trick belongs to Bash. On many Linux systems /bin/sh is dash and does not support it: invoke bash explicitly or use another method.
Netcat's -e flag is absent from most modern builds (nmap-ncat, OpenBSD netcat). If nc -e fails, use the mkfifo variant.
The shell you get is dumb: no Ctrl+C, no arrows or tab. Stabilize the TTY (python3 -c 'import pty;pty.spawn(...)' + stty raw -echo) before working.
After stabilizing, export TERM=xterm and set rows/cols with stty, or full-screen tools like vim or less will break.
Responsible use
These commands are for systems you own or have explicit written authorisation to test (labs, CTFs, contracted engagements). Using them against third-party infrastructure without permission is illegal in most countries.
Una reverse shell hace que la máquina víctima inicie la conexión de vuelta hacia el atacante, en lugar de esperar conexiones entrantes como una bind shell. Es la técnica estándar tras explotar un servicio, porque suele atravesar firewalls y NAT que bloquean puertos entrantes pero permiten tráfico saliente. Esta cheatsheet reúne los one-liners más usados por lenguaje y las herramientas para recibirlos.
No existe un one-liner universal: lo que funciona depende de qué intérpretes hay en la víctima y de qué shell es realmente /bin/sh. El truco /dev/tcp es una característica de Bash, no de POSIX sh, así que falla en sistemas donde /bin/sh es dash. Y como el flag -e de netcat falta en casi todas las builds modernas, el patrón real de campo es el mkfifo. Por eso conviene tener a mano varias alternativas.
Arranca siempre el listener (nc -lvnp 4444) antes de disparar el payload: si la víctima conecta y no hay nada escuchando, la shell se pierde.
El truco /dev/tcp es propio de Bash. En muchos Linux /bin/sh es dash y no lo soporta: invoca bash explícitamente o usa otro método.
El flag -e de netcat no existe en la mayoría de builds modernas (nmap-ncat, OpenBSD netcat). Si nc -e falla, usa la variante con mkfifo.
La shell que recibes es dumb: sin Ctrl+C, sin flechas ni tab. Estabiliza la TTY (python3 -c 'import pty;pty.spawn(...)' + stty raw -echo) antes de trabajar.
Tras estabilizar, exporta TERM=xterm y ajusta rows/cols con stty, o herramientas de pantalla completa como vim o less se romperán.
Uso responsable
Estos comandos son para entornos propios o con autorización explícita por escrito (laboratorios, CTF, auditorías contratadas). Usarlos contra infraestructura ajena sin permiso es ilegal en la mayoría de países.