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許可證的條款,該寶石可作為開源。