Added support of custom categories from config

pull/3/head
Sami Mokaddem 2017-11-02 16:10:40 +01:00
parent 6f3998df68
commit 4e396d2eb3
4 changed files with 30 additions and 51 deletions

View File

@ -22,6 +22,7 @@ clusteringDistance = 10
[CONTRIB]
#[1.5 -> +inf]
rankMultiplier = 2
categories = ["internal_reference", "targeting_data", "antivirus_detection", "payload_delivery", "artifacts_dropped", "payload_installation", "persistence_mechanism", "network_activity", "payload_type", "attribution", "external_analysis", "financial_fraud", "support_Tool", "social_network", "person", "other" ]
[Log]
field_to_plot = Attribute.category

View File

@ -28,6 +28,8 @@ serv_redis_db = redis.StrictRedis(
port=cfg.getint('RedisGlobal', 'port'),
db=cfg.getint('RedisDB', 'db'))
categories = json.loads(cfg.get('CONTRIB', 'categories'))
subscriber_log = redis_server_log.pubsub(ignore_subscribe_messages=True)
subscriber_log.psubscribe(cfg.get('RedisLog', 'channel'))
subscriber_map = redis_server_map.pubsub(ignore_subscribe_messages=True)
@ -143,9 +145,13 @@ def geo():
@app.route("/contrib")
def contrib():
categ_list = json.loads(cfg.get('CONTRIB', 'categories'))
categ_list_str = [ s[0].upper() + s[1:].replace('_', ' ') for s in json.loads(cfg.get('CONTRIB', 'categories'))]
return render_template('contrib.html',
currOrg="",
rankMultiplier=cfg.getfloat('CONTRIB' ,'rankMultiplier')
rankMultiplier=cfg.getfloat('CONTRIB' ,'rankMultiplier'),
categ_list=json.dumps(categ_list),
categ_list_str=categ_list_str
)
@app.route("/_getLastContributor")
@ -217,49 +223,18 @@ def getTop5Overtime():
@app.route("/_getCategPerContrib")
def getCategPerContrib():
data = [
{
'rank': random.randint(1,16),
'logo_path': 'logo1',
'org': 'CIRCL',
'network_activity': random.randint(100,1600),
'payload_delivery': random.randint(100,1600),
'others': random.randint(1,16)
},
{
'rank': random.randint(1,16),
'logo_path': 'logo2',
'org': 'CASES',
'network_activity': random.randint(10,1600),
'payload_delivery': random.randint(10,1600),
'others': random.randint(1,16)
},
{
'rank': random.randint(1,16),
'logo_path': 'logo3',
'org': 'SMILE',
'network_activity': random.randint(1,160),
'payload_delivery': random.randint(1,160),
'others': random.randint(1,160)
},
{
'rank': random.randint(1,16),
'logo_path': 'logo4',
'org': 'ORG4',
'network_activity': random.randint(1,160),
'payload_delivery': random.randint(1,160),
'others': random.randint(1,16)
},
{
'rank': random.randint(1,16),
'logo_path': 'logo5',
'org': 'ORG5',
'network_activity': random.randint(1,16),
'payload_delivery': random.randint(1,16),
'others': random.randint(1,16)
},
]
return jsonify(data*2)
data = []
for d in range(15):
dic = {}
dic['rank'] = random.randint(1,16)
dic['logo_path'] = 'logo'
dic['org'] = 'Org'+str(d)
for f in categories:
dic[f] = random.randint(0,1600)
data.append(dic)
return jsonify(data)
@app.route("/_getAllOrg")
def getAllOrg():

View File

@ -56,6 +56,7 @@ var optionDatatable_Categ = {
responsive: true,
searching: true,
scrollY: '39vh',
"scrollX": true,
scrollCollapse: true,
paging: false,
"info": false,
@ -251,10 +252,11 @@ $(document).ready(function() {
getRankIcon(row.rank),
row.logo_path,
row.org,
row.network_activity,
row.payload_delivery,
row.others
];
for (categ of categ_list) {
to_add.push(row[categ]);
}
datatableCateg.row.add(to_add);
}
datatableCateg.draw();

View File

@ -155,10 +155,9 @@
<th>#</th>
<th>Org rank</th>
<th>Logo</th>
<th>Organization name</th>
<th>Network Activity</th>
<th>Payload delivery</th>
<th>Others</th>
{% for categ in categ_list_str %}
<th>{{ categ }}</th>
{% endfor %}
</tr>
</thead>
<tbody>
@ -239,6 +238,8 @@
/* DATA FROM CONF */
var currOrg = "{{ currOrg }}";
var rankMultiplier = {{ rankMultiplier }};
var categ_list = JSON.parse('{{ categ_list|safe }}');
var categ_list_str = JSON.parse("{{ categ_list_str|safe }}");
</script>
<script src="{{ url_for('static', filename='js/contrib.js') }}"></script>