(query_str)
| 42 | |
| 43 | |
| 44 | def query(query_str): |
| 45 | fofa_web_host_port = [] # 存放开放web服务器的ip/domain和port,用来后面的cms识别 |
| 46 | fofa_service_host_port = [] # 存放非Web服务器的ip/domain和port,用来后面的未授权漏洞检测 |
| 47 | |
| 48 | qbase64 = str(base64.b64encode(query_str.encode(encoding='utf-8')), 'utf-8') |
| 49 | url = r'https://fofa.so/api/v1/search/all?email={}&key={}&qbase64={}&size={}&page={}&fields=host,title,ip,domain,port,server,protocol,city'.format(email, key, qbase64, size, page) |
| 50 | try: |
| 51 | ret = json.loads(requests.get(url=url, headers=headers, timeout=10, verify=False).text) |
| 52 | fofa_Results = ret['results'] |
| 53 | for result in fofa_Results: |
| 54 | isWeb, host_port = filter_web(result) |
| 55 | if isWeb: |
| 56 | fofa_web_host_port.append(host_port) |
| 57 | else: |
| 58 | fofa_service_host_port.append(host_port) |
| 59 | return fofa_Results, fofa_web_host_port, fofa_service_host_port |
| 60 | |
| 61 | except Exception as e: |
| 62 | print('[error] fofa 查询 {} : {}'.format(query_str, e.args)) |
| 63 | return [], [], [] |
| 64 |
no test coverage detected