> 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/targets.md).

# Targets

### What are "Targets"?

In Metasploit, an exploit module isn't always a one-size-fits-all script. Targets are unique identifiers that adapt the exploit code to run against a *specific* version of an operating system, service pack, or software release.

#### Why do targets matter? (Under the Hood)

Exploits (like buffer overflows) rely on hardcoded memory addresses (Return Addresses, e.g., `jmp esp` or `pop/pop/ret`). These memory addresses shift around based on:

* The Operating System version (e.g., Win 7 vs. Win 10)
* The applied Service Pack (e.g., SP1 vs. SP3)
* The installed software version (e.g., Internet Explorer 8 vs. IE 9)
* Even the language pack installed!

If you select the wrong target, the exploit will point to the wrong memory address, which typically results in the target service crashing instead of granting a reverse shell.

### Key Commands for Target Selection

Before setting a target, you must have an exploit module selected (`use exploit/...`).

#### 1. The `info` Command

Always run this when looking at a new exploit. It acts as the module's documentation.

Bash

```bash
info
```

> Best Practice: The `info` command explains the vulnerability, lists the author, and shows the required target dependencies. Reading this is mandatory for maintaining a clean, safe working environment and avoiding unintended service crashes during an assessment.

#### 2. Viewing Available Targets

To see the list of specific software/OS versions the exploit supports:

Bash

```bash
show targets
```

*Example Output:*

Plaintext

```bash
Exploit targets:
   Id  Name
   --  ----
   0   Automatic
   1   IE 7 on Windows XP SP3
   2   IE 8 on Windows XP SP3
   6   IE 9 on Windows 7
```

#### 3. Setting the Target

By default, most modules are set to `0 Automatic`, meaning Metasploit will attempt to perform service detection and pick the right memory addresses itself.

However, if you have already enumerated the target and know the exact version, it is much safer and more reliable to specify the target ID manually:

Bash

```bash
set target 6
```

> Result: This forces Metasploit to use the exact return addresses required for Internet Explorer 9 running on Windows 7.

### Advanced Target Identification (Preview)

If an automatic target fails and the standard list doesn't match perfectly, advanced exploit development requires manual target identification. This involves:

1. Obtaining a copy of the target's binary files (`.exe` or `.dll`).
2. Using tools like `msfpescan` to manually locate a suitable return address in the binary's memory structure. *(Covered in deeper exploit development modules).*


---

# 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/targets.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.
