diff --git a/var/www/modules/base64Decoded/Flask_base64Decoded.py b/var/www/modules/base64Decoded/Flask_base64Decoded.py index 0ecf2c2e..6678451b 100644 --- a/var/www/modules/base64Decoded/Flask_base64Decoded.py +++ b/var/www/modules/base64Decoded/Flask_base64Decoded.py @@ -45,6 +45,31 @@ def substract_date(date_from, date_to): l_date.append( date.strftime('%Y%m%d') ) return l_date +def list_sparkline_values(date_range_sparkline, hash): + sparklines_value = [] + for date_day in date_range_sparkline: + nb_seen_this_day = r_serv_metadata.zscore('base64_date:'+date_day, hash) + if nb_seen_this_day is None: + nb_seen_this_day = 0 + sparklines_value.append(int(nb_seen_this_day)) + return sparklines_value + +def get_file_icon(estimated_type): + file_type = estimated_type.split('/')[0] + # set file icon + if file_type == 'application': + file_icon = 'fa-file-o ' + elif file_type == 'audio': + file_icon = 'fa-file-video-o ' + elif file_type == 'image': + file_icon = 'fa-file-image-o' + elif file_type == 'text': + file_icon = 'fa-file-text-o' + else: + file_icon = 'fa-file' + + return file_icon + def one(): return 1 @@ -130,18 +155,7 @@ def base64Decoded_page(): nb_seen_in_paste is not None and \ size is not None: - file_type = estimated_type.split('/')[0] - # set file icon - if file_type == 'application': - file_icon = 'fa-file-o ' - elif file_type == 'audio': - file_icon = 'fa-file-video-o ' - elif file_type == 'image': - file_icon = 'fa-file-image-o' - elif file_type == 'text': - file_icon = 'fa-file-text-o' - else: - file_icon = 'fa-file' + file_icon = get_file_icon(estimated_type) if r_serv_metadata.hexists('metadata_hash:'+hash, 'vt_link'): b64_vt = True @@ -150,12 +164,7 @@ def base64Decoded_page(): b64_vt = False b64_vt_link = '' - sparklines_value = [] - for date_day in date_range_sparkline: - nb_seen_this_day = r_serv_metadata.zscore('base64_date:'+date_day, hash) - if nb_seen_this_day is None: - nb_seen_this_day = 0 - sparklines_value.append(int(nb_seen_this_day)) + sparklines_value = list_sparkline_values(date_range_sparkline, hash) b64_metadata.append( (file_icon, estimated_type, hash, nb_seen_in_paste, size, first_seen, last_seen, b64_vt, b64_vt_link, sparklines_value) ) @@ -170,6 +179,38 @@ def hash_by_type(): type = 'text/plain' return render_template('base64_type.html',type = type) +@base64Decoded.route('/base64Decoded/base64_hash') +def base64_hash(): + hash = request.args.get('hash') + return render_template('base64_hash.html') + +@base64Decoded.route('/base64Decoded/showHash') +def showHash(): + hash = request.args.get('hash') + #hash = 'e02055d3efaad5d656345f6a8b1b6be4fe8cb5ea' + + estimated_type = r_serv_metadata.hget('metadata_hash:'+hash, 'estimated_type') + # hash not found + if estimated_type is None: + base64Decoded_page() + + else: + file_icon = get_file_icon(estimated_type) + size = r_serv_metadata.hget('metadata_hash:'+hash, 'size') + first_seen = r_serv_metadata.hget('metadata_hash:'+hash, 'first_seen') + last_seen = r_serv_metadata.hget('metadata_hash:'+hash, 'last_seen') + nb_seen_in_all_pastes = r_serv_metadata.hget('metadata_hash:'+hash, 'nb_seen_in_all_pastes') + + num_day_type = 6 + date_range_sparkline = get_date_range(num_day_type) + sparkline_values = list_sparkline_values(date_range_sparkline, hash) + + print(sparkline_values) + + return render_template('showHash.html', hash=hash, size=size, estimated_type=estimated_type, file_icon=file_icon, + first_seen=first_seen, + last_seen=last_seen, nb_seen_in_all_pastes=nb_seen_in_all_pastes, sparkline_values=sparkline_values) + @base64Decoded.route('/base64Decoded/hash_by_type_json') def hash_by_type_json(): type = request.args.get('type') @@ -217,9 +258,6 @@ def range_type_json(): date_from = request.args.get('date_from') date_to = request.args.get('date_to') - date_from = '20180601' - date_to = '20180709' - date_range = [] if date_from is not None and date_to is not None: #change format diff --git a/var/www/modules/base64Decoded/templates/base64Decoded.html b/var/www/modules/base64Decoded/templates/base64Decoded.html index 60aceaae..b3a4d8a6 100644 --- a/var/www/modules/base64Decoded/templates/base64Decoded.html +++ b/var/www/modules/base64Decoded/templates/base64Decoded.html @@ -121,14 +121,14 @@ nb paste size Virus Total - Test + Sparkline {% for b64 in l_64 %}   {{ b64[1] }} - {{ b64[2] }} + {{ b64[2] }} {{ b64[5] }} {{ b64[6] }} {{ b64[3] }} @@ -302,7 +302,7 @@ var svg = d3.select("#barchart_type").append("svg") function barchart_type_stack(url, id) { - d3.json("/base64Decoded/range_type_json") + d3.json("/base64Decoded/range_type_json?date_from={{date_from}}&date_to={{date_to}}") .then(function(data){ var labelVar = 'date'; //A @@ -474,11 +474,7 @@ function barchart_type(url, id) { d.value = +d.value; }); - {% if daily_type_chart %} x.domain(data.map(function(d) { return d.date; })); - {% else %} - x.domain(data.map(function(d) { return d.date.substring(5); })); - {% endif %} y.domain([0, d3.max(data, function(d) { return d.value; })]); var label = svg.append("g") @@ -492,7 +488,9 @@ function barchart_type(url, id) { {% if daily_type_chart %} .attr("transform", "rotate(-20)" ); {% else %} - .attr("transform", "rotate(-70)" ); + .attr("transform", "rotate(-70)" ) + .attr("class", "bar") + .on("click", function (d) { window.location.href = "/base64Decoded/"+'?date_from='+d+'&date_to='+d }); {% endif %} svg.append("g") @@ -510,11 +508,7 @@ function barchart_type(url, id) { .enter().append("rect") .attr("class", "bar") //.style("fill", "steelblue") - {% if daily_type_chart %} .attr("x", function(d) { return x(d.date); }) - {% else %} - .attr("x", function(d) { return x(d.date.substring(5)); }) - {% endif %} .attr("width", x.bandwidth()) .attr("y", function(d) { return y(d.value); }) .attr("height", function(d) { return height - y(d.value); }) @@ -534,11 +528,7 @@ function barchart_type(url, id) { //.text(function(d) { return d.value; }); .text(d.value) .style("text-anchor", "middle") - {% if daily_type_chart %} .attr('x', x(d.date) + x.bandwidth()/2) - {% else %} - .attr('x', x(d.date.substring(5)) + x.bandwidth()/2) - {% endif %} .attr('y', y(d.value)); } }); diff --git a/var/www/modules/base64Decoded/templates/showHash.html b/var/www/modules/base64Decoded/templates/showHash.html new file mode 100644 index 00000000..95c1f5fb --- /dev/null +++ b/var/www/modules/base64Decoded/templates/showHash.html @@ -0,0 +1,172 @@ + + + + + + + + Analysis Information Leak framework Dashboard + + + + + + + + + + + + + + + + + + + + + + + {% include 'navbar.html' %} + +
+
+ + +
+ + +
+
+

{{ hash }} :

+     + 6 / 26 +
  • + +
    +
    + + + + + + + + + + + + + + + + + + + + +
    Estimated typeFirst_seenLast_seenSize (Kb)nb_seen_in_all_pastes
      {{ estimated_type }}{{ first_seen }}{{ last_seen }}{{ size }}{{ nb_seen_in_all_pastes }}
    +
    +
    +
    +
    + +
    + +
+
+
+ + + + + + + + + + + + +