> For the complete documentation index, see [llms.txt](https://olb.gitbook.io/thm-ctf-write-ups/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://olb.gitbook.io/thm-ctf-write-ups/basic-pentesting.md).

# Basic Pentesting

{% embed url="<https://tryhackme.com/r/room/basicpentestingjt>" %}

Lien Gitbook : <https://olb.gitbook.io/thm-ctf-write-ups/basic-pentesting>

IP=10.10.57.76 &#x20;

## Nmap&#x20;

Résultats:

* Port 22 SSH open&#x20;
* Port 80 http open -Apache 2.4.18&#x20;
* Port 139 / 445 samba open&#x20;
* Port 8080 http open –Apache Tomcat/9.0.7&#x20;
* Port 8009 ajp13&#x20;

&#x20;<https://book.hacktricks.xyz/network-services-pentesting/8009-pentesting-apache-jserv-protocol-ajp> &#x20;

## &#x20;Nikto&#x20;

```
nikto -h 10.10.57.76
```

&#x20;Résultat: `+ /development/: Directory indexing found`&#x20;

&#x20;On se rend sur `/development/`

<img src="https://lh7-us.googleusercontent.com/lnbANnNfmr9A-wz2Bryp-9vsmW_viu64YV3Vmdc4H7nUBqczCZlCSph4tU6XJR8drR9uz1b4QGq7FcxHo95dlt6khUsolRM0dhJlhx6LGcjCQf9fMP85YS55sVYW2vzfnz8XjDJgptr2DJuYvPicliw" alt="" data-size="original">

&#x20;[On lit](#user-content-fn-1)[^1] : [http://10.10.57.76/development/dev.txt<br>](http://10.10.57.76/development/dev.txt)

* User K and user J ?&#x20;
* version 2.5.12 ? Struts ?&#x20;
* SMB (à creuser)&#x20;

On lit aussi : <http://10.10.57.76/development/j.txt>&#x20;

* J a un mdp faible (brute force de J ?)  &#x20;

## Enum4linux

On enumère smb/samba (445) avec le script enum4linux

```
enum4linux 10.10.57.76 | tee enum.txt
```

Résultat:

* \[+] Enumerating users using SID S-1-22-1 and logon username '', password ''&#x20;

`S-1-22-1-1000 Unix User\kay (Local User)`&#x20;

`S-1-22-1-1001 Unix User\jan (Local User)`&#x20;

&#x20;Donc désormais:

* On a nos user J et K => jan et kay&#x20;
* Jan a un mdp faible donc => brute force via Hydra sur ssh&#x20;

## Brute force SSH (hydra)

```
hydra -l jan -P /usr/share/wordlists/rockyou.txt 10.10.57.76 ssh  -V 
```

<figure><img src="https://100368042-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9atCPHvlQFB0GlCVKzJB%2Fuploads%2FZLWhNRXjTXUzbZSw8dNQ%2Fimage.png?alt=media&amp;token=e633fa08-8f6c-4585-a8bb-a76e3f5769b3" alt=""><figcaption></figcaption></figure>

```
ssh jan@10.10.57.76 
```

`jan:armando`&#x20;

![](https://lh7-us.googleusercontent.com/_UzGvjexJEu6Fwdvqfv448VoWwGGtob-u75kqd0kWJMYJ0Vzd9YxiPfGOxQR9ALqftD2D0IZjhvlcT7vBrD8dpQOIOQ3AAi5brj7VWDqyvZNpKPlAZ5sEfn7TlQLzyBDONEUyr26MBd4izLLxyR0XA4)

## &#x20;PrivEsc

* sudo –l => pas permis&#x20;
* Fichiers /etc/xxx => pas de permission&#x20;
* SUID/GUID &#x20;

`find / -type f -a \( -perm -u+s -o -perm -g+s \) -exec ls -l {} \; 2> /dev/null`  &#x20;

\=> RAS&#x20;

Utilisation de[ linpeas](https://github.com/carlospolop/PEASS-ng/tree/master/linPEAS) pour chercher une élévation de privilège éventuelle ?&#x20;

* Il faut le charger sur la VM cible&#x20;
* Pas d'écriture possible sur `/home/jan` donc on va sur `/tmp`&#x20;

<figure><img src="https://100368042-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9atCPHvlQFB0GlCVKzJB%2Fuploads%2FNV957OGJ8E1V6ogqaifS%2Fimage.png?alt=media&amp;token=a6172c51-0dab-41b2-84b2-e61b8157ed3d" alt=""><figcaption></figcaption></figure>

* On lance un serveur python sur sa Kali&#x20;

<figure><img src="https://100368042-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9atCPHvlQFB0GlCVKzJB%2Fuploads%2FqAZgcEHF1MJ1VbLstVC9%2Fimage.png?alt=media&amp;token=05666bca-5760-46b0-948e-2796bc436b33" alt=""><figcaption></figcaption></figure>

* Et un wget sur la VM cible&#x20;

<figure><img src="https://100368042-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9atCPHvlQFB0GlCVKzJB%2Fuploads%2Fo9kTA5HqtI3Yt8HRXHho%2Fimage.png?alt=media&amp;token=a8929194-4090-4ecf-8c5f-ccb8099b7331" alt=""><figcaption></figcaption></figure>

On execute `linpeas.sh`

<figure><img src="https://100368042-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9atCPHvlQFB0GlCVKzJB%2Fuploads%2FRZk2w4CJT02KOkNgz2Ns%2Fimage.png?alt=media&amp;token=cd3348f0-9633-49b2-9abf-832b6c0bdef3" alt=""><figcaption></figcaption></figure>

&#x20;Linpeas nous informe qu'une clé privée est sur le répertoire home de kay !!

<figure><img src="https://100368042-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9atCPHvlQFB0GlCVKzJB%2Fuploads%2FmUZ4K2nbvSfYJQRbOgQw%2Fimage.png?alt=media&amp;token=27203ab4-46a9-49a2-bf7a-43de644ca087" alt=""><figcaption></figcaption></figure>

On la récupère dans un fichier kay.private et on essaye de se connecter en ssh avec &#x20;

<figure><img src="https://100368042-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9atCPHvlQFB0GlCVKzJB%2Fuploads%2FPvyFOgOa6ewnVYSAbiyl%2Fimage.png?alt=media&amp;token=8d4d6568-85ec-433d-8e09-36cc9940a088" alt=""><figcaption></figcaption></figure>

La clé est partagée par passphrase.

On la brute force avec john:

<figure><img src="https://100368042-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9atCPHvlQFB0GlCVKzJB%2Fuploads%2FRfSQ5Id6LFdfYlH6cwxp%2Fimage.png?alt=media&amp;token=350c470a-ad78-4af7-89b9-9c333fcc4360" alt=""><figcaption></figcaption></figure>

Passphrase:`beeswax`&#x20;

On se connecte en ssh avec la clé RSA de kay et la passphrase:

<figure><img src="https://100368042-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9atCPHvlQFB0GlCVKzJB%2Fuploads%2FFPtalu3I86MwitAchUFE%2Fimage.png?alt=media&amp;token=d8c4d4c9-4226-4efa-823f-c41895167424" alt=""><figcaption></figcaption></figure>

Flag final dans le répertoire home de kay&#x20;

<figure><img src="https://100368042-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9atCPHvlQFB0GlCVKzJB%2Fuploads%2F3blXkp2t5grp5XfWcE0e%2Fimage.png?alt=media&amp;token=ef799d26-933a-4e79-887c-5972283ac152" alt=""><figcaption></figcaption></figure>

&#x20;

&#x20;

&#x20;

&#x20;

&#x20;

&#x20;

&#x20;

&#x20;

&#x20;

<br>

[^1]:
