# Metasploit

## Usage:

To enter the metasploit framework typethe command below:

```bash
sudo msfconsole
```

<figure><img src="https://3672032160-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3Qsmtw2a8kQMt8K7P5qR%2Fuploads%2FqIsoN86VKP3jsW8B0NZr%2Fimage.png?alt=media&#x26;token=78638f99-9124-45ac-86f0-ab9f99edd8e0" alt=""><figcaption></figcaption></figure>

### Search:

You can search for exploits as shown below:

```bash
search <service>
```

<figure><img src="https://3672032160-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3Qsmtw2a8kQMt8K7P5qR%2Fuploads%2Fsp3VXqTY0nbQfh09sA54%2Fimage.png?alt=media&#x26;token=57600ca4-0f96-443f-9c3f-409d5e6187f2" alt=""><figcaption></figcaption></figure>

If you want info on any of the exploits show in search type: This will pull up an html  page on usage.

```bash
info <number_of_exploit>
```

### Select Exploit:

To select exploit use the use command:

```bash
use <number_of_exploit>
```

<figure><img src="https://3672032160-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3Qsmtw2a8kQMt8K7P5qR%2Fuploads%2FiP6eMc6S2EHz5yZGEvME%2Fimage.png?alt=media&#x26;token=9c89105b-146a-406a-833d-5b3bc2f981b1" alt=""><figcaption><p>Selected exploit zero</p></figcaption></figure>

Alternativity you can go straight to the exploit:

<figure><img src="https://lh4.googleusercontent.com/geagL3W4HRpTgM-hVOBYcfw-L9RQ1MIqcSLg3YWq3T9zOS9y49Arq09wJUQNN0yL1fCaA9ScvwWAVW4-bIVTABUDI8FQYPyjlSb-nCs8SvBCpDJZp8lBRavY2Ynaxf9frFFs4jHKJ5ffnUiQd69Ww-k" alt=""><figcaption></figcaption></figure>

### Options

Now that an exploit has been selected we need to configure the options.

<figure><img src="https://3672032160-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3Qsmtw2a8kQMt8K7P5qR%2Fuploads%2FrCluP90mgk5JaaOwovWD%2Fimage.png?alt=media&#x26;token=acf08b47-ded2-4fba-9b12-fd246c5560ff" alt=""><figcaption></figcaption></figure>

To edit an option:

<figure><img src="https://lh5.googleusercontent.com/IAOTVEFGSjb4LDaKRYAMn92C56Ge0Cdu2uPYYJda0vvC_Pb2N5WW0XD_b0wU-TSvlBqlDULiMkXqdiTfb2niQObzl3CiNzsoXDfdkOI0cSAKkoK1COM-tMJWmhNssyMwaiXN8Vo_IRI-nTm1mHY7b14" alt=""><figcaption></figcaption></figure>

### Payloads:

<figure><img src="https://lh3.googleusercontent.com/agYULcGAkbSs8ijtQ27hPtsadrCwaG1zBZRsx29et-Sp89hioL6aAh2sBHRMJEk54DgHLa9F2mVz4W_d1uPo9SuBzC6aWPr4jVgiqemDQeYjTy_ibjcaX8GOZo4uTBqH8glarpK18vAk7VUospDRz1w" alt=""><figcaption></figcaption></figure>

You can change the payload selected:

```bash
use <number_of_payload>
```

### Run/Exploit:

<figure><img src="https://lh3.googleusercontent.com/iU5cPYoRQ_EPBYP9r0Tdoik1jYqRH5A4DB-O0Ah35QGh2BBFPiF_h2GziwP4gK4zI8O2vNlQUY0zhKtIrYd1VTDgzS9HjNQJ0xrxQKQ19RJtiJcrI4OtPmS2ufXZ_MycT80UlHXMn8zu1ZT6pGCZ448" alt=""><figcaption></figcaption></figure>

### Enter Terminal:

Below you can see how to enter a terminal from shell.

```
shell
```

```bash
python -c 'import pty; pty.spawn("/bin/bash")'
```

<figure><img src="https://lh4.googleusercontent.com/qOLGbT1fRrCeG7raKNnZDAfQF0FsRCRJp8ui8CyI2CuiwTBnRlVouRynvxvOlWomJRAQikdnhFR0vlPKhbjAyvMA75gMvhvg6k8rEqFbt39dIPr9mJuyDhikFEAu07LEKjoBu3vMRQpjgn26Tn_QK7U" alt=""><figcaption></figcaption></figure>
