chg: Improve cookies in hostnode view

pull/79/head
Raphaël Vinot 2020-06-11 15:13:31 +02:00
parent 0ed7dbb5cb
commit 1c408af3b0
2 changed files with 80 additions and 35 deletions

View File

@ -469,6 +469,12 @@ class Lookyloo():
'url_object': url
}
# If the url path is too long, we want to limit it to 60 chars
if len(to_append['url_path']) > 50:
to_append['url_path_short'] = to_append['url_path'][:60] + ' [...]'
else:
to_append['url_path_short'] = to_append['url_path']
# Optional: SaneJS information
if hasattr(url, 'body_hash') and url.body_hash in sanejs_lookups:
if sanejs_lookups[url.body_hash]:
@ -485,7 +491,8 @@ class Lookyloo():
to_display: Dict[str, Set[Tuple[str, str]]] = defaultdict(set)
for cookie, contexts in url.cookies_sent.items():
if not contexts:
# FIXME Locally created?
# Locally created?
to_display[cookie].add(('Unknown origin', ))
continue
for context in contexts:
to_display[cookie].add((context['setter'].hostname, context['setter'].hostnode_uuid))
@ -493,10 +500,21 @@ class Lookyloo():
# Optional: Cookies received from server in response -> map to nodes who send the cookie in request
if hasattr(url, 'cookies_received'):
to_display = defaultdict(set)
to_display = {'3rd_party': defaultdict(set), 'sent': defaultdict(set), 'not_sent': defaultdict(set)}
for domain, c_received, is_3rd_party in url.cookies_received:
if c_received not in ct.root_hartree.cookies_sent:
# This cookie is never sent.
if is_3rd_party:
to_display['3rd_party'][c_received].add((domain, ))
else:
to_display['not_sent'][c_received].add((domain, ))
continue
for url_node in ct.root_hartree.cookies_sent[c_received]:
to_display[c_received].add((url_node.hostname, url_node.hostnode_uuid))
if is_3rd_party:
to_display['3rd_party'][c_received].add((url_node.hostname, url_node.hostnode_uuid))
else:
to_display['sent'][c_received].add((url_node.hostname, url_node.hostnode_uuid))
to_append['cookies_received'] = to_display
urls.append(to_append)

View File

@ -47,7 +47,6 @@
<button type="button" class="btn btn-info" onclick="whereAmI('{{ hostname_uuid }}')">Locate node on tree</button>
<a href="{{ url_for('hostnode_details_text', tree_uuid=tree_uuid, node_uuid=hostname_uuid) }}" class="btn btn-info" role="button">Get URLs as text</a>
</center>
<p>Click on the URL to get the content of the response</p>
<ul class="list-group-flush">
{% for url in urls %}
<li class="list-group-item">
@ -68,7 +67,7 @@
<path fill-rule="evenodd" d="M9.655 8H2.333c-.264 0-.398.068-.471.121a.73.73 0 0 0-.224.296 1.626 1.626 0 0 0-.138.59V14c0 .342.076.531.14.635.064.106.151.18.256.237a1.122 1.122 0 0 0 .436.127l.013.001h7.322c.264 0 .398-.068.471-.121a.73.73 0 0 0 .224-.296 1.627 1.627 0 0 0 .138-.59V9c0-.342-.076-.531-.14-.635a.658.658 0 0 0-.255-.237A1.122 1.122 0 0 0 9.655 8zm.012-1H2.333C.5 7 .5 9 .5 9v5c0 2 1.833 2 1.833 2h7.334c1.833 0 1.833-2 1.833-2V9c0-2-1.833-2-1.833-2zM8.5 4a3.5 3.5 0 1 1 7 0v3h-1V4a2.5 2.5 0 0 0-5 0v3h-1V4z"/>
</svg>
{%endif%}
... /{{ url['url_path'] }}
... /{{ url['url_path_short'] }}
</div>
<ul class="list-group">
<li class="list-group-item">
@ -118,25 +117,51 @@
</div>
{% endif %}
{% if url['url_object'].set_third_party_cookies %}
<div>This response contains 3rd party cookies.</div>
{% endif %}
{% if url['cookies_received'] %}
<p class="h6">List of cookies received in the response to that URL</p>
<ul class="list-group">
{% for cookie, details in url['cookies_received'].items() %}
<li class="list-group-item">{{ cookie }}
<ul class="list-group">
{% for hostname, hostnode_uuid in details %}
<li class="list-group-item"> {{ hostname }} -
<button type="button" class="btn btn-info" onclick="whereAmI('{{ hostnode_uuid }}')">Show on tree node sending this cookie</button>
</li>
<div>
<p class="h5">Cookies</p>
{% if url['cookies_received']['3rd_party'] %}
<div>This response contains 3rd party cookies:</div>
<ul>
{% for cookie, details in url['cookies_received']['3rd_party'].items() %}
{% for detail in details %}
{% if detail|length == 1 %}
<li>{{ detail[0] }}: {{ cookie }}</li>
{% else %}
<li>{{ detail[0] }}: {{ cookie }} -
<button type="button" class="btn btn-info" onclick="whereAmI('{{ detail[1] }}')">Show node sending this cookie</button>
</li>
{% endif %}
{% endfor %}
</ul>
</li>
{% endfor %}
</ul>
</p>
{% endfor %}
</ul>
{% endif %}
{% if url['cookies_received']['sent'] %}
<div>Other cookies sent somewhere else in the capture</div>
<ul>
{% for cookie, details in url['cookies_received']['sent'].items() %}
{% for detail in details %}
<li>{{ detail[0] }}: {{ cookie }} -
<button type="button" class="btn btn-info" onclick="whereAmI('{{ detail[1] }}')">Show node sending this cookie</button>
</li>
{% endfor %}
{% endfor %}
</ul>
{% endif %}
{% if url['cookies_received']['not_sent'] %}
<div>Other cookies, but never sent</div>
<ul>
{% for cookie, details in url['cookies_received']['not_sent'].items() %}
{% for detail in details %}
<li>{{ detail[0] }}: {{ cookie }}</li>
{% endfor %}
{% endfor %}
</ul>
{% endif %}
<div>
{% endif %}
</li>
@ -163,21 +188,23 @@
{% endif %}
{% if url['cookies_sent'] %}
<p class="h6">List of cookies sent in the request to that URL</p>
<ul class="list-group">
<div>
<p class="h5">Cookies</p>
<div>List of cookies sent in the request</div>
<ul>
{% for cookie, details in url['cookies_sent'].items() %}
<li class="list-group-item">{{ cookie }}
<ul class="list-group">
{% for hostname, hostnode_uuid in details %}
<li class="list-group-item"> {{ hostname }} -
<button type="button" class="btn btn-info" onclick="whereAmI('{{ hostnode_uuid }}')">Show on tree node setting this cookie</button>
</li>
{% endfor %}
</ul>
</li>
{% for detail in details %}
{% if detail|length == 1 %}
<li> {{ detail[0] }}: {{ cookie }}</li>
{%else %}
<li>{{ detail[0] }}: {{ cookie }} -
<button type="button" class="btn btn-info" onclick="whereAmI('{{ detail[1] }}')">Show on tree node setting this cookie</button>
</li>
{% endif %}
{% endfor %}
{% endfor %}
</ul>
</p>
</ul>
</div>
{% endif %}
</li>
</ul>