Searchsploit Mastery
Table of Contents
- What is Searchsploit?
- Installation and Setup
- Database Structure Deep Dive
- Complete Command-Line Reference
- Basic Search Operations
- Advanced Search Techniques
- Practical OSCP Scenarios
- Searchsploit vs. Web Exploit-DB
- Automation and Scripting
- Efficiency Tips for Exam Day
- Common Pitfalls and How to Avoid Them
- Quick Reference Cheat Sheet
1. What is Searchsploit?
Searchsploit is the official command-line interface (CLI) for Exploit-DB, the world’s largest curated public exploit database maintained by Offensive Security — the same organization behind the OSCP certification.
Why Searchsploit Matters for OSCP
| Reason | Detail |
|---|---|
| Offline Access | Works without internet — critical for exam environments with restricted connectivity |
| Speed | Instant local search vs. browser-based web searches |
| Scriptable | Integrates into automation pipelines and custom tools |
| Exam-Relevant | The primary exploit lookup tool expected during the OSCP exam |
| Structured Output | JSON, mirrored files, and editor integration for rapid workflow |
How It Works
Searchsploit is essentially a local mirror of the Exploit-DB Git repository. It indexes all exploit files, shellcode, and research papers stored in the database, then provides a fast, grep-like search interface against that local index. When you run a search, it queries the local filesystem — not a remote server — which is why it’s blazing fast and works offline.
┌─────────────────────────────────────────────────┐
│ Your Machine │
│ │
│ ┌──────────────┐ ┌──────────────────────┐ │
│ │ searchsploit │───▶│ Local Exploit-DB │ │
│ │ (CLI Tool) │ │ (Git Repository) │ │
│ └──────────────┘ └──────────────────────┘ │
│ │ │
│ ▼ │
│ exploits/ shells/ papers/ │
│ (100,000+ files indexed) │
└─────────────────────────────────────────────────┘
▲ │
│ --update ▼
┌──────────────┐ ┌──────────────────┐
│ Your Query │ │ GitLab.com │
│ "Apache 2.4" │ │ exploitdb.git │
└──────────────┘ └──────────────────┘
2. Installation and Setup
Method 1: Kali Linux (Pre-Installed)
Kali Linux ships with searchsploit pre-installed. This is the environment you’ll use during the OSCP exam.
# Verify installation
searchsploit --version
# Check the installed path
which searchsploit
# Output: /usr/bin/searchsploit
# Verify the database location
searchsploit --shell
# This opens the exploitdb directory in your shell
Default database location on Kali:
/usr/share/exploitdb/
Method 2: Manual Git Clone (Any Linux Distribution)
If you’re running a non-Kali distro (Parrot OS, Ubuntu, etc.) or want a custom installation:
# Clone the official Exploit-DB repository from GitLab
git clone https://gitlab.com/exploit-database/exploitdb.git
# Navigate into the directory
cd exploitdb
# Make the searchsploit script executable (usually already is)
chmod +x searchsploit
# Run it from the local directory
./searchsploit --version
# Update the database
./searchsploit --update
Method 3: Installing System-Wide
To make searchsploit available globally after a manual clone:
# Option A: Symlink to /usr/local/bin
sudo ln -s /path/to/exploitdb/searchsploit /usr/local/bin/searchsploit
# Option B: Copy the script
sudo cp /path/to/exploitdb/searchsploit /usr/local/bin/searchsploit
# Now you can run it from anywhere
searchsploit --version
Method 4: pip Installation (Alternative)
# Install via pip
pip3 install searchsploit
# Note: The pip package may lag behind the Git version
# For OSCP, the Git/Kali version is recommended
Updating the Database
This is critical. The Exploit-DB database is updated daily. An outdated database means missing exploits.
# Standard update (recommended before every exam lab session)
searchsploit --update
# What happens during update:
# 1. searchsploit runs 'git pull' inside the exploitdb directory
# 2. New exploits, shells, and papers are downloaded
# 3. The local index is refreshed
# 4. You get a summary of new entries
# Example output:
# [*] Exploit-DB updated successfully.
# [*] 15 new exploits added
# [*] 3 new papers added
Exam Tip: Run searchsploit --update at the very beginning of your exam lab session. The exam machines may have a slightly stale database.
Verifying Your Installation
# Full health check
searchsploit --version
# Should output the version number
# Check database size
find /usr/share/exploitdb/exploits -type f | wc -l
# Should return thousands of files
# Quick test search
searchsploit "test"
# Should return results
3. Database Structure Deep Dive
Understanding the directory structure is essential for efficient searching and for manually browsing when search results are ambiguous.
Top-Level Layout
/usr/share/exploitdb/
│
├── exploits/ ← Main exploit repository (organized by platform)
│ ├── windows/ ← Windows-specific exploits
│ ├── unix/ ← Unix/BSD exploits
│ ├── linux/ ← Linux-specific exploits
│ ├── macosx/ ← macOS exploits
│ ├── ios/ ← iOS exploits
│ ├── android/ ← Android exploits
│ ├── hardware/ ← Hardware/IoT/embedded exploits
│ ├── multiple/ ← Cross-platform exploits
│ └── webapps/ ← Web application exploits
│
├── shells/ ← Shellcode payloads (raw binary shells)
│
├── papers/ ← Research papers, write-ups, technical articles
│
├── searchsploit ← The CLI tool itself (Perl script)
│
└── .git/ ← Git metadata (for --update)
Platform Directories Explained
| Directory | Content | OSCP Relevance |
|---|---|---|
windows/ |
Windows OS, services, and application exploits | Very High — Windows boxes are common |
linux/ |
Linux kernel, services, and application exploits | Very High — Linux boxes are common |
unix/ |
BSD, Solaris, AIX, HP-UX exploits | Medium — occasional targets |
webapps/ |
Web application exploits (CMS, frameworks, etc.) | Very High — web app vulns are frequent |
multiple/ |
Exploits that work across multiple platforms | High — protocol-level vulns (SMB, RDP, etc.) |
macosx/ |
macOS-specific exploits | Low — rare on OSCP |
ios/ |
iOS exploits | Very Low — not on OSCP |
android/ |
Android exploits | Low — not on OSCP |
hardware/ |
Router, IoT, firmware exploits | Low — occasional |
Sub-Directory Organization Within Platforms
Each platform directory is further organized by category:
exploits/windows/
├── remote/ ← Remote exploits (network-accessible)
├── local/ ← Local exploits (require existing access, often privesc)
├── dos/ ← Denial of service
├── exploits/ ← General exploits
├── exploits_dont_work/ ← Known non-working exploits (still useful for reference!)
└── asp/ ← ASP-specific web exploits
exploits/linux/
├── remote/
├── local/
├── dos/
├── exploits/
└── exploits_dont_work/
exploits/webapps/
├── against_*/ ← Exploits targeting specific backends
├── cgi/
├── asp/
├── php/
└── (application-specific subdirs)
The shells/ Directory
Contains raw shellcode — small binary payloads for various architectures and scenarios:
shells/
├── bind/ ← Bind shell shellcode (opens a port on target)
├── connect/ ← Reverse shell shellcode (connects back to attacker)
├── egg/ ← Egg hunter shellcode
├── meterpreter/ ← Meterpreter stagers
└── various/ ← Other shellcode types
OSCP Relevance: You rarely need raw shellcode directly, but understanding these helps when an exploit references shellcode injection.
The papers/ Directory
Contains research papers, technical write-ups, and advisory documents:
papers/
├── 2000s/
├── 2010s/
├── 2020s/
└── (organized by year and topic)
Pro Tip: Papers are goldmines for understanding exploit techniques. When an exploit doesn’t work, the corresponding paper often explains the underlying vulnerability and may reveal adaptation strategies.
Exploit File Naming Convention
Each exploit file has a unique numeric ID:
49409.py ← Python exploit, ID 49409
50383.rb ← Ruby exploit, ID 50383
16891.txt ← Text-based exploit/payload, ID 16891
The file extension tells you the language:
.py— Python.rb— Ruby.pl— Perl.c— C source (needs compilation).txt— Text-based (may contain payloads, instructions, or non-script exploits).php— PHP.java— Java
4. Complete Command-Line Reference
Syntax
searchsploit [OPTIONS] [SEARCH_TERMS]
All Available Flags
| Flag | Short | Description | Example |
|---|---|---|---|
-m |
Mirror a single exploit to current directory | searchsploit -m 49409.py |
|
-mm |
Mirror multiple exploits to current directory | searchsploit -mm Apache 2.4 |
|
-w |
Wildcard search (each term is a separate wildcard) | searchsploit -w "apache" "traversal" |
|
-x |
Open exploit in default editor | searchsploit -x 49409.py |
|
-j |
Output results as JSON | searchsploit -j Apache |
|
-p |
Filter by platform | searchsploit -p windows Apache |
|
-t |
Filter by type (remote/local/dos/etc.) | searchsploit -t remote Apache |
|
-e |
Exclude platform from results | searchsploit -e windows Apache |
|
--update |
Update the Exploit-DB database | searchsploit --update |
|
--shell |
Open a shell in the exploitdb directory | searchsploit --shell |
|
--folders |
List all platform folders | searchsploit --folders |
|
--nmap |
Import results from an Nmap NSE script | searchsploit --nmap results.xml |
|
--version |
Show searchsploit version | searchsploit --version |
|
--help |
-h |
Show help message | searchsploit --help |
Deep Dive: Each Flag
-m (Mirror Single)
Copies a single exploit file to your current working directory. You must specify the exact filename.
# Mirror a specific exploit by filename
searchsploit -m 49409.py
# Output:
# [-] Mirroring: 49409.py
# [*] /path/to/exploitdb/exploits/windows/local/49409.py
# -> ./49409.py
When to use: You’ve identified the exact exploit you want and need a local copy to modify or execute.
-mm (Mirror Multiple)
Copies all matching exploit files to your current working directory. Takes search terms like a normal search.
# Mirror all Apache 2.4 exploits
searchsploit -mm Apache 2.4
# Output:
# [-] Mirroring: 50383.py
# [*] /path/to/exploitdb/exploits/linux/remote/50383.py
# -> ./50383.py
# [-] Mirroring: 50402.py
# [*] /path/to/exploitdb/exploits/linux/remote/50402.py
# -> ./50402.py
When to use: You want to download a batch of related exploits for review.
Warning: Can create filename conflicts if exploits from different platforms share the same ID. Use a dedicated directory:
mkdir -p ~/exploits/apache && cd ~/exploits/apache
searchsploit -mm Apache 2.4
-w (Wildcard Search)
Each search term becomes an independent wildcard pattern. This is fundamentally different from normal search behavior.
# Normal search: ALL terms must appear in the title
searchsploit Apache HTTP Server 2.4
# Wildcard search: EACH term is searched independently (OR-like behavior)
searchsploit -w "apache" "httpd"
# Returns results containing "apache" OR "httpd"
# Wildcard with partial matching
searchsploit -w "joom" "sql"
# Matches "Joomla" + "SQL Injection" even if terms are partial
Critical distinction:
- Normal search = AND logic (all terms must match)
- Wildcard search = each term is a glob pattern, results match if ANY pattern matches
-x (Open in Editor)
Opens the specified exploit file in your system’s default text editor ($EDITOR environment variable).
# Opens 49409.py in vim (or whatever $EDITOR is set to)
searchsploit -x 49409.py
# You can also use the full path
searchsploit -x exploits/windows/local/49409.py
Pro Tip: Set your editor before the exam:
export EDITOR=nano # For beginners
export EDITOR=vim # For vim users
export EDITOR=code # For VS Code users
-j (JSON Output)
Returns search results in structured JSON format. Essential for scripting and automation.
searchsploit -j Apache 2.4
# Output:
# [
# {
# "title": "Apache HTTP Server 2.4.49 - Path Traversal and Remote Code Execution",
# "platform": "linux",
# "wiki_id": 50383,
# "file_path": "/usr/share/exploitdb/exploits/linux/remote/50383.py",
# "type": "remote"
# },
# ...
# ]
-p (Platform Filter)
Restricts results to a specific platform directory.
# Only Windows exploits
searchsploit -p windows "privilege escalation"
# Only Linux exploits
searchsploit -p linux kernel
# Only web application exploits
searchsploit -p webapps joomla
# Valid platform values:
# windows, unix, linux, macosx, ios, android, hardware, multiple, webapps
-t (Type Filter)
Filters by exploit type within the matched results.
# Only remote exploits
searchsploit -t remote Apache
# Only local exploits (privilege escalation)
searchsploit -t local Windows
# Only denial of service
searchsploit -t dos Apache
# Valid type values:
# remote, local, dos, exploits, exploits_dont_work, asp, cgi, php
-e (Exclude Platform)
Excludes results from a specific platform.
# Search for SMB exploits but exclude Windows-specific ones
searchsploit -e windows SMB
# Useful when you want cross-platform exploits only
searchsploit -e windows -e linux SMB
--nmap (Nmap Integration)
Imports vulnerability data from Nmap’s vuln NSE script output and searches Exploit-DB for matching exploits.
# Step 1: Run Nmap with vuln script
nmap --script vuln -oX vuln_results.xml 10.10.10.1
# Step 2: Feed results to searchsploit
searchsploit --nmap vuln_results.xml
# This automatically searches Exploit-DB for exploits matching
# the CVEs and vulnerabilities found by Nmap
--shell (Enter Database Directory)
Opens a new shell session inside the exploitdb directory. Useful for manual browsing.
searchsploit --shell
# You're now in /usr/share/exploitdb/
# You can manually browse:
ls exploits/windows/local/
cat exploits/windows/local/49409.py
grep -r "CVE-2021" exploits/
--folders (List Platforms)
Lists all available platform directories.
searchsploit --folders
# Output:
# android
# hardware
# ios
# linux
# macosx
# multiple
# unix
# webapps
# windows
5. Basic Search Operations
Single-Term Search
The simplest form — search for one keyword:
searchsploit Apache
# Returns ALL entries with "Apache" in the title
# Results are displayed in a table format:
# Apache 2.4.49 - Path Traversal and Remote Code Execution | linux/remote/50383.py
# Apache HTTP Server 2.4.50 - Path Traversal | linux/remote/50402.py
# Apache Struts 2.3.5 - Remote Code Execution | multiple/remote/49534.py
Multi-Term Search (AND Logic)
All terms must appear in the title. Order does not matter.
searchsploit Apache 2.4.49
# Only returns entries containing BOTH "Apache" AND "2.4.49"
# This is equivalent to: searchsploit 2.4.49 Apache
searchsploit Windows SMB EternalBlue
# Returns entries with ALL three terms
Case-Insensitive Search
Searchsploit is case-insensitive by default:
searchsploit apache # Same as
searchsploit Apache # Same as
searchsploit APACHE
Searching by Exploit ID
You can search using the numeric ID directly:
searchsploit 49409
# Returns the specific exploit with ID 49409
# Useful when you know the ID from a reference
Combining with less for Large Results
# Pipe through less for scrollable output
searchsploit Windows | less
# Search within results using / in less
searchsploit Apache | less
# Then type: /2.4.49 (to find within results)
6. Advanced Search Techniques
Combining Multiple Flags
# Platform + Type + Search terms
searchsploit -p windows -t local "privilege escalation"
# Exclude platform + Search terms
searchsploit -e windows -e linux "SMB"
# Wildcard + Platform
searchsploit -p webapps -w "joomla" "sql"
# Mirror + Platform + Search
searchsploit -mm -p linux "Apache 2.4"
Wildcard Mastery
The -w flag treats each quoted term as an independent glob pattern:
# Find exploits with "apache" OR "httpd" in the title
searchsploit -w "apache" "httpd"
# Find exploits matching "eternal*" (EternalBlue, EternalRomance, etc.)
searchsploit -w "eternal*"
# Find exploits with "CVE-2021-*" pattern
searchsploit -w "CVE-2021-*"
# Combine partial matches
searchsploit -w "micro*" "exchange"
# Matches "Microsoft Exchange" even though terms are partial
Piping to Other Tools
# Count results
searchsploit Apache | wc -l
# Filter results with grep
searchsploit Windows | grep -i "privilege"
# Extract just the file paths
searchsploit Apache 2.4 | grep -oP '\d+\.\w+$'
# Save results to a file
searchsploit Windows privilege escalation > windows_privesc_exploits.txt
# Get unique platforms for a search term
searchsploit SMB | awk '{print $2}' | cut -d'/' -f1 | sort -u
JSON Output Parsing
# Parse JSON output with jq
searchsploit -j Apache 2.4 | jq '.[].title'
# Get just the file paths
searchsploit -j Apache 2.4 | jq -r '.[].file_path'
# Get titles and platforms
searchsploit -j Apache 2.4 | jq -r '.[] | "\(.title) [\(.platform)]"'
# Filter JSON by platform
searchsploit -j Apache | jq '.[] | select(.platform == "linux")'
# Count results programmatically
searchsploit -j Apache | jq 'length'
Using --shell for Advanced Browsing
# Enter the database directory
searchsploit --shell
# Now use standard Linux tools for powerful searches:
# Find all Python exploits in Windows local directory
find exploits/windows/local/ -name "*.py" | head -20
# Search file contents (not just titles)
grep -rl "CVE-2021-41773" exploits/
# Find recently added exploits (by filename number)
ls -1 exploits/linux/remote/ | sort -n | tail -20
# Find all exploits for a specific version
grep -rl "2.4.49" exploits/
# Count exploits by platform
for dir in exploits/*/; do echo "$dir: $(find "$dir" -type f | wc -l)"; done
The Search Algorithm
Understanding how searchsploit matches is crucial:
- Title Matching: Search terms are matched against the exploit title (first comment line in the file), NOT the file contents
- AND Logic: All non-wildcard terms must appear in the title
- Case Insensitive: Matching ignores case
- No Regex: Standard search does NOT support regular expressions — only literal string matching
- Wildcard (
-w): Each term becomes a glob pattern (*and?supported)
Exploit file header example:
#!/usr/bin/env python
# Exploit Title: Apache HTTP Server 2.4.49 - Path Traversal and Remote Code Execution
# Date: 2021-01-07
# Exploit Author: Security Researcher
# Version: Apache 2.4.49
# Tested on: Ubuntu 20.04
searchsploit "Apache 2.4.49" → MATCHES (all terms in title)
searchsploit "Path Traversal" → MATCHES (all terms in title)
searchsploit "Ubuntu" → NO MATCH (not in title, only in "Tested on")
searchsploit "Remote Code" → MATCHES (both terms in title)
7. Practical OSCP Scenarios
Scenario 1: Windows Service Exploitation
Situation: You’ve enumerated a Windows machine and found IIS 10.0 running.
# Step 1: Broad search
searchsploit IIS 10
# Step 2: Narrow down
searchsploit IIS 10.0
# Step 3: Filter by type (remote for initial access)
searchsploit -p windows -t remote IIS
# Step 4: If you find a specific CVE
searchsploit CVE-2021-26855
# Step 5: Mirror the best candidate
searchsploit -m 50493.py
# Step 6: Review before executing
cat 50493.py
Scenario 2: Linux Kernel Privilege Escalation
Situation: You have a low-privilege shell on a Linux box. uname -a returns 5.4.0-42-generic.
# Step 1: Search by kernel version
searchsploit Linux 5.4.0
# Step 2: Filter for local exploits (privesc)
searchsploit -p linux -t local 5.4
# Step 3: Search for the specific kernel family
searchsploit -p linux -t local "kernel" "5.4"
# Step 4: If you know the CVE
searchsploit CVE-2020-25630
# Step 5: Mirror and review
searchsploit -mm -p linux -t local "5.4"
Scenario 3: Web Application Exploitation
Situation: You’ve identified a Joomla 3.9.28 installation.
# Step 1: Search the webapps platform
searchsploit -p webapps Joomla
# Step 2: Narrow to version
searchsploit -p webapps Joomla 3.9.28
# Step 3: Search for specific vulnerability type
searchsploit -p webapps Joomla SQL
# Step 4: Wildcard for partial version match
searchsploit -p webapps -w "joomla" "3.9"
# Step 5: Mirror all matching exploits
mkdir -p ~/exploits/joomla && cd ~/exploits/joomla
searchsploit -mm -p webapps Joomla 3.9
Scenario 4: SMB / Protocol Exploitation
Situation: Port 445 is open, running SMBv1 on a Windows machine.
# Step 1: Search for SMB exploits
searchsploit SMB
# Step 2: Filter for Windows platform
searchsploit -p windows SMB
# Step 3: Search for EternalBlue specifically
searchsploit EternalBlue
# Step 4: Search by CVE
searchsploit CVE-2017-0144
# Step 5: Cross-platform SMB exploits
searchsploit -p multiple SMB
# Step 6: Mirror the exploit
searchsploit -m 43970.py
Scenario 5: Microsoft Exchange Exploitation
Situation: You’ve found an Exchange Server on port 443.
# Step 1: Broad search
searchsploit Exchange
# Step 2: Narrow to Microsoft Exchange
searchsploit Microsoft Exchange
# Step 3: Search for ProxyShell
searchsploit ProxyShell
# Step 4: Search by CVE
searchsploit CVE-2021-34473
# Step 5: Filter for remote exploits
searchsploit -t remote Exchange
# Step 6: Mirror multiple candidates
mkdir -p ~/exploits/exchange && cd ~/exploits/exchange
searchsploit -mm "Microsoft Exchange"
Scenario 6: OpenVPN / Service-Specific
Situation: You’ve found OpenVPN 2.4.7 running on the target.
# Step 1: Search by service name
searchsploit OpenVPN
# Step 2: Add version
searchsploit OpenVPN 2.4.7
# Step 3: Filter by platform
searchsploit -p linux OpenVPN
# Step 4: If no exact version match, try broader
searchsploit OpenVPN 2.4
Scenario 7: Database Exploitation
Situation: MySQL 5.7 is running on the target.
# Step 1: Search for MySQL exploits
searchsploit MySQL
# Step 2: Add version
searchsploit MySQL 5.7
# Step 3: Filter by type
searchsploit -t remote MySQL 5.7
# Step 4: Check multiple platform
searchsploit -p multiple MySQL
Scenario 8: When You Only Have Partial Information
Situation: You know the vendor but not the exact product or version.
# Start broad, narrow down iteratively
# Vendor-level search
searchsploit Microsoft
# Product-level
searchsploit Microsoft IIS
# Version-level (when you get more info)
searchsploit Microsoft IIS 10
# Use wildcard for partial info
searchsploit -w "micro*" "iis"
# Use --shell for manual browsing when search fails
searchsploit --shell
# Then: ls exploits/windows/remote/ | grep -i iis
8. Searchsploit vs. Web Exploit-DB
Comparison Table
| Feature | Searchsploit (CLI) | Exploit-DB (Web) |
|---|---|---|
| Speed | Instant (local) | Depends on connection |
| Offline | Yes | No |
| Search Depth | Title only | Title + description + tags |
| JSON Output | Yes (-j) |
API available |
| Mirroring | Yes (-m, -mm) |
Manual download |
| Editor Integration | Yes (-x) |
No |
| Community Comments | No | Yes |
| Code Preview | No (must mirror) | Yes (inline) |
| Advanced Filters | Platform, type, exclude | Platform, type, author, date |
| Nmap Integration | Yes (--nmap) |
No |
| Scriptable | Yes | Limited (API) |
| Exam Access | Available | May be restricted |
When to Use CLI (Searchsploit)
- During the OSCP exam — web access may be limited
- Quick lookups — faster than opening a browser
- Batch operations — mirroring multiple exploits
- Automation — scripting exploit research
- Offline environments — no internet required
When to Use Web (Exploit-DB)
- Reading community comments — reliability feedback
- Previewing code — before downloading
- Advanced filtering — by date, author, verified status
- Finding papers — web interface has better paper browsing
- Cross-referencing — checking multiple sources simultaneously
Hybrid Workflow (Recommended)
1. Use searchsploit for quick local search
2. Mirror promising candidates with -m
3. Review code locally with cat or -x
4. If uncertain, cross-reference on exploit-db.com
5. Check community comments for reliability tips
6. Adapt and test
9. Automation and Scripting
Basic Automation Script
#!/bin/bash
# auto_exploit_search.sh - Automated exploit research helper
# Usage: ./auto_exploit_search.sh <service> <version> [platform]
SERVICE=$1
VERSION=$2
PLATFORM=${3:-""}
echo "========================================="
echo " Exploit Research: $SERVICE $VERSION"
echo "========================================="
# Update database first
echo "[*] Updating exploit database..."
searchsploit --update 2>/dev/null
# Build search command
if [ -n "$PLATFORM" ]; then
echo "[*] Searching with platform filter: $PLATFORM"
RESULTS=$(searchsploit -p "$PLATFORM" "$SERVICE" "$VERSION")
else
echo "[*] Searching all platforms..."
RESULTS=$(searchsploit "$SERVICE" "$VERSION")
fi
# Count results
COUNT=$(echo "$RESULTS" | grep -c "/")
echo "[*] Found $COUNT potential exploits"
# Display results
echo ""
echo "$RESULTS"
# Save to file
OUTPUT="exploits_${SERVICE}_${VERSION}_$(date +%Y%m%d).txt"
echo "$RESULTS" > "$OUTPUT"
echo "[*] Results saved to $OUTPUT"
JSON-Based Programmatic Search
#!/usr/bin/env python3
"""
exploit_searcher.py - Programmatic Exploit-DB search using searchsploit JSON output
"""
import subprocess
import json
import sys
def search_exploits(*terms, platform=None, exploit_type=None):
"""Search Exploit-DB using searchsploit JSON output."""
cmd = ["searchsploit", "-j"]
if platform:
cmd.extend(["-p", platform])
if exploit_type:
cmd.extend(["-t", exploit_type])
cmd.extend(list(terms))
result = subprocess.run(cmd, capture_output=True, text=True)
if result.returncode != 0:
print(f"Error: {result.stderr}")
return []
try:
return json.loads(result.stdout)
except json.JSONDecodeError:
return []
def display_results(exploits):
"""Pretty-print exploit search results."""
if not exploits:
print("No exploits found.")
return
print(f"\n{'='*70}")
print(f" Found {len(exploits)} exploit(s)")
print(f"{'='*70}\n")
for i, exp in enumerate(exploits, 1):
print(f" [{i}] {exp['title']}")
print(f" Platform: {exp['platform']}")
print(f" Type: {exp['type']}")
print(f" ID: {exp['wiki_id']}")
print(f" Path: {exp['file_path']}")
print()
def mirror_exploit(exploit_id, filename):
"""Mirror a specific exploit to the current directory."""
cmd = ["searchsploit", "-m", f"{exploit_id}.{filename}"]
result = subprocess.run(cmd, capture_output=True, text=True)
print(result.stdout)
return result.returncode == 0
# Example usage
if __name__ == "__main__":
if len(sys.argv) < 2:
print(f"Usage: {sys.argv[0]} <search_term> [search_term...]")
sys.exit(1)
exploits = search_exploits(*sys.argv[1:])
display_results(exploits)
Nmap + Searchsploit Pipeline
#!/bin/bash
# nmap_exploit_pipeline.sh - Scan and find exploits automatically
TARGET=$1
if [ -z "$TARGET" ]; then
echo "Usage: $0 <target_ip>"
exit 1
fi
echo "[*] Scanning target: $TARGET"
# Step 1: Service discovery
nmap -sV -sC -oX scan_results.xml "$TARGET" 2>/dev/null
# Step 2: Extract services
echo ""
echo "[*] Discovered services:"
grep "service=" scan_results.xml | sed 's/.*name="\([^"]*\)".*version="\([^"]*\)".*/ \1 (version: \2)/'
# Step 3: Search for exploits using Nmap data
echo ""
echo "[*] Searching for exploits..."
searchsploit --nmap scan_results.xml 2>/dev/null
# Step 4: Also do manual searches for top services
echo ""
echo "[*] Manual searches for top services:"
for service in $(grep "service=" scan_results.xml | sed 's/.*name="\([^"]*\)".*/\1/' | head -5); do
echo ""
echo " --- $service ---"
searchsploit "$service" | head -5
done
10. Efficiency Tips for Exam Day
The 30-Second Rule
During the exam, you should be able to go from service identification to exploit in hand in under 30 seconds:
0-5s: Identify service and version from enumeration
5-10s: Run searchsploit with specific terms
10-20s: Scan results, identify best candidate
20-30s: Mirror the exploit with -m
Pre-Made Aliases
Add these to your ~/.bashrc before the exam:
# Quick aliases for common searches
alias ss='searchsploit'
alias ssu='searchsploit --update'
alias ssw='searchsploit -p windows'
alias ssl='searchsploit -p linux'
alias sswa='searchsploit -p webapps'
alias ssm='searchsploit -mm'
# Quick mirror function
ssm() {
searchsploit -m "$1"
}
The Search Hierarchy (Follow This Order)
Level 1: Exact match (fastest, most precise)
searchsploit "Apache 2.4.49"
Level 2: Product + version range
searchsploit "Apache 2.4"
Level 3: Product only
searchsploit "Apache"
Level 4: CVE-based (if you know the CVE)
searchsploit "CVE-2021-41773"
Level 5: Wildcard (when terms are partial)
searchsploit -w "apach*" "2.4*"
Level 6: Manual browsing (last resort)
searchsploit --shell
ls exploits/linux/remote/ | grep -i apache
Quick Exploit Evaluation Checklist
When you find a candidate exploit, quickly check:
□ Title matches your target service and version?
□ Platform matches (windows/linux/webapps)?
□ Type matches your access level (remote vs local)?
□ Date is reasonable (not too old, not brand new untested)?
□ File extension matches available interpreter (.py → python3)?
□ "Tested on" section matches your target environment?
Directory Organization During Exam
# Create a clean workspace at the start of each box
mkdir -p ~/oscp/<BOX_IP>/exploits
cd ~/oscp/<BOX_IP>/exploits
# Now mirror exploits here
searchsploit -m 49409.py
# All exploits for this box stay organized
The “Exploit Doesn’t Work” Decision Tree
Exploit fails?
│
├─→ Check version match → Mismatch? → Search for version-specific exploit
│
├─→ Check dependencies → Missing? → Install with apt/pip
│
├─→ Check permissions → Insufficient? → Try different exploit type
│
├─→ Read the code → Understand the vulnerability → Adapt manually
│
└─→ Check exploit-db.com → Read comments → Find working alternative
11. Common Pitfalls and How to Avoid Them
Pitfall 1: Version Mismatch
Problem: The exploit targets version 2.4.49 but your target runs 2.4.51.
Solution:
# Search for the exact version first
searchsploit "Apache 2.4.51"
# If no exact match, check if the vulnerability affects a range
# Read the exploit header for version information
searchsploit -x 50383.py
# Look for lines like:
# # Version: Apache 2.4.49 through 2.4.50
# This tells you the affected range
Pitfall 2: Platform Confusion
Problem: Using a Linux exploit against a BSD system (or vice versa).
Solution:
# Always verify the platform
uname -a # On the target
# Linux vs FreeBSD vs OpenBSD matters!
# Filter by the correct platform
searchsploit -p unix FreeBSD # Not -p linux!
searchsploit -p linux # For Linux targets
Pitfall 3: Remote vs. Local Confusion
Problem: Trying to use a local privilege escalation exploit for initial access.
Solution:
# Need initial access? Use remote exploits
searchsploit -t remote Apache
# Already have a shell? Use local exploits for privesc
searchsploit -t local Linux kernel
# Remember:
# remote = no access needed (network attack)
# local = existing low-priv shell needed (privilege escalation)
Pitfall 4: Missing Dependencies
Problem: Python exploit fails because a required module isn’t installed.
Solution:
# Check the exploit's imports at the top of the file
head -20 exploit.py
# Common missing modules and fixes:
pip3 install requests # for 'import requests'
pip3 install pyyaml # for 'import yaml'
apt install python3-dev # for C extension compilation
apt install build-essential # for compiling C exploits
# For C exploits, compile first:
gcc exploit.c -o exploit
./exploit
Pitfall 5: Title-Only Search Limitation
Problem: Searching for “Ubuntu” returns nothing because it’s in the “Tested on” field, not the title.
Solution:
# Searchsploit only searches titles, not file contents
# Use --shell + grep for content search:
searchsploit --shell
grep -rl "Ubuntu 20.04" exploits/
# Or search by the vulnerability/CVE instead
searchsploit "CVE-2021-41773"
Pitfall 6: Filename Conflicts with -mm
Problem: Mirroring multiple exploits overwrites files with the same ID.
Solution:
# Always use a dedicated directory
mkdir -p ~/exploits/session_$(date +%H%M%S) && cd "$_"
# Or mirror one at a time with -m
searchsploit -m 49409.py
searchsploit -m 50383.py
# Or use --shell to copy manually with unique names
cp /usr/share/exploitdb/exploits/windows/local/49409.py ./win_privesc_49409.py
Pitfall 7: Stale Database
Problem: The exploit you need was added yesterday but your database is weeks old.
Solution:
# Always update first
searchsploit --update
# Check when your database was last updated
cd /usr/share/exploitdb
git log -1 --format="%ci"
# If --update fails (network issue), try manually:
cd /usr/share/exploitdb
git pull
Pitfall 8: Exploits That “Don’t Work”
Problem: The exploit is in the exploits_dont_work/ directory.
Solution:
# Don't ignore these! They often contain:
# - Partial working code you can adapt
# - Proof of concept that demonstrates the vulnerability
# - Shellcode or payloads you can reuse
# Search including non-working exploits
searchsploit -t exploits_dont_work Apache
# Read the code — often the fix is a small modification
12. Quick Reference Cheat Sheet
Most Used Commands (Memorize These)
# The 5 commands you'll use 90% of the time:
searchsploit <term> # Basic search
searchsploit -m <filename> # Mirror single exploit
searchsploit -mm <terms> # Mirror multiple exploits
searchsploit -p <platform> <term> # Platform-filtered search
searchsploit --update # Update database
Common Search Patterns
# Windows privilege escalation
searchsploit -p windows -t local "privilege escalation"
# Linux kernel exploit
searchsploit -p linux -t local kernel <version>
# Web app exploit
searchsploit -p webapps <app_name> <version>
# Service-specific remote exploit
searchsploit -t remote <service_name>
# CVE-based search
searchsploit CVE-XXXX-XXXXX
# Cross-platform protocol exploit
searchsploit -p multiple <protocol>
Quick Decision Matrix
| You Have | You Need | Command |
|---|---|---|
| Service name + version | Initial access | searchsploit -t remote <service> <version> |
| Low-priv shell + OS version | Root/Admin | searchsploit -p <os> -t local <version> |
| Web app name + version | Web exploit | searchsploit -p webapps <app> <version> |
| CVE number | Any exploit | searchsploit CVE-XXXX-XXXXX |
| Partial info | Broad search | searchsploit -w "<partial1>" "<partial2>" |
| Nmap XML | Automated search | searchsploit --nmap results.xml |
Exam Day Checklist
Before starting:
[ ] searchsploit --update
[ ] Verify: searchsploit --version
[ ] Create workspace: mkdir -p ~/oscp/exploits
During engagement:
[ ] Identify service + version
[ ] Search with specific terms
[ ] Evaluate top 2-3 candidates
[ ] Mirror with -m
[ ] Read the code (headers + usage)
[ ] Check dependencies
[ ] Adapt if needed
[ ] Execute
Keyboard Shortcuts for Speed
# Use bash history to repeat searches
↑ arrow # Previous command
Ctrl+R # Reverse search history
!ss # Repeat last command starting with 'ss'
# Tab completion works with searchsploit flags
searchsploit -<Tab> # Shows available flags
# Quick file review after mirroring
searchsploit -m 49409.py && cat 49409.py | head -30
Summary
Searchsploit is your primary weapon for exploit research during the OSCP exam. Master these core competencies:
- Speed: Go from service identification to mirrored exploit in under 30 seconds
- Precision: Use platform (
-p) and type (-t) filters to narrow results instantly - Verification: Always read exploit headers to confirm version and platform compatibility
- Organization: Mirror exploits to dedicated directories per target
- Adaptation: When an exploit doesn’t work, read the code and understand the vulnerability — this skill separates pass from fail
The tool itself is simple. The mastery comes from knowing what to search for, how to evaluate results, and when to adapt the code. Practice these searches repeatedly until they become muscle memory.