DNS侦察工具包

一个用于威胁情报和OSINT调查的DNS侦察工具包,提供DNS查询功能,支持多解析器和并发操作。

  • by bonetrees
  • Python
  • 本地部署
  • 更新于
在 GitHub 查看 bonetrees/dns-mcp-server

使用说明

DNS OSINT MCP服务器

作为MCP服务器构建的DNS侦察工具包,用于威胁情报和OSINT调查。提供DNS查询功能,支持多个解析器和并发操作。

特性

核心DNS工具

  • dns_query:查询特定的DNS记录类型(A、AAAA、MX、TXT、NS、SOA、CNAME、CAA、SRV、PTR)
  • dns_reverse_lookup:IP地址的反向DNS(PTR)查找
  • dns_bulk_query:多个域的并发批量查询
  • dns_bulk_reverse_lookup:多个IP的并发反向DNS查找
  • dns_query_all:通过所有记录类型的并发查询进行全面的域分析

OSINT分析工具

  • dns_propagation_check:检测多个解析器之间的DNS不一致
  • dns_wildcard_check:识别通配符DNS配置和安全风险
  • dns_responde_analysis:分析异常检测的响应时间

高性能

  • 异步性能:具有速率限制的高速并发操作(比顺序操作快3-5倍)
  • 多解析器支持:系统、公共、谷歌、Cloudflare、Quad9、OpenDNS或自定义解析器
  • 每个解析器速率限制:每个解析器每秒30个请求,以防止滥用
  • OSINT集中错误处理:详细的DNS异常分析和可操作的情报
  • 威胁情报功能:专为威胁行为者基础设施测绘和分析而设计
  • 集中式配置:强大的参数验证和可配置的默认值
  • 综合测试:边缘案例、性能基准和真实场景的测试覆盖率超过90%

先决条件

  • Python 3.10+
  • 依赖管理诗

建筑

dns_mcp_server/
├── server.py           # FastMCP server with plugin architecture
├── config.py           # Centralized configuration management
├── resolvers.py        # Async DNS resolvers with aiodns
├── rate_limiter.py     # Per-resolver rate limiting
├── formatters.py       # OSINT-aware error formatting
├── core_tools.py       # Basic DNS query tools
├── bulk_tools.py       # High-performance bulk operations
└── osint_tools.py      # Advanced OSINT analysis tools

tests/
├── test_config.py      # Configuration validation tests
├── test_edge_cases.py  # Error resilience & edge cases
├── test_performance.py # Performance benchmarks
├── test_osint_tools.py # OSINT tool functionality
└── test_async_dns.py   # Async DNS operations

关键设计原则:

  • 插件架构:工具在FastMCP服务器上自动注册
  • 异步优先:所有DNS操作都使用asyncio以获得最佳性能
  • 速率限制:每个解析器的节流功能可防止滥用
  • OSINT聚焦:错误消息包括威胁情报上下文
  • 高度可测试:全面的模拟和集成测试

安装

  1. 克隆并设置存储库:
cd /path/to/dns-mcp-server
poetry install
  1. 运行服务器:
# Using Poetry (recommended)
poetry run dns-mcp-server

# Or using Python module
python -m dns_mcp_server

# Or with Poetry
poetry run python -m dns_mcp_server

配置

添加到您的Claude MCP设置中:

{
  "mcpServers": {
    "dns-osint": {
      "command": "poetry",
      "args": ["run", "dns-mcp-server"],
      "cwd": "/path/to/dns-mcp-server"
    }
  }
}
  • 注意:您可能需要添加完整路径 poetry 和 dns-mcp-server
  • 注意:您可能需要将诗歌直接指向您的项目文件夹文件,例如: "args": ["run","-C", "/path/to/dns-mcp-server","python", "-m", "dns_mcp_server"]

OSINT用例

威胁参与者基础设施映射

# Comprehensive domain profiling
dns_query_all(domain="suspicious.example.com", resolver_type="public")

# Check DNS consistency across resolvers
dns_propagation_check(domain="malware.example.com", record_type="A")

# Analyze response patterns
dns_response_analysis(domain="c2.example.com", iterations=15)

网络钓鱼和恶意软件分析

# Detect wildcard DNS (common in phishing kits)
dns_wildcard_check(domain="phishing.example.com", test_count=5)

# Compare results across resolvers to detect DNS poisoning
dns_propagation_check(
    domain="suspicious.example.com",
    resolvers={"google": "8.8.8.8", "cloudflare": "1.1.1.1", "quad9": "9.9.9.9"}
)

基础设施勘测

# Bulk domain analysis
dns_bulk_query(
    domains=["domain1.com", "domain2.com", "domain3.com"],
    record_type="A",
    resolver_type="cloudflare",
    max_workers=10
)

# Reverse lookup for IP ranges
dns_bulk_reverse_lookup(
    ips=["192.168.1.1", "192.168.1.2", "192.168.1.3"],
    resolver_type="quad9"
)

# Mail server analysis
dns_query(domain="target.com", record_type="MX", resolver_type="google")

DNS安全评估

# Check for DNS inconsistencies (potential security issues)
result = dns_propagation_check(domain="company.com")
if not result["is_consistent"]:
    print("WARNING: DNS inconsistency detected!")
    print(f"Trust level: {result['osint_analysis']['trust_level']}")

# Wildcard detection for subdomain security
wildcard_result = dns_wildcard_check(domain="company.com")
if wildcard_result["has_wildcard"]:
    risk = wildcard_result["osint_insights"]["risk_level"]
    print(f"Wildcard DNS detected - Risk level: {risk}")

解析器类型

  • 系统:使用系统默认解析器
  • 公共:多解析器方法(8.8.8.8、1.1.1.1、9.9.9.9)
  • 谷歌:谷歌DNS(8.8.8.8,8.8.4.4)
  • 云耀:Cloudflare DNS(1.1.1.1、1.0.0.1)
  • quad9:Quad9 DNS(9.9.9.9,149.112.112.112)
  • opendns:开放域名系统(208.67.222.2222208.67.220.220)
  • 定制:指定自定义名称服务器IP

支持的DNS记录类型

  • A.:IPv4地址
  • AAAA:IPv6地址
  • 导弹试验:邮件交换服务器
  • 文本:文本记录(SPF、DKIM、验证)
  • 纳秒:名称服务器
  • 面向服务的架构:权力的开始
  • 别名:规范名称
  • 中国民航局:证书颁发机构授权
  • 运动休闲车:服务记录
  • PTR:反向DNS记录

示例响应

单个查询响应

{
  "domain": "example.com",
  "record_type": "A",
  "nameserver": "cloudflare",
  "query_time_seconds": 0.045,
  "records": ["93.184.216.34"],
  "record_count": 1
}

全面的域名配置文件

{
  "domain": "example.com",
  "nameserver": "public",
  "total_query_time_seconds": 0.234,
  "records": {
    "A": ["93.184.216.34"],
    "AAAA": ["2606:2800:220:1:248:1893:25c8:1946"],
    "MX": ["10 mail.example.com"],
    "TXT": ["v=spf1 include:_spf.example.com ~all"],
    "NS": ["ns1.example.com", "ns2.example.com"]
  },
  "record_types_found": 5,
  "total_records": 6,
  "errors": {
    "CAA": {"error": "no_records", "type": "NoAnswer"}
  }
}

安全与道德

该工具专为合法的安全研究、威胁情报和OSINT调查而设计。在进行侦察活动之前,始终确保您有适当的授权。

发展

增强测试框架

该项目包括多个类别的综合测试:

# Run all tests
poetry run pytest

# Or use the enhanced test runner
python test_runner.py all

# Test specific categories
python test_runner.py config      # Configuration tests
python test_runner.py edge        # Edge cases and error resilience
python test_runner.py performance # Performance benchmarks
python test_runner.py osint       # OSINT tool tests
python test_runner.py integration # Network-dependent tests

阶段集成测试

# Test Phase 1: Async performance improvements
python test_runner.py async

# Test Phase 2: OSINT analysis tools
python test_runner.py phase2

# Test Phase 3: Code organization & testing
python test_runner.py phase3

配置管理

服务器对所有设置使用集中配置:

from dns_mcp_server.config import config

# Default settings
print(f"Rate limit: {config.default_rate_limit}/sec")
print(f"Timeout: {config.default_timeout}s")
print(f"Max workers: {config.default_max_workers}")

# Validation functions
from dns_mcp_server.config import validate_record_type, get_performance_rating

# Automatic validation and clamping
record_type = validate_record_type("a")  # Returns "A"
rating = get_performance_rating(0.05)    # Returns "EXCELLENT"

代码格式化

poetry run black .
poetry run isort .

已完成的增强功能

  • 异步性能优化:并发执行的批量查询速度提高5-10倍
  • OSINT分析工具:DNS传播检查、通配符检测、响应时间分析
  • 增强的错误处理:带有调查提示的OSINT感知错误消息
  • 集中式配置:强大的参数验证和可配置的默认值
  • 综合测试:性能基准测试覆盖率超过90%
  • 每个解析器速率限制:防止DNS服务器滥用和阻止
  • 专业代码组织:具有适当文档的模块化架构

未来的增强功能

TODO:DNS漫游和子域发现

在结对编程会议期间添加-2025年8月19日

  • [ ] 基于字典的子域枚举:使用单词表强行使用公共子域

    dns_subdomain_walk(domain="target.com", wordlist=["www", "mail", "api"], max_workers=50)
    
  • [ ] 证书透明度集成:通过CT日志发现子域

    dns_ct_subdomain_search(domain="target.com")  # Passive subdomain discovery
    
  • [ ] DNS区域传输尝试:尝试AXFR/IXFR区域转移

    dns_zone_transfer(domain="target.com")  # Attempt zone transfer
    
  • [ ] 被动DNS数据库查询:与被动DNS源集成

    dns_passive_lookup(domain="target.com")  # Historical DNS data
    

当前路线图

  • []子域枚举功能 (见上文DNS行走部分)
  • []DNS区域传输尝试 (见上文DNS行走部分)
  • []证书透明度集成 (见上文DNS行走部分)
  • []历史DNS数据分析
  • []高级相关性特征
  • []导出功能(JSON、CSV)
  • []Web仪表板界面
  • []基于机器学习的异常检测

许可证

这个项目是开源的,可以在MIT许可证下使用。


狩猎快乐!