本文整理汇总了Python中shodan.WebAPI方法的典型用法代码示例。如果您正苦于以下问题:Python shodan.WebAPI方法的具体用法?Python shodan.WebAPI怎么用?Python shodan.WebAPI使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类shodan
的用法示例。
在下文中一共展示了shodan.WebAPI方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: import shodan [as 别名]
# 或者: from shodan import WebAPI [as 别名]
def __init__(self, host):
self.host = host
self.key = "oCiMsgM6rQWqiTvPxFHYcExlZgg7wvTt"
if self.key == "":
print "You need an API key in order to use SHODAN database. You can get one here: http://www.shodanhq.com/"
sys.exit()
self.api = WebAPI(self.key)
示例2: __init__
# 需要导入模块: import shodan [as 别名]
# 或者: from shodan import WebAPI [as 别名]
def __init__(self,host):
self.host=host
self.shodan_api_key = "oykKBEq2KRySU33OxizNkOir5PgHpMLv"
if self.shodan_api_key =="":
print "You need an API key in order to use SHODAN database. You can get one here: http://www.shodanhq.com/"
sys.exit()
self.api = WebAPI(self.shodan_api_key)
示例3: run
# 需要导入模块: import shodan [as 别名]
# 或者: from shodan import WebAPI [as 别名]
def run(self, info):
# This is where we'll collect the data we'll return.
results = []
# Skip unsupported IP addresses.
if info.version != 4:
return
ip = info.address
parsed = netaddr.IPAddress(ip)
if parsed.is_loopback() or \
parsed.is_private() or \
parsed.is_link_local():
return
# Query Shodan for this host.
try:
key = self.get_api_key()
api = WebAPI(key)
shodan = api.host(ip)
except Exception, e:
tb = traceback.format_exc()
Logger.log_error("Error querying Shodan for host %s: %s" % (ip, str(e)))
Logger.log_error_more_verbose(tb)
return
# Make sure we got the same IP address we asked for.