MCPcopy
hub / github.com/knownsec/pocsuite3 / search

Method search

pocsuite3/modules/fofa/__init__.py:68–102  ·  view source on GitHub ↗
(self, dork, pages=1, resource='host')

Source from the content-addressed store, hash-verified

66 logger.error(str(ex))
67
68 def search(self, dork, pages=1, resource='host'):
69 if resource == 'host':
70 resource = 'protocol,ip,port'
71 else:
72 resource = 'protocol,host'
73
74 dork = b64encode(dork.encode()).decode()
75 search_result = set()
76
77 try:
78 for page in range(1, pages + 1):
79 time.sleep(1)
80 url = (
81 f"{self.api_url}/search/all?email={self.user}&key={self.token}&qbase64={dork}&"
82 f"fields={resource}&page={page}"
83 )
84 resp = requests.get(url, headers=self.headers, timeout=60)
85 if resp and resp.status_code == 200 and "results" in resp.json():
86 content = resp.json()
87 for match in content['results']:
88 if resource == "protocol,ip,port":
89 ip = match[1]
90 if is_ipv6_address_format(ip):
91 ip = f'[{ip}]'
92 search_result.add("%s://%s:%s" % (match[0], ip, match[2]))
93 else:
94 if '://' not in match[1]:
95 search_result.add("%s://%s" % (match[0], match[1]))
96 else:
97 search_result.add(match[1])
98 else:
99 logger.error("[PLUGIN] Fofa:{}".format(resp.text))
100 except Exception as ex:
101 logger.error(str(ex))
102 return search_result
103
104
105if __name__ == "__main__":

Callers 15

__init__.pyFile · 0.45
urlparseFunction · 0.45
command_searchMethod · 0.45
_set_network_proxyFunction · 0.45
_set_pocs_modulesFunction · 0.45
exec_moduleMethod · 0.45
urlparseFunction · 0.45
extract_regex_resultFunction · 0.45
get_poc_nameFunction · 0.45
get_optionMethod · 0.45
get_revision_numberFunction · 0.45
extract_regexFunction · 0.45

Calls 5

is_ipv6_address_formatFunction · 0.90
errorMethod · 0.80
decodeMethod · 0.45
encodeMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected