mirror of https://github.com/CIRCL/lookyloo
chg: Remove extra code, return unziped resources
parent
e79387ee0d
commit
4d23d7ac36
|
@ -82,12 +82,11 @@ class Lookyloo():
|
||||||
self.logger.warning('Unable to setup the MISP module')
|
self.logger.warning('Unable to setup the MISP module')
|
||||||
|
|
||||||
self.context = Context(self.sanejs)
|
self.context = Context(self.sanejs)
|
||||||
|
self._captures_index: Dict[str, CaptureCache] = {}
|
||||||
|
|
||||||
if not self.redis.exists('cache_loaded'):
|
if not self.redis.exists('cache_loaded'):
|
||||||
self._init_existing_dumps()
|
self._init_existing_dumps()
|
||||||
|
|
||||||
self._captures_index: Dict[str, CaptureCache] = {}
|
|
||||||
|
|
||||||
def cache_user_agents(self, user_agent: str, remote_ip: str) -> None:
|
def cache_user_agents(self, user_agent: str, remote_ip: str) -> None:
|
||||||
'''Cache the useragents of the visitors'''
|
'''Cache the useragents of the visitors'''
|
||||||
today = date.today().isoformat()
|
today = date.today().isoformat()
|
||||||
|
@ -1092,14 +1091,6 @@ class Lookyloo():
|
||||||
if not hostnode:
|
if not hostnode:
|
||||||
raise MissingUUID(f'Unable to find UUID {node_uuid} in {node_uuid}')
|
raise MissingUUID(f'Unable to find UUID {node_uuid} in {node_uuid}')
|
||||||
|
|
||||||
cnames_path = ct.root_hartree.har.path.parent / 'cnames.json'
|
|
||||||
if cnames_path.exists():
|
|
||||||
with cnames_path.open() as f:
|
|
||||||
host_cnames = json.load(f)
|
|
||||||
cnames = self._build_cname_chain(host_cnames, hostnode.name)
|
|
||||||
if cnames:
|
|
||||||
hostnode.add_feature('cname', cnames)
|
|
||||||
|
|
||||||
known_content = self.context.find_known_content(hostnode)
|
known_content = self.context.find_known_content(hostnode)
|
||||||
|
|
||||||
urls: List[Dict[str, Any]] = []
|
urls: List[Dict[str, Any]] = []
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
import base64
|
import base64
|
||||||
from zipfile import ZipFile, ZIP_DEFLATED
|
|
||||||
from io import BytesIO, StringIO
|
from io import BytesIO, StringIO
|
||||||
import os
|
import os
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
@ -810,16 +809,17 @@ def get_ressource(tree_uuid: str, node_uuid: str):
|
||||||
else:
|
else:
|
||||||
h_request = None
|
h_request = None
|
||||||
ressource = lookyloo.get_ressource(tree_uuid, node_uuid, h_request)
|
ressource = lookyloo.get_ressource(tree_uuid, node_uuid, h_request)
|
||||||
to_return = BytesIO()
|
if ressource:
|
||||||
with ZipFile(to_return, 'w', ZIP_DEFLATED) as zfile:
|
filename, to_return, mimetype = ressource
|
||||||
if ressource:
|
if not mimetype.startswith('image'):
|
||||||
filename, r, mimetype = ressource
|
# Force a .txt extension
|
||||||
zfile.writestr(filename, r.getvalue())
|
filename += '.txt'
|
||||||
else:
|
else:
|
||||||
zfile.writestr('file.txt', b'Unknown Hash')
|
to_return = BytesIO(b'Unknown Hash')
|
||||||
|
filename = 'file.txt'
|
||||||
|
mimetype = 'text/text'
|
||||||
to_return.seek(0)
|
to_return.seek(0)
|
||||||
return send_file(to_return, mimetype='application/zip',
|
return send_file(to_return, mimetype=mimetype, as_attachment=True, attachment_filename=filename)
|
||||||
as_attachment=True, attachment_filename='file.zip')
|
|
||||||
|
|
||||||
|
|
||||||
@app.route('/tree/<string:tree_uuid>/url/<string:node_uuid>/ressource_preview', methods=['GET'])
|
@app.route('/tree/<string:tree_uuid>/url/<string:node_uuid>/ressource_preview', methods=['GET'])
|
||||||
|
|
Loading…
Reference in New Issue