Skip to content
leg3ndProjects & tools
01Home02Projects03Tools04Notes
GMT+8
O/ OSCP exploitation reference
Workspace controls Memory only · 0 steps
Visualize path ↗
Command values 0 filled

Temporary connection values clear on reload. Passwords, hashes and tickets remain placeholders. Check address-family syntax in the selected command.

Reference index ↗ Search all procedures & variants ↗
01Discovery02Enumeration03Initial access04Usable access05Local privilege06Active Directory07Internal access08Evidence & reporting

QUICK REFERENCE

Discovery›Services›Web mapping›Web exploitation›Credentials›Public exploits›Sessions & transfers›Linux escalation›Windows escalation›AD enumeration›AD identity attacks›Lateral movement›Pivoting & tunnels›Execution troubleshooting›Integration & evidence›
174 methods · 15 topicsFull reference on GitHub ↗Commands · scripts · next steps
Tools/OSCP/Discovery/Discovery

REFERENCE / 7 TASKS

Discovery

Check your route, scan the assigned host with Nmap, then identify the applications on open ports. Keep UDP as a separate pass.

Contents ↓Tools & scripts ↓Commands ↓First-pass workflow ↓Full procedure index ↗

Contents

Jump to a task. Commands and variants are visible below; full checks and explanations stay on each technique page.

  • Source and reachability
    • Validate the source path and discover hosts
    • Enumerate reachable endpoints from a Windows source
  • Transport coverage and application identity
    • Discover TCP ports with SYN or connect scans
    • Probe UDP and resolve ambiguous silence
    • Identify applications and validate selected NSE checks
    • Discriminate unknown listeners and use scanner alternatives
  • Evidence and re-enumeration
    • Validate uncertain results and rebuild the service queue

Tools & scripts

Nmap upstream ↗
Full TCP coverage; identify applications on the ports found.
Enumeration toolkit launchers upstream ↗
Run explicit upstream-tool profiles by stage; retain raw reports and command provenance without automatic exploitation.
Nmap UDP upstream ↗
Keep UDP results and ambiguous silence separate from TCP.

Source and reachability

Validate the source path and discover hosts

Contents ↑

Use when: No response, a new subnet, or uncertainty about the interface and route

Needs: Correct VPN/interface and explicit scope; discovery probes must be compatible with the path

From the target's working folder

Purpose: Confirm the source path and discover explicitly assigned hosts before spending time on port coverage.

# From the target's working folder
mkdir -p scans
ip -br addr
ip route get TARGET

# One host
nmap -sn -n -oA scans/host TARGET

# Host discovery
nmap -sn -n -iL targets.txt -oA scans/hosts

# Explicitly assigned subnet
nmap -sn -n -oA scans/subnet SUBNET

Read: selected interface/source address. A route lookup does not prove reachability.

Read / verify → Record source address/interface, route and the exact responding endpoint; a missing ping response does not prove a host is down.

If it fails → No route or wrong VPN interface is an environment failure. If only discovery is blocked, use the known-host TCP method; a SOCKS path requires a compatible connect-based client.

  • An assigned host needs an initial service queue or full TCP coverage → Discover TCP ports with SYN or connect scans
  • TCP enumeration is incomplete for the objective or DNS/SNMP/RPC clues suggest UDP → Probe UDP and resolve ambiguous silence
  • One reachable pivot can connect to one internal TCP destination → Relay a single TCP service through a fixed forward
  • The useful vantage point is a Windows host without Nmap → Enumerate reachable endpoints from a Windows source

Prerequisite checks & examples →Full technique →

Enumerate reachable endpoints from a Windows source

Contents ↑

Use when: The useful vantage point is a Windows host without Nmap

Needs: A permitted Windows shell, explicit target list and built-in networking support

Test one TCP port from the Windows source host

# Test one TCP port from the Windows source host
Test-NetConnection -ComputerName TARGET -Port PORTS

# Scan a low-port range
1..1024 | % {echo ((New-Object Net.Sockets.TcpClient).Connect("DC_IP", $_)) "TCP port $_ is open"} 2>$null

# Check a selected port list
22,80,443,445,3389 | % {echo ((New-Object Net.Sockets.TcpClient).Connect("TARGET", $_)) "TCP port $_ is open"} 2>$null

Read: TcpTestSucceeded, source and destination addresses. Use one number for PORTS. Failure does not distinguish a closed port, filtering or a path problem.

Read / verify → Associate each result with the actual Windows source and selected port; do not claim UDP or full-port coverage.

If it fails → A false result may be routing, filtering or service absence; use route and listener evidence before deciding the service is down.

  • A foothold exposes an interface/subnet or a loopback-only service → Discover pivot interfaces, routes and internal service context
  • A WinRM listener and a candidate endpoint-authorized account → Use WinRM, WinRS or PowerShell remoting
  • Scanners disagree, a result is ambiguous, or a new identity changes accessible behavior → Validate uncertain results and rebuild the service queue

Prerequisite checks & examples →Full technique →

Transport coverage and application identity

Discover TCP ports with SYN or connect scans

Contents ↑

Use when: An assigned host needs an initial service queue or full TCP coverage

Needs: SYN scanning needs raw-packet privileges; connect scanning needs OS TCP connections; specify selected versus full port coverage

2. Get initial TCP results

# 2. Get initial TCP results
sudo nmap -sS -n -oA scans/tcp-initial TARGET

# Assigned host list, SYN scan
sudo nmap -sS -n -iL targets.txt -oA scans/tcp-initial-list

# One host, connect scan without raw-packet privileges
nmap -sT -n -oA scans/tcp-connect TARGET

# Selected ports or a range
sudo nmap -sS -n -p PORTS -oA scans/tcp-selected TARGET

# Find relevant services across assigned hosts
sudo nmap -sS -n -p PORTS -iL targets.txt -oA scans/tcp-service-sweep

# 3. Complete TCP coverage
sudo nmap -sS -n -p- -oA scans/tcp-all TARGET

# Connect scan
nmap -sT -n -p- -oA scans/tcp-all-connect TARGET

# Recheck relevant ports with response reasons
sudo nmap -sS -n -Pn --reason -p PORTS -oA scans/tcp-recheck TARGET

# Proceed with full TCP coverage despite failed discovery
sudo nmap -sS -n -Pn -p- -oA scans/tcp-all-no-discovery TARGET

# Full TCP with normal timing and periodic progress
sudo nmap -sS -n -p- -T3 --stats-every 30s -oA scans/tcp-normal TARGET

# Faster timing on a stable path
sudo nmap -sS -n -p- -T4 --stats-every 30s -oA scans/tcp-faster TARGET

Inspect additional endpoints before narrowing the investigation. TCP coverage says nothing about UDP.

This is a bounded first view, not complete TCP coverage

Use ordinary connect calls when a previously established proxy is the only route. This is a bounded first view, not complete TCP coverage:

# This is a bounded first view, not complete TCP coverage
proxychains nmap -sT -Pn -n --top-ports 100 -oA scans/tcp-proxy-top100 TARGET

proxychains cannot turn SYN probes or UDP into proxied TCP connections. -Pn avoids discovery probes that may not traverse the proxy. Confirm the proxy route first, preserve the 100-port limit, and expand with another connect scan only when scope and path permit it.

Read / verify → Retain the selected port set, source context, completion/errors and raw output; follow open ports with focused application evidence.

If it fails → Filtered is not closed. Through SOCKS use supported TCP-connect behavior and skip unsupported raw discovery/UDP; if results conflict, compare from the actual source.

  • A listener has a port-based label or uncertain version → Identify applications and validate selected NSE checks
  • SMB/RPC endpoints, domain clues or new credentials → Enumerate SMB/RPC shares, files and identities
  • An HTTP endpoint, redirect or hostname-dependent response → Establish scheme, host, redirects and request state

Prerequisite checks & examples →Full technique →

Probe UDP and resolve ambiguous silence

Contents ↑

Use when: TCP enumeration is incomplete for the objective or DNS/SNMP/RPC clues suggest UDP

Needs: Raw-packet access and UDP reachability from the real source; bounded or full selection must be explicit

5. Check UDP separately

Purpose: Sample UDP separately, preserve ambiguous states, and expand only when the objective or evidence warrants it.

# 5. Check UDP separately
sudo nmap -sU -n --top-ports 20 -oA scans/udp-top20 TARGET

# Expand to 100 common ports when more coverage is warranted
sudo nmap -sU -n --top-ports 100 -oA scans/udp-top100 TARGET

# Check a relevant UDP port/list
sudo nmap -sU -n -p PORTS -oA scans/udp-selected TARGET

# Add application probes to resolve a useful candidate
sudo nmap -sU -n -sV -p PORTS -oA scans/udp-detail TARGET

# Full UDP coverage when the objective justifies the cost
sudo nmap -sU -n -p- --stats-every 60s -oA scans/udp-all TARGET

# Combined TCP/UDP selection
sudo nmap -sS -sU -n -p T:22,80,445,U:53,123,161 -oA scans/tcp-udp TARGET

This selects UDP ports 1-65535 and may take a long time because silence requires waiting and ICMP errors may be rate-limited. It is the coverage-expansion option, not a universal first command. Continue service work in parallel and preserve the result if the scan cannot finish.

Read / verify → Use an application response for a confirmed service; document unresolved silence, coverage and ICMP rate-limit effects.

If it fails → Do not translate UDP silence into a closed service. Retry a focused application-aware probe or a different permitted vantage point.

  • UDP/161 evidence or an exposed management plane → Extract configuration and process information through SNMP
  • A DNS server, domain name or host aliases → Expand names through DNS records and zone transfers
  • RPC/NFS listeners or export information → Inspect RPC/NFS exports and effective file identity

Prerequisite checks & examples →Full technique →

Identify applications and validate selected NSE checks

Contents ↑

Use when: A listener has a port-based label or uncertain version

Needs: A reachable selected port; scripts must match the application and permitted assessment behavior

4. Identify discovered applications

Purpose: Identify applications on discovered ports and choose only the probing needed for the next decision.

# 4. Identify discovered applications
nmap -sT -n -sV -p PORTS -oA scans/tcp-services TARGET

# Identify applications on discovered ports
nmap -sT -n -sV -sC -p PORTS -oA scans/tcp-services-default TARGET

# Lighter version probing when time or fragile service behavior matters
nmap -sT -n -sV --version-light -p PORTS -oA scans/tcp-services-light TARGET

# Inspect behavior locally
nmap --script-help http-headers

# After identifying HTTP, inspect its relevant port(s)
nmap -sT -n -p PORTS --script http-headers -oA scans/http-headers TARGET

# Estimate OS from network-stack behavior
sudo nmap -n -O -oA scans/os TARGET

# Request more tentative OS guesses
sudo nmap -n -O --osscan-guess -oA scans/os-guesses TARGET

# Bundle OS/version detection, default scripts and traceroute
sudo nmap -sS -n -A -oA scans/combined-detail TARGET

Next: choose service-specific enumeration from application evidence. A version match alone does not establish exploitability.

Light mode tries fewer uncommon probes and can miss an identity that the default intensity finds. Use the default first unless a concrete constraint justifies the tradeoff.

OS guesses are hypotheses. These use default TCP coverage; -A does not mean all ports. Choose this bundle only when its additional probing is useful.

Read / verify → Preserve the responding product/version evidence and distinguish an inferred fingerprint from a confirmed vulnerable build.

If it fails → A timeout, generic banner or scanner label leaves identity inconclusive; use native protocol clients or the unknown-port method.

  • A nonstandard listener, slow TCP discovery or a scanner-specific candidate → Discriminate unknown listeners and use scanner alternatives
  • An HTTP endpoint, redirect or hostname-dependent response → Establish scheme, host, redirects and request state
  • A product/version clue, advisory or component-specific public PoC → Match a public exploit to the actual component and configuration
  • An rsync daemon banner, TCP/873 listener or disclosed rsync module → Inspect rsync modules and retrieve selected artifacts
  • A UDP/69 service plus a plausible filename from configuration, source or boot metadata → Retrieve an evidence-backed file over TFTP
  • An FTP banner or accessible listing → Use anonymous or authenticated FTP file access
  • An SSH service and a known password, private key or agent context → Use SSH passwords, keys and forwarding-capable access
  • SMTP capabilities or mail-related account clues → Enumerate SMTP identities and accessible mailbox protocols
  • A DNS server, domain name or host aliases → Expand names through DNS records and zone transfers
  • RPC/NFS listeners or export information → Inspect RPC/NFS exports and effective file identity
  • SMB/RPC endpoints, domain clues or new credentials → Enumerate SMB/RPC shares, files and identities
  • UDP/161 evidence or an exposed management plane → Extract configuration and process information through SNMP
  • A MySQL-compatible service and valid application/database credentials → Use MySQL/MariaDB data and file primitives
  • SQL Server credentials or a Windows identity accepted by the database → Use SQL Server rights, impersonation and command facilities
  • PostgreSQL access or an application connection string → Use PostgreSQL data and privileged program execution
  • A Redis listener or application cache credentials → Inspect Redis access and persistence boundaries
  • An Oracle TNS listener or connection descriptor → Triage Oracle listener and database identity
  • An exposed remote-access application and compatible known credentials → Validate RDP, WinRM, VNC and Telnet access contexts
  • LDAP/Kerberos listeners or a probable AD domain → Discover LDAP naming contexts and authenticated search
  • A confirmed SIP or IRC application → Investigate SIP/IRC identity and configuration clues

Prerequisite checks & examples →Full technique →

Discriminate unknown listeners and use scanner alternatives

Contents ↑

Use when: A nonstandard listener, slow TCP discovery or a scanner-specific candidate

Needs: Explicit bounded scope; raw scanning alternatives need their required privileges and conservative rates

RustScan: fast TCP discovery, Nmap interpretation

Prerequisite: RustScan and Nmap on Kali; direct TCP reachability. Coverage: only the explicit TCP range. Decisive output: a discovered port that Nmap can reproduce and identify.

# RustScan: fast TCP discovery, Nmap interpretation
rustscan -a TARGET -r 1-65535 --ulimit 5000 -- \
  -Pn -sV -sC -oA rustscan-followup

# Bounded first 1,000 TCP ports
rustscan -a TARGET -r 1-1000 --ulimit 5000 -- \
  -Pn -sV -sC -oA rustscan-1000

Use only for a quick selection. It is not full TCP coverage and is not equivalent to Nmap's default top-1,000 selection.

Masscan: raw-packet discovery, then validation

Prerequisite: root/raw-packet access and a directly routed target. Choose it: for a large authorized address/port space where discovery speed matters. Failure cue: high loss or inconsistent results at the chosen rate.

# Masscan: raw-packet discovery, then validation
sudo masscan TARGET -p1-65535 --rate 500 -oL masscan-open.txt

# Treat each hit as a candidate and recheck with Nmap
PORTS=$(awk '$1 == "open" && $2 == "tcp" {print $3}' masscan-open.txt \
  | sort -nu | paste -sd,)
test -n "$PORTS" && sudo nmap -Pn -sV -sC -p "$PORTS" TARGET -oA masscan-verified

# Unknown-port discrimination
nmap -Pn -sV --version-all -p PORT TARGET -oN port-PORT-version.txt
nmap --script-help banner
nmap -Pn --script=banner -p PORT TARGET -oN port-PORT-banner.txt
nc -nv TARGET PORT
openssl s_client -connect TARGET:PORT -servername HOSTNAME
curl -vk --max-time 10 https://TARGET:PORT/

Inspect a script before selecting it

# Inspect a script before selecting it
nmap --script-help SCRIPT_NAME
grep -i 'SCRIPT_NAME' /usr/share/nmap/scripts/script.db

# Run a named script against a confirmed service/port
nmap -Pn -sV --script SCRIPT_NAME -p PORT TARGET -oN nse-SCRIPT_NAME.txt

# NSE candidate checks
nmap -Pn -sV --script vuln -p PORTS TARGET -oN nse-vuln-candidates.txt

Nikto: bounded web-server candidate generation

Prerequisite: an identified HTTP(S) endpoint. Choose it: after manual baselining to identify common files, headers and server misconfiguration candidates. Decisive output: a finding manually reproduced with the same host, path and authentication context.

# Nikto: bounded web-server candidate generation
nikto -h http://TARGET:PORT -output nikto-TARGET-PORT.txt

# HTTPS, host name and tuning variants
nikto -h https://HOSTNAME:PORT -output nikto-HOSTNAME-PORT.txt
nikto -h http://TARGET:PORT -vhost HOSTNAME -output nikto-vhost.txt
nikto -h http://TARGET:PORT -Tuning 123b -output nikto-focused.txt

Tuning codes are version-sensitive. Inspect nikto -H / local documentation before relying on a copied code set.

Nikto is explicitly listed as allowed by the current OffSec exam guide, but its findings remain scanner candidates. Recheck the guide before an exam and manually validate anything that affects an attack decision.

Read / verify → Confirm the endpoint through independent application behavior and preserve the rate/scope used for discovery.

If it fails → No response may require TLS or a protocol-first request. Avoid treating speed-oriented results as complete, and keep prohibited mass vulnerability scanners outside the exam path.

  • A listener has a port-based label or uncertain version → Identify applications and validate selected NSE checks
  • An HTTP endpoint, redirect or hostname-dependent response → Establish scheme, host, redirects and request state
  • A product/version clue, advisory or component-specific public PoC → Match a public exploit to the actual component and configuration

Prerequisite checks & examples →Full technique →

Evidence and re-enumeration

Validate uncertain results and rebuild the service queue

Contents ↑

Use when: Scanners disagree, a result is ambiguous, or a new identity changes accessible behavior

Needs: A selected endpoint and a test that can resolve the decision-changing uncertainty

Netcat connection check

Keep source, destination, transport and port consistent when comparing results. Revisit relevant checks after a new route, foothold or identity changes access.

# Netcat connection check
nc -nv -w 3 -z TARGET PORTS

# Netcat connection check
nc -nvv -w 3 -z TARGET PORTS

Readable text only, with verbose output and port-state reasons

# Readable text only, with verbose output and port-state reasons
sudo nmap -sS -n -v --reason -p PORTS -oN scans/tcp-check.txt TARGET

Open saved .nmap or .txt output in a text editor. -oA writes .nmap, .gnmap and .xml; -oN writes only normal text. Use a different output prefix when retaining another run.

For every useful endpoint, capture one line with this structure

# For every useful endpoint, capture one line with this structure
SOURCE -> TARGET | tcp/udp PORT | OBSERVED STATE | APPLICATION EVIDENCE | COVERAGE LIMIT | NEXT TEST

Next: carry the complete endpoint tuple into Stage 02 service enumeration and choose the cheapest protocol-aware test that can change your understanding or access. Keep an explicit return item for incomplete TCP, UDP or application coverage.

Next: carry the complete endpoint tuple into Stage 02 service enumeration and choose the cheapest protocol-aware test that can change your understanding or access. Keep an explicit return item for incomplete TCP, UDP or application coverage.

  • open establishes a reachable endpoint from the scan source; it does not establish a vulnerability or usable authentication.
  • closed records an explicit rejection in that context. Move on unless later evidence changes the route, source or target state.
  • filtered leaves the listener state unresolved because filtering, loss or the path prevented classification.
  • unfiltered means the selected probe reached the port but could not determine whether it was open or closed; use a scan type that can answer the required question.
  • UDP open|filtered is inconclusive. A useful protocol probe may reduce uncertainty, but another silence can remain inconclusive.
  • closed|filtered is also an explicit ambiguity. Preserve it unless resolving the distinction changes the next action.
  • A port-based service label is a clue. Use application evidence before treating product, version, operating system or machine role as confirmed.
  • Record the exact target, transport, selected ports and source position. A successful narrow scan does not cover untested ports, the other transport or another network position.

Rank candidates by the cheapest test likely to produce access, credentials, sensitive information or a decisive prerequisite. Prefer observed application behavior over conventional port numbers. Keep at least one return item for incomplete coverage so an attractive early service does not erase the rest of the map.

Re-run network discovery after a new source host, route, tunnel or target restart. Re-enumerate a service after a new credential or identity. Inspect local listeners after a foothold. Recheck a previous result when the source, target state, port selection or network conditions changed—not simply because the first attack failed.

Read / verify → Record which layer was demonstrated: transport, application, authentication, read/write or execution.

If it fails → Connection success with no useful response needs a protocol-aware test; repeated identical failures without new evidence do not justify repeating the same path.

  • A listener has a port-based label or uncertain version → Identify applications and validate selected NSE checks
  • A password tied to a plausible user and service → Validate known passwords and context-specific reuse
  • Several hosts, identities, routes or competing hypotheses need coordination → Maintain state and select the next evidence-producing test

Prerequisite checks & examples →Full technique →

First pass: tools and findings

Use the steps matching your current access. Follow a concrete finding instead of completing every technique in order.

Confirm the source route

Run from the machine that will send the scan. Keep the assigned scope explicit.

ip addr
ip route get TARGET
nmap -sn SUBNET -oA host-discovery
  • If A route selects the expected interface/source → Discover TCP ports with SYN or connect scans

    Reachability still needs a probe; a route lookup alone is not a live host.

Otherwise: No response from host discovery: test the assigned host without assuming it is offline. Open Discover TCP ports with SYN or connect scans →

Full commands & alternatives →

Build a TCP port list with Nmap

The command below scans all TCP ports with SYN privileges. Create the scans output directory first; use the complete connect-scan variant when unprivileged. Keep the fast initial pass distinct from full coverage.

sudo nmap -sS -n -p- -oA scans/tcp-all TARGET
  • If An open TCP port → Identify applications and validate selected NSE checks

    Run focused service detection on the discovered ports, including nonstandard ones.

Otherwise: Only TCP was checked: investigate UDP when the objective or DNS/SNMP/RPC clues call for it. Open Probe UDP and resolve ambiguous silence →

Full commands & alternatives →

Identify the responding application

Keep the endpoint and raw service output; choose the matching client from its response.

nmap -Pn -sV -p PORTS TARGET -oA selected-services
nmap --script-help SCRIPT_NAME
  • If SMB/RPC responds → Enumerate SMB/RPC shares, files and identities

    Check anonymous or known-identity share access.

  • If An HTTP response or redirect → Establish scheme, host, redirects and request state

    Resolve the correct scheme and hostname before directory discovery.

  • If An unrecognized listener → Discriminate unknown listeners and use scanner alternatives

    Send a protocol-specific probe instead of choosing an exploit by port number.

Otherwise: Results conflict with client behavior: rebuild the endpoint queue from confirmed responses. Open Validate uncertain results and rebuild the service queue →

Full commands & alternatives →

Additional organization and gap review informed by 0xsyr0/OSCP ↗. Tool links open upstream sources.

HomeProjectsToolsNotes
Interactive toolsOSCP notes ↗Extended OSCP workspace ↗Attack-path visualizer ↗

© 2026 Armaan. Built with curiosity.

GitHub ↗GMT+8