Shodan的又一种玩法-实时资产监控

admin 2019年5月23日15:19:13评论116 views字数 1357阅读4分31秒阅读模式

shodan 配置

安装

➜  ~ sudo easy_install shodan

安装完之后运行

➜  ~ shodan init XXXXXXXXXXXXXXXXXXXX

设置API Key

Shodan的又一种玩法-实时资产监控

然后就可以看到相关账户信息

普通的membership 只有16个IP可以设置。

Shodan的又一种玩法-实时资产监控

然后我们用其他的,十多万个IP可以设置,基本够用。

设置监控

使用到shodan的alert功能:

Shodan的又一种玩法-实时资产监控

alert 示例

命令:shodan alert create "ANT" 203.209.224.0/19

创建

Shodan的又一种玩法-实时资产监控

然后可以设置多个(比如这样就设置完成了)

Shodan的又一种玩法-实时资产监控

取回数据

1.shodan 官方会发送相关Alert邮件信息,到账号邮箱。

2.可以通过shodan stream 取回数据。

之前旧的方法,已经不行了:

shodan alert triggers
shodan alert enable ALERTID malware

现在可以通过stream进行获取:shodan stream --alert=all --fields ip_str,port --datadir=./shodan-data/,可以取到实时更新的数据,储存在相关的文件夹下:

Shodan的又一种玩法-实时资产监控

资产ICS监控

通过python进行监控高风险服务,ICS相关信息

#!/usr/bin/env python

from shodan import Shodan
from shodan.helpers import get_ip
from shodan.cli.helpers import get_api_key


# Configuration
EMAIL_TO = '[email protected]'
EMAIL_FROM = 'ics-alerts'


# Setup the Shodan API connection
api = Shodan(get_api_key())

# Subscribe to results for all networks:
for banner in api.stream.alert():
   # Check whether the banner is from an ICS service
   if 'tags' in banner and 'ics' in banner['tags']:
       send_mail()


def send_mail(subject, content):
   """Send an email using a local mail server."""
   from smtplib import SMTP
   server = SMTP()
   server.connect()
   server.sendmail(EMAIL_FROM, EMAIL_TO, 'Subject: {}nn{}'.format(subject, content))
   server.quit()

手机捷径

在iOS更新到12点几的时候,多了个捷径功能可以自定好多东西:

Shodan的又一种玩法-实时资产监控

在这里我做了一个大概的极简Demo(多图预警)

Shodan的又一种玩法-实时资产监控

Shodan的又一种玩法-实时资产监控

Shodan的又一种玩法-实时资产监控

Shodan的又一种玩法-实时资产监控

流程

  1. 获取日期

  2. 下载对应服务器的文件

  3. 读取弹框。

结尾

捷径还可以设置siri之类的,有很多东西可以用python做,不过pythonista需要收钱,就没有搞。

还有很多东西可以优化,每隔5分钟获取一次最新资产,和后台数据库对比然之类的。手机提醒分分钟挖到新上线业务的。

写的比较仓促,希望大家举一反三,谢谢!


本文始发于微信公众号(米斯特安全团队):Shodan的又一种玩法-实时资产监控

  • 左青龙
  • 微信扫一扫
  • weinxin
  • 右白虎
  • 微信扫一扫
  • weinxin
admin
  • 本文由 发表于 2019年5月23日15:19:13
  • 转载请保留本文链接(CN-SEC中文网:感谢原作者辛苦付出):
                   Shodan的又一种玩法-实时资产监控http://cn-sec.com/archives/354094.html

发表评论

匿名网友 填写信息