MadExploits/linemadpeas
GitHub: MadExploits/linemadpeas
一款 Bash 编写的 Linux 权限提升枚举与漏洞扫描工具,能自动检测系统中的提权向量并提供可执行的利用方法。
Stars: 11 | Forks: 2
🔐 Linux 权限提升枚举工具



**带有 Exploit 方法的全面 Linux 权限提升扫描器**
[功能](#-features) • [安装](#-installation) • [用法](#-usage) • [输出](#-output) • [漏洞](#-vulnerabilities-detected)
## 📋 描述
**Linux 权限提升枚举工具** 是一个 bash 脚本,旨在对 Linux 系统进行全面枚举,以查找权限提升漏洞。该工具不仅能检测漏洞,还提供了可以直接使用的 exploit 方法和示例命令。
该工具非常适用于:
- 🎯 **渗透测试** - 识别系统中的安全漏洞
- 🔍 **安全审计** - 对 Linux 系统进行安全审计
- 📚 **学习** - 学习各种权限提升技术
- 🛡️ **防御安全** - 了解需要修补的安全漏洞
## ✨ 功能
### 🎨 **增强型用户界面**
- 吸引人的 ASCII art 横幅
- 每个扫描阶段的进度条
- 带颜色的输出(Critical、Warning、Info、Success)
- 用于部分标题的框线绘制
- 实时进度追踪
### 🔎 **全面的漏洞检测**
- **25+ 种检查类别** 覆盖了各种权限提升攻击向量
- 自动检测已知漏洞
- 深入检查错误配置
### 💣 **Exploit 方法与示例**
- 每个漏洞的 exploit 方法说明
- 可直接使用的示例命令
- CVE 参考和 exploit 链接
- 每种技术的提示与技巧
### 📊 **双重输出文件**
- **枚举报告** - 完整的扫描结果报告
- **Exploit 方法** - 包含 exploit 方法和示例的独立文件
## 🚀 安装说明
### **方法 1:Clone Repository**
```
git clone https://github.com/MadExploits/linemadpeas.git
cd linemadpeas
chmod +x madpeas.sh
```
### **方法 2:手动下载**
```
wget https://raw.githubusercontent.com/MadExploits/linemadpeas/refs/heads/main/madpeas.sh
chmod +x madpeas.sh
```
### **前提条件**
- 操作系统:Linux(所有发行版)
- Shell:Bash 4.0+
- 权限:普通用户(不需要 root)
- 可选工具:`getcap`、`docker`、`systemctl`(用于某些检查)
## 📖 用法
### **基本用法**
```
./madpeas.sh
```
### **自定义输出**
```
# 脚本将自动创建带有时间戳的输出文件
# 格式:privilege_escalation_report_YYYYMMDD_HHMMSS.txt
# 格式:exploit_methods_YYYYMMDD_HHMMSS.txt
```
### **在远程系统中使用**
```
# 上传脚本到目标
scp madpeas.sh user@target:/tmp/
# SSH 到目标并运行
ssh user@target
cd /tmp
chmod +x madpeas.sh
./madpeas.sh
# 下载结果
scp user@target:/tmp/privilege_escalation_report_*.txt ./
scp user@target:/tmp/exploit_methods_*.txt ./
```
### **配合 Curl 使用(单行命令)**
```
curl -sSL https://raw.githubusercontent.com/MadExploits/linemadpeas/refs/heads/main/madpeas.sh | bash
```
## 📁 输出
该工具会生成 **2 个输出文件**:
### 1. **枚举报告**
`privilege_escalation_report_YYYYMMDD_HHMMSS.txt`
- 完整的扫描结果报告
- 系统信息
- 发现的所有漏洞
- 系统配置
- 网络信息
- 以及更多
### 2. **Exploit 方法**
`exploit_methods_YYYYMMDD_HHMMSS.txt`
- 每个漏洞的 exploit 方法
- 可直接使用的示例命令
- CVE 参考
- 指向 exploit 代码的链接
- 提示与技巧
## 🎯 检测到的漏洞
该工具可检测多种类型的权限提升漏洞:
### **1. SUID/SGID Binaries**
- 检测带有 SUID/SGID 位的 binaries
- 识别可能被利用的 binaries
- 针对 find、python、vim、nmap、bash 等的 Exploit 方法
### **2. Sudo 配置错误**
- 无密码的 Sudo 权限 (NOPASSWD)
- 危险的 sudo 命令(vim、python、find 等)
- CVE-2019-14287(Sudo bypass)
- CVE-2021-3156(Baron Samedit)
### **3. 全局可写文件与目录**
- 所有用户均可写的文件和目录
- PATH 劫持机会
- 可写的脚本和服务文件
### **4. Cron Jobs**
- 系统级 cron jobs
- 用户 cron jobs
- 可写的 cron 文件
- 通配符利用
### **5. Linux Capabilities**
- 带有危险 capabilities 的文件
- cap_setuid、cap_dac_override 等
### **6. 环境变量**
- PATH 操纵
- LD_PRELOAD 劫持
- LD_LIBRARY_PATH 问题
### **7. 可写系统文件**
- `/etc/passwd` 可写
- `/etc/shadow` 可写
- `/etc/sudoers` 可写
- `/etc/sudoers.d` 可写
### **8. Docker & 容器**
- Docker 组成员身份
- 容器逃逸机会
- 特权容器
### **9. 内核 Exploit**
- **Dirty COW** (CVE-2016-5195)
- **DirtyPipe** (CVE-2022-0847) ⭐ 新增
- 内核版本分析
- Exploit 研究建议
### **10. NFS 共享**
- 带有 `no_root_squash` 的 NFS 导出
- 挂载的 NFS 共享
### **11. Systemd 服务与定时器**
- 可写的 systemd 服务文件
- 用户 systemd 服务
- Systemd 定时器
### **12. 密码文件**
- 可读的 `/etc/shadow`
- 备份密码文件
- UID 为 0 的用户
### **13. SSH 密钥**
- SSH 私钥
- 授权密钥
- SSH 配置
### **14. 历史文件**
- Bash 历史
- Python 历史
- MySQL 历史
- 潜在的凭证
### **15. 附加检查**
- Polkit/pkexec (PwnKit - CVE-2021-4034)
- Screen/Tmux 会话
- LXD/LXC 容器
- Init 脚本
- 挂载的文件系统
## 🔥 DirtyPipe 检测 (CVE-2022-0847)
此工具现在可以检测影响以下版本的 **DirtyPipe 漏洞**:
- Linux 内核 5.8 至 5.16.11
- Linux 内核 5.10.102
- Linux 内核 5.15.25
- Linux 内核 5.17
检测到该漏洞时,工具将显示:
- ⚠️ Critical 警告
- 📝 漏洞说明
- 💻 exploit 命令示例
- 🔗 指向 exploit 代码库的链接
## 📸 截图
### 横幅与进度
```
╔══════════════════════════════════════════════════════════════════════╗
║ ║
║ ██╗ ██╗███╗ ██╗██████╗ ███████╗ █████╗ ███████╗ ║
║ ██║ ██║████╗ ██║██╔══██╗██╔════╝██╔══██╗██╔════╝ ║
║ ██║ ██║██╔██╗ ██║██████╔╝█████╗ ███████║███████╗ ║
║ ██║ ██║██║╚██╗██║██╔═══╝ ██╔══╝ ██╔══██║╚════██║ ║
║ ███████╗██║██║ ╚████║██║ ███████╗██║ ██║███████║ ║
║ ╚══════╝╚═╝╚═╝ ╚═══╝╚═╝ ╚══════╝╚═╝ ╚═╝╚══════╝ ║
║ ║
║ Privilege Escalation Enumeration & Exploitation Tool ║
║ Comprehensive Vulnerability Scanner with Exploit Methods ║
║ Powered by: https://github.com/MadExploits ║
║ ║
╚══════════════════════════════════════════════════════════════════════╝
[████████████████████████████████████████████████░░] 92% - Checking: Final Summary
```
### 输出示例
```
[!!!] CRITICAL: Potential DirtyPipe vulnerability (CVE-2022-0847) detected!
┌──────────────────────────────────────────────────────────────────────┐
│ EXPLOIT METHOD: DirtyPipe (CVE-2022-0847)
├──────────────────────────────────────────────────────────────────────┤
Method: Uninitialized variable in pipe implementation allows...
Example: git clone https://github.com/Arinerron/CVE-2022-0847...
└──────────────────────────────────────────────────────────────────────┘
```
## 🛠️ 疑难解答
### **权限被拒绝**
```
chmod +x madpeas.sh
```
### **脚本无法执行某些检查**
- 某些检查需要特定的工具(getcap、docker 等)
- 如果工具不可用,脚本会自动跳过这些检查
- 这是正常现象,不会影响其他检查
### **未生成输出文件**
- 确保目录可写
- 检查磁盘空间
- 确保没有权限问题
## ⚠️ 免责声明
此工具仅供**教育和合法的安全测试**目的使用。用户对使用此工具负全部责任。作者不对将此工具用于非法活动负责。
**仅在以下情况下使用:**
- ✅ 您拥有的系统
- ✅ 获得书面许可的系统
- ✅ 测试/开发环境
- ✅ 授权的渗透测试
**不要用于:**
- ❌ 未经授权访问系统
- ❌ 非法活动
- ❌ 破坏他人的系统
## 🤝 贡献
非常欢迎贡献!请:
1. Fork 本仓库
2. 创建功能分支 (`git checkout -b feature/AmazingFeature`)
3. 提交更改 (`git commit -m 'Add some AmazingFeature'`)
4. 推送到分支 (`git push origin feature/AmazingFeature`)
5. 发起 Pull Request
## 📚 参考与资源
- [GTFOBins](https://gtfobins.github.io) - 绕过技术
- [Exploit-DB](https://www.exploit-db.com) - Exploit 数据库
- [Linux 内核 Exploit](https://github.com/SecWiki/linux-kernel-exploits)
- [LinPEAS](https://github.com/carlospolop/PEASS-ng) - 灵感来源
- [HackTricks](https://book.hacktricks.xyz) - 权限提升指南
## 👤 作者
**MadExploits**
- GitHub: [@MadExploits](https://github.com/MadExploits)
- Repository: [linemadpeas](https://github.com/MadExploits/linemadpeas)
## 📄 许可证
该项目基于 MIT 许可证授权 - 有关详细信息,请参阅 [LICENSE](LICENSE) 文件。
## ⭐ Star 历史
如果这个工具对您有帮助,请考虑给这个仓库点个 ⭐!
**用 ❤️ 为安全社区打造**
[⬆ 回到顶部](#-linux-privilege-escalation-enumeration-tool)
标签:Bash, CSV导出, Cutter, Web报告查看器, 协议分析, 应用安全, 无线安全, 权限提升, 系统提权