Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def api_test():
'''
get verified with zoomeye
'''
amnt = int(
console.input_check(
"[*] How many results do you want? (10 IPs on each page) ",
check_type=int).strip())
threads = []
api = ZoomEyeAPI('zoomeye.conf')
access_token = api.login()
headers = {
'Authorization': 'JWT ' + access_token,
}
status = threading.Thread(target=progress, args=(ZoomEyeAPI.OUTFILE,))
status.setDaemon(True)
status.start()
limit = 0
for page in range(1, int(amnt / 10)):
thd = threading.Thread(
target=crawler, args=(ZoomEyeAPI.QRY, amnt, page, headers,))
threads.append(thd)
for job in threads:
job.setDaemon(True)
job.start()
if limit == 0 or limit == 10:
limit = 0
job.join()
limit += 1
'''
put things together
'''
try:
api_test()
except (EOFError, KeyboardInterrupt, SystemExit):
pass
else:
console.print_error('[-] Error with api_test')
debug_traceback()
if __name__ == '__main__':
try:
ZoomEyeAPI.QRY = console.input_check(
"[*] Your query is: ", allow_blank=False)
ZoomEyeAPI.OUTFILE = '../data/zoomeye-{}.txt'.format(
'-'.join(ZoomEyeAPI.QRY.replace(':', '_').split()))
main()
except KeyboardInterrupt:
print('\n[*] Exiting...')
else:
debug_traceback()
def crawler(qery, _, page, headers):
'''
fetch result from zoomeye
'''
try:
r_get = requests.get(
url='https://api.zoomeye.org/host/search?query=' +
qery +
'&facet=app,os&page=' +
str(page),
headers=headers)
r_decoded = json.loads(r_get.text)
for item in r_decoded['matches']:
save_str_to_file(ZoomEyeAPI.OUTFILE, item['ip'])
except BaseException:
pass