> For the complete documentation index, see [llms.txt](https://capcap-1.gitbook.io/capcap/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://capcap-1.gitbook.io/capcap/readme/ctf-modules/getting-started_mod-2/exploitation.md).

# Exploitation

Use this page when enumeration gives you a real lead.

### Quick loop

1. Verify the finding.
2. Match the version.
3. Choose the safest exploit path.
4. Get code execution.
5. Stabilize access and record proof.

{% stepper %}
{% step %}

### Confirm the target and weakness

Do not run an exploit on a guess.

Match:

* service
* version
* target OS
* auth state

Best sources:

* banners
* headers
* Nmap service detection
* app version pages
  {% endstep %}

{% step %}

### Search for public exploit paths

Start with local exploit references.

Then check framework support.

```bash
searchsploit <SERVICE> <VERSION>
searchsploit -t <PRODUCT>
msfconsole
search <SERVICE> <VERSION>
```

Prioritize:

* exploits matching the exact version
* exploits with clear usage notes
* modules that support `check`
  {% endstep %}

{% step %}

### Validate before you run

Read the exploit first.

Check what it needs.

Look for:

* required credentials
* required paths or endpoints
* target architecture
* payload settings

{% hint style="warning" %}
If the version match is weak, keep enumerating first.
{% endhint %}
{% endstep %}

{% step %}

### Execute with the lowest-risk path

Try safe verification before full exploitation.

Use direct exploit code or Metasploit when it fits the target.

```bash
searchsploit -x <EDB_PATH>
searchsploit -m <EDB_PATH>
```

Common Metasploit flow:

```bash
use <MODULE>
show options
set RHOSTS <TARGET_IP>
set LHOST <YOUR_IP>
check
run
```

{% endstep %}

{% step %}

### Stabilize access

Once you get a shell, make it usable fast.

Common next actions:

* upgrade to a TTY
* confirm user and hostname
* capture proof

```bash
whoami
hostname
id
python3 -c 'import pty; pty.spawn("/bin/bash")'
```

{% endstep %}
{% endstepper %}

### Fast decision rules

* If creds work, try login paths before exploit code.
* If a module supports `check`, use it first.
* If an exploit needs many edits, confirm the version again.
* If the shell is unstable, fix it before moving on.

### Useful references

* [Searchsploit](/capcap/readme/cheat-sheets/searchsploit.md)
* [Metasploit](/capcap/readme/cheat-sheets/metasploit.md)
* [Workflow-Service Enumeration](/capcap/readme/ctf-modules/getting-started_mod-2/wf-service-enumeration.md)
* [Workflow-Web Enumeration](/capcap/readme/ctf-modules/getting-started_mod-2/wf-web-enumeration.md)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://capcap-1.gitbook.io/capcap/readme/ctf-modules/getting-started_mod-2/exploitation.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
