Cyber Services / All lessons / CEH — Ethical Hacking / Searchsploit Command-Line Exploit Database Search

Searchsploit Command-Line Exploit Database Search

Module 47 of 130 · 12 min read · Free to read

MODULES ↓ Command blocks have a COPY button

What is Searchsploit?

Searchsploit is a command-line utility included with Kali Linux that allows for fast, offline searching of the Exploit Database (Exploit-DB) archive. Exploit-DB is a project maintained by Offensive Security, curating public exploits, shellcode, and security papers. Searchsploit provides ethical hackers and penetration testers with a quick way to identify potential exploits for known vulnerabilities discovered during assessments.

Purpose & Ethics: Searchsploit helps identify known vulnerabilities and associated public exploit code. Use this information responsibly during authorized penetration tests to demonstrate impact and risk. Never use exploit code against systems without explicit permission.

I. Installation & Keeping the Database Current

Searchsploit is pre-installed on Kali Linux. However, the exploit database itself needs regular updates as new exploits are added constantly.

Update Exploit Database:

This command downloads the latest archive from Exploit-DB. Run this periodically.

sudo searchsploit -u
Network Required: The -u flag requires an active internet connection. Core searching works offline once updated.

Verify Installation:

Check the version or display the help menu.

searchsploit -h

II. Searching for Exploits

Searchsploit matches keywords against exploit titles, paths, and sometimes content.

A. Basic Keyword Search

Provide one or more space-separated terms. Searchsploit performs a case-insensitive AND search (all terms must appear).

searchsploit term1 [term2 ...]

Examples:

searchsploit apache 2.4
searchsploit windows local privilege escalation
searchsploit openssh 7.
searchsploit oracle weblogic

B. Title Search (-t)

Restricts the search to only match keywords within the exploit titles, often yielding more relevant results.

searchsploit -t term1 [term2 ...]

Example:

# Search titles for "WordPress Plugin" related exploits
searchsploit -t wordpress plugin contact form

C. Removing Unwanted Results (--exclude)

Use --exclude (followed by '|' separated terms in quotes) to filter out results containing specific keywords. Case-insensitive.

searchsploit search terms --exclude "termA|termB|..."

Example:

# Search for Windows exploits, excluding DoS and Proof of Concept
searchsploit windows privilege escalation --exclude "DoS|Proof of Concept|Metasploit"

D. Platform and Type Filtering (--platform, --type)

Filter results based on the target platform or exploit type defined in Exploit-DB.

searchsploit --platform platform search terms
searchsploit --type type search terms

Common types: local, remote, webapps, dos, shellcode. Common platforms: linux, windows, php, osx, bsd, hardware, multiple.

Examples:

# Find Linux local privilege escalation exploits
searchsploit --platform linux --type local privilege escalation

# Find PHP web application exploits
searchsploit --platform php --type webapps

# Find remote exploits for Windows
searchsploit --platform windows --type remote

E. JSON Output (-j)

Outputs results in JSON format, useful for scripting or integration with other tools.

searchsploit -j apache struts remote

III. Interpreting Search Results

The default output typically shows two columns:

Exploit TitlePath
Apache HTTP Server 2.4.49 - Path Traversalapache/remote/50383.sh
Apache HTTP Server 2.4.50 - Path Traversalapache/remote/50450.sh
......

Pay attention to the Path as you'll need it to examine, read, or copy the exploit.

IV. Examining and Using Exploits

A. Examine Exploit Details (-x, --examine)

Displays metadata like the full path and Exploit-DB URL without showing the code.

searchsploit -x path/to/exploit

Example:

searchsploit -x php/webapps/51739.txt

B. View Exploit Code/Description (-p, --path or --cat)

Prints the full content of the exploit file to the terminal. Essential for reading the code or instructions.

searchsploit -p path/to/exploit

Example:

searchsploit -p php/webapps/51739.txt | less

(Piping to less is recommended for readability).

C. Copy Exploit Locally (-m, --mirror)

Copies the exploit file(s) to your current working directory or a specified location for closer inspection, modification, or execution.

searchsploit -m path/to/exploit
searchsploit -m EDB-ID
searchsploit -m path1 ID2 --path /destination/path/

Examples:

# Copy exploit by path
searchsploit -m php/webapps/51739.txt

# Copy exploit by ID to Desktop
searchsploit -m 51739 --path ~/Desktop/

V. Reading and Understanding Exploits

Finding an exploit is only the first step. Before attempting to use any code from Exploit-DB, you **must** read and understand it.

How to Read an Exploit File:
  1. View the Content: Use searchsploit -p path/to/exploit | less or copy it (-m) and open it in a text editor (nano, vim, gedit, VS Code, etc.).
  2. Look for Comments/Headers: Most well-written exploits start with comments explaining:
    • The targeted software and vulnerable versions.
    • The specific vulnerability (e.g., Buffer Overflow, SQL Injection, RCE) and often a CVE number.
    • The author and date.
    • **Usage instructions:** How to run the script, required arguments (target IP, port, LHOST, LPORT, etc.).
    • Dependencies: Required libraries or tools (e.g., Python `requests`, `pwntools`, specific C libraries).
  3. Analyze the Code Logic: Understand the steps the code takes. Is it connecting to a port? Sending specific data? Trying default credentials? Receiving data? Look for network connections, system calls, file operations, and data manipulation.
  4. Identify Payloads: Is there shellcode embedded? Is it trying to execute a specific command on the target? Understand what the malicious payload is.
  5. Check for Destructive Actions: Does the code delete files, modify configurations, or perform actions that could damage the target system beyond exploitation?
  6. Look for Callbacks/Exfiltration: Does the code attempt to send data back to an unknown external server? This could be a backdoor aimed at the *user* of the exploit. Be extremely wary.
  7. Understand Text/PoC Files (.txt): Files ending in .txt often contain detailed descriptions, proof-of-concept steps (how to trigger the vulnerability manually), or theoretical explanations rather than executable code. Read these carefully to understand how to verify the vulnerability.
Never Run Blindly: If you don't understand what the code does, **do not run it**. It's better to miss an exploitation opportunity than to damage the target system or compromise your own machine.

VI. Testing Exploits and Verifying Vulnerabilities (The Critical Step)

Finding a potential exploit with Searchsploit is just the beginning. The next crucial phase involves carefully testing that exploit to verify if the target system is truly vulnerable. This step **must only** be performed within a controlled lab environment or during an authorized penetration test with explicit, written permission.

WARNING: Extreme Caution Required! Running exploit code, even public ones, carries significant risks. It can crash services, destroy data, or even contain backdoors targeting the attacker. **Never run exploit code you haven't thoroughly read and understood.** Always test in isolated, non-production environments first.
Ethical Exploit Testing Workflow
  1. 1. Environment Setup & Isolation:
    • Set up your Kali Linux attack machine.
    • Deploy an isolated target virtual machine specifically chosen or configured to be vulnerable to the exploit you intend to test (e.g., Metasploitable, older OS versions, specific vulnerable applications like DVWA).
    • Ensure the network configuration (e.g., VirtualBox Host-only or NAT Network) allows your Kali machine to reach the target VM, but isolates both from your production network and the internet unless explicitly required by the exploit (and understood).
    • Snapshot Target VM: Before running any exploit, take a snapshot of the target VM. This allows you to easily revert the system if the exploit causes unintended damage or instability.
  2. 2. Obtain Explicit Authorization:
    • In a professional context, reconfirm that testing this specific vulnerability with exploit code is within the scope of your engagement agreement and rules of engagement. Document this authorization.
    • For personal labs, ensure you are only targeting systems you own and control within your isolated lab network.
  3. 3. Deeply Understand the Exploit:
    • Go back to Section V (Reading Exploits). Re-read the code, comments, and any accompanying text files (.txt).
    • Identify the *exact* target software versions the exploit is designed for. Mismatches often lead to failure or crashes.
    • Pinpoint the required arguments: Target IP (RHOST), Port (RPORT), Attacker IP (LHOST), Listener Port (LPORT), URL, username/password, command to execute, etc. Note the specific flags or syntax needed (--target, -t, etc.).
    • Understand the *mechanism*: Does it trigger a buffer overflow? Inject SQL? Upload a file? Exploit a configuration flaw?
    • Determine the *expected outcome*: A reverse shell? Command execution? File read? Information disclosure? Service crash?
    • Note any hardcoded values (IPs, ports, paths) that might need modification for your specific environment.
  4. 4. Prepare the Exploit & Environment:
    • Copy the Exploit: Use searchsploit -m EDB-ID/path to copy the necessary files to your working directory.
    • Install Dependencies: Check comments/code for requirements. Install them on your Kali machine:
      • Python libraries: pip install requests paramiko beautifulsoup4 (examples)
      • System libraries (for C code): Look for #include directives. Install dev packages: sudo apt update && sudo apt install libc6-dev libssl-dev libssh-dev (examples)
    • Compile (if necessary): For C exploits (.c):
      gcc exploit_file.c -o exploit_binary_name -lcrypto -pthread

      (Add necessary libraries with -l, like -lcrypto for OpenSSL functions, -pthread for threading).

    • Set Permissions: Make scripts executable: chmod +x exploit.sh exploit.py exploit_binary_name
    • Set Up Listeners: If the exploit provides a reverse shell or sends data back, set up a listener *before* running the exploit:
      • Netcat Listener (Simple): nc -lvnp LISTENING_PORT
      • Metasploit Listener (More Robust):
        msfconsole -q
        use exploit/multi/handler
        set payload payload_used_by_exploit  # e.g., linux/x64/shell_reverse_tcp
        set LHOST YOUR_KALI_IP
        set LPORT LISTENING_PORT
        run -j
  5. 5. Execute the Exploit (Carefully):
    • Run the exploit from your Kali machine, targeting the authorized VM, providing all necessary arguments identified in Step 3. Double-check IPs and ports.
    • Conceptual Examples:

      # Python script with common args
      ./exploit.py --rhost TARGET_IP --rport TARGET_PORT --lhost YOUR_KALI_IP --lport 4444
      
      # Shell script needing a URL
      ./exploit.sh http://TARGET_IP/vulnerable_app/
      
      # Compiled C exploit needing IP and command
      ./exploit_binary TARGET_IP "id;hostname"
  6. 6. Observe Results & Analyze:
    • Monitor the exploit's terminal output for success messages, error messages (Python tracebacks, connection errors, etc.), or data returned.
    • Check your listener window (nc or Metasploit): Did a connection come in? Do you have a shell prompt (# or $)? Can you run commands (id, whoami, ls)?
    • Check the target system (if possible): Did the targeted service crash or restart? Are there unusual processes running? Were any files created or modified?
    • Note any specific error codes or behaviors.
  7. 7. Verify Vulnerability & Troubleshoot:
    • Success: If you achieved the expected outcome (e.g., got a shell, executed a command, retrieved a file), the vulnerability is confirmed.
    • Failure: If the exploit didn't work:
      • Re-read the exploit code/comments – did you miss a requirement or argument?
      • Verify the target service/software version *exactly* matches the exploit's target. Even minor version differences matter.
      • Check all arguments provided (IPs, ports, LHOST/LPORT). Typos are common.
      • Ensure your listener was running *before* executing the exploit.
      • Verify basic network connectivity between Kali and the target VM (ping, check VM network settings). Check for host-based firewalls on the target.
      • Try different payloads if the exploit allows.
      • Look for updated versions of the exploit or alternative exploits for the same vulnerability. Public exploits aren't always reliable.
  8. 8. Document Findings:
    • Record the vulnerability (e.g., CVE number).
    • Note the specific exploit used (EDB-ID, path).
    • Detail the exact commands run (including listener setup).
    • Describe the results (success, failure, errors, shell obtained, commands executed).
    • Capture screenshots or command output as evidence.
    • Assess the impact (e.g., remote code execution, information disclosure).
Focus on Verification, Not Destruction: The primary goal in ethical hacking and penetration testing is usually to *prove* the vulnerability exists and assess its risk. Avoid causing unnecessary damage or disruption. Clean up any changes made or listeners left behind if appropriate for the engagement scope.

VII. Powerful Searchsploit Examples

Here are diverse examples showcasing Searchsploit's capabilities:

Practical Usage Scenarios

1. Find exploits for a specific Apache version:

searchsploit apache 2.4.49

2. Find Remote Code Execution (RCE) exploits for Windows:

searchsploit --platform windows --type remote "Remote Code Execution"

3. Find WordPress plugin exploits (title search):

searchsploit -t wordpress plugin

4. Find exploits for vsftpd 2.3.4:

searchsploit vsftpd 2.3.4

5. Find Linux Kernel exploits for Privilege Escalation, excluding specific kernel versions:

searchsploit --platform linux --type local kernel --exclude "2.6.22|4.4.0"

6. Search for exploits related to a specific CVE (use the CVE number as a keyword):

searchsploit CVE-2021-44228
searchsploit log4j

7. Find web application exploits for Joomla:

searchsploit --type webapps joomla

8. List available exploits for ProFTPD, focusing on titles:

searchsploit -t proftpd

9. Find exploits for Microsoft Exchange Server, excluding Denial of Service:

searchsploit "Microsoft Exchange" --exclude "DoS"

10. Find shellcode for Linux x86_64:

searchsploit --platform linux --type shellcode x86_64

11. Search for exploits related to Samba (SMB) on Linux:

searchsploit --platform linux samba

12. Examine the details of an exploit using its EDB-ID:

searchsploit -x 49971

13. View the code of a specific Python exploit:

searchsploit -p python/remote/49971.py | less

14. Mirror (copy) all found exploits for 'Apache Struts' to a local directory:

mkdir struts_exploits
searchsploit "Apache Struts" -m --path ./struts_exploits/

(Note: `-m` used with a search term copies *all* matching results).

15. Find exploits for routers (often platform 'hardware' or specific brands):

searchsploit --platform hardware router d-link
searchsploit cisco router remote

16. Search for SQL Injection exploits in PHP web applications:

searchsploit --platform php --type webapps "SQL Injection"

17. Find exploits for OpenSSL, excluding older versions (example):

searchsploit openssl --exclude "1.0.1|1.0.0"

18. Search for Local File Inclusion (LFI) exploits:

searchsploit "Local File Inclusion" LFI

19. Find exploits for Jenkins CI server:

searchsploit jenkins

20. Search for exploits affecting MacOS (osx platform):

searchsploit --platform osx local

21. Find exploits related to Adobe Flash (often remote type):

searchsploit "Adobe Flash" --type remote

22. Get JSON output for Drupal exploits:

searchsploit -j drupal

23. Find exploits for Tomcat application server:

searchsploit tomcat

24. Search for exploits targeting Internet Explorer (often via webapps or specific versions):

searchsploit "Internet Explorer" 11

25. Find exploits related to VNC (Virtual Network Computing):

searchsploit vnc remote

VIII. Best Practices & Tips

  • Update Frequently: Keep your local database current with searchsploit -u.
  • Be Specific: Use precise keywords, software versions, and platform/type filters for better results.
  • Use Title Search: -t often yields more relevant exploits than a general keyword search.
  • Examine Before Copying/Running: Use -x or -p / --cat to review exploit details and code.
  • Read the Code: Never run exploit code you haven't read and understood thoroughly.
  • Check Exploit-DB Website: Sometimes the website (Exploit-DB.com) has additional comments, ratings, or discussions about specific exploits not visible via Searchsploit.
  • Combine with Vulnerability Scanners: Use tools like Nmap (with NSE vuln scripts), Nessus, or OpenVAS to identify potential CVEs, then use Searchsploit to find corresponding public exploits.
  • Test Safely: Always test exploits in a controlled lab environment against authorized targets before considering use in a real assessment.

IX. Conclusion

Searchsploit is an essential command-line tool for quickly querying the vast Exploit Database archive. It enables ethical hackers to efficiently find publicly known exploits relevant to vulnerabilities identified during assessments. Mastering its search options and, critically, understanding how to safely read, analyze, and test the retrieved code are crucial skills for effective penetration testing and vulnerability validation.

Modules (130) ← CEH — Ethical Hacking