mirror of https://github.com/CIRCL/lookyloo
new: Add stats
parent
cd972076b5
commit
d3971cc47c
|
@ -88,6 +88,14 @@ class Lookyloo():
|
|||
sample_config = json.load(_c)
|
||||
return sample_config[entry]
|
||||
|
||||
def get_statistics(self, capture_dir: Path) -> Dict:
|
||||
# We need the pickle
|
||||
ct = self._load_pickle(capture_dir / 'tree.pickle')
|
||||
if not ct:
|
||||
self.logger.warning(f'Unable to trigger the modules unless the tree ({capture_dir}) is cached.')
|
||||
return
|
||||
return ct.root_hartree.stats
|
||||
|
||||
def trigger_modules(self, capture_dir: Path, force: bool=False) -> None:
|
||||
# We need the pickle
|
||||
ct = self._load_pickle(capture_dir / 'tree.pickle')
|
||||
|
|
|
@ -306,7 +306,7 @@ publicsuffix2 = "^2.20191221"
|
|||
six = "^1.14.0"
|
||||
|
||||
[package.source]
|
||||
reference = "63f41bd539701fa86c1989883cb2ecb70a540fd8"
|
||||
reference = "59195eab02971545cc7adbec01af1ea472a7b2bc"
|
||||
type = "git"
|
||||
url = "https://github.com/viper-framework/har2tree.git"
|
||||
[[package]]
|
||||
|
|
|
@ -178,6 +178,15 @@ def trigger_modules(tree_uuid, force):
|
|||
return redirect(url_for('modules', tree_uuid=tree_uuid))
|
||||
|
||||
|
||||
@app.route('/tree/<string:tree_uuid>/stats', methods=['GET'])
|
||||
def stats(tree_uuid):
|
||||
capture_dir = lookyloo.lookup_capture_dir(tree_uuid)
|
||||
if not capture_dir:
|
||||
return Response('Not available.', mimetype='text/text')
|
||||
stats = lookyloo.get_statistics(capture_dir)
|
||||
return render_template('statistics.html', uuid=tree_uuid, stats=stats)
|
||||
|
||||
|
||||
@app.route('/tree/<string:tree_uuid>/modules', methods=['GET'])
|
||||
def modules(tree_uuid):
|
||||
capture_dir = lookyloo.lookup_capture_dir(tree_uuid)
|
||||
|
|
|
@ -10,10 +10,10 @@
|
|||
<dl class="row">
|
||||
{% for e in entries['malicious'] %}
|
||||
<dt class="col-sm-3">{{ e[0] }}</dt>
|
||||
<dd class="col-sm-3">{{ e[1] }}</li>
|
||||
<dd class="col-sm-3">{{ e[1] }}</dd>
|
||||
{% endfor %}
|
||||
</center>
|
||||
</ul>
|
||||
</dl>
|
||||
{% else %}
|
||||
<p class="lead">No vendors consider this URL as malicious.</p>
|
||||
{% endif%}
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
<div>
|
||||
{% if stats %}
|
||||
{% for key, value in stats.items() %}
|
||||
<dl class="row">
|
||||
<dt class="col-sm-3">{{ key }}</dt>
|
||||
<dd class="col-sm-3">{{ value }}</dd>
|
||||
</center>
|
||||
</dl>
|
||||
{% endfor %}
|
||||
{% endif%}
|
||||
</div>
|
|
@ -22,6 +22,13 @@
|
|||
});
|
||||
</script>
|
||||
<script>
|
||||
$('#statsModal').on('show.bs.modal', function(e) {
|
||||
var button = $(e.relatedTarget);
|
||||
var modal = $(this);
|
||||
modal.find('.modal-body').load(button.data("remote"));
|
||||
});
|
||||
</script>
|
||||
<script>
|
||||
$('.modulesForceRefresh').on('click',function(){
|
||||
$('.modal-body').load("{{ url_for('trigger_modules', tree_uuid=tree_uuid, force=True) }}",function(){
|
||||
$('#modulesModal').modal({show:true});
|
||||
|
@ -140,6 +147,8 @@
|
|||
|
||||
<a href="#modulesModal" data-remote="{{ url_for('trigger_modules', tree_uuid=tree_uuid, force=False) }}"
|
||||
data-toggle="modal" data-target="#modulesModal" class="btn btn-info" role="button">Show third party reports</a>
|
||||
<a href="#statsModal" data-remote="{{ url_for('stats', tree_uuid=tree_uuid) }}"
|
||||
data-toggle="modal" data-target="#statsModal" class="btn btn-info" role="button">Show Statistics</a>
|
||||
{% if enable_mail_notification %}
|
||||
<a href="#emailModal" data-toggle="modal" data-target="#emailModal" class="btn btn-info" role="button">Notify by mail</a>
|
||||
{%endif%}
|
||||
|
@ -156,6 +165,25 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<div class="modal fade" id="statsModal" tabindex="-1" role="dialog">
|
||||
<div class="modal-dialog modal-xl" role="document">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title" id="modulesModalLabel">Statistics</h5>
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
... loading statistics ...
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="modal fade" id="modulesModal" tabindex="-1" role="dialog">
|
||||
<div class="modal-dialog modal-xl" role="document">
|
||||
<div class="modal-content">
|
||||
|
|
Loading…
Reference in New Issue