Table of Contents

1 Introduction

  • Shodan 是联网设备搜索引擎

1.1 All About the Data

  • Banner 服务相关的文本信息
  • Device Metadata 地理位置,主机名,操作系统信息
  • IPv6 2015 年之后开始支持

1.2 Data Collection

  • Frequency 24 小时实时更新数据库
  • Distributed 全世界都部署有分布式爬虫,保证网络封锁不影响结果准确性
  • Randomized 基本算法:
    1. 产生一个随机 IPv4 地址
    2. 从 shodan 理解的端口列表中随机产生一个
    3. 检查这个地址和端口,获取 banner
    4. 返回 1

1.3 SSL in Depth

  • SSL 相关的信息包括 SSL 证书都保存在 banner 的 ssl 属性

1.3.1 Vulnerability Testing

 
  1. Heartbleed

    • banner 会有另外两个属性
      opts.heartbleed ,一小段 overflow 获得的数据
      opts.vulns ,CVE-2014-0160
    • 搜索在美国受此影响的设备
      country:US vuln:CVE-2014-0160
  2. FREAK
    • opts.vulns , CVE-2015-0204
  3. Logjam
    • dhparams
      .prime
      .publickey
      .bits
      .generator
      .fingerprint

1.3.2 Version

  • 爬虫会使用多个 SSL 版本
    SSLv2, SSLv3, TLSv1.0, TLSv1.1, TLSv1.2
  • 获得目标支持的 SSL 版本信息会放在 ssl.versions
  • 搜索支持特定 SSL 版本的设备
    ssl.version:sslv2

1.3.3 Follow the Chain

  • 证书链会保存在 ssh.chain 属性

1.4 Beyond the Basics

  • shodan 会尝试从 banner 中解析有用的信息

1.4.1 Web Components

  • http.components
  • http.components.jQuery.categories
  • 获取所有可能的 categories
    shodan stats –facets http.componentcategory:1000 http

1.4.2 Cascading

  • 如果 banner 里有 ip 地址信息,会进一步抓取其 banner
  • 两个属性
    • _shodan.id
    • _shodan.options.referrer

2 Web Interfaces

 

2.1 Search Query Explained

  • 默认是在 banner 搜索指定字符
  • 默认在各搜索字串间是 and
  • 搜索元数据用 search filter

2.2 Introducing Filters

  • 带空格的文本用双引号 city:“San Diego”
  • 多个项用逗号 port:23,1023
  • 不包含 -city:“San Diego”
  • hash 属性
    shodan 中的每个 banner 都有个计算出的 hash 属性,banner 为空则 hash 为 0
  • 结合多个 filter 使用
    port:8080 -hash:0
  • 一些常用的 filter
    category 例如 ics,malware
    city
    country
    net 例如 net:190.20.40.0/24
    org 例如 "Verizon Wireless“

2.3 Shodan Search Engine

  • 默认查询只搜索 30 天内的数据

2.3.1 Download Data

  • 下载结果需要 export credit,需要购买,一个 credit 可下载最高 10000 个结果

2.3.2 Generate Report

  • 报告创建免费

2.3.3 Shared Search Queries

  • 可以查看别人共享的查询语句

2.3.4 Example: Finding Non-Default Services

  • product:opennssh -port:22

2.4 Shodan Maps

  • 会显示最多 1000 个结果,随着放大缩小会修改显示在视线范围内的设备数量

2.4.1 Map Styles

2.5 Shodan Exploits

  • https://exploits.shodan.io/ 会从多个来源搜索 exp,其实和 shodan 本身功能没啥关系了
  • 支持的 filters
    author
    description
    platform
    type remote/dos

2.6 Shodan Images

2.7 Exercises: Website

  • 找到 4SICS 网站
  • 有多少支持匿名访问的 VNC 服务
  • 瑞典 Sweden 有多少存在 Heartbleed 并支持 SSLv3 的 IP
  • 你的组织内有多少存在 Heartbleed 的 IP
  • 找到你城市内的所有工控设备
  • USA 最流行的 RAT 是哪种

3 External Tools

 

3.1 Shodan Command-Line Interface

 

3.1.1 Gettig Started

  • 安装
    easyinstall shodan
    shodan init APIKEY

3.1.2 alert

create
list
clear
remove

3.1.3 convert

  • 能够把 shodan 生成的 JSON 文件转换成 kml csv 格式

3.1.4 count

  • 返回查询结果条数
    shodan count microsoft iis 6.0

3.1.5 download

shodan download microsoft-data microsoft iis 6.0

3.1.6 host

  • 查询主机信息
    shodan host 189.201.128.250

3.1.7 honeyscore

  • 检查主机是否是伪装成工控系统的蜜罐
    shodan honeyscore 41.231.95.212

3.1.8 info

  • 查询 API 的查询条数和下载条数

3.1.9 myip

  • 返回自己的公网 ip

3.1.10 parse

  • 可以解析之前下载的文件
    shodan parse –fields ipstr,port,org –separator , microsoft-data.json.gz

3.1.11 scan

提供了多条子命令,最常用的是 submit
shodan scan submit 202.69.165.20

3.1.12 search

shodann search –fields ipstr,port,org,hostname microsoft iis 6.0

3.1.13 stats

  • 按照某个分类显示结果统计

shodan stats –facets country apache

3.1.14 stream

  • 提供了访问爬虫实时获取的数据
  1. -datadir
  2. -limit
  3. -ports

3.1.15 Example: Network Analysis

shodan count net:78.13/16
shodan stats –facets port net:78.13/16
shodan stats –facets port:100000 net:78.13/16
shodan stats –facets product “HTTP net:78.13/16 -port:80,443”
shodan stats –facets ssl.version HTTP net:78.13/16

3.1.16 Example: Telnet Research

mkdir telnet-data
shodan stream –ports 23,1023,2323 –datadir telnet-data/ –limit 10000

3.2 Maltego Add-On

3.3 Browser Plug-Ins

3.4 Exercises: Command-Line Interface

  • 下载 Sweden 和 Norway 内有 Heartbleed 的 IP,从中过滤出 Sweden 的 IP
  • 使用实时 stream 下载最近 1000 个 banner,并用 Google Maps 映射
  • 写个脚本下载已知恶意 ip 列表并封掉到这些 ip 的流量
    iptables -A OUTPUT -d x.x.x.x -j DROP

4 Developer API

  • shodan 提供了两种 API
    REST API, 正常查询
    Streaming API

4.1 Usage Limits

  • 如果查询包含 filter 或者查询了第二页,会消耗一个 query credit
  • 每月重置 query 和 scan credit 条数

4.2 Introducing Facets

  • facets 现在只能通过 API 和 cli 访问

4.3 Gettign Started

easyinstall shodan
easyinstall -U shodan

4.4 Initialization

import shodan
api = shodan.Shodan('your api key')

4.5 Search

try:
results = api.search('apache')
print('Results found: %s' % results['total'])
for result in results['matches']:
print 'IP: %s' % results['ip_str']
print result['data']
print ''
except shodan.APIError, e:
print 'Error: %s' % e
  • 默认返回第 1 页,只包含 100 个结果 api.search(’apache’, page=2)
  • 返回数据是个字典 .total .matches .data .hostname .ipython.ipstr’.os .port .timestamp
  • 默认太长的数据会被截断 api.search(’hasscreenshot:true’, minify=False)
  • 遍历所有结果

    for banner in api.search_cursor('apache'):
    print(bannner['ip_str'])

4.6 Host Lookup

  • 查询指定 ip
host = api.host('1.1.1.1')
print """
IP: %s
Organization: %s
Operating System: %s
""" % (host['ip_str'], host.get('org', 'n/a'), host.get('os', 'n/a')) for item in host['data']:
print """
Port: %s
Banner: %s
""" % (item['port'], item['data'])
  • 默认只返回最近的数据,用 history 参数返回所有历史数据 host = api.host(’1.1.1.1’, history=True)

4.7 Scanning

  • api 的 scan 不会立刻扫描
  • 使用示例

    scan = api.scan('1.1.1.1/24')
    scan2 = api.scan(['1.1.1.1', '2.2.2.2/16'])

4.8 Real-Time Stream

4.9 Network Alert

 

4.9.1 Creating a Network Alert

4.9.2 Subscribling

4.9.3 Using the Shodan Command-Line Interface

4.10 Example: Public MongoDB Data

4.11 Exercises: Shodan API

5 Industrial Control Systems

 

5.1 Common Abbreviations

BMS Building Management System DCS Distributed Control System HMI Human Machine Interface ICS Industrial Control System PLC Programmable Logic Controller RTU Remote Treminal Unit SCADA Supervisory Control and Data Acquisition VNC Virtual Network Computing

5.2 Protocols

  • 有两种识别网上的控制系统的方式
    1. Non-ICS protocols used in an ICS environment 一些工控设备可以通过 web 界面或者远程连接访问
    2. ICS protocols ICS 协议都没有认证,但是基本都是私有协议,意味着能访问但无法交互

5.3 Securing Internet-Connected ICS

5.4 Use Cases

 

5.4.1 Assessing ICS for the USA

5.4.2 Identifying Honeypots

 
  1. What is a honeypot?

    • 最流行的工控蜜罐:Conpot
  2. Why Detect Them?
  3. Default Configurations
    • 默认配置会返回同样的 banner,包括 serial number, PLC names 等
  4. History Matters
    • 历史中可能出现错误配置,比如模板没有解析,直接输出出来了
  5. Emulate Devices, Not Services
    • 蜜罐可能同时模拟太多服务
  6. Location, Location, Location
    • 部署在一些云上的工控多半是蜜罐
      Amazon EC2
      Rackspace
      Digital Ocean
      Vultr
      Microsoft Azure
      Google Cloud
    • 蜜罐最好是部署在一些城市 ISP 的 IP 范围
  7. Honeyscore
  8. Tag: honeypot
    • 判断蜜罐的算法也被集成在了爬虫中,同时会检测一些流行的 web 应用,Elastic 等的蜜罐

6 Appendix A: Banner Specification

 

6.1 General Properties

asn
data
ip
ipstr
ipv6
port
timestamp
hash
hostnames
domains
link 网络连接类型,以太网或者光猫
location
opts
org
isp
os
uptime
tags
transport 传输层协议

6.2 Elastic Properties

elastic.cluster
elastic.indices
elastic.nodes

6.3 HTTP(S) Properties

http.components
http.host
http.html
http.htmlhash
http.location
http.redirects
http.robots
http.server
http.sitemap
http.title

6.4 Location Properties

  • location 的一些子属性
    areacode
    city
    countrycode
    countrycode3
    countryname
    dmacode 美国专用
    latitude
    longitude 经度
    postalcode
    regioncode

6.5 SMB Properties

smb.anonymous
smb.capabilities
smb.shares
smb.smbversion
smb.software
smb.raw

6.6 SSH Properties

ssh.cipher
ssh.fingerprint
ssh.kex 服务器支持的 key 交换算法
ssh.key
ssh.mac

6.7 SSL Properties

ssl.acceptablecas 服务器支持的证书授权
ssl.cert
ssl.cipher
ssl.chain
ssl.dhparams
ssl.tlsext
ssl.versions

6.8 ISAKMP Properties

  • 针对使用 ISAKMP 协议的 VPN,比如 IKE

6.9 Special Properties

6.10 Example

7 Appendix B: List of Search Filters

 

7.1 General Filters

7.2 HTTP Filters

7.3 NTP Filters

7.4 SSL Filters

7.5 Telnet Filters

8 Appendix C: Search Facets

 

8.1 General Facets

8.2 HTTP Facets

8.3 NTP Facets

8.4 SSH Facets

8.5 SSL Facets

8.6 Telnet Facets

9 Appendix D: List of Ports

10 Appendix E: Sample SSL Banner

11 Exercise Solutions

 

11.1 Website

11.2 Command-Line Interface

11.3 Shodan API

Author: cat

Created: 2019-11-23 六 23:22

shodan 文档学习笔记的更多相关文章

  1. torch文档学习笔记

    下面为官方文档学习笔记    http://pytorch.org/docs/0.3.0/index.html 1.torch.Tensor from __future__ import print_ ...

  2. 通过程序校验xml文档学习笔记

    校验xml文档,可以通过程序来校验,利用一段js代码即可. 各行代码的含义已经写出,运行这个html文件,检验如下xml代码: 结果如下: 如果xml文档出现错误: 结果如下: 其中,obj.asyn ...

  3. Spring3.0官网文档学习笔记(八)--3.4.3~3.4.6

    3.4.3 使用depends-on     使用depends-on能够强制使一个或多个beans先初始化,之后再对这个bean进行初始化. 多个bean之间用","." ...

  4. Spring3.0官网文档学习笔记(一)

    Part 1 Spring框架概述 Spring是模块化的,在应用中仅仅须要引入你所须要用到的模块的jar包,其余的jar包不用引入. spring框架支持声明式的事务管理,通过RMI或web ser ...

  5. Spring3.0官网文档学习笔记(七)--3.4.2

    3.4.2 依赖与配置的细节     3.4.2.1  Straight values (primitives, Strings, and so on)     JavaBeans PropertyE ...

  6. Spring3.0官网文档学习笔记(二)

    1.3 使用场景 典型的成熟的spring web应用 spring使用第三方框架作为中间层 远程使用场景 EJB包装 1.3.1 依赖管理.命名规则(包)     spring-*.jar *号代表 ...

  7. android官网文档学习笔记

    1.android的四大组件的了大概功能 activity:负责显示界面,和用户交互. service:运行在后台. content provider:为程序app之间的数据访问提供接口. broad ...

  8. Spring3.0官网文档学习笔记(四)--3.1~3.2.3

    3.1 Spring IoC容器与Beans简单介绍     BeanFactory接口提供对随意对象的配置:     ApplicationContext是BeanFactory的子接口.整合了Sp ...

  9. pytorch文档学习笔记(2)

    三.CUDA semantics 二.Broadcasting semantics  广播机制 广播机制要第一项对齐,第一项对齐后(相等)才能广播,或者某个第一项为1. 但如果两个size个数相等,则 ...

随机推荐

  1. Java Web项目中使用Freemarker生成Word文档遇到的问题

    这段时间项目中使用了freemarker生成word文档.在项目中遇到了几个问题,在这里记录一下.首先就是关于遍历遇到的坑.整行整行的遍历是很简单的,只需要在整行的<w:tr></w ...

  2. mac外接显示器 字体发虚解决方案

    描述 今天买的LG性价比之王21:9的2k显示器到了,但是连接mbp后发现,字体发虚,模糊 Macbook 外接显示器默认为 TV 模式,TV 渲染模式下,文字效果非常非常非常差 解决 下载 patc ...

  3. 百万年薪python之路 -- 并发编程之 多线程 三

    1. 阻塞,非阻塞,同步,异步 进程运行的三个状态: 运行,就绪,阻塞. 从执行的角度: ​ 阻塞: 进程运行时,遇到IO了,进程挂起,CPU被切走. ​ 非阻塞: 进程没有遇到IO 当进程遇到IO, ...

  4. 面试官:"准备用HashMap存1w条数据,构造时传10000还会触发扩容吗?"

    // 预计存入 1w 条数据,初始化赋值 10000,避免 resize. HashMap<String,String> map = new HashMap<>(10000) ...

  5. 用最复杂的方式学会数组(Python实现动态数组)

    Python序列类型 在本博客中,我们将学习探讨Python的各种"序列"类,内置的三大常用数据结构--列表类(list).元组类(tuple)和字符串类(str). 不知道你发现 ...

  6. JVM(8) 线程安全与锁优化

    面向过程编程:程序编写以算法为核心,程序员会把数据和过程分别作为独立的部分来考虑,数据代表问题空间的客体,程序代码则用于处理这些数据.这种思维方式直接站在计算机的角度去抽象问题和解决问题,称为面向过程 ...

  7. ansible模块之command、shell、script、file、copy、fetch

    前戏 ansible 批量在远程主机上执行命令 openpyxl 操作excel表格 puppet ansible slatstack ansible epel源 第一步: 下载epel源 wget ...

  8. 【xinsir】分享一个查找文件的脚手架

    program.command('find <name>').action(name => { if (name) { inquirer .prompt([ { type: 'inp ...

  9. [Java] 生成二维码源码,可以在二维码中间加logo,底部可以加文字介绍

    链接:https://pan.baidu.com/s/1bc1h-ix-No-2o9Ysd4_B3Q提取码:0ad4

  10. 安卓—自定义 AlertDialog 的样式

    自定义修改安卓弹出框的样式 效果图: 1.在style.xml下添加 <!-- 自定义弹出样式 --> <style name="MyDialogStyle" p ...