Goal Reached Thanks to every supporter — we hit 100%!

Goal: 1000 CNY · Raised: 1000 CNY

100.0%

CVE-2016-5195 PoC — Linux kernel 竞争条件问题漏洞

Source
Associated Vulnerability
Title:Linux kernel 竞争条件问题漏洞 (CVE-2016-5195)
Description:Linux kernel是美国Linux基金会的开源操作系统Linux所使用的内核。 Linux kernel 2.x至4.8.3之前的4.x版本中的mm/gup.c文件存在竞争条件问题漏洞,该漏洞源于程序没有正确处理copy-on-write(COW)功能写入只读内存映射。本地攻击者可利用该漏洞获取权限。
Description
my personal POC of CVE-2016-5195(dirtyCOW)
Readme
# CVE-2016-5195
my personal POC and EXPLOIT of CVE-2016-5195 (dirty COW)

# Usage

## POC: write files arbitrarily

Just a simply POC of this CVE, compile the file `poc.c` as follow:

```shell
$ gcc poc.c -o poc -static -lpthread
```

You shall run it as follow:

```shell
./poc destination_file fake_file
```

You shall make sure the destination file is at least readable. The content of the destination file will be overwrite by the one of the fake, **if failed, just try more times until it succeed.**

**ONLY the content in the length of the original file will be write**

## EXPLOIT: GET THE ROOT

### I. generate a new ROOT user

Compile the file `root_newuser.c` as follow:

```shell
$ gcc root_newuser.c -o dirty -static -lpthread -lcrypt
```

Then run it as follow:

```shell
$ ./dirty new_username new_password
```

Type your new username and a password, it'll generate a new user WITH ROOT in the file `/etc/passwd`, check the first line of the file to see if it's successful and login with your new username and new password, then **JUST ENJOY THE POWER OF THE ROOT**

### II. overwrite SUID application to provide a ROOT SHELL

Compile the file `root_suid.c` as follow:

```shell
$ gcc root_suid.c -o dirty -static -lpthread
```

Then you can run it simply without any extra arguments. Check if the `/usr/bin/passwd` get changed(`sha256sum` may be useful) and then run it. Then **IT COMES TO THE TIME OF THE ROOT!**

# Analyzation of the CVE-2016-5195

You can visit [my blog](https://arttnba3.cn) for more information about this CVE
File Snapshot

[4.0K] /data/pocs/e702660b56c769a65c308b98a2bf546cbfa89d85 ├── [1.6K] poc.c ├── [1.5K] README.md ├── [2.4K] root_newuser.c └── [2.3K] root_suid.c 0 directories, 4 files
Shenlong Bot has cached this for you
Remarks
    1. It is advised to access via the original source first.
    2. If the original source is unavailable, please email f.jinxu#gmail.com for a local snapshot (replace # with @).
    3. Shenlong has snapshotted the POC code for you. To support long-term maintenance, please consider donating. Thank you for your support.