mcpField
I
implementing-attack-surface-management

implementing-attack-surface-management

github.com/mukul975安全35.2k70 次安装8 周前更新
代码仓库

关于 implementing-attack-surface-management

面向安全团队构建或运营外部攻击面管理项目的技能,涵盖子域发现、服务指纹识别、Shodan 与 Censys 搜索、Nuclei 扫描及暴露评分。

主要功能

  1. 01使用 subfinder 发现子域
  2. 02探测存活主机和服务指纹
  3. 03通过 Shodan 和 Censys 搜索资产
  4. 04使用 Nuclei 扫描漏洞
  5. 05加权计算暴露评分

适用场景

  1. 01从零建立外部攻击面管理项目
  2. 02在授权范围内开展侦察
  3. 03监控组织的互联网暴露资产
  4. 04按优先级处置暴露风险

安装

复制下面的命令,在终端中运行。

$npx skills add https://github.com/mukul975/anthropic-cybersecurity-skills --skill implementing-attack-surface-management

安装后在 Claude Code 中输入/implementing-attack-surface-management确认已加载。

包含的文件

除 SKILL.md 外,安装时一起下载的参考资料和脚本。

LICENSE
references/
api-reference.md
asm-reference.md
scripts/
agent.py

详细介绍

实施攻击面管理

使用时机

  • 从头构建外部攻击面管理(EASM)计划时
  • 为渗透测试项目开展经过授权的外部侦察时
  • 持续监控组织面向互联网的资产暴露情况时
  • 为外部攻击面风险评分并确定修复优先级时
  • 将多个发现工具集成到自动化 ASM 流水线中时

先决条件

  • 已安装 requests、shodan、censys 库的 Python 3.8+
  • Shodan API 密钥(免费套餐每月提供 100 次查询)
  • Censys API ID 和 Secret(提供免费套餐)
  • 已安装 ProjectDiscovery 工具:subfinder、httpx、nuclei
  • 从源代码构建 ProjectDiscovery 工具所需的 Go 1.21+
  • 所有外部扫描活动均已获得适当授权
  • 目标域名和 IP 范围,并附有书面范围说明文档

说明

阶段 1:通过多个来源枚举子域名

使用 subfinder 开展被动子域名发现,利用数十种数据来源, 包括证书透明度日志、DNS 数据集和搜索引擎。

# Install ProjectDiscovery tools
go install -v github.com/projectdiscovery/subfinder/v2/cmd/subfinder@latest
go install -v github.com/projectdiscovery/httpx/cmd/httpx@latest
go install -v github.com/projectdiscovery/nuclei/v3/cmd/nuclei@latest

# Basic subdomain enumeration
subfinder -d example.com -o subdomains.txt

# Verbose with all sources and recursive enumeration
subfinder -d example.com -all -recursive -o subdomains_full.txt

# Multi-domain enumeration from file
subfinder -dL domains.txt -o all_subdomains.txt

# Using OWASP Amass for deeper enumeration
amass enum -d example.com -passive -o amass_subdomains.txt

# Merge and deduplicate results
cat subdomains.txt amass_subdomains.txt | sort -u > combined_subdomains.txt
阶段 2:发现在线主机并识别服务

探测已发现的子域名,以识别在线主机、技术和服务。

# HTTP probing with technology detection
cat combined_subdomains.txt | httpx -sc -cl -ct -title -tech-detect \
    -follow-redirects -json -o httpx_results.json

# Detailed service fingerprinting
cat combined_subdomains.txt | httpx -sc -cl -ct -title -tech-detect \
    -favicon -hash sha256 -jarm -cdn -cname \
    -follow-redirects -json -o httpx_detailed.json
阶段 3:通过 Shodan 发现资产

查询 Shodan,查找已发现资产暴露的服务、开放端口和已知漏洞。

import shodan

api = shodan.Shodan("YOUR_SHODAN_API_KEY")

# Search by organization
results = api.search("org:\"Example Corp\"")
for service in results["matches"]:
    print(f"{service['ip_str']}:{service['port']} - {service.get('product', 'unknown')}")
    if service.get("vulns"):
        for cve in service["vulns"]:
            print(f"  CVE: {cve}")

# Search by hostname
results = api.search("hostname:example.com")

# Search by SSL certificate
results = api.search("ssl.cert.subject.cn:example.com")

# Get host details with all services
host = api.host("93.184.216.34")
print(f"IP: {host['ip_str']}")
print(f"Ports: {host['ports']}")
print(f"Vulns: {host.get('vulns', [])}")
阶段 4:通过 Censys 发现资产

使用 Censys 通过证书和主机搜索来发现面向互联网的资产。

from censys.search import CensysHosts, CensysCerts

# Host search
hosts = CensysHosts()
query = hosts.search("services.tls.certificates.leaf.subject.common_name: example.com")
for page in query:
    for host in page:
        print(f"IP: {host['ip']}")
        for service in host.get("services", []):
            print(f"  Port: {service['port']} Protocol: {service['transport_protocol']}")
            print(f"  Service: {service.get('service_name', 'unknown')}")

# Certificate transparency search
certs = CensysCerts()
query = certs.search("parsed.names: example.com")
for page in query:
    for cert in page:
        print(f"Fingerprint: {cert['fingerprint_sha256']}")
        print(f"Names: {cert.get('parsed', {}).get('names', [])}")
阶段 5:使用 Nuclei 扫描漏洞

使用 Nuclei 模板对已发现的资产执行有针对性的漏洞扫描。

# Update nuclei templates
nuclei -ut

# Scan with all templates
cat combined_subdomains.txt | httpx -silent | nuclei -o nuclei_results.txt

# Scan with specific severity
cat combined_subdomains.txt | httpx -silent | \
    nuclei -severity critical,high -o critical_findings.txt

# Scan with specific template categories
cat combined_subdomains.txt | httpx -silent | \
    nuclei -tags cve,misconfig,exposure -o categorized_findings.txt

# Scan for exposed panels and sensitive files
cat combined_subdomains.txt | httpx -silent | \
    nuclei -tags panel,exposure,config -o exposed_panels.txt
阶段 6:暴露评分算法

依据 OWASP 攻击面分析原则为每项资产评分,使用基于相对攻击面商数(RSQ) 以及损害潜力与所需工作量之比推导出的加权公式。

评分算法考虑以下因素:

  1. 开放端口和服务 - 根据服务风险加权(管理端口的分值更高)
  2. 已知漏洞 - 根据 CVSS 分数加权
  3. 技术年龄 - 过时软件会提高分数
  4. 暴露级别 - 面向互联网还是需要身份验证才能访问
  5. 数据敏感度 - 根据服务类型和内容指标评估
# Exposure Score = sum of weighted factors, normalized to 0-100
# See agent.py for the full implementation

示例

# Run complete ASM pipeline against a target domain
python agent.py \
    --domain example.com \
    --action full_scan \
    --shodan-key YOUR_KEY \
    --censys-id YOUR_ID \
    --censys-secret YOUR_SECRET \
    --output asm_report.json

# Subdomain enumeration only
python agent.py \
    --domain example.com \
    --action enumerate \
    --output subdomains.json

# Exposure scoring on previously discovered assets
python agent.py \
    --domain example.com \
    --action score \
    --input previous_scan.json \
    --output scored_assets.json

# Multi-domain scan from file
python agent.py \
    --domain-list targets.txt \
    --action full_scan \
    --output multi_domain_report.json

评论

支持 Markdown