Skip to content

Commit

Permalink
new ZoomEye API
Browse files Browse the repository at this point in the history
  • Loading branch information
Xyntax committed Jul 12, 2016
1 parent 3f098f1 commit 45034ac
Show file tree
Hide file tree
Showing 15 changed files with 289 additions and 621 deletions.
14 changes: 14 additions & 0 deletions lib/api/censys/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# !/usr/bin/env python
# -*- coding: utf-8 -*-
__author__ = 'xy'

import censys.certificates

UID = "login for API key"
SECRET = "login for API secret"

certificates = censys.certificates.CensysCertificates(UID, SECRET)
fields = ["parsed.subject_dn", "parsed.fingerprint_sha256", "parsed.fingerprint_sha1"]

for c in certificates.search("current_valid_nss: true"):
print c["parsed.subject_dn"]
2 changes: 1 addition & 1 deletion lib/api/shodan/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def _initial():
api_path = os.path.join(os.path.expanduser('~'), '.shodan-api-key')
if not os.path.isfile(api_path):
with open(api_path, 'w') as fp:
fp.write(raw_input('[-] First time using Shodan-api, please input your API-KEY > '))
fp.write(raw_input('[-] First time using Shodan-API, please input your API-KEY > '))
API_KEY = open(api_path).read().strip()
return shodan.Shodan(API_KEY)

Expand Down
16 changes: 0 additions & 16 deletions lib/api/zoomeye/rcGen.py

This file was deleted.

61 changes: 61 additions & 0 deletions lib/api/zoomeye/search.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import os
import sys
from lib.api.zoomeye.zoomeye import ZoomEye
from lib.core.data import logger
from lib.core.log import CUSTOM_LOGGING
from lib.core.enums import EXIT_STATUS


def _initial():
z = ZoomEye()
token_path = os.path.join(os.path.expanduser('~'), '.zoomeye-token')
if not os.path.isfile(token_path):
msg = 'ZoomEye API authorization failed, Please input ZoomEye Email and Password.'
logger.log(CUSTOM_LOGGING.SUCCESS, msg)
token = z.login()
if token:
open(token_path, 'w').write(token)
msg = 'Save ZoomEye access token to: ' + token_path
logger.log(CUSTOM_LOGGING.SUCCESS, msg)
else:
msg = 'Invalid ZoomEye username or password.'
logger.log(CUSTOM_LOGGING.ERROR, msg)
sys.exit(EXIT_STATUS.ERROR_EXIT)

else:
msg = 'Load ZoomEye access token from: ' + token_path
logger.log(CUSTOM_LOGGING.SUCCESS, msg)
z.setToken(open(token_path).read())

info = z.resources_info()['resources']

if info:
logger.log(CUSTOM_LOGGING.SUCCESS, msg)
msg = 'Available ZoomEye search, web-search:{}, host-search:{}'.format(info['web-search'], info['host-search'])
logger.log(CUSTOM_LOGGING.SYSINFO, msg)
else:
os.remove(token_path)
msg = 'ZoomEye API authorization failed, Please re-run it and enter a new token.'
logger.log(CUSTOM_LOGGING.ERROR, msg)
sys.exit(EXIT_STATUS.ERROR_EXIT)

return z


def dorkSearch(query, type='host', page=1):
z = _initial()
ans = []
for page_n in range(page):
data = z.dork_search(query, resource=type, page=page_n)
if data:
for i in data:
ip_str = i.get('ip')
if i.has_key('portinfo'):
ip_str = ip_str + ':' + str(i.get('portinfo').get('port'))
ans.append(ip_str)
else:
break
return ans
112 changes: 0 additions & 112 deletions lib/api/zoomeye/x.py

This file was deleted.

Loading

0 comments on commit 45034ac

Please sign in to comment.