galaxy tag info + fix

pull/206/head
Terrtia 2018-05-30 16:18:58 +02:00
parent dbe67e094b
commit 8a87b7b082
No known key found for this signature in database
GPG Key ID: 1E1B1F50D84613D0
7 changed files with 229 additions and 16 deletions

View File

@ -123,10 +123,16 @@ r_serv_tags = redis.StrictRedis(
decode_responses=True)
# add default ail taxonomies
r_serv_tags.sadd('active_taxonomies', 'infoleak')
r_serv_tags.sadd('active_taxonomies', 'gdpr')
r_serv_tags.sadd('active_taxonomies', 'fpf')
# add default tags
taxonomies = Taxonomies()
for tag in taxonomies.get('infoleak').machinetags():
r_serv_tags.sadd('active_tag_infoleak', tag)
for tag in taxonomies.get('gdpr').machinetags():
r_serv_tags.sadd('active_tag_infoleak', tag)
for tag in taxonomies.get('fpf').machinetags():
r_serv_tags.sadd('active_tag_infoleak', tag)
# ============ MAIN ============

View File

@ -41,6 +41,11 @@ list_clusters = []
for c in clusters.values():
list_clusters.append(c.to_json())
# tags numbers in galaxies
total_tags = {}
for name, tags in clusters.items(): #galaxie name + tags
total_tags[name] = len(tags)
# ============ FUNCTIONS ============
def one():
return 1
@ -174,6 +179,9 @@ def get_tagged_paste():
tags = request.args.get('ltags')
list_tags = tags.split(',')
list_tag = []
for tag in list_tags:
list_tag.append(tag.replace('"','\"'))
# TODO verify input
@ -249,6 +257,7 @@ def get_tagged_paste():
year=currentSelectYear,
all_path=all_path,
tags=tags,
list_tag = list_tag,
paste_tags=paste_tags,
bootstrap_label=bootstrap_label,
content=all_content,
@ -339,13 +348,10 @@ def addTags():
# verify input
gal = tag.split(':')[1]
gal = gal.split('=')[0]
print(tag)
print(gal)
print(active_galaxies)
if gal in active_galaxies:
if tag in r_serv_tags.smembers('active_tag_galaxies_' + gal):
print('adding ...')
#add tag
r_serv_metadata.sadd('tag:'+path, tag)
r_serv_tags.sadd(tag, path)
@ -416,6 +422,9 @@ def edit_taxonomie():
else:
active = False
n = str(r_serv_tags.scard('active_tag_' + id))
badge = n + '/' + str(len(taxonomies.get(id).machinetags()))
name = taxonomies.get(id).name
description = taxonomies.get(id).description
version = taxonomies.get(id).version
@ -430,6 +439,7 @@ def edit_taxonomie():
return render_template("edit_taxonomie.html",
id=id,
name=name,
badge = badge,
description = description,
version = version,
active=active,
@ -526,10 +536,6 @@ def galaxies():
active_galaxies = r_serv_tags.smembers('active_galaxies')
total_tags = {}
for name, tags in clusters.items(): #galaxie name + tags
total_tags[name] = len(tags)
name = []
icon = []
version = []
@ -588,6 +594,9 @@ def edit_galaxy():
type = id
active_tag = r_serv_tags.smembers('active_tag_galaxies_' + type)
n = str(r_serv_tags.scard('active_tag_galaxies_' + type))
badge = n + '/' + str(total_tags[type])
name = cluster['name']
description = cluster['description']
version = cluster['version']
@ -629,6 +638,7 @@ def edit_galaxy():
return render_template("edit_galaxy.html",
id = type,
name = name,
badge = badge,
description = description,
version = version,
active = active,
@ -775,11 +785,77 @@ def edit_galaxy_tag():
else:
return "INCORRECT INPUT"
@Tags.route("/Tags/test")
def test():
@Tags.route("/Tags/tag_galaxy_info")
def tag_galaxy_info():
return render_template("test.html",
id = '1')
galaxy = request.args.get('galaxy')
tag = request.args.get('tag')
full_tag = tag
title = tag.split(':')[1]
tag = tag.split('=')[1]
tag = tag[1:-1]
#get clusters
for clusters_json in list_clusters:
cluster = json.loads(clusters_json)
if cluster['type'] == galaxy:
val = cluster['values']
source = cluster['source']
for data in val:
if tag == data['value']:
try:
description = data['description']
except KeyError:
description = ''
if r_serv_tags.sismember('active_tag_galaxies_' + galaxy, full_tag):
active = True
else:
active = False
synonyms = []
metadata = []
try:
meta = data['meta']
list_metadata = []
for key in meta:
if key != 'synonyms':
if type(meta[key]) is list:
for item in meta[key]:
list_metadata.append(key + ' : ' + item)
else:
list_metadata.append(key + ' : ' + meta[key])
try:
synonyms = meta['synonyms']
bool_synonyms = True
except KeyError:
synonyms = []
bool_synonyms = False
except KeyError:
pass
if synonyms:
bool_synonyms = True
else:
bool_synonyms = False
if list_metadata:
metadata = True
else:
metadata = False
return render_template("tag_galaxy_info.html",
title = title,
description = description,
source = source,
active = active,
synonyms = synonyms,
bool_synonyms = bool_synonyms,
metadata = metadata,
list_metadata = list_metadata)
return 'INVALID INPUT'
# ========= REGISTRATION =========
app.register_blueprint(Tags)

View File

@ -72,6 +72,8 @@
<script>
var ltags
$(document).ready(function(){
activePage = "page-Tags"
$("#"+activePage).addClass("active");
$.getJSON('/Tags/get_all_tags',
function(data) {

View File

@ -58,6 +58,8 @@
<div class="panel-heading">{{ name }}
{% if active %}
<span class="label label-success pull-right"> Enabled</span>
<span class="pull-right">&nbsp;&nbsp;&nbsp;</span>
<span class="badge badge-light pull-right">{{ badge }}</span>
{% endif %}
{% if not active %}
<span class="label label-danger pull-right"> Disabled</span>
@ -107,7 +109,9 @@
<input type="checkbox" value="{{ tag[0] }}" id="{{ tag[0] }}" name="tag_disabled" >
{% endif %}
</td>
<td>{{ tag[0] }}</td>
<td>
<a href="{{ url_for('Tags.tag_galaxy_info') }}?galaxy={{ request.args.get('galaxy') }}&tag={{ tag[0] }}">{{ tag[0] }}</a>
</td>
<td>{{ tag[1] }}</td>
<td style="text-align: center;">
{% if status[loop.index0] %}

View File

@ -58,6 +58,8 @@
<div class="panel-heading">{{ name }}
{% if active %}
<span class="label label-success pull-right"> Enabled</span>
<span class="pull-right">&nbsp;&nbsp;&nbsp;</span>
<span class="badge badge-light pull-right">{{ badge }}</span>
{% endif %}
{% if not active %}
<span class="label label-danger pull-right"> Disabled</span>

View File

@ -0,0 +1,116 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Analysis Information Leak framework Dashboard</title>
<!-- Core CSS -->
<link href="{{ url_for('static', filename='css/bootstrap.min.css') }}" rel="stylesheet">
<link href="{{ url_for('static', filename='font-awesome/css/font-awesome.css') }}" rel="stylesheet">
<link href="{{ url_for('static', filename='css/sb-admin-2.css') }}" rel="stylesheet">
<link href="/static//css/dataTables.bootstrap.css" rel="stylesheet" type="text/css" />
<!-- JS -->
<script type="text/javascript" src="{{ url_for('static', filename='js/dygraph-combined.js') }}"></script>
<script language="javascript" src="{{ url_for('static', filename='js/jquery.js')}}"></script>
<script src="/static//js/bootstrap.min.js"></script>
<script src="/static//js/jquery.dataTables.min.js"></script>
<script src="/static//js/dataTables.bootstrap.js"></script>
<style>
.tooltip-inner {
text-align: left;
height: 200%;
width: 200%;
max-width: 500px;
max-height: 500px;
font-size: 13px;
}
xmp {
white-space:pre-wrap;
word-wrap:break-word;
}
.test thead{
background: #d91f2d;
color: #fff;
}
</style>
</head>
<body>
{% include 'navbar.html' %}
<div id="page-wrapper">
<div class="row">
<div class="col-lg-12">
<a href="{{ url_for('Tags.edit_galaxy') }}?galaxy={{ request.args.get('galaxy') }}" class="btn btn-light pull-left">
<i class="fa fa-arrow-left fa"></i> {{ request.args.get('galaxy') }} Galaxy
</a>
</div>
<!-- /.col-lg-12 -->
</div>
<!-- /.row -->
<div class="panel panel-primary">
<div class="panel-heading">{{ title }}
{% if active %}
<span class="label label-success pull-right"> Enabled</span>
{% endif %}
{% if not active %}
<span class="label label-danger pull-right"> Disabled</span>
{% endif %}
</div>
<div class="panel-body">
{{ description }}
<br><br>
Source: {{ source }}
{% if metadata %}
<div class="panel panel-info pull-right" style="width: 60%;">
<div class="panel-heading"> Metadata :
<ul class="list-group">
{% for meta in list_metadata %}
<li class="list-group-item">{{ meta }}</li>
{% endfor %}
</ul>
</div>
</div>
{% endif %}
{% if bool_synonyms %}
<br><br>
<ul class="list-group" style="width: 30%;">
<li class="list-group-item active">synonyms :</li>
{% for synonym in synonyms %}
<li class="list-group-item">{{ synonym }}</li>
{% endfor %}
</ul>
{% endif %}
</div>
</div>
</div>
<!-- /#page-wrapper -->
</body>
<script>
$(document).ready(function(){
//search_table = $('#myTable_').DataTable({ "order": [[ 2, "desc" ]] });
$('#myTable_').DataTable(
{
"aLengthMenu": [[5, 10, 15, 20, -1], [5, 10, 15, 20, "All"]],
"iDisplayLength": 15,
//"order": [[ 1, "asc" ]]
}
);
});
</script>
</html>

View File

@ -178,17 +178,25 @@ $(document).ready(function(){
$.getJSON('/Tags/get_all_tags',
function(data) {
activePage = "page-Tags"
$("#"+activePage).addClass("active");
//var valueData = ["infoleak:automatic-detection=\"bitcoin-address\"","infoleak:automatic-detection=\"aws-key\"",'misp-galaxy:botnet="Marina Botnet"'];
var valueData = [
{% for tag in list_tag %}
'{{tag|safe}}',
{% endfor %}
];
ltags = $('#ltags').tagSuggest({
data: data,
//value: ["infoleak:automatic-detection=\"bitcoin-address\"","infoleak:automatic-detection=\"aws-key\""],
value: valueData,
sortOrder: 'name',
maxDropHeight: 200,
name: 'ltags',
});
//ltags.setValue(["{{ tags }}"]);
ltags.setValue(["infoleak:automatic-detection='bitcoin-address'","infoleak:automatic-detection='aws-key'"]);
//ltags.setValue([{id:"infoleak:automatic-detection='bitcoin-address'",name:"infoleak:automatic-detection='bitcoin-address'"}}]);
});
});
@ -200,7 +208,6 @@ $(document).ready(function(){
window.location.replace("{{ url_for('Tags.get_tagged_paste') }}?ltags=" + data);
}
function emptyTags() {
console.log('b');
ltags.clear();
}
</script>