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]]: 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''' '''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: if url.empty_response:
return None return None
if not h or h == url.body_hash: 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']) @app.route('/body_hashes/<string:body_hash>', methods=['GET'])
def body_hash_details(body_hash: str): def body_hash_details(body_hash: str):
from_popup = request.args.get('from_popup')
captures, domains = lookyloo.get_body_hash_investigator(body_hash.strip()) 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']) @app.route('/urls/<string:url>', methods=['GET'])

View File

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

View File

@ -197,7 +197,7 @@
{% endif %} {% endif %}
{# Link to list of captures with the same hash #} {# Link to list of captures with the same hash #}
<p> <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. Show more information about this response body.
</a> </a>
</p> </p>
@ -238,7 +238,7 @@
{% if 'other_captures' in details %} {% if 'other_captures' in details %}
{{ indexed_hash(details['other_captures'], hash) }} {{ indexed_hash(details['other_captures'], hash) }}
{% endif %} {% 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. Show more information about this embedded content.
</a></p> </a></p>
</div> </div>