> 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_10-visual-recon.md).

# recon\_10 (visual recon)

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

### **OBJECTIVE**

For this challenge, your goal is to use visual reconnaissance. You will need to find the website with the key in <mark style="color:red;">**red**</mark>.

### **VISUAL RECONNAISSANCE**

For this challenge, the web applications are hosted under: **`0x["%02x"].a.hackycorp.com`** as in:

* **0x00.a.hackycorp.com**
* **0x01.a.hackycorp.com**
* **...**
* **0x0a.a.hackycorp.com**
* **0x0b.a.hackycorp.com**
* **...**

If you haven't done visual reconnaissance before, you can try to use the tool [**Aquatone**](https://github.com/michenriksen/aquatone) to get images that you can browse easily to find the right key (in red).

### **SOLUTION**

Let’s first try to check manually the first 4 links of the sequence.

We notice that the output color of the keys is <mark style="color:blue;">**`blue`**</mark> and **`black`**.

The keys in the website are images, so we can solve this challenge by saving the output image of each site and then checking them visually after visiting all sites to find the text in <mark style="color:red;">**`red`**</mark>.

It would be very tedious to manually do this, so we’ll use a script to automate the saving of the output.

<figure><img src="https://290105472-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F89FZKOizBQcf0e0Qdrp8%2Fuploads%2F3TLkuIMLGiopKhWln3DA%2FScreenshot_2024-08-01_at_03.06.35.png?alt=media&amp;token=bbdcb72b-e734-4595-9b32-0bdee751bcd9" alt="" width="563"><figcaption></figcaption></figure>

<figure><img src="https://290105472-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F89FZKOizBQcf0e0Qdrp8%2Fuploads%2FnXD5hY69C0jREAHngOYp%2FScreenshot_2024-08-01_at_03.07.06.png?alt=media&amp;token=5c55c8c2-ec60-4de0-80db-9e4dd8bf474a" alt="" width="563"><figcaption></figcaption></figure>

<figure><img src="https://290105472-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F89FZKOizBQcf0e0Qdrp8%2Fuploads%2F45ha7H1BoaSXk3m6NJ49%2FScreenshot_2024-08-01_at_03.07.23.png?alt=media&amp;token=ac866912-36bc-4673-afa5-c1f567c4d00c" alt="" width="563"><figcaption></figcaption></figure>

<figure><img src="https://290105472-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F89FZKOizBQcf0e0Qdrp8%2Fuploads%2FQ6Ru26Olj70bWFyUMn8e%2FScreenshot_2024-08-01_at_03.07.38.png?alt=media&amp;token=366c8fe4-1741-49e8-9735-8ecc50c6e205" alt="" width="563"><figcaption></figcaption></figure>

Click the tabs to see the thought process on how we arrived at the final code used to automate the printing process of the key on each page for easy viewing later.

{% tabs %}
{% tab title="Final Code" %}
For each line, the script uses `curl` to download a file named `logo.png` from the specified URL and saves it with the filename `<line>.png`. This script helps automate the process of downloading and saving files from multiple URLs listed in a text file.

```bash
for i in `cat hosts.txt`;
do curl $i/logo.png -o $i.png
done
```

Wait until all is done.

<figure><img src="https://290105472-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F89FZKOizBQcf0e0Qdrp8%2Fuploads%2FCmWD8Uh8AAc37ATGyp8P%2FScreenshot_2024-08-01_at_03.19.18.png?alt=media&amp;token=d89e3595-a094-4288-9db4-5fbaecddbc53" alt="" width="563"><figcaption></figcaption></figure>
{% endtab %}

{% tab title="Step 1" %}
We’ll first try to generate a sequence of numbers. Let’s try generating 1 to 10.

```bash
seq 1 10
```

<figure><img src="https://290105472-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F89FZKOizBQcf0e0Qdrp8%2Fuploads%2FFwL0lg4vRbLpJ6roa9DM%2FScreenshot_2024-08-01_at_03.09.15.png?alt=media&amp;token=545f0f62-e876-4bbf-ac90-7fe22f2916a8" alt="" width="563"><figcaption></figcaption></figure>
{% endtab %}

{% tab title="Step 2" %}
We'll use a `for` loop to count from 0 to 150. The script prints each number, showing how you can easily loop through a range of numbers in a shell script.

```bash
for i in `seq 0 150`; do
echo $i
done
```

<figure><img src="https://290105472-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F89FZKOizBQcf0e0Qdrp8%2Fuploads%2FtkJj9GJDgCuOJWRtJxRZ%2FScreenshot_2024-08-01_at_03.11.10.png?alt=media&amp;token=ead4f885-ed62-433a-9a32-f810dd7f9f74" alt="" width="563"><figcaption></figcaption></figure>
{% endtab %}

{% tab title="Step 3" %}
This `for` loop to count from 0 to 150 and print each number in its hexadecimal (base 16) format. The script converts each number to hexadecimal and displays it on a new line.

```bash
for i in `seq 0 150`; do
printf " %x\n" $i 
done 
```

* **`%x`** — treats the input as hex

<figure><img src="https://290105472-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F89FZKOizBQcf0e0Qdrp8%2Fuploads%2FUUrzYWSoJxLyfxwODRiZ%2FScreenshot_2024-08-01_at_03.12.13.png?alt=media&amp;token=fc4915b2-0c54-49e2-8536-9cb1670e1e08" alt="" width="563"><figcaption></figcaption></figure>
{% endtab %}

{% tab title="Step 4" %}
Each hostname will be formatted with a hexadecimal number and appended to a file named `hosts.txt`. This script creates a list where each line follows the format `0x`<mark style="color:orange;">`<hexadecimal number>`</mark>`.a.hackycorp.com`.

```bash
for i in `seq 0 150`;  do 
printf "0x%02x.a.hackycorp.com\n" $i >> hosts.txt
```

* `%02`
  * `2` — means 2 digits
  * `0` — as padding (e.g. `01`)
* `>>` — if just single `>`, the last line of the sequence will only be printed

<figure><img src="https://290105472-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F89FZKOizBQcf0e0Qdrp8%2Fuploads%2Folr24fcytL48DYHaBdg7%2FScreenshot_2024-08-01_at_03.13.56.png?alt=media&amp;token=465c66fa-2089-42eb-9cca-ee62412323e3" alt="" width="563"><figcaption></figcaption></figure>
{% endtab %}

{% tab title="Step 5" %}
When we print the final output, we get the desired format of the URL.

```bash
vi hosts.txt
```

<figure><img src="https://290105472-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F89FZKOizBQcf0e0Qdrp8%2Fuploads%2F52uRU63uaCtvwWN0KwRM%2FScreenshot_2024-08-01_at_03.15.03.png?alt=media&amp;token=c906a414-5f6b-431c-95d6-a54abb11ec81" alt="" width="563"><figcaption></figcaption></figure>
{% endtab %}
{% endtabs %}

Once everything is saved, open all photos at once.

<figure><img src="https://290105472-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F89FZKOizBQcf0e0Qdrp8%2Fuploads%2FVSWN3Wrx7FBBhs0RP60I%2FScreenshot_2024-08-01_at_04.01.12.png?alt=media&amp;token=428396ed-e80d-4548-b38a-008b8690dc90" alt="" width="563"><figcaption></figcaption></figure>

{% hint style="success" %}
Visually scan the photos to check for the key in red text.
{% endhint %}

<figure><img src="https://290105472-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F89FZKOizBQcf0e0Qdrp8%2Fuploads%2F3cHVngfqqvYTvtGktroU%2Fimage.png?alt=media&amp;token=a228b9cd-6516-4f20-87a0-299c91141dca" alt="" width="563"><figcaption></figcaption></figure>

{% hint style="success" %}
You can also open the image name back in the browser to view the key.
{% endhint %}

<figure><img src="https://290105472-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F89FZKOizBQcf0e0Qdrp8%2Fuploads%2FejDYB0zffckNk9elcgC3%2Fimage%201.png?alt=media&amp;token=54cb9750-f5ec-4f99-abf2-df445e877971" alt="" width="563"><figcaption></figcaption></figure>
