关联漏洞
标题:
Linux kernel 安全漏洞
(CVE-2022-0847)
描述:Linux kernel是美国Linux基金会的开源操作系统Linux所使用的内核。 Linux kernel 存在安全漏洞,该漏洞源于新管道缓冲区结构的“flag”变量在 Linux 内核中的 copy_page_to_iter_pipe 和 push_pipe 函数中缺乏正确初始化。非特权本地用户利用该漏洞可以提升权限至root。以下产品和版本受到影响:Linux Kernel 5.8-5.16.11、5.8-5.15.25、5.8-5.10.102。
描述
Simple Exploit for Dirty Pipe Vulnerability (CVE-2022-0847) This repository contains a simple proof of concept (PoC) for the Dirty Pipe vulnerability (CVE-2022-0847), which affects Linux kernel versions 5.8 to 5.16. This exploit demonstrates local privilege escalation by leveraging improper handling of pipe buffers in the kernel.
介绍
# Dirty Pipe Exploit (CVE-2022-0847)
## Overview
This repository contains a **Proof of Concept (PoC)** exploit for the **Dirty Pipe vulnerability (CVE-2022-0847)**, which affects **Linux kernel versions 5.8 to 5.16**. This vulnerability allows **local privilege escalation** by exploiting improper handling of pipe buffers in the kernel, enabling an attacker to modify read-only files (such as SUID binaries) and execute arbitrary code with elevated privileges.
## Description
The Dirty Pipe vulnerability is a critical issue found in Linux kernel versions between **5.8 and 5.16**. It allows local privilege escalation by exploiting improper handling of pipe buffers in the kernel. This vulnerability can be triggered by writing to a read-only file (such as SUID binaries), which can lead to **arbitrary code execution** and potentially a **root shell** on the affected system.
### Key Features:
- **Privilege Escalation**: Escalates privileges from an unprivileged user to root.
- **Targeted Attack**: Targets read-only files like SUID binaries.
- **Custom ELF Shellcode**: Injects custom shellcode into a target file to spawn a root shell.
- **Anti-Debugging**: Contains anti-debugging mechanisms to avoid detection by reverse engineers.
## Exploit Flow
1. **Kernel Version Check**: Verifies the kernel version to ensure it lies within the vulnerable range (5.8 to 5.16).
2. **Pipe Buffer Manipulation**: The exploit manipulates the pipe buffer flags to trigger the Dirty Pipe vulnerability.
3. **Payload Injection**: A custom ELF shellcode is injected into the target file (e.g., a SUID binary).
4. **Hijack SUID Binary**: The targeted binary is hijacked by overwriting its contents with the injected shellcode.
5. **Execute Hijacked Binary**: The hijacked binary is executed, resulting in the spawning of a root shell.
6. **Restore Original Binary**: The original content of the SUID binary is restored to avoid detection.
7. **Persistent Root Shell**: A root shell is opened with elevated privileges.
### Prerequisites
- A **Linux** system running a vulnerable kernel version (**5.8 to 5.16**).
- A **SUID binary** that can be exploited for privilege escalation.
### Compilation and Running the Exploit
To compile the exploit, run the following command:
gcc dirtypipe.c -Wall -O2 -fno-pie -no-pie -o dirtypipe
Notes:
Ensure that the target SUID binary is exploitable and resides in a path that can be accessed by the user running the exploit.
The system must be running a vulnerable version of the Linux kernel (5.8 to 5.16).
Anti-Debugging Features
The exploit contains an anti-debugging mechanism to prevent detection by debugging tools such as gdb. If the exploit detects the presence of a debugger, it will terminate early, making it more difficult for attackers to analyze the code.
How It Works:
The exploit checks for debugging activity by inspecting /proc/self/status and uses ptrace system calls to detect if the program is being traced by a debugger.
If a debugger is detected, the exploit will stop executing and exit, making reverse engineering harder.
Disclaimer
This exploit is provided for educational and research purposes only. Unauthorized use of this exploit is illegal and unethical. Running this exploit on any system without explicit permission from the system owner is prohibited and could result in legal consequences.
The author is not responsible for any damages, data loss, or legal ramifications resulting from the use or misuse of this exploit.
文件快照
[4.0K] /data/pocs/bb740b17eb2b5be14573d445699573e54bc21864
├── [ 11K] dirtypipe.c
├── [1.0K] LICENSE
└── [3.5K] README.md
0 directories, 3 files
备注
1. 建议优先通过来源进行访问。
2. 如果因为来源失效或无法访问,请发送邮箱到 f.jinxu#gmail.com 索取本地快照(把 # 换成 @)。
3. 神龙已为您对POC代码进行快照,为了长期维护,请考虑为本地POC付费,感谢您的支持。