diff --git a/config/config.cfg.default b/config/config.cfg.default index 02b277c..988cc7b 100644 --- a/config/config.cfg.default +++ b/config/config.cfg.default @@ -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 diff --git a/server.py b/server.py index ac93fd1..68efcfb 100755 --- a/server.py +++ b/server.py @@ -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(): diff --git a/static/js/contrib.js b/static/js/contrib.js index e3a2a0c..26aa59e 100644 --- a/static/js/contrib.js +++ b/static/js/contrib.js @@ -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(); diff --git a/templates/contrib.html b/templates/contrib.html index 1a13c0c..0b09812 100644 --- a/templates/contrib.html +++ b/templates/contrib.html @@ -155,10 +155,9 @@ # Org rank Logo - Organization name - Network Activity - Payload delivery - Others + {% for categ in categ_list_str %} + {{ categ }} + {% endfor %} @@ -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 }}");