Shodan使用指南

道锋潜鳞
2020-03-24 / 0 评论 / 517 阅读 / 正在检测是否收录...

前言

Shodan是一个搜素互联网链接设备的搜索引擎,不同于Google、Baidu这些搜素引擎。用户可以在Shodan上使用Shodan搜索语法查找链接到互联网的摄像头、路由器、服务器等设备信息。在渗透测试中是个非常非常不错的神器。

Shodan的工作原理

Shodan 通过扫描全网设备并抓取解析各个设备返回的 banner 信息,通过了解这些信息 Shodan 就能得知网络中哪一种 Web 服务器是最受欢迎的,或是网络中到底存在多少可匿名登录的 FTP 服务器。

注:banner信息:用于描述设备所运行服务的标志性文本信息。

Shodan的使用

在使用Shodan之前我们需要注册一个Shodan账户,之后才可以使用:

Shodan的使用方法较为简单,你可以将其当成一个“网络区域的”浏览器,之所以这样说是因为它具备搜索引擎的功能,而且是主要面对于网络设备的。

Shodan初试

条目介绍:

左侧部分:

Top Countries                             使用最多的国家
Top services                              使用最多的服务
Top organizations                         使用最多的组织
Top operating systems                     使用最多的操作系统
Top products (Software name)              使用最多的产品

中间部分:

涉及与搜素关键词有关的Target,主要包含的信息有:

IP地址
主机名
该主机所处国家、区域
该条目的收录收录时间
Banner信息

如果想要获得更加详细的信息可以点击“Details”之后获取与此目标相关的信息内容:

Shodan的使用语法

面对大量的信息量,如果要获取我们想要的目标信息,那么就必须附加限制条件缩小范围是最后的结果更加精确,与Google一样Shodan也有相应的语言可以使用:

hostname——————————搜索指定的主机或域名,例如 hostname:baidu
port——————————————搜索指定的端口或服务,例如 port:80
country———————————搜索指定的国家,例如 country:US
city——————————————搜索指定的城市,例如 city:Chengdu
org———————————————搜索指定的组织或公司,例如 org:"Google"
isp———————————————搜索指定的ISP供应商,例如 isp:"China Telecom"
product———————————搜索指定的操作系统/软件/平台,例如 product:"Apache httpd"
version———————————搜索指定的软件版本,例如 version:"1.6.2"
geo———————————————搜索指定的地理位置,参数为经纬度,例如 geo:"31.8639, 117.2808"
before/after——————搜索指定收录时间前后的数据,格式为dd-mm-yy,例如 before:"11-11-15"
net———————————————搜索指定的IP地址或子网,例如 net:"210.45.240.0/24"

查找位于国内的Nginx服务器

nginx country:"CN"

查找 GWS(Google Web Server) 服务器:

"Server: gws" hostname:"google"

查找指定网段的华为设备:

huawei net:"61.191.146.0/24"

如上通过在基本关键字后增加指定的过滤关键字,能快速的帮助发现我们感兴趣的内容。当然,还有更快速更有意思的方法,那就是点击 Shodan 搜索栏右侧的 “Explore” 按钮,就会得到很多别人分享的搜索语法

命令行下使用 Shodan

Shodan 是由官方提供的 Python 库的,项目位于:https://github.com/achillean/shodan-python

安装

pip install shodan

或者

git clone https://github.com/achillean/shodan-python.git && cd shodan-python
python setup.py install

安装完后我们先看下帮助信息:

➜  ~ shodan -h
Usage: shodan [OPTIONS] COMMAND [ARGS]...
Options:
  -h, --help  Show this message and exit.
  Commands:
  alert       Manage the network alerts for your account  # 管理账户的网络提示
  convert     Convert the given input data file into a...  # 转换输入文件
  count       Returns the number of results for a search  # 返回查询结果数量
  download    Download search results and save them in a...  # 下载查询结果到文件
  honeyscore  Check whether the IP is a honeypot or not.  # 检查 IP 是否为蜜罐
  host        View all available information for an IP...  # 显示一个 IP 所有可用的详细信息
  info        Shows general information about your account  # 显示账户的一般信息
  init        Initialize the Shodan command-line  # 初始化命令行
  myip        Print your external IP address  # 输出用户当前公网IP
  parse       Extract information out of compressed JSON...  # 解析提取压缩的JSON信息,即使用download下载的数据
  scan        Scan an IP/ netblock using Shodan.  # 使用 Shodan 扫描一个IP或者网段
  search      Search the Shodan database  # 查询 Shodan 数据库
  stats       Provide summary information about a search...  # 提供搜索结果的概要信息
  stream      Stream data in real-time.  # 实时显示流数据

常用示例

init

初始化命令行工具。

➜  ~ shodan init [API_Key]
Successfully initialized

count

返回查询的结果数量。

➜  ~ shodan count microsoft iis 6.0
575862

download

将搜索结果下载到一个文件中,文件中的每一行都是 JSON 格式存储的目标 banner 信息。默认情况下,该命令只会下载1000条结果,如果想下载更多结果需要增加--limit 参数。

0

评论 (0)

取消