mcpField
A
asn-infrastructure-mapping

asn-infrastructure-mapping

github.com/uphiago安全1.3k44 次安装8 周前更新
代码仓库

关于 asn-infrastructure-mapping

用于从域名经 ASN 和 CIDR 网段映射组织 IP 基础设施的安全技能,延伸至主机和服务发现。还涵盖顶级域名扩展及子组织发现,以扩大侦察范围。

主要功能

  1. 01将域名映射到 ASN 和 CIDR 网段
  2. 02将 CIDR 网段展开为 IP 地址
  3. 03通过反向 DNS 发现主机名
  4. 04枚举同名不同顶级域的域名
  5. 05映射域名、IP 和服务

适用场景

  1. 01将侦察范围扩展到较短的子域名列表之外
  2. 02在已确认的 IP 网段中查找非标准端口服务
  3. 03调查子公司及国际域名基础设施

安装

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

$npx skills add https://github.com/uphiago/recon-skills --skill asn-infrastructure-mapping

安装后在 Claude Code 中输入/asn-infrastructure-mapping确认已加载。

详细介绍

ASN 基础设施映射

通过从域名追溯到 ASN(自治系统号)、提取 CIDR 范围,并发现所有自有 IP 块中的每个主机名和服务,绘制组织的完整 IP 基础设施图。包含 TLD 扩展,可查找使用不同顶级域名、拥有独立基础设施的关联域名。

使用时机

  • 你有一个目标域名,并想发现该组织拥有的所有 IP。
  • 被动子域名枚举只找到少数主机——其余主机可能位于关联 TLD 或不同 IP 范围。
  • 目标有已知 ASN,可扩展至完整 CIDR 块。
  • Web 专用侦察无法发现非标准端口上的服务。
  • 收购的子公司或国际域名可能位于不同 ASN 上,安全性也可能较弱。

先决条件

  • terminal whois、dnsx、mapcidr、httpx 和 asnmap。
  • 目标域名和/或属于该组织的已知 IP。
  • Shodan API 密钥(可选,用于更深入的 OSINT)。

快速检测

# Start: domain → IP → ASN → CIDR ranges
IP=$(dig target.com +short | head -1)
ASN=$(whois $IP | grep -i "origin\|OriginAS" | awk '{print $NF}' | head -1)
echo "ASN: $ASN"
whois -h whois.radb.net -- "-i origin $ASN" | grep -Eo "([0-9.]+){4}/[0-9]+" | sort -u

操作步骤

阶段 1 — 域名到 ASN 的发现
# asnmap — automated domain → ASN
asnmap -d target.com

# Manual whois approach
IP=$(dig target.com +short | head -1)
whois $IP | grep -iE "origin|OriginAS|route:|descr:" | head -10

# spk — finds all ASNs for a company by name (including subsidiaries)
spk -json -s "Company Name"

# Webtools
# https://bgp.he.net — search by company name
# https://asnlookup.com — search by org name, ASN, or CIDR
# https://bgp.tools — modern BGP explorer
阶段 2 — ASN 到 CIDR 范围
# asnmap — direct CIDR extraction
asnmap -a AS33905 -silent > cidr_ranges.txt

# RADB whois — full route objects
whois -h whois.radb.net -- "-i origin AS33905" \
  | grep -Eo "([0-9.]+){4}/[0-9]+" \
  | sort -u >> cidr_ranges.txt

# metabigor — multi-source IP intelligence
echo "Company Name" | metabigor net --org -o cidr_ranges.txt
echo "ASN33905" | metabigor net --asn -o cidr_ranges.txt
阶段 3 — CIDR 到单个 IP
# mapcidr — split CIDR into flat IP list
cat cidr_ranges.txt | mapcidr -silent > all_ips.txt
wc -l all_ips.txt

# prips — alternative IP generator
while read cidr; do prips "$cidr"; done < cidr_ranges.txt >> all_ips.txt

# Scan discovered IPs for live web services
cat all_ips.txt | httpx \
  -ports 80,443,8080,8443,3000,5000,8000,8888,9090,9443 \
  -status-code -title -web-server -silent \
  -o live_ip_services.txt
阶段 4 — 对 IP 范围进行反向 DNS 查询
# dnsx PTR — resolve hostnames from IP blocks
cat cidr_ranges.txt | dnsx -silent -resp-only -ptr > ptr_domains.txt

# Filter for target-related hosts
grep -i "target" ptr_domains.txt > ptr_target.txt

# hakrevdns — reverse DNS at scale
hakrevdns -d target.com -R resolvers.txt

# resolveDomains — check which IPs serve target content
resolveDomains -d all_subs.txt > resolved.txt
awk '{print $3}' resolved.txt | sort -u > unique_ips.txt
阶段 5 — TLD 扩展
# tldbrute — discover all registered TLD variants
tldbrute -d target.com

# Manual IANA TLD list approach
wget -q https://data.iana.org/TLD/tlds-alpha-by-domain.txt
ROOT=$(echo "target.com" | cut -d. -f1)
cat tlds-alpha-by-domain.txt | tr '[:upper:]' '[:lower:]' \
  | while read tld; do echo "$ROOT.$tld"; done \
  | httpx -silent -mc 200 > tlds_alive.txt

# Apply to all known subdomains
cat all_subs.txt | while read sub; do
  cat tlds-alpha-by-domain.txt | tr '[:upper:]' '[:lower:]' \
    | sed "s/^/$sub./"
done | dnsx -silent > subs_tld_expanded.txt
阶段 6 — 架构可视化
# Map which domains belong to which IP
cat unique_ips.txt | while read ip; do
  echo -n "$ip: "
  grep -l "$ip" resolved.txt 2>/dev/null | tr '\n' ' '
  echo
done > ip_to_domain_map.txt

# Identify shared infrastructure (one IP serving multiple domains — CDN or reverse proxy)
awk '{if (NF > 2) print}' ip_to_domain_map.txt > shared_infra.txt

# Scan non-web ports on ALL discovered IPs  
naabu -l all_ips.txt -p - -rate 1000 -c 50 -exclude-ports 80,443 -o all_services.txt
阶段 7 — 子组织发现
# Extract all company/organization names from whois
cat all_ips.txt | while read ip; do
  whois $ip 2>/dev/null | grep -iE "OrgName|org-name|descr:" | head -1
done | sort -u > subsidiary_names.txt

# For each subsidiary, repeat the ASN → CIDR pipeline
cat subsidiary_names.txt | while read org; do
  metabigor net --org "$org" >> expanded_cidr.txt
done

注意事项

  • CIDR 范围可能非常庞大(例如 AWS)。 仅扫描已确认属于目标的 IP 范围,不要扫描整个托管服务提供商的地址空间。
  • RADB whois 数据可能已过时。 请通过多个来源交叉验证(bgp.he.net、Censys、Shodan)。
  • TLD 扩展会产生大量噪声。 通常只有 .com/.org/.net/.io/.dev 能产生有用结果。
  • 反向 DNS 可能会泄露内部主机名。 在外部侦察中应谨慎处理——这些泄露本身就是发现结果。
  • 子组织发现可能导致目标超出范围。 扫描前务必确认关联关系。

验证

  1. 通过至少两个来源(whois + bgp.he.net 或 asnmap)确认 CIDR 范围。
  2. 对发现的 IP 进行反向 DNS 查询,返回了与目标相关的主机名。
  3. TLD 扩展发现了关联 TLD 上的活跃域名。
  4. Web 服务扫描在非标准端口上发现了独特的应用。
  5. 映射完整基础设施:域名 → IP → 服务 → 漏洞。

相关技能

  • subdomain-enumeration — 在扩展到 IP 基础设施前,先生成初始子域名列表。
  • origin-ip-discovery — 知道 CIDR 范围后,识别 CDN 后方的源站 IP。
  • vhost-enumeration — 扫描发现的 IP,查找隐藏的虚拟主机。
  • port-mass-scan — 扫描所有发现的 IP,查找暴露的服务。

评论

支持 Markdown