本文整理匯總了Python中shodan.WebAPI.createAndAddInterface方法的典型用法代碼示例。如果您正苦於以下問題:Python WebAPI.createAndAddInterface方法的具體用法?Python WebAPI.createAndAddInterface怎麽用?Python WebAPI.createAndAddInterface使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類shodan.WebAPI
的用法示例。
在下文中一共展示了WebAPI.createAndAddInterface方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: WebAPI
# 需要導入模塊: from shodan import WebAPI [as 別名]
# 或者: from shodan.WebAPI import createAndAddInterface [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