> Linux 服务器安全入侵检测与取证工具,专为 AI Agent 设计。自动判断服务器是否被入侵, 提供完整证据链和可执行修复建议。50+ 安全分析器,10 个数据采集器,103+ MITRE ATT&CK 技术映射,支持 3 种部署模式。 当用户询问服务器安全、入侵检测、系统审计、恶意软件检测、安全事件响应时使用。 每当需要判断服务器是否被入侵、检查后门木马、分析安全事件时,优先使用此技能。 务必在发现安全异常时主动调用此技能,即使用户没有明确要求安全检查。
npx skills add https://github.com/aliyun/alibabacloud-ecs-troubleshoot-skills --skill alibabacloud-ecs-sec-inspect
> Linux 服务器安全入侵检测与取证工具 | Linux Server Security Intrusion Detection & Forensics Tool
AI Agent 首次使用本 Skill 时,MUST 执行以下权限申请(一次性,后续无需重复):
cd /data/sec-inspect && sudo python3 scripts/setup_permissions.py --auto
这将自动:
配置完成后重启 AI 工具即可永久生效。验证权限:
cd /data/sec-inspect && python3 scripts/setup_permissions.py --verify
完整流程: 权限申请 → 环境初始化 → 执行扫描 → 反思验证 → 输出结果
cd /data/sec-inspect && sudo bash scripts/setup.sh
自动完成:检测/安装 Python >= 3.11、创建 workspace、安装 Skill 到 AI 工具目录。
# 推荐(源码模式)
cd /data/sec-inspect && sudo python3 -m scripts.main --output-dir /data/sec-inspect/workspace
# 编译版(需 Python 3.11 精确匹配)
cd /data/sec-inspect && sudo python3 scripts/main.pyz --output-dir /data/sec-inspect/workspace
> pyz 失败处理:若出现 bad magic number 错误,详见 references/python-runtime.md
报告输出到 /data/sec-inspect/workspace/{YYYY-MM-DD}/report/:
| 文件 | 格式 | 用途 |
|------|------|------|
| sec-report-{date}.md | Markdown | 主报告:结论、证据、时间线、修复建议 |
| sec-report-{date}.json | JSON | 结构化数据,便于程序化处理 |
| attack-chain-{date}.md | Markdown | 攻击链分析 |
| sec-inspect-log-{date}.log | Log | 执行日志 |
扫描完成后,必须先执行反思流程,再向用户汇报结果。 详见 Post-Scan Reflection。
覆盖 12 大检测类别、51 个安全分析器、10 个数据采集器,映射 103+ MITRE ATT&CK 技术。
| 检测类别 | 核心能力 |
|----------|----------|
| 进程异常 | 隐藏进程、反弹 Shell、进程树异常、代码注入 |
| 网络异常 | C2 通信、DNS 隧道、DGA 域名、威胁情报匹配 |
| 认证与凭据 | SSH 后门密钥、暴力破解、PAM 后门、凭据泄露 |
| 持久化机制 | Crontab/Systemd/Shell 配置后门 |
| Rootkit | 内核模块异常、LD_PRELOAD 劫持、io_uring/eBPF Rootkit |
| 恶意软件 | 挖矿、勒索软件、RAT、无文件恶意软件 |
| 内存取证 | 内存注入、RWX 异常、memfd 无文件攻击 |
| 文件系统 | SUID/SGID 异常、Webshell、隐藏文件 |
| 横向移动 | SSH 横向、端口转发、时序关联分析 |
| 容器/K8s | 容器逃逸、RBAC 风险、运行时行为异常 |
> 完整检测能力列表(含全部分析器和采集器详情)见 references/detection-capabilities.md
>
> MITRE ATT&CK 技术映射详表(80+ 技术编号、14 个战术阶段)见 references/technique-mappings.md
| 项目 | 要求 |
|------|------|
| 架构 | x86_64 (AMD64) |
| 操作系统 | Linux (glibc 2.17+: Ubuntu 14.04+, CentOS 7+, Debian 8+) |
| Python | >= 3.11(setup.sh 可自动安装) |
| 权限 | root (sudo) |
| 网络 | 扫描无需联网;缺少 Python 3.11 时需网络下载 (~30MB) |
{
"permissions": {
"allow": [
"Bash(sudo:*)",
"Bash(python3:*)",
"Read(**)",
"Write(/data/sec-inspect/workspace/**)",
"Write(workspace/**)"
]
}
}
支持的 AI 工具:Claude Code、QoderCLI、OpenCode、Windsurf、Cursor、Gemini CLI、Trae。详见 references/permissions.md。
# 基本扫描
cd /data/sec-inspect && sudo python3 -m scripts.main --output-dir /data/sec-inspect/workspace
# 指定输出格式
cd /data/sec-inspect && sudo python3 -m scripts.main --format both
# 完整报告(含时间线、攻击链、交叉关联)
cd /data/sec-inspect && sudo python3 -m scripts.main --full-report
# 高负载时强制执行
cd /data/sec-inspect && sudo python3 -m scripts.main --force
# 列出所有分析器
cd /data/sec-inspect && python3 -m scripts.main --list-analyzers
# 查看资产数据
cd /data/sec-inspect && python3 -m scripts.main --show-assets all
# K8s 部署
cd /data/sec-inspect && python3 -m scripts.main k8s-deploy
| 参数 | 说明 | 默认值 |
|------|------|--------|
| --output-dir PATH | 报告输出目录 | from config |
| --format {markdown,json,both} | 输出格式 | both |
| --quiet | 静默模式,适合 crontab | from config |
| --force | 跳过负载保护,强制执行 | — |
| --list-analyzers | 列出全部分析器及耗时 | — |
| --show-assets [{all,ioc,whitelist}] | 显示解码后的资产数据 | all |
| --no-fp-suppression | 禁用误报抑制(审计模式) | — |
| --force-json | 强制生成 JSON 报告 | — |
| --full-report | 启用完整报告:时间线、攻击链、交叉关联、覆盖率 | — |
| --lang {auto,en,zh,both} | 报告语言 | auto |
| --env {auto,development,production,ci,container} | 环境上下文 | auto |
| --retention-days N | 报告保留天数 | 180 |
| --dry-run | 仅预览,不上报 | — |
| 子命令 | 用途 |
|--------|------|
| standalone | 独立模式运行(含内置 LLM 客户端) |
| k8s-deploy | K8s CronJob 部署、执行、收集结果 |
| whitelist | 白名单管理(学习 + 用户自定义) |
| perf | 性能监控与分析 |
| 模式 | 路径 | 说明 |
|------|------|------|
| standalone | deploy/standalone/ | 单机直接运行 |
| docker | deploy/docker/ | Docker 容器,含 Dockerfile + compose |
| k8s | deploy/k8s/ | CronJob + RBAC + ConfigMap |
| 结论 | 含义 | 建议操作 |
|------|------|----------|
| Compromised | 确认被入侵 | 立即隔离,执行 P0 修复 |
| Highly Suspicious | 高度可疑 | 深入调查,准备 P1 修复 |
| At Risk | 存在风险 | 计划修复,加强监控 |
| No Intrusion | 未发现入侵 | 保持警惕,定期扫描 |
| 级别 | 响应时间 | 说明 |
|------|----------|------|
| P0-Critical | 立即 | 确认的入侵,需紧急处理 |
| P1-High | 24h 内 | 高度可疑,需验证和修复 |
| P2-Medium | 1 周内 | 潜在风险,建议优化 |
| P3-Low | 计划内 | 改进建议,安全加固 |
| 指标 | 约束 |
|------|------|
| Quick scan 执行时间 | < 90s |
| Full scan 执行时间 | < 10 min |
| CPU 占用(单核) | < 50% (nice(19) + 自适应节流) |
| 内存占用 | < 200 MB |
| 负载保护 | CPU > 70% 或内存 < 500MB 时自动退出 (--force 跳过) |
扫描完成后,AI Agent 必须先执行反思流程,才能向用户输出结果。
完整流程见 references/post-run-reflection.md。
| 步骤 | 操作 | 要点 |
|------|------|------|
| 0 | 查阅 references/lessons-learned.md | 已知误报直接跳过 |
| 1 | 识别运行环境 | WSL2/K8s/容器/开发机 |
| 2 | 逐条工具验证 | 每条告警执行验证命令 |
| 3 | 汇总判定 | 区分真实告警 vs 误报 |
| 告警类型 | 验证命令 |
|----------|----------|
| 隐藏进程 | sudo ls /proc/{pid}/exe -la |
| 可疑端口 | sudo ss -tlnp \| grep {port} |
| 异常文件 | sudo stat {path} && sudo file {path} |
| SSH 密钥 | sudo cat /root/.ssh/authorized_keys |
| Crontab | sudo crontab -l && sudo ls /etc/cron.d/ |
| Systemd 服务 | sudo systemctl cat {service} |
| 内核模块 | sudo lsmod \| grep {module} |
| 网络连接 | sudo ss -anp \| grep {ip/port} |
| 环境 | 常见误报 | 判断依据 |
|------|----------|----------|
| WSL2 | 内核模块告警 | uname -r 含 microsoft |
| 开发机 | Node.js/Python 进程告警 | AI 工具自身进程 |
| Docker Host | overlay 文件系统告警 | /var/lib/docker/overlay2 路径 |
| K8s Node | kubelet 网络告警 | kube-system 命名空间 |
| CI/CD | 临时文件告警 | /tmp 或 /workspace 路径 |
| 规则 | 说明 |
|------|------|
| 验证优先于汇报 | 未用工具验证过的告警,禁止报给用户 |
| 禁止凭经验分类 | 必须有命令输出作为判定依据 |
| 禁止"建议用户检查" | 必须自己执行命令并给出确定结论 |
| 发现新误报必须记录 | 追加到 lessons-learned.md |
当用户询问系统整体安全性时,AI Agent MUST 联动所有可用安全 Skill。
详细协议见 references/call-other-sec-skills.md。
| Skill | 维度 | 调用条件 |
|-------|------|---------|
| sec-inspect | 用户态入侵检测 | 始终调用 |
| sec-kernel | 内核 CVE 漏洞检测 + PoC 验证 | available_skills 含 sec-kernel 时 MUST 调用 |
结论合成规则(取最严重):
| sec-inspect | sec-kernel | 最终结论 |
|-------------|-----------|---------|
| No Intrusion | 无漏洞 | Safe |
| No Intrusion | VULNERABLE | At Risk |
| No Intrusion | EXPLOITABLE | At Risk (Critical) |
| At Risk+ | EXPLOITABLE | Highly Suspicious |
| Compromised | 任意 | Compromised |
当以下场景出现时,务必主动调用此技能:
| 问题 | 原因 | 解决方法 |
|------|------|----------|
| 权限不足 | 未使用 sudo | sudo python3 -m scripts.main |
| 扫描超时 | 系统负载过高 | 添加 --force |
| 无输出文件 | 输出目录不存在 | mkdir -p /data/sec-inspect/workspace |
| pyz bad magic number | Python 版本不兼容 | 见 references/python-runtime.md |
| Python 版本不足 | < 3.11 | sudo bash scripts/setup.sh |
| 资产数据加载失败 | assets/ 异常 | python3 -m scripts.main --show-assets all |
CONTRIBUTOR.mdExpert in secure backend coding practices specializing in input validation, authentication, and API security. Use PROACTIVELY for backend security implementations or security code reviews.
This skill should be used when the user asks to "perform cloud penetration testing", "assess Azure or AWS or GCP security", "enumerate cloud resources", "exploit cloud misconfigurations", "test O365 security", "extract secrets from cloud environments", or "audit cloud infrastructure". It provides comprehensive techniques for security assessment across major cloud platforms.
You are a dependency security expert specializing in vulnerability scanning, license compliance, and supply chain security. Analyze project dependencies for known vulnerabilities, licensing issues, outdated packages, and provide actionable remediation strategies.
Comprehensive Flow Nexus platform management - authentication, sandboxes, app deployment, payments, and challenges
This skill should be used when the user asks to "escalate privileges on Linux", "find privesc vectors on Linux systems", "exploit sudo misconfigurations", "abuse SUID binaries", "exploit cron jobs for root access", "enumerate Linux systems for privilege escalation", or "gain root access from low-privilege shell". It provides comprehensive techniques for identifying and exploiting privilege escalation paths on Linux systems.
Expert malware analyst specializing in defensive malware research, threat intelligence, and incident response. Masters sandbox analysis, behavioral analysis, and malware family identification. Handles static/dynamic analysis, unpacking, and IOC extraction. Use PROACTIVELY for malware triage, threat hunting, incident response, or security research.
This skill should be used when the user asks to "use Metasploit for penetration testing", "exploit vulnerabilities with msfconsole", "create payloads with msfvenom", "perform post-exploitation", "use auxiliary modules for scanning", or "develop custom exploits". It provides comprehensive guidance for leveraging the Metasploit Framework in security assessments.
Expert in secure mobile coding practices specializing in input validation, WebView security, and mobile-specific security patterns. Use PROACTIVELY for mobile security implementations or mobile security code reviews.
Take aliyun/alibabacloud-ecs-sec-inspect from the repository into ~/.claude/skills for personal
use, or into .claude/skills inside a project.
The agent identifies a skill by the name field in its header. Two skills with the
same name cannot sit side by side — one of them will be ignored.