new: Download embedded resource

pull/78/head
Raphaël Vinot 2020-07-11 02:10:56 +02:00
parent e5e4e4972e
commit 89725b8ed0
3 changed files with 25 additions and 3 deletions

View File

@ -781,10 +781,10 @@ class Lookyloo():
if h in to_append['embedded_ressources']:
# Skip duplicates
continue
freq = self.indexing.body_hash_fequency(h)
to_append['embedded_ressources'][h] = freq
freq_embedded = self.indexing.body_hash_fequency(h)
to_append['embedded_ressources'][h] = freq_embedded
to_append['embedded_ressources'][h]['type'] = mimetype
if freq['hash_freq'] > 1:
if freq_embedded['hash_freq'] > 1:
to_append['embedded_ressources'][h]['other_captures'] = self.hash_lookup(h, url.name, capture_uuid)
if hasattr(self, 'sanejs') and self.sanejs.available:
to_lookup = list(to_append['embedded_ressources'].keys())

View File

@ -227,6 +227,21 @@ def urlnode_post_request(tree_uuid: str, node_uuid: str):
as_attachment=True, attachment_filename='posted_data.txt')
@app.route('/tree/<string:tree_uuid>/url/<string:node_uuid>/embedded_ressource', methods=['POST'])
def get_embedded_ressource(tree_uuid: str, node_uuid: str):
url = lookyloo.get_urlnode_from_tree(tree_uuid, node_uuid)
h_request = request.form.get('ressource_hash')
for mimetype, blobs in url.embedded_ressources.items():
for h, blob in blobs:
if h == h_request:
to_return = BytesIO()
with ZipFile(to_return, 'w', ZIP_DEFLATED) as zfile:
zfile.writestr('file.bin', blob.getvalue())
to_return.seek(0)
return send_file(to_return, mimetype='application/zip',
as_attachment=True, attachment_filename='file.zip')
@app.route('/tree/<string:tree_uuid>/url/<string:node_uuid>', methods=['GET'])
def urlnode_details(tree_uuid: str, node_uuid: str):
urlnode = lookyloo.get_urlnode_from_tree(tree_uuid, node_uuid)

View File

@ -124,6 +124,7 @@
across all the captures on this lookyloo instance, in <b>{{ url['body_hash_details']['hash_domains_freq'] }}</b> unique domains.
</br>
{% if 'other_captures' in url['body_hash_details'] %}
{% set total_captures = url['body_hash_details']['other_captures']['different_url']|length + url['body_hash_details']['other_captures']['same_url']|length %}
{% if total_captures > 0 %}
@ -169,6 +170,7 @@
<p><a href="{{ url_for('body_hash_details', body_hash=url['url_object'].body_hash) }}">
Show more information about this response body.
</a></p>
{% endif %}
<div>
{% endif %}
@ -196,8 +198,12 @@
<div>
This file (<b>{{ details['type'] }}</b>) can be found <b>{{ details['hash_freq'] }}</b> times
across all the captures on this lookyloo instance, in <b>{{ details['hash_domains_freq'] }}</b> unique domains.
<form method="post" action="{{ url_for('get_embedded_ressource', tree_uuid=tree_uuid, node_uuid=url['url_object'].uuid) }}">
<button class="btn btn-primary" name="ressource_hash" value="{{ hash }}">Download the embedded ressource</button>
</form>
</br>
{% if 'other_captures' in details %}
{% set total_captures = details['other_captures']['different_url']|length + details['other_captures']['same_url']|length %}
{% if total_captures > 0 %}
@ -243,6 +249,7 @@
<p><a href="{{ url_for('body_hash_details', body_hash=url['url_object'].body_hash) }}">
Show more information about this embedded content.
</a></p>
{% endif %}
<div>
{% endfor %}
</div>