> For the complete documentation index, see [llms.txt](https://www.marialc.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://www.marialc.com/pentesterlab-labs/recon-badge/recon_06-vhost.md).

# recon\_06 (vhost)

View the exercise here: [PentesterLab: Recon 06](https://pentesterlab.com/exercises/recon_06/course)

### **OBJECTIVE**

For this challenge, your goal is to access the default virtual host ("vhost").

### **FUZZING DIRECTORIES**

When accessing a new webserver, it often pays off to replace the hostname with the IP address or to provide a random **Host** header in the request. To do this, you can either modify the request in a web proxy or use:

```bash
curl -H "Host: ...."
```

### **SOLUTION**

#### **Solution #1:**

Do DNS resolution to get IP.

**`dig`** (Domain Information Groper) is used to query DNS servers. This command will return details such as the A record (the IP address of `hackycorp.com`), which you’ll use in later steps.

```bash
dig hackycorp.com
```

<figure><img src="https://290105472-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F89FZKOizBQcf0e0Qdrp8%2Fuploads%2FVofG8jfx2nB50wmctvSP%2FScreenshot_2024-07-31_at_23.48.03.png?alt=media&amp;token=502b11e6-61d4-4d0f-9998-18c6503a2463" alt=""><figcaption></figcaption></figure>

{% hint style="success" %}
Connect the client to the IP address:&#x20;

<pre class="language-bash"><code class="lang-bash"><strong>curl http://51.X.X.X/ -v
</strong></code></pre>

* The command makes a request to the IP address and shows you the entire process, including the HTTP headers and the response from the server. This helps you see how the server reacts, providing information that could lead to finding the key or solution for the challenge.
  {% endhint %}

<figure><img src="https://290105472-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F89FZKOizBQcf0e0Qdrp8%2Fuploads%2Fjl6UqPodQpHOoqkxe1iR%2Fimage.png?alt=media&amp;token=8d6c0afe-ffea-4ca1-b0b6-985afd818956" alt="" width="563"><figcaption></figcaption></figure>

#### **Solution #2:**

{% hint style="success" %}
Access the IP on a browser to get the flag.
{% endhint %}

<figure><img src="https://290105472-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F89FZKOizBQcf0e0Qdrp8%2Fuploads%2FmDCbhrLtlSmvclrjADHL%2Fimage%201.png?alt=media&amp;token=05f26841-b61b-4db0-bcf1-84617b468759" alt="" width="563"><figcaption></figcaption></figure>

***

{% hint style="info" %}

#### **Additional Notes:**

```bash
curl http://hackycorp.com/ -v
```

* If we just use the URL, not the IP, we only get html response because we are accessing the website itself.
* The host header is different.
  {% endhint %}

<figure><img src="https://290105472-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F89FZKOizBQcf0e0Qdrp8%2Fuploads%2FyRiaqXSKVHntMKyMSaC6%2Fimage%202.png?alt=media&amp;token=c18dbc98-7291-4ff9-b2d3-20349c78eb9b" alt="" width="563"><figcaption></figcaption></figure>

{% hint style="info" %}

#### Additional Notes (cont.):

But if we add a header, we'll get the flag:

```bash
curl http://hackycorp.com/ -v -H "Host: test"
```

* **`-v`** verbose option
* **`-H`** to add header
  {% endhint %}

<figure><img src="https://290105472-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F89FZKOizBQcf0e0Qdrp8%2Fuploads%2FqJgOjSTiAopK9ezf5Lbz%2Fimage%203.png?alt=media&amp;token=d2e3814b-574e-41bf-8c93-9ddec833849b" alt="" width="563"><figcaption></figcaption></figure>
