> 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_07-vhost-over-tls.md).

# recon\_07 (vhost over TLS)

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

### **OBJECTIVE**

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

### **DEFAULT VHOST OVER TLS**

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: ...."
```

This time you need to check the TLS version of the website to get the key

### **SOLUTION**

This command performs a DNS lookup to retrieve the IP address associated with the domain `hackycorp.com`.

```bash
dig hackycorp.com
```

<figure><img src="https://290105472-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F89FZKOizBQcf0e0Qdrp8%2Fuploads%2FT2WXfCAWwUWkhUoh18xT%2FScreenshot_2024-08-01_at_02.38.10.png?alt=media&amp;token=e216c371-a845-4459-a36b-42e7fc7ff875" alt="" width="563"><figcaption></figcaption></figure>

{% hint style="info" %}

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

* `curl` is used to send HTTP requests to the given IP address. In this case, you're trying to access the site using its IP directly over TLS (`https://`). However, because the IP address does not match the hostname in the SSL certificate, this step is likely to fail with an SSL error.
  {% endhint %}

<figure><img src="https://290105472-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F89FZKOizBQcf0e0Qdrp8%2Fuploads%2FD9DBAlrigTgSmYlG1qSv%2FScreenshot_2024-08-01_at_02.34.01.png?alt=media&amp;token=55bef964-3a02-4be7-9b4b-7e6ce0736cca" alt="" width="563"><figcaption></figcaption></figure>

{% hint style="success" %}

```bash
curl https://51.X.X.X/ --insecure
```

* This ignores SSL certificate verification and forces the connection.
* **`--insecure`** allows `curl` to bypass SSL certificate validation. This is necessary because the certificate is tied to the domain name (`hackycorp.com`), not the IP address.
* The request should succeed, but you won't get the default virtual host because it still assumes you're accessing via the IP address rather than the expected hostname.
  {% endhint %}

<figure><img src="https://290105472-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F89FZKOizBQcf0e0Qdrp8%2Fuploads%2FNRniuy0mn7Ath5SSufVG%2Fimage.png?alt=media&amp;token=a57ba9eb-98c4-4e70-96b9-c41794136d6b" alt="" width="563"><figcaption></figcaption></figure>

***

{% hint style="info" %}

```bash
curl https://51.X.X.X --insecure -v
```

* **`-v`** flag enables verbose mode, showing you detailed information about the request, including SSL/TLS handshake details, headers, and response.
  {% endhint %}

<figure><img src="https://290105472-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F89FZKOizBQcf0e0Qdrp8%2Fuploads%2FylUb7F0cLoRs1HuSWnUj%2Fimage%201.png?alt=media&amp;token=5060a5b8-794f-45d1-b2b8-c51ca7915f52" alt="" width="563"><figcaption></figcaption></figure>

{% hint style="success" %}

```bash
curl https://51.X.X.X --insecure -v -H 'Host: test'
```

* some targets may allow us to access another version of the website, so it is important to check the behavior of an application when using a hostname that is not the one the application is expecting
  {% endhint %}

<figure><img src="https://290105472-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F89FZKOizBQcf0e0Qdrp8%2Fuploads%2FWgqfqph0aFuEuoAmYSyW%2Fimage%202.png?alt=media&amp;token=44b832d8-e834-43c6-a3b2-83283177d01f" alt="" width="563"><figcaption></figcaption></figure>
