mirror of https://github.com/CIRCL/lookyloo
new: API to query hostnames
parent
4dae7a447f
commit
068c92d5a4
|
@ -704,7 +704,7 @@ class Lookyloo():
|
||||||
to_return[capture_uuid]['urlnodes'][urlnode.uuid]['hash'] = urlnode.body_hash
|
to_return[capture_uuid]['urlnodes'][urlnode.uuid]['hash'] = urlnode.body_hash
|
||||||
return to_return
|
return to_return
|
||||||
|
|
||||||
def get_hostname_occurrences(self, hostname: str):
|
def get_hostname_occurrences(self, hostname: str, with_urls_occurrences: bool=False):
|
||||||
capture_uuids = self.indexing.get_captures_hostname(hostname)
|
capture_uuids = self.indexing.get_captures_hostname(hostname)
|
||||||
to_return: Dict[str, Dict] = {cuuid: {} for cuuid in capture_uuids}
|
to_return: Dict[str, Dict] = {cuuid: {} for cuuid in capture_uuids}
|
||||||
for capture_uuid in capture_uuids:
|
for capture_uuid in capture_uuids:
|
||||||
|
@ -716,7 +716,17 @@ class Lookyloo():
|
||||||
if not ct:
|
if not ct:
|
||||||
raise MissingUUID(f'Unable to find {capture_dir}')
|
raise MissingUUID(f'Unable to find {capture_dir}')
|
||||||
to_return[capture_uuid]['start_timestamp'] = ct.root_hartree.start_time.isoformat()
|
to_return[capture_uuid]['start_timestamp'] = ct.root_hartree.start_time.isoformat()
|
||||||
to_return[capture_uuid]['hostnodes'] = [hn.uuid for hn in ct.root_hartree.hostname_tree.search_node(name=hostname)]
|
to_return[capture_uuid]['hostnodes'] = []
|
||||||
|
for hostnode in ct.root_hartree.hostname_tree.search_nodes(name=hostname):
|
||||||
|
to_return[capture_uuid]['hostnodes'].append(hostnode.uuid)
|
||||||
|
if with_urls_occurrences:
|
||||||
|
to_return[capture_uuid]['urlnodes'] = {}
|
||||||
|
for urlnode in hostnode.urls:
|
||||||
|
to_return[capture_uuid]['urlnodes'][urlnode.uuid] = {'start_time': urlnode.start_time.isoformat(),
|
||||||
|
'url': urlnode.name,
|
||||||
|
'hostnode_uuid': urlnode.hostnode_uuid}
|
||||||
|
if hasattr(urlnode, 'body_hash'):
|
||||||
|
to_return[capture_uuid]['urlnodes'][urlnode.uuid]['hash'] = urlnode.body_hash
|
||||||
return to_return
|
return to_return
|
||||||
|
|
||||||
def get_cookie_name_investigator(self, cookie_name: str):
|
def get_cookie_name_investigator(self, cookie_name: str):
|
||||||
|
|
|
@ -615,5 +615,12 @@ def json_hash_info(h: str):
|
||||||
@app.route('/json/url_info', methods=['POST'])
|
@app.route('/json/url_info', methods=['POST'])
|
||||||
def json_url_info():
|
def json_url_info():
|
||||||
to_query = request.get_json(force=True)
|
to_query = request.get_json(force=True)
|
||||||
occrrences = lookyloo.get_url_occurrences(to_query['url'])
|
occurrences = lookyloo.get_url_occurrences(**to_query)
|
||||||
return jsonify(occrrences)
|
return jsonify(occurrences)
|
||||||
|
|
||||||
|
|
||||||
|
@app.route('/json/hostname_info', methods=['POST'])
|
||||||
|
def json_hostname_info():
|
||||||
|
to_query = request.get_json(force=True)
|
||||||
|
occurrences = lookyloo.get_hostname_occurrences(**to_query)
|
||||||
|
return jsonify(occurrences)
|
||||||
|
|
Loading…
Reference in New Issue