module PWN::Plugins::Shodan

def self.api_info(opts = {})

def self.api_info(opts = {})
i_key].to_s.scrub
i_key }
,
info',
 => e

def self.authors

def self.authors
st.pentest@0dayinc.com>

def self.extract_uris(opts = {})

def self.extract_uris(opts = {})
 = opts[:search_results_hash]
.each_with_object([]) do |value, uris|
alue = *URI.extract(value.to_s).select do |uri|
 uri)
ris_from_value)
or,
IError,
mponentError
=> e

def self.get_uris(opts = {})

def self.get_uris(opts = {})
pts[:search_results]
 do |search_results_hash|
_hash: search_results_hash
 => e

def self.help

def self.help
= #{self}.services_by_ips(
ired - shodan api key',
equired - comma-delimited list of ip addresses to target'
als = PWN::Plugins::Shodan.query_result_totals(
ired shodan api key',
ed - shodan search query',
nal - comma-separated list of properties to get summary information'
 #{self}.search(
ired shodan api key',
ed - shodan search query',
nal - comma-separated list of properties to get summary information'
#{self}.tokens(
ired shodan api key',
ed - shodan search query',
wls = #{self}.ports_shodan_crawls(
ired shodan api key'
lf}.list_on_demand_scan_protocols(
ired shodan api key'
ponse = #{self}.scan_network(
ired shodan api key',
equired - comma-delimited list of ip addresses to target'
sponse = #{self}.scan_internet(
ired shodan api key',
d - port to scan (see #ports_shodan_crawls for list)',
uired - supported shodan protocol (see #list_on_demand_scan_protocols for list)'
lt = #{self}.scan_status(
ired shodan api key',
ired - unique ID returned by #scan_network',
crawls = #{self}.services_shodan_crawls(
ired shodan api key'
ries_result = #{self}.saved_search_queries(
ired shodan api key',
l - page number to iterate over results (each page contains 10 items)',
l - sort results by available parameters :votes|:timestamp',
al - sort :asc|:desc (ascending or descending)'
s_result = #{self}.most_popular_tags(
ired shodan api key',
'optional - number of results to return (defaults to 10)'
elf}.my_profile(
ired shodan api key'
lf}.my_pub_ip(
ired shodan api key'
f}.api_info(
ired shodan api key'
lity_scores = #{self}.honeypot_probability_scores(
ired shodan api key',
equired - comma-delimited list of ip addresses to target'
}.get_uris(
: 'required - search_results object returned from #search method'

def self.honeypot_probability_scores(opts = {})

def self.honeypot_probability_scores(opts = {})
i_key].to_s.scrub
:target_ips].to_s.scrub.gsub(/\s/, '').split(',')
ty_scores = []
i_key }
 |target_ip|
n_rest_call(
ey,
bs/honeyscore/#{target_ip}",

lity_scores.push("#{target_ip} => #{response}")
ty_scores
 => e

def self.list_on_demand_scan_protocols(opts = {})

def self.list_on_demand_scan_protocols(opts = {})
i_key].to_s.scrub
i_key }
,
an/protocols',
 => e

def self.most_popular_tags(opts = {})

def self.most_popular_tags(opts = {})
i_key].to_s.scrub
s[:result_count].to_i
ount
api_key }
,
an/query/tags',
 => e

def self.my_profile(opts = {})

def self.my_profile(opts = {})
i_key].to_s.scrub
i_key }
,
unt/profile',
 => e

def self.my_pub_ip(opts = {})

def self.my_pub_ip(opts = {})
i_key].to_s.scrub
i_key }
,
s/myip',
 => e

def self.ports_shodan_crawls(opts = {})

def self.ports_shodan_crawls(opts = {})
i_key].to_s.scrub
i_key }
,
an/ports',
 => e

def self.query_result_totals(opts = {})

def self.query_result_totals(opts = {})
i_key].to_s.scrub
y].to_s.scrub
ets].to_s.scrub

,
an/host/count',
 => e

def self.saved_search_queries(opts = {})

def self.saved_search_queries(opts = {})
i_key].to_s.scrub
.to_i
.to_sym
r].to_sym

s
,
an/query',
 => e

def self.scan_internet(opts = {})

def self.scan_internet(opts = {})
i_key].to_s.scrub
.to_i
rotocol].to_s.scrub
i_key }
#{port}&protocol=#{protocol}"
st,
,
an/scan/internet',
body
 => e

def self.scan_network(opts = {})

def self.scan_network(opts = {})
i_key].to_s.scrub
:target_ips].to_s.scrub.gsub(/\s/, '')
i_key }
{target_ips}"
st,
,
an/scan',
body
 => e

def self.scan_status(opts = {})

def self.scan_status(opts = {})
i_key].to_s.scrub
an_id].to_s.scrub
,
an/scan/status/#{scan_id}",
 => e

def self.search(opts = {})

def self.search(opts = {})
i_key].to_s.scrub
y].to_s.scrub
ets].to_s.scrub

,
an/host/search',
 => e

def self.services_by_ips(opts = {})

def self.services_by_ips(opts = {})
i_key].to_s.scrub
:target_ips].to_s.scrub.gsub(/\s/, '').split(',')
[]
i_key }
 |target_ip|
n_rest_call(
ey,
odan/host/#{target_ip}",

push(response)
or => e
push(error: e.message)
 => e

def self.services_shodan_crawls(opts = {})

def self.services_shodan_crawls(opts = {})
i_key].to_s.scrub
i_key }
,
an/services',
 => e

def self.shodan_rest_call(opts = {})

def self.shodan_rest_call(opts = {})
shodan_obj]
ts[:http_method].nil?
t
s[:http_method].to_s.scrub.to_sym
est_call].to_s.scrub
ms]
ttp_body].to_s.scrub
 = 'https://api.shodan.io'
_key]
Plugins::TransparentBrowser.open(browser_type: :rest)
er_obj[:browser]::Request
lient.execute(
odan_api_uri}/#{rest_call}",
 'application/json; charset=UTF-8',
s
se
lient.execute(
odan_api_uri}/#{rest_call}",
 'application/json; charset=UTF-8',
s
ody,
se
ror("Unsupported HTTP Method #{http_method} for #{self} Plugin")
.scrub, symbolize_names: true)
ror => e
serError #{e.message}",
all,
oManyRequests
uests.  Sleeping 10s...'
=> e
st', '404 Resource Not Found'
e.response}"

def self.tokens(opts = {})

def self.tokens(opts = {})
i_key].to_s.scrub
y].to_s.scrub
,
an/host/search/tokens',
 => e

def self.valid_uri?(opts = {})

def self.valid_uri?(opts = {})
s[:uri].to_s)
ude?(uri.scheme)
or,
IError,
mponentError
=> e