mirror of https://github.com/CIRCL/lookyloo
new: Show preview of embeded ressources if it is an image.
parent
f32fd8f3c4
commit
b91bbe5f07
|
@ -753,20 +753,17 @@ def get_ressource(tree_uuid: str, node_uuid: str):
|
||||||
as_attachment=True, attachment_filename='file.zip')
|
as_attachment=True, attachment_filename='file.zip')
|
||||||
|
|
||||||
|
|
||||||
@app.route('/tree/<string:tree_uuid>/url/<string:node_uuid>/ressource_preview', methods=['POST', 'GET'])
|
@app.route('/tree/<string:tree_uuid>/url/<string:node_uuid>/ressource_preview', methods=['GET'])
|
||||||
def get_ressource_preview(tree_uuid: str, node_uuid: str):
|
@app.route('/tree/<string:tree_uuid>/url/<string:node_uuid>/ressource_preview/<string:h_ressource>', methods=['GET'])
|
||||||
if request.method == 'POST':
|
def get_ressource_preview(tree_uuid: str, node_uuid: str, h_ressource: Optional[str]=None):
|
||||||
h_request = request.form.get('ressource_hash')
|
ressource = lookyloo.get_ressource(tree_uuid, node_uuid, h_ressource)
|
||||||
else:
|
|
||||||
h_request = None
|
|
||||||
ressource = lookyloo.get_ressource(tree_uuid, node_uuid, h_request)
|
|
||||||
if not ressource:
|
if not ressource:
|
||||||
return None
|
return Response('No preview available.', mimetype='text/text')
|
||||||
filename, r, mimetype = ressource
|
filename, r, mimetype = ressource
|
||||||
if mimetype.startswith('image'):
|
if mimetype.startswith('image'):
|
||||||
return send_file(r, mimetype=mimetype,
|
return send_file(r, mimetype=mimetype,
|
||||||
as_attachment=True, attachment_filename=filename)
|
as_attachment=True, attachment_filename=filename)
|
||||||
return None
|
return Response('No preview available.', mimetype='text/text')
|
||||||
|
|
||||||
|
|
||||||
@app.route('/tree/<string:tree_uuid>/url/<string:node_uuid>/hashes', methods=['GET'])
|
@app.route('/tree/<string:tree_uuid>/url/<string:node_uuid>/hashes', methods=['GET'])
|
||||||
|
|
|
@ -218,14 +218,18 @@
|
||||||
<div class="collapse" id="embedded_full_list_{{ url['url_object'].uuid }}">
|
<div class="collapse" id="embedded_full_list_{{ url['url_object'].uuid }}">
|
||||||
<div class="card card-body">
|
<div class="card card-body">
|
||||||
{% for hash, details in url['embedded_ressources'].items() %}
|
{% for hash, details in url['embedded_ressources'].items() %}
|
||||||
|
<div>
|
||||||
{% if details['known_content'] %}
|
{% if details['known_content'] %}
|
||||||
{{ known_content_details(details['known_content']) }}
|
{{ known_content_details(details['known_content']) }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{{ ressource_legitimacy_details(details['legitimacy'], details['body_size']) }}
|
{{ ressource_legitimacy_details(details['legitimacy'], details['body_size']) }}
|
||||||
|
</div>
|
||||||
<div>
|
<div>
|
||||||
This file {% if details['type'] %}(<b>{{ details['type'] }}</b>){% endif %} can be found <b>{{ details['hash_freq'] }}</b> times
|
This file {% if details['type'] %}(<b>{{ details['type'] }}</b>){% endif %} 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.
|
across all the captures on this lookyloo instance, in <b>{{ details['hash_domains_freq'] }}</b> unique domains.
|
||||||
{{ get_ressource_button(tree_uuid, url['url_object'].uuid, hash, 'Download the embedded ressource') }}
|
{{ get_ressource_button(tree_uuid, url['url_object'].uuid, hash,
|
||||||
|
'Download the embedded ressource',
|
||||||
|
details['type'] and details['type'].startswith('image')) }}
|
||||||
</br>
|
</br>
|
||||||
{% if enable_context_by_users %}
|
{% if enable_context_by_users %}
|
||||||
{{ context_form(tree_uuid, url['url_object'].uuid, hostnode_uuid, hash, 'hostnode_popup') }}
|
{{ context_form(tree_uuid, url['url_object'].uuid, hostnode_uuid, hash, 'hostnode_popup') }}
|
||||||
|
|
|
@ -119,9 +119,14 @@
|
||||||
</div>
|
</div>
|
||||||
{% endmacro %}
|
{% endmacro %}
|
||||||
|
|
||||||
{% macro get_ressource_button(capture_uuid, urlnode_uuid, hash, text) %}
|
{% macro get_ressource_button(capture_uuid, urlnode_uuid, hash, text, can_preview=False) %}
|
||||||
<form method="post" action="{{ url_for('get_ressource', tree_uuid=capture_uuid, node_uuid=urlnode_uuid) }}">
|
<form method="post" action="{{ url_for('get_ressource', tree_uuid=capture_uuid, node_uuid=urlnode_uuid) }}">
|
||||||
<button class="btn btn-info" name="ressource_hash" value="{{ hash }}">{{ text }}</button>
|
<button class="btn btn-info" name="ressource_hash" value="{{ hash }}"
|
||||||
|
{% if can_preview %}
|
||||||
|
data-toggle="tooltip" data-placement="bottom" data-html="true"
|
||||||
|
title='<img src="{{ url_for('get_ressource_preview', tree_uuid=capture_uuid, node_uuid=urlnode_uuid, h_ressource=hash) }}"/>'
|
||||||
|
{% endif %}
|
||||||
|
>{{ text }}</button>
|
||||||
</form>
|
</form>
|
||||||
{% endmacro %}
|
{% endmacro %}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue