首页 > 代码库 > zabbix批量检测以及zoomeye搜索
zabbix批量检测以及zoomeye搜索
zabbix批量检测
0x11 利用zoomeye批量获取IP
zoomeye开放了API之后一直想用它批量一次,这次zabbix爆出来之后,闲的没事就找了一个批量拿IP的zoomeye脚本,现在分享出来.
1 #coding: utf-8 2 ‘‘‘ 3 author : xnianq 4 date : 2016-08-25 5 ‘‘‘ 6 import os 7 import requests 8 import json 9 access_token=‘‘10 ip_list=[]11 def login():12 """13 输入帐号密码,进行登录操作14 :return: 访问口令 access_token15 """16 user = raw_input(‘[-] input : username :‘)17 passwd = raw_input(‘[-] input : passwd :‘)18 data =http://www.mamicode.com/ {19 ‘username‘ : user,20 ‘password‘ : passwd21 }22 data_encoded = json.dumps(data)23 try:24 r = requests.post(url="https://api.zoomeye.org/user/login",data=http://www.mamicode.com/data_encoded)25 r_decode = json.loads(r.text)26 global access_token27 access_token = r_decode[‘access_token‘]28 except Exception,e:29 print ‘[-] info : username or password seems wrong,please try again .‘30 exit()31 def saveStrToFile(file,str):32 """33 将字符串写入文本中34 :param file:35 :param str:36 :return:37 """38 with open(file,‘w‘) as output:39 output.write(str)40 def saveListToFile(file,list):41 """42 将列表逐行写入文件中43 :param file:44 :param list:45 :return:46 """47 s = ‘\n‘.join(list)48 with open(file,‘w‘) as output:49 output.write(s)50 def apiTest():51 """52 进行Api测试53 :return:54 """55 page = 156 global access_token57 with open(‘access_token.txt‘,‘r‘) as input:58 access_token = input.read()59 headers = {60 ‘Authorization‘ : ‘JWT ‘ + access_token,61 }62 while(True):63 try:64 r = requests.get(url = ‘https://api.zoomeye.org/host/search?query=“zabbix”&page=‘+str(page),headers=headers)65 r_decoded = json.loads(r.text)66 for x in r_decoded[‘matches‘]:67 print x[‘ip‘]68 ip_list.append(x[‘ip‘])69 print ‘[-] info : count ‘ + str(page*10)70 except Exception,e:71 if str(e.message) == ‘matches‘:72 print ‘[-] info : account was break ,excceeding the max limitations‘73 break74 else:75 print ‘[-] info :‘ + str(e.message)76 else:77 if page == 100 :78 break79 page +=180 def main():81 if not os.path.isfile(‘access_token.txt‘):82 print ‘[-] info : access_toke is not exists,please login‘83 login()84 saveStrToFile(‘access_token.txt‘,access_token)85 apiTest()86 saveListToFile(‘ip_list.txt‘,ip_list)87 if __name__ == ‘__main__‘:88 main()
zabbix批量检测以及zoomeye搜索
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。