> For the complete documentation index, see [llms.txt](https://ret2basic.gitbook.io/ctfnote/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://ret2basic.gitbook.io/ctfnote/red-teaming/exploitation/metasploit.md).

# Metasploit

## Staged vs. Non-staged Payloads

{% hint style="info" %}
Try staged payloads first, but don't forget to try non-staged payloads if staged payloads don't work.
{% endhint %}

A staged payload breaks the payload into small pieces (stages) and chains them together in the end. It is good for:

1. **Small buffer**
2. **AV evasion**

However, staged payload might not work in some scenarios. If that is the case, try its non-staged counterpart.

A **staged** payload looks like this:

```
windows/x64/meterpreter/reverse_tcp
```

and a **non-staged** payload looks like this:

```
windows/x64/meterpreter_reverse_tcp
```

## Add Exploits to Metasploit

If `searchsploit` finds a Metasploit exploit but it is not in the Metasploit framework, add it manually:

```bash
cp <exploit_path> /usr/share/metasploit-framework/modules/exploits/linux/http
```

In Metasploit, run `reload_all`.

```bash
msf6 > reload_all
```

## Advanced Options

Metasploit modules have some **advanced options** for you to play with. For example, in `exploit/linux/samba/is_known_pipename`, we have to set SMB version to 1. This is done in one of the advanced options:

![exploit/linux/samba/is\_known\_pipename advanced options](/files/ckNispMKyRLptys7Mfv6)

Set `SMB:ProtocolVersion` to 1:

```bash
msf6 exploit(linux/samba/is_known_pipename) > set SMB::ProtocolVersion 1
```

## Meterpreter


---

# 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://ret2basic.gitbook.io/ctfnote/red-teaming/exploitation/metasploit.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.
