ICode9

精准搜索请尝试: 精确搜索
首页 > 编程语言> 文章详细

Python利用shadon进行信息收集

2021-10-28 22:32:27  阅读:246  来源: 互联网

标签:shadon 收集 Python res Shodan api key print shodan


常用shodan函数

shodan_api.count(query,facets=None) 查询结果数量
shodan_api.host(ip,history=False):获取一个IP的详细信息
shodan_api.port():获取Shodan可查询的端口号
shodan_api.protocols():获取Shodan可查询的协议
shodan_api.services():获取Shodan可查询的服务
shodan_api.scan(ips,force=False):使用Shodan进行扫描,ips可以为字符或字典类型

利用api查询信息

import shodan

key = '########'
api = shodan.Shodan(key)

res = api.search('nginx')
print(res['total'])

total查询结果主机数量
官网中可以查看键值

在这里插入图片描述

IP查询

import shodan

key = '########'
api = shodan.Shodan(key)

res = api.host('110.242.68.4')
print(res['country_name'])

China

同理 可以在官网SearchMethods中查看键值

在这里插入图片描述

shodan查询脚本

import shodan
import json
import sys

key = '########'
api = shodan.Shodan(key)

if len(sys.argv) == 1:
    print("usage: %s"%sys.argv[0])
    sys.exit(1)
try:
    query = ''.join(sys.argv[1:])
    result = api.search(query)
    for results in result['matches']:
        print(results['ip_str'] + ":" + str(results['port']))

except Exception as e:
    print("Error %s" %e)

在这里插入图片描述

Shodan搜索JAWS摄像头

import shodan
import json

key = '###'
api = shodan.Shodan(key)

res = api.search('JAWS/1.0')
print("found:%s"%res['total'])
for ress in res['matches']:
    print(ress['ip_str']+":"+str(ress['port']))

在这里插入图片描述

人生漫漫其修远兮,网安无止境。
一同前行,加油!

标签:shadon,收集,Python,res,Shodan,api,key,print,shodan
来源: https://blog.csdn.net/qq_45924653/article/details/121024640

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有