Shodan的现代异步Ruby Gem,这是世界上第一个用于Internet连接设备的搜索引擎。
$ gem install shodanz
require "shodanz"
client = Shodanz . client . new ( key : "YOUR_API_KEY" )注意,您还可以设置
SHODAN_API_KEY环境变量,而不是在创建客户端时将API密钥作为参数传递。
Shodanz利用异步提供异步IO。这并没有使用Shodanz打破任何现有的脚本,但是现在提供了更多的灵活性来编写更多令人敬畏的东西,例如异型蜜罐检测器:
注意要使任何shodanz方法异步运行,只需将其包裹在
Async { ... }块中即可。要等待其他任何异步操作在块中进行填充,请在其上致电。.wait。
REST API提供了搜索Shodan,查找主机,获取查询和各种实用程序方法的摘要信息,以使开发更容易。有关如何使用它的更多想法,请参阅REST API文档。
搜索内容,是'ya吗?
返回给定主机IP上找到的所有服务。
client . host ( "8.8.8.8" ) # Default
client . host ( "8.8.8.8" , history : true ) # All historical banners should be returned.
client . host ( "8.8.8.8" , minify : true ) # Only return the list of ports and the general host information, no banners. 使用与网站相同的查询语法搜索shodan,并使用facets获取不同属性的摘要信息。
client . host_search ( "mongodb" )
client . host_search ( "nginx" )
client . host_search ( "apache" , after : "1/12/16" )
client . host_search ( "ssh" , port : 22 , page : 1 )
client . host_search ( "ssh" , port : 22 , page : 2 )
client . host_search ( "ftp" , port : 21 , facets : { link : "Ethernet or modem" } ) 此方法的行为与host_search相同,唯一的区别是,该方法不会返回任何主机结果,它仅返回与查询和任何所请求的任何构面信息相匹配的结果总数。结果,此方法不会消耗查询信用。
client . host_count ( "apache" )
client . host_count ( "apache" , country : "US" )
client . host_count ( "apache" , country : "US" , state : "MI" )
client . host_count ( "apache" , country : "US" , state : "MI" , city : "Detroit" )
client . host_count ( "nginx" , facets : { country : 5 } )
client . host_count ( "apache" , facets : { country : 5 } ) 使用此方法请求Shodan爬网或NetBlock。
client . scan ( "8.8.8.8" ) 使用此方法请求Shodan爬上特定端口的Internet。
此方法仅限于具有Shodan数据许可证的安全研究人员和公司。要申请作为研究人员访问此方法的访问,请发送电子邮件[email protected] ,以提供有关您项目的信息。访问仅限于防止滥用。
client . crawl_for ( port : 80 , protocol : "http" ) 使用此方法获取用户保存在Shodan中的搜索查询列表。
client . community_queries
client . community_queries ( page : 2 )
client . community_queries ( sort : "votes" )
client . community_queries ( sort : "votes" , page : 2 )
client . community_queries ( order : "asc" )
client . community_queries ( order : "desc" ) 使用此方法搜索用户保存在Shodan中的搜索查询目录。
client . search_for_community_query ( "the best" )
client . search_for_community_query ( "the best" , page : 2 ) 使用此方法获取Shodan中保存的搜索查询的流行标签列表。
client . popular_query_tags
client . popular_query_tags ( 20 ) 此方法返回一个对象,该对象包含启动Internet扫描时可以使用的所有协议。
client . protocols 此方法返回shodan爬行者正在寻找的端口号列表。
client . ports 返回有关链接到此API密钥的Shodan帐户的信息。
client . profile 查找提供的主机名列表的IP地址。
client . resolve ( "google.com" )
client . resolve ( "google.com" , "bing.com" ) 查找为IP地址列表定义的主机名。
client . reverse_lookup ( "74.125.227.230" )
client . reverse_lookup ( "74.125.227.230" , "204.79.197.200" ) 显示您的客户在连接到Web服务器时发送的HTTP标头。
client . http_headers 从Internet上看到您当前的IP地址。
client . my_ip 计算一个蜜罐概率得分,范围从0(不是蜜罐)到1.0(是蜜罐)。
client . honeypot_score ( '8.8.8.8' ) client . info流API是一项基于HTTP的服务,它返回Shodan收集的实时数据流。有关如何使用它的更多想法,请参阅流媒体API文档。
该流提供了Shodan收集的所有数据。如果您需要访问所有内容和/或想要在本地存储自己的Shodan数据库,请使用此流。如果您只关心特定端口,请使用端口流。
client . banners do | data |
# do something with banner data
puts data
end 如果您只对位于某些ASN中的设备感兴趣,则此流提供了横幅流的过滤,避免横幅的视图。
client . banners_within_asns ( 3303 , 32475 ) do | data |
# do something with banner data
puts data
end 如果您只对某些国家 /地区的设备感兴趣,则此流提供了横幅流的过滤,避免横幅的视图。
client . banners_within_countries ( "DE" , "US" , "JP" ) do | data |
# do something with banner data
puts data
end 仅返回指定端口列表的横幅数据。如果您只对特定的端口列表感兴趣,则此流提供了横幅流的过滤,带宽的视图。
client . banners_on_ports ( 21 , 22 , 80 ) do | data |
# do something with banner data
puts data
end 订阅网络警报中描述的所有IP范围中发现的横幅。
client . alerts do | data |
# do something with banner data
puts data
end 订阅在特定网络警报中定义的IP范围内发现的横幅。
client . alert ( "HKVGAIRWD79Z7W2T" ) do | data |
# do something with banner data
puts data
endexploits API提供了对多个漏洞/漏洞数据源的访问权限。有关如何使用它的更多想法,请参阅利用API文档。
搜索各种数据源以获取利用,并使用方面获取摘要信息。
client . exploits_api . search ( "python" ) # Search for python vulns.
client . exploits_api . search ( port : 22 ) # Port number for the affected service if the exploit is remote.
client . exploits_api . search ( type : "shellcode" ) # A category of exploit to search for.
client . exploits_api . search ( osvdb : "100007" ) # Open Source Vulnerability Database ID for the exploit. 此方法的行为与利用API search方法相同,其差异是没有返回任何结果。
client . exploits_api . count ( "python" ) # Count python vulns.
client . exploits_api . count ( port : 22 ) # Port number for the affected service if the exploit is remote.
client . exploits_api . count ( type : "shellcode" ) # A category of exploit to search for.
client . exploits_api . count ( osvdb : "100007" ) # Open Source Vulnerability Database ID for the exploit. 根据MIT许可证的条款,该宝石可作为开源。