
关于
提供在渗透测试中利用 Shodan 作为侦察工具的系统化方法论
name: shodan-reconnaissance description: "提供在渗透测试中利用 Shodan 作为侦察工具的系统化方法论。" risk: unknown source: community author: zebbern date_added: "2026-02-27"
Shodan 侦察与渗透测试
目的
提供在渗透测试中利用 Shodan 作为侦察工具的系统化方法论。此技能涵盖 Shodan Web 界面、命令行界面(CLI)、REST API、搜索过滤器、按需扫描和网络监控功能,用于发现暴露的服务、易受攻击的系统和 IoT 设备。
输入 / 前提条件
- Shodan 账户:shodan.io 的免费或付费账户
- API 密钥:从 Shodan 账户仪表板获取
- 目标信息:要调查的 IP 地址、域名或网络范围
- Shodan CLI:已安装的基于 Python 的命令行工具
- 授权:对目标网络进行侦察的书面许可
输出 / 交付物
- 资产清单:已发现的主机、端口和服务列表
- 漏洞报告:已识别的 CVE 和暴露的易受攻击服务
- Banner 数据:揭示软件版本的服务 Banner
- 网络映射:资产的地理和组织分布
- 截图集:暴露界面的可视化侦察
- 导出数据:用于进一步分析的 JSON/CSV 文件
核心工作流
1. 安装与配置
安装 Shodan CLI
# Using pip
pip install shodan
# Or easy_install
easy_install shodan
# On BlackArch/Arch Linux
sudo pacman -S python-shodan
初始化 API 密钥
# Set your API key
shodan init YOUR_API_KEY
# Verify setup
shodan info
# Output: Query credits available: 100
# Scan credits available: 100
检查账户状态
# View credits and plan info
shodan info
# Check your external IP
shodan myip
# Check CLI version
shodan version
2. 基本主机侦察
查询单个主机
# Get all information about an IP
shodan host 1.1.1.1
# Example output:
# 1.1.1.1
# Hostnames: one.one.one.one
# Country: Australia
# Organization: Mountain View Communications
# Number of open ports: 3
# Ports:
# 53/udp
# 80/tcp
# 443/tcp
检查主机是否为蜜罐
# Get honeypot probability score
shodan honeyscore 192.168.1.100
# Output: Not a honeypot
# Score: 0.3
3. 搜索查询
基本搜索(免费)
# Simple keyword search (no credits consumed)
shodan search apache
# Specify output fields
shodan search --fields ip_str,port,os smb
过滤搜索(1 积分)
# Product-specific search
shodan search product:mongodb
# Search with multiple filters
shodan search product:nginx country:US city:"New York"
统计结果数
# Get result count without consuming credits
shodan count openssh
# Output: 23128
shodan count openssh 7
# Output: 219
下载结果
# Download 1000 results (default)
shodan download results.json.gz "apache country:US"
# Download specific number of results
shodan download --limit 5000 results.json.gz "nginx"
# Download all available results
shodan download --limit -1 all_results.json.gz "query"
解析下载的数据
# Extract specific fields from downloaded data
shodan parse --fields ip_str,port,hostnames results.json.gz
# Filter by specific criteria
shodan parse --fields location.country_code3,ip_str -f port:22 results.json.gz
# Export to CSV format
shodan parse --fields ip_str,port,org --separator , results.json.gz > results.csv
4. 搜索过滤器参考
网络过滤器
ip:1.2.3.4 # 特定 IP 地址
net:192.168.0.0/24 # 网络范围(CIDR)
hostname:example.com # 主机名包含
port:22 # 特定端口
asn:AS15169 # 自治系统号
地理过滤器
country:US # 两字母国家代码
country:"United States" # 完整国家名称
city:"San Francisco" # 城市名称
state:CA # 州/地区
postal:94102 # 邮政编码
geo:37.7,-122.4 # 经纬度坐标
组织过滤器
org:"Google" # 组织名称
isp:"Comcast" # ISP 名称
服务/产品过滤器
product:nginx # 软件产品
version:1.14.0 # 软件版本
os:"Windows Server 2019" # 操作系统
http.title:"Dashboard" # HTTP 页面标题
http.html:"login" # HTML 内容
http.status:200 # HTTP 状态码
ssl.cert.subject.cn:*.example.com # SSL 证书
ssl:true # 启用了 SSL
漏洞过滤器
vuln:CVE-2019-0708 # 特定 CVE
has_vuln:true # 存在任何漏洞
截图过滤器
has_screensh`
兼容工具
Claude CodeCursor
标签
安全
