mcpField
I
implementing-attack-surface-management

implementing-attack-surface-management

github.com/mukul975セキュリティ35.2k70 回インストール8 週間前に更新
リポジトリ

implementing-attack-surface-management について

外部攻撃対象領域管理プログラムを構築・運用するセキュリティチーム向けのスキルです。サブドメイン発見、サービスのフィンガープリント、ShodanとCensysでの検索、Nucleiスキャン、露出スコア算出を扱います。

主な機能

  1. 01subfinderによるサブドメイン発見
  2. 02稼働ホストの確認とサービス識別
  3. 03ShodanとCensysによる資産検索
  4. 04Nucleiによる脆弱性スキャン
  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 の攻撃対象領域分析の原則に基づいて各資産をスコアリングします。Relative Attack Surface Quotient(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

コメント