本文整理汇总了Python中shodan.WebAPI.createAndAddHost方法的典型用法代码示例。如果您正苦于以下问题:Python WebAPI.createAndAddHost方法的具体用法?Python WebAPI.createAndAddHost怎么用?Python WebAPI.createAndAddHost使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类shodan.WebAPI
的用法示例。
在下文中一共展示了WebAPI.createAndAddHost方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: WebAPI
# 需要导入模块: from shodan import WebAPI [as 别名]
# 或者: from shodan.WebAPI import createAndAddHost [as 别名]
import xmlrpclib
SHODAN_API_KEY = "insert your API key here"
api = WebAPI(SHODAN_API_KEY)
# Wrap the request in a try/ except block to catch errors
try:
# Search Shodan
print "Search Shodan"
results = api.search('apache')
#Connect to faraday
print "Connecting Farday"
api = xmlrpclib.ServerProxy("http://127.0.0.1:9876/")
# Show the results
print 'Results found: %s' % results['total']
for result in results['matches']:
if "ip" in result:
print 'IP: %s' % result['ip']
print result['data']
print ''
h_id = api.createAndAddHost(result['ip'],result['os'] if result['os'] is not None else "")
i_id = api.createAndAddInterface(h_id,result['ip'],"00:00:00:00:00:00", result['ip'], "0.0.0.0", "0.0.0.0",[],
"0000:0000:0000:0000:0000:0000:0000:0000","00","0000:0000:0000:0000:0000:0000:0000:0000",
[],"",result['hostnames'] if result['hostnames'] is not None else [])
s_id = api.createAndAddServiceToInterface(h_id, i_id, "www",
"tcp",str(result['port']),"open","Apache",result['data'])
except Exception, e:
print 'Error: %s' % e