关联漏洞
标题:
Sudo 缓冲区错误漏洞
(CVE-2021-3156)
描述:Sudo是一款使用于类Unix系统的,允许用户通过安全的方式使用特殊的权限执行命令的程序。 Sudo 1.9.5p2 之前版本存在缓冲区错误漏洞,攻击者可使用sudoedit -s和一个以单个反斜杠字符结束的命令行参数升级到root。
介绍
# CVE-2021-3156 (Sudo Baron Samedit)
This repository is CVE-2021-3156 exploit targeting Linux x64. For writeup, please visit https://datafarm-cybersecurity.medium.com/exploit-writeup-for-cve-2021-3156-sudo-baron-samedit-7a9a4282cb31
Credit to [Braon Samedit of Qualys for the original advisory](https://www.qualys.com/2021/01/26/cve-2021-3156/baron-samedit-heap-based-overflow-sudo.txt).
---
### Files
##### Exploit on glibc with tcache
* **exploit_nss.py** auto detect all requirements and number of entries in /etc/nsswitch.conf
* **exploit_nss_manual.py** simplified version of exploit_nss.py for better exploit understanding
* **exploit_timestamp_race.c** overwrite def_timestamp and race condition to modify /etc/passwd
##### Exploit on glibc without tcache
* **exploit_defaults_mailer.py** the exploit overwrite struct defaults to modify mailer binary path. It requires sudo compiled without disable-root-mailer such as CentOS 6 and 7.
* **exploit_userspec.py** the exploit overwrite struct userspec to bypass authentication and add a new user in /etc/passwd. Support only sudo version 1.8.9-1.8.23.
* **exploit_cent7_userspec.py** simplified version of exploit_userspec.py for understanding but target only CentOS 7 with default configuration
* **exploit_nss_d9.py** overwrite struct service_user on Debian 9 but support only default /etc/nsswith.conf
* **exploit_nss_u16.py** overwrite struct service_user on Ubuntu 16.04 but support only default /etc/nsswith.conf
* **exploit_nss_u14.py** overwrite struct service_user on Ubuntu 14.04 but support only default /etc/nsswith.conf
##### Others
* **asm/** tinyelf library and executable for embedded in python exploit
* **gdb/** scripts that used for debugging sudo heap
---
### Choosing exploit
*For Linux distributions that glibc has tcache support and enabled (CentOS 8, Ubuntu >= 17.10, Debian 10):*
* try **exploit_nss.py** first
* If an error is not glibc tcache related, you can try **exploit_timestamp_race.c** next
*For Linux distribution that glibc has no tcache support:*
* if a target is Debian 9, Ubuntu 16.04, or Ubuntu 14.04, try **exploit_nss_xxx.py** for specific version first
* next, try **exploit_defaults_mailer.py**. If you know a target sudo is compiled with *--disable-root-mailer*, you can skip this exploit. The exploit attempt to check root mailer flag from sudo binary. But sudo permission on some Linux distribution is 4711 (-rws--x--x) which is impossible to check on target system. (Known work OS is CentOS 6 and 7)
* last, try **exploit_userspec.py**
文件快照
[4.0K] /data/pocs/96334dd7bbaaf36f52a0e9e36d85920377f7eb3e
├── [4.0K] asm
│ ├── [1.3K] tinylib.asm
│ └── [1.0K] tinysh.asm
├── [5.9K] exploit_cent7_userspec.py
├── [ 13K] exploit_defaults_mailer.py
├── [2.8K] exploit_nss_d9.py
├── [1.3K] exploit_nss_manual.py
├── [8.0K] exploit_nss.py
├── [3.1K] exploit_nss_u14.py
├── [2.8K] exploit_nss_u16.py
├── [7.4K] exploit_timestamp_race.c
├── [ 23K] exploit_userspec.py
├── [4.0K] gdb
│ ├── [1.1K] cmds_cent7
│ ├── [1.0K] cmds_cent8
│ ├── [ 802] cmds_deb10
│ ├── [1.1K] cmds_deb9
│ ├── [1.0K] cmds_u14
│ ├── [ 968] cmds_u16
│ ├── [1.0K] cmds_u18
│ ├── [ 758] gdbexp.py
│ ├── [ 546] gdbroot.py
│ ├── [5.5K] parse.py
│ └── [1.7K] patch.py
├── [1.5K] LICENSE
├── [2.5K] README.md
└── [ 13K] sudo-hax-me-a-sandwich
2 directories, 25 files
备注
1. 建议优先通过来源进行访问。
2. 如果因为来源失效或无法访问,请发送邮箱到 f.jinxu#gmail.com 索取本地快照(把 # 换成 @)。
3. 神龙已为您对POC代码进行快照,为了长期维护,请考虑为本地POC付费,感谢您的支持。