lookyloo/website/web/templates/macros.html

145 lines
5.2 KiB
HTML

{% macro sanejs_details(details) %}
<div>
{% if details is string %}
<b>{{ details }} </b>
{% else %}
This file is known as part of <b>{{ details[0] }}</b>
version <b>{{ details[1] }}</b>: <b>{{ details[2] }}</b>.
{% if details[3] > 1%}
It is also present in <b>{{ details[3] -1 }}</b> other libraries.
{%endif%}
{%endif%}
</div>
{% endmacro %}
{% macro indexed_hash(details, identifier_for_toggle) %}
{% set total_captures = details['different_url']|length + details['same_url']|length %}
{# Only show details if the hits are in an other capture #}
{% if total_captures > 0 %}
<p>
The same file was seen in <b>{{ total_captures }}</b> other captures.
<button class="btn btn-primary collapsed" type="button" data-toggle="collapse" data-target="#captureslist_{{ identifier_for_toggle }}" aria-expanded="false" aria-controls="collapseExample">
<span class="if-collapsed">Show other captures</span>
<span class="if-not-collapsed">Hide other captures</span>
</button>
</p>
{# Lists of other captures loading the same content... #}
<div class="collapse" id="captureslist_{{ identifier_for_toggle }}">
<div class="card card-body">
{% if details['different_url']|length > 0 %}
{# ... on other URLs #}
<div>
<p>The following captures get the same file from a <b>different URL</b></p>
{{ other_captures_table(details['different_url']) }}
</div>
{% endif %}
</br>
{% if details['same_url']|length > 0 %}
{# ... on the same URL #}
<div>
<p>The following captures get the same file from the <b>same URL</b></p>
{{ other_captures_table(details['same_url']) }}
</div>
{% endif %}
</div>
</div>
{% else %}
<p>This file is loaded multiple times in this capture.</p>
{% endif %}
{% endmacro %}
{% macro other_captures_table(entries) %}
<div class="table-responsive">
<table id="table_other_captures" class="table">
<thead>
<tr>
<th>Title</th>
<th>Timestamp</th>
<th>Domain</th>
</tr>
</thead>
<tbody>
{% for capture_uuid, urlnode_uuid, title, timestamp, hostname in entries %}
<tr>
<td>
<a href="#/" onclick="openTreeInNewTab('{{ capture_uuid }}', '{{ urlnode_uuid }}')">{{ title }}</a>
</td>
<td>{{ timestamp }}</td>
<td>{{ hostname }}</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
{% endmacro %}
{% macro indexed_cookies(header_text, button_text, cookies) %}
{% if cookies %}
<div>{{ header_text }}</div>
<ul>
{% for cookie, details in cookies.items() %}
{% set cookie_name_value = cookie.split('=', 1) %}
{% for detail in details %}
{% if detail|length == 1 %}
<li>
{{ detail[0] }}: <a href="{{ url_for('cookies_name_detail', cookie_name=cookie_name_value[0]) }}">
{{ cookie_name_value[0] }}</a>={{ shorten_string(cookie_name_value[1], 200) }}
</li>
{% else %}
<li>
{{ detail[0] }}: <a href="{{ url_for('cookies_name_detail', cookie_name=cookie_name_value[0]) }}">
{{ cookie_name_value[0] }}</a>={{ shorten_string(cookie_name_value[1], 200) }} -
</br>
{{ button_text }}
<button type="button" class="btn btn-info" onclick="whereAmI('{{ detail[1] }}')">Locate</button>
</li>
{% endif %}
{% endfor %}
{% endfor %}
</ul>
{% endif %}
{% endmacro %}
{% macro popup_icons(lookup_dict, urlnode, tree_uuid) %}
<div>
{% for key, path in lookup_dict.items() %}
{% if urlnode[key] %}
{% if key == "request_cookie" %}
<a href="{{ url_for('urlnode_request_cookies', tree_uuid=tree_uuid, node_uuid=urlnode.uuid) }}" title="Download all the cookies in the request to the server">
<img src="{{ path }}" alt="{{ key }}" width="21" height="21"/>
</a>
{% elif key == "response_cookie"%}
<a href="{{ url_for('urlnode_response_cookies', tree_uuid=tree_uuid, node_uuid=urlnode.uuid) }}" title="Download all the cookies in the response from the server">
<img src="{{ path }}" alt="{{ key }}" width="21" height="21"/>
</a>
{% elif key in ["js", "exe", "css", "font", "html", "json", "image", "video", "unknown_mimetype", "text", "unset_mimetype", "octet-stream", "livestream"] and not urlnode.empty_response %}
<a href="{{ url_for('urlnode_details', tree_uuid=tree_uuid, node_uuid=urlnode.uuid) }}" title="Download the content of the response">
<img src="{{ path }}" alt="{{ key }}" width="21" height="21"/>
</a>
{% elif key == "redirect" %}
{% for child in urlnode.children if child.name == urlnode.redirect_url %}
<a href="#/" role="button" onclick="whereAmI('{{ child.hostnode_uuid }}')" title="See the node the URL redirects to.">
<img src="{{ path }}" alt="{{ key }}" width="21" height="21"/>
</a>
{% else %}
<img src="{{ path }}" alt="{{ key }}" width="21" height="21"/>
{% endfor %}
{% if urlnode.redirect_url %}
<div title='{{ urlnode.redirect_url }}'>Redirect to: {{ shorten_string(urlnode.redirect_url, 50) }}</div>
{%endif%}
{% else %}
<img src="{{ path }}" alt="{{ key }}" width="21" height="21"/>
{%endif%}
{%endif%}
{% endfor %}
</div>
{% endmacro %}
{% macro shorten_string(string, cut_length) %}
{% if string|length > cut_length %}
{{ string[:cut_length] }} [...]
{% else %}
{{ string }}
{%endif%}
{% endmacro %}