def fofa_api(): # TODO 付费获取结果的功能实现 """ Get query result from Fofa :param query: query string :param limit: query amount :param offset: start page :return: query result """ global email, key # load query, limit, offset from cmd_opts query = cmd_opts.query limit = cmd_opts.limit offset = cmd_opts.offset # 从配置文件中读取email和key try: email = read_conf(path.config, 'fofa', 'email') key = read_conf(path.config, 'fofa', 'key') print('{} - {}'.format(email, key)) if check(email, key): pass else: raise # will go to except block # 读取手工输入的email和key except: warning('Automatic authorization failed.') email = input("Fofa Email: ").strip() key = input("Fofa Key: ").strip() if not check(email, key): error( 'Fofa API authorization failed, Please re-run it and enter a valid key.' ) exit() query = base64.b64encode(query) request = "https://fofa.so/api/v1/search/all?email={0}&key={1}&qbase64={2}".format( email, key, query) global result try: response = requests.get(request, timeout=3) resp = response.readlines()[0] resp = json.loads(resp) if resp["error"] is None: for item in resp.get('results'): result.append(item[0]) if resp.get('size') >= 100: info("{0} items found! just 100 returned....".format( resp.get('size'))) except: sys.exit() finally: return result
def init_zoomeye(): """ 初始化zoomeye, 读取配置文件 :return: None """ global access_token, email, password email = read_conf(path.config, 'zoomeye', 'email') password = read_conf(path.config, 'zoomeye', 'password') # 输出读取的配置文件信息 # info('zoomeye infomation \nemail : {} \npassword : {}\n'.format(email, password)) pass
def init_censys(): """ Init censys, read UID and SECRET from config file :return: """ global UID, SECRET # email = read_conf(path.config, 'zoomeye', 'email') UID = read_conf(path.config, 'censys', 'UID') SECRET = read_conf(path.config, 'censys', 'SECRET') if UID and SECRET: info('UID : {} SECRET:{}'.format(UID, SECRET)) else: warning( 'please refer to this url : {} and fill in UID and SECRET'.format( 'https://www.censys.io/account/api'))
def init_shodan(): """ Init Shodan, read config file to fetch API_KEY 从配置文件中获取API_KEY :return: None """ global API_KEY, api API_KEY = read_conf(path.config, 'shodan', 'api_key') if API_KEY: info(API_KEY) else: API_KEY = input('please input API_KEY') api = shodan.Shodan(API_KEY) # init