用 find -perm 审计 SUID/SGID 二进制文件
枚举所有以提权身份运行的程序——这里出现意外条目就是经典的本地提权漏洞。
执行 `sudo find / -xdev -type f \( -perm -4000 -o -perm -2000 \) -exec ls -l {} +` 列出全部 SUID 和 SGID 程序。
01命令
命令
$ sudo find / -xdev -type f \( -perm -4000 -o -perm -2000 \) -exec ls -l {} +02作用说明
`-perm -4000` 匹配带 setuid 位的文件,`-perm -2000` 匹配 setgid 位;两者用 `-o` 组合可以一次扫完。`-xdev` 让 find 不跨文件系统,避免钻进 /proc 和挂载的网络盘——想全盘扫描就去掉它并加 `2>/dev/null`。正常系统里有一份已知基线(passwd、sudo、ping、mount);出现其他东西——编辑器、shell、某份 bash 副本——就是值得彻查的红旗。
03风险
!注意: 不要盲目去掉查到的 SUID 位:剥掉 /usr/bin/sudo 或 /usr/bin/passwd 会弄坏系统。用包管理器校验(rpm -Va / debsums)比对二进制是否被篡改。
04撤销
✓无需撤销——该命令不会改变持久状态。
05来源
- find(1) — search for files in a directory hierarchy依据: Documents -perm -mode (all permission bits set) matching for SUID (-4000) and SGID (-2000) checks.
最后验证: 2026-09-17 · 分类: 安全与隐私