fix: body hash page on direct access

pull/199/head
Raphaël Vinot 2021-04-20 17:32:17 +02:00
parent 9952e4de32
commit 39e894b7b0
4 changed files with 20 additions and 5 deletions

View File

@ -991,7 +991,11 @@ class Lookyloo():
def get_ressource(self, tree_uuid: str, urlnode_uuid: str, h: Optional[str]) -> Optional[Tuple[str, BytesIO, str]]:
'''Get a specific resource from a URL node. If a hash s also given, we want an embeded resource'''
url = self.get_urlnode_from_tree(tree_uuid, urlnode_uuid)
try:
url = self.get_urlnode_from_tree(tree_uuid, urlnode_uuid)
except IndexError:
# unable to find the uuid, the cache is probably in a weird state.
return None
if url.empty_response:
return None
if not h or h == url.body_hash:

View File

@ -723,8 +723,9 @@ def cookies_name_detail(cookie_name: str):
@app.route('/body_hashes/<string:body_hash>', methods=['GET'])
def body_hash_details(body_hash: str):
from_popup = request.args.get('from_popup')
captures, domains = lookyloo.get_body_hash_investigator(body_hash.strip())
return render_template('body_hash.html', body_hash=body_hash, domains=domains, captures=captures)
return render_template('body_hash.html', body_hash=body_hash, domains=domains, captures=captures, from_popup=from_popup)
@app.route('/urls/<string:url>', methods=['GET'])

View File

@ -14,11 +14,13 @@
});
</script>
{% if from_popup %}
<script type="text/javascript">
function openTreeInNewTab(treeUUID) {
window.opener.openTreeInNewTab(treeUUID);
};
</script>
{% endif %}
{% endblock %}
@ -31,7 +33,9 @@
{% block content %}
<center>
<h4>{{ body_hash }}</h4>
{% if from_popup %}
<button onclick="window.history.back();" class="btn btn-info" type="button">Go Back</button>
{% endif %}
</center>
<div class="table-responsive">
<table id="table" class="table" style="width:96%">
@ -56,7 +60,13 @@
<p>The same file was seen in these captures:</p>
<ul>
{% for capture_uuid, title in captures %}
<li><a href="#/" onclick="openTreeInNewTab('{{ capture_uuid }}')">{{ title }}</a></li>
<li>
{% if from_popup %}
<a href="#/" onclick="openTreeInNewTab('{{ capture_uuid }}')">{{ title }}</a>
{% else %}
<a href="{{ url_for('tree', tree_uuid=capture_uuid) }}")">{{ title }}</a>
{% endif %}
</li>
{% endfor %}
</ul>
{% endblock %}

View File

@ -197,7 +197,7 @@
{% endif %}
{# Link to list of captures with the same hash #}
<p>
<a href="{{ url_for('body_hash_details', body_hash=url['url_object'].body_hash) }}">
<a href="{{ url_for('body_hash_details', body_hash=url['url_object'].body_hash, from_popup=True) }}">
Show more information about this response body.
</a>
</p>
@ -238,7 +238,7 @@
{% if 'other_captures' in details %}
{{ indexed_hash(details['other_captures'], hash) }}
{% endif %}
<p><a href="{{ url_for('body_hash_details', body_hash=url['url_object'].body_hash) }}">
<p><a href="{{ url_for('body_hash_details', body_hash=url['url_object'].body_hash, from_popup=True) }}">
Show more information about this embedded content.
</a></p>
</div>