seedon198/Farsight

GitHub: seedon198/Farsight

一站式侦察与威胁情报框架,整合域名发现、资产探测、威胁监控和仿冒检测,支持无 API 优雅降级运行。

Stars: 10 | Forks: 3

## [🎯 黑帽兵器库 2025 精选展示 🎯](https://www.blackhat.com/sector/2025/arsenal/schedule/index.html#farsight-cli-based-recon-and-threat-intelligence-framework-47707) **加入我们在 BlackHat Arsenal 2025 的活动** | **主题:基于 CLI 的侦察与威胁情报框架**

FARSIGHT Logo

# FARSIGHT [![Python](https://img.shields.io/badge/Python-3.9+-blue?style=for-the-badge&logo=python)](https://python.org) [![License](https://img.shields.io/badge/License-MIT-green?style=for-the-badge)](LICENSE) [![Stars](https://img.shields.io/github/stars/seedon198/Farsight?style=for-the-badge)](https://github.com/seedon198/Farsight/stargazers) *深受全球安全专业人士信赖的综合侦察与威胁情报框架* ## 概述 FARSIGHT 是一个强大的、基于 Python 的侦察和威胁情报框架,专为安全专业人士设计。它以快速、模块化、CLI 优先的工具形式,提供全面的域名情报、资产发现和威胁监控能力。 ### 主要特性 - **纯 Python 实现**:完全使用 Python 构建,以实现最大的可移植性 - **API 可选架构**:无论有无 API 密钥均可运行,并具有增强的回退机制 - **快速且模块化**:异步优先设计,通过并行处理实现最佳性能 - **CLI 优先方法**:使用 Typer 构建的直观命令行界面 - **全面的报告功能**:生成带有可视化风险指示器的详细 Markdown 和 PDF 报告 - **优雅降级**:在 API 故障时通过智能替代方法平稳恢复 - **无外部二进制依赖**:可选集成外部工具 ## 模块 1. **组织域名发现**:WHOIS 分析、证书透明度数据、被动 DNS、相关域名发现 2. **侦察 / 资产发现**:高级 DNS 枚举,对所有发现的子域名进行全面端口扫描 3. **威胁情报**:泄露检测、凭据暴露、暗网提及、邮箱信誉分析 4. **仿冒域名检测**:优化的域名排列与分析,包含内容相似性评估 5. **新闻监控**:全面的新闻追踪,支持多来源和相关性评分 6. **报告生成**:输出结构化的 Markdown/PDF 格式报告,带有可视化风险指示器 ## 安装说明 FARSIGHT 需要 Python 3.9+ 和一些依赖项。请按照以下步骤完成设置: ### 前置条件 - Python 3.9 或更高版本 - pip (Python 包安装工具) ### 快速设置 ``` # 1. Clone repository git clone https://github.com/seedon198/Farsight.git cd Farsight # 2. Create a virtual environment (recommended) python3 -m venv venv # 3. Activate virtual environment # On macOS/Linux: source venv/bin/activate # On Windows: # venv\Scripts\activate # 4. Install core dependencies pip install -r requirements.txt # 5. Install optional dependencies for full functionality pip install dnstwist rapidfuzz gnews markdown reportlab # 6. Verify installation python -m farsight --help ``` ### 快速开始 安装完成后,您可以立即开始使用 FARSIGHT: ``` # Activate your virtual environment source venv/bin/activate # Run a basic scan python -m farsight scan example.com # Run a comprehensive scan with all modules python -m farsight scan example.com --all --verbose ``` ### 替代方案:使用 Poetry(推荐用于开发) 如果您更喜欢使用 Poetry 进行依赖管理: ``` # Install Poetry if you haven't already curl -sSL https://install.python-poetry.org | python3 - # Install dependencies poetry install # Activate the virtual environment poetry shell # Run FARSIGHT poetry run python -m farsight --help ``` ### 开发设置 用于开发和贡献代码: ``` # Install development dependencies pip install -r requirements-dev.txt # Install pre-commit hooks (optional) pre-commit install ``` ### API 密钥(可选) FARSIGHT 可以在没有 API 密钥的情况下运行,但某些功能将受到限制。为了获得最佳体验,建议将以下 API 密钥设置为环境变量: ``` export FARSIGHT_SHODAN_API_KEY="your-api-key" export FARSIGHT_CENSYS_API_KEY="your-api-key" export FARSIGHT_SECURITYTRAILS_API_KEY="your-api-key" export FARSIGHT_VIRUSTOTAL_API_KEY="your-api-key" export FARSIGHT_INTELX_API_KEY="your-api-key" export FARSIGHT_LEAKPEEK_API_KEY="your-api-key" ``` ## 使用方法 FARSIGHT 设计简单易用,同时提供强大的侦察能力。请确保先激活您的虚拟环境: ``` # Activate virtual environment (if using one) source venv/bin/activate # On macOS/Linux # or # venv\Scripts\activate # On Windows ``` ### 基本命令 ``` # Display help information python -m farsight --help # Display version information python -m farsight version # Show scan command options python -m farsight scan --help ``` ### 运行扫描 ``` # Basic scan (organization discovery + reconnaissance) python -m farsight scan example.com # Basic scan with custom output file python -m farsight scan example.com --output my_report.md # Comprehensive scan with all modules python -m farsight scan example.com --all --verbose # Custom scan with specific modules python -m farsight scan example.com --modules org,recon,threat --verbose # Generate a PDF report python -m farsight scan example.com --output report.pdf --all # Force overwrite existing report python -m farsight scan example.com --force ``` ### 扫描深度级别 FARSIGHT 支持不同的扫描深度级别,用于控制扫描过程的详尽程度: - **深度 1**:基础侦察(默认) - 快速、非侵入式扫描 - **深度 2**:增强侦察 - 更彻底的扫描,包含额外检查 - **深度 3**:全面分析 - 最彻底的扫描,使用所有可用技术 ``` # Run a quick scan (depth 1) python -m farsight scan example.com --depth 1 # Run a thorough scan (depth 3) python -m farsight scan example.com --depth 3 --all ``` ## 模块详解 FARSIGHT 采用模块化架构设计,允许您独立或组合使用特定模块。以下是每个模块的概述: ### 组织发现 此模块通过各种技术发现与组织相关的域名: - 用于获取组织信息的 WHOIS 数据分析 - 来自 crt.sh 的证书透明度日志 - 来自公共来源的被动 DNS 数据 - 基于 API 的可选查询 (SecurityTrails, Censys) ### 侦察 此模块识别资产和网络基础设施: - DNS 枚举(A, AAAA, MX, TXT, NS 记录) - 使用多种技术的高级子域名发现: - 证书透明度日志 - DNS 暴力破解 - 被动 DNS 来源 - 使用 asyncio 对所有发现的子域名进行全面端口扫描 - 邮件安全评估(SPF, DMARC, DKIM) - 可选的基于 API 的服务(Shodan, Censys) ### 威胁情报 此模块识别潜在的安全威胁: - 来自公共来源的数据泄露检测 - 具有关联分析的凭据暴露监控 - 具有风险分类的高级暗网提及追踪 - 具有风险评分的邮箱信誉分析 - 当 API 不可用时的替代监控方法 - 报告中的可视化风险指示器(🟢, 🔵, 🔴, ⚠️) ### 仿冒域名检测 此模块识别潜在的仿冒域名: - 优化的域名排列生成 - 具有回退机制的增强 DNS 解析检查 - 具有年限评估的注册数据分析 - 高级内容相似性检查 - 用于钓鱼检测的 MX 记录分析 - 改进的相似性阈值(默认 60%)以便更好地检测 - 分析相似性和风险评分 - 检测域名抢注技术 ### 新闻监控 此模块追踪最近的新闻提及: - 关于目标的最近新闻文章,支持多个来源 - 来源可信度评估和发布者信息 - 每篇文章的相关性评分 - 当主要 API 不可用时的替代方法 - 优先排序文章的整洁输出格式 ### 报告生成 此模块生成综合报告: - 包含详细发现的 Markdown 报告 - 可选的 PDF 转换 - 结构化数据展示 - 执行摘要和技术细节 ## 配置 FARSIGHT 的行为可以通过环境变量或直接参数进行配置: ### 环境变量 设置这些环境变量以配置 API 密钥和全局设置: ``` # API Keys export FARSIGHT_SHODAN_API_KEY="your-api-key" export FARSIGHT_CENSYS_API_KEY="your-api-key" export FARSIGHT_SECURITYTRAILS_API_KEY="your-api-key" export FARSIGHT_VIRUSTOTAL_API_KEY="your-api-key" export FARSIGHT_INTELX_API_KEY="your-api-key" export FARSIGHT_LEAKPEEK_API_KEY="your-api-key" # Global Settings export FARSIGHT_TIMEOUT=60 # Default timeout in seconds export FARSIGHT_MAX_CONCURRENT=20 # Max concurrent requests ``` ### 命令行选项 许多配置选项可以直接在命令行中提供: ``` # Set timeout and concurrency python -m farsight scan example.com --timeout 60 --concurrency 20 # Force overwrite existing reports python -m farsight scan example.com --output report.md --force # Enable verbose output for debugging python -m farsight scan example.com --verbose ``` ## 报告 FARSIGHT 默认生成 Markdown 格式的综合报告,如果安装了所需的库,还可以选择转换为 PDF。报告包括: - 包含关键发现的执行摘要 - 来自每个模块的详细技术结果 - 数据的可视化表示(如适用) - 基于发现的建议 示例报告部分: ``` # FARSIGHT Reconnaissance Report ## Target: example.com **Scan Date:** 2025-05-17 17:57:11 **Scan Depth:** 2 **Modules Run:** org, recon, threat, typosquat, news ## Executive Summary This report presents the findings from a reconnaissance scan of **example.com**. - **12** domains/subdomains discovered - **5** open ports found - **Well-protected** email security posture ``` ## 项目架构 FARSIGHT 采用以下架构构建: ``` farsight/ ├── __init__.py # Package initialization ├── __main__.py # CLI entry point ├── main.py # Main CLI application ├── config.py # Configuration management ├── cli/ # CLI interface using Typer │ └── scan.py # Scan command implementation ├── modules/ # Core functionality modules │ ├── org_discovery.py # Organization domain discovery │ ├── recon.py # DNS enumeration and port scanning │ ├── threat_intel.py # Threat intelligence gathering │ ├── typosquat.py # Typosquatting detection │ ├── news.py # News monitoring │ └── report_writer.py # Report generation └── utils/ # Utility functions ├── api_handler.py # API interaction with failover ├── common.py # Common utilities ├── dns.py # DNS operations └── subdomain_enum.py # Subdomain enumeration utilities ``` ## 依赖项 ### 核心依赖(必需) - **typer**: CLI 接口框架 - **python-whois**: WHOIS 查询 - **aiohttp**: 异步 HTTP 请求 - **dnspython**: DNS 解析和查询 - **beautifulsoup4**: Web 抓取 - **requests**: 用于 API 请求的 HTTP 库 ### 可选依赖(推荐) - **dnstwist**: 增强的仿冒域名检测 - **rapidfuzz**: 更好的仿冒域名相似性评分 - **gnews**: 新闻文章检索 - **markdown**: Markdown 报告处理 - **reportlab**: PDF 报告生成 ### 安装说明 - 所有核心依赖项通过 `pip install -r requirements.txt` 安装 - 可选依赖项可以通过以下方式安装:`pip install dnstwist rapidfuzz gnews markdown reportlab` - 该工具在没有可选依赖项的情况下也能工作,但功能有限 ## 故障排除 ### 常见问题 **问题:`No module named farsight.__main__`** ``` # Solution: Make sure you're in the project directory and using the correct Python cd /path/to/Farsight python -m farsight --help ``` **问题:可选依赖项出现 `ModuleNotFoundError`** ``` # Solution: Install optional dependencies pip install dnstwist rapidfuzz gnews markdown reportlab ``` **问题:创建虚拟环境时权限被拒绝** ``` # Solution: Use --user flag or check permissions python3 -m venv --user venv # or sudo python3 -m venv venv ``` **问题:Command not found: python** ``` # Solution: Use python3 instead python3 -m farsight --help ``` **问题:报告文件已存在** ``` # Solution: Use --force flag to overwrite python -m farsight scan example.com --force ``` ### 获取帮助 1. 查看帮助:`python -m farsight --help` 2. 查看扫描选项:`python -m farsight scan --help` 3. 运行时带详细输出:`python -m farsight scan example.com --verbose` 4. 查看 [GitHub Issues](https://github.com/seedon198/Farsight/issues) 了解已知问题 ## 贡献指南 FARSIGHT 是一个开源项目,欢迎各种贡献。以下是贡献方式: 1. Fork 本仓库 2. 创建一个功能分支 (`git checkout -b feature/amazing-feature`) 3. 提交您的更改 (`git commit -m 'Add amazing feature'`) 4. 推送到分支 (`git push origin feature/amazing-feature`) 5. 提交一个 Pull Request ## 许可证 FARSIGHT 基于 MIT 许可证授权。有关详细信息,请参阅 [LICENSE](LICENSE) 文件。 ## 致谢 FARSIGHT 利用了以下项目和服务: - [Typer](https://typer.tiangolo.com/) - CLI 框架 - [aiohttp](https://docs.aiohttp.org/) - 异步 HTTP 客户端/服务器 - [dnspython](https://www.dnspython.org/) - DNS 工具包 - [python-whois](https://pypi.org/project/python-whois/) - WHOIS 查询 - [BeautifulSoup](https://www.crummy.com/software/BeautifulSoup/) - Web 抓取 - [dnstwist](https://github.com/elceef/dnstwist) - 域名排列引擎 - [rapidfuzz](https://github.com/maxbachmann/rapidfuzz) - 快速字符串匹配 - [gnews](https://github.com/ranahaani/gnews) - 新闻文章检索 - [markdown](https://python-markdown.github.io/) - Markdown 解析 - [reportlab](https://www.reportlab.com/) - PDF 生成 - 公共数据源,包括 [crt.sh](https://crt.sh/), [RapidDNS](https://rapiddns.io/), 和 [DNSDB.io](https://dnsdb.io/) ## 免责声明 FARSIGHT 按“原样”提供,不提供任何形式的明示或暗示的保证。作者和贡献者对因使用本软件而产生的任何损害概不负责。 本工具专为进行授权安全评估的安全专业人士设计。在扫描任何域名或网络之前,请务必确保您已获得适当的授权。 ## 联系方式 如有问题、建议或需要支持,请在 [GitHub 仓库](https://github.com/seedon198/Farsight)上开启 issue。
标签:AsyncIO, BlackHat Arsenal, DNS枚举, ESC4, ESC6, FARSIGHT, GitHub, OSINT, Python安全工具, Sigma 规则, Splunk, Typer, WHOIS查询, 侦察框架, 动态插桩, 协议探测, 域名分析, 威胁情报, 子域名挖掘, 安全报告生成, 实时处理, 对称加密, 开发者工具, 异步编程, 红队作战, 网络安全, 网络安全工具, 自动化审计, 证书透明度, 逆向工具, 隐私保护, 黑帽兵器库