From f7d38bea16e2971a9b68ad7245e9fb73bb54ac13 Mon Sep 17 00:00:00 2001 From: Terrtia Date: Thu, 5 Jul 2018 13:58:40 +0200 Subject: [PATCH] add: base64 date and type selector --- .../base64Decoded/Flask_base64Decoded.py | 29 ++++++++++++-- .../templates/base64Decoded.html | 38 ++++++++++++++++--- var/www/update_thirdparty.sh | 18 ++++++--- 3 files changed, 72 insertions(+), 13 deletions(-) diff --git a/var/www/modules/base64Decoded/Flask_base64Decoded.py b/var/www/modules/base64Decoded/Flask_base64Decoded.py index de91816c..2893d38e 100644 --- a/var/www/modules/base64Decoded/Flask_base64Decoded.py +++ b/var/www/modules/base64Decoded/Flask_base64Decoded.py @@ -49,6 +49,13 @@ def one(): return 1 # ============= ROUTES ============== +@base64Decoded.route("/base64Decoded/all_base64_search", methods=['POST']) +def all_base64_search(): + date_from = request.form.get('date_from') + date_to = request.form.get('date_to') + type = request.form.get('type') + print(type) + return redirect(url_for('base64Decoded.base64Decoded_page', date_from=date_from, date_to=date_to, type=type)) @base64Decoded.route("/base64Decoded/", methods=['GET']) def base64Decoded_page(): @@ -59,8 +66,11 @@ def base64Decoded_page(): #date_from = '20180628' #date_to = '20180628' - if type not in r_serv_metadata.smembers('hash_all_type'): - type = None + if type is not None: + #retrieve + char + type = type.replace(' ', '+') + if type not in r_serv_metadata.smembers('hash_all_type'): + type = None date_range = [] if date_from is not None and date_to is not None: @@ -72,6 +82,12 @@ def base64Decoded_page(): if not date_range: date_range.append(datetime.date.today().strftime("%Y%m%d")) + date_from = date_range[0][0:4] + '-' + date_range[0][4:6] + '-' + date_range[0][6:8] + date_to = date_from + + else: + date_from = date_from[0:4] + '-' + date_from[4:6] + '-' + date_from[6:8] + date_to = date_to[0:4] + '-' + date_to[4:6] + '-' + date_to[6:8] # display day type bar chart if len(date_range) == 1 and type is None: @@ -142,7 +158,10 @@ def base64Decoded_page(): b64_metadata.append( (file_icon, estimated_type, hash, nb_seen_in_paste, size, first_seen, last_seen, b64_vt, b64_vt_link, sparklines_value) ) - return render_template("base64Decoded.html", l_64=b64_metadata, vt_enabled=vt_enabled, type=type, daily_type_chart=daily_type_chart, daily_date=daily_date) + l_type = r_serv_metadata.smembers('hash_all_type') + + return render_template("base64Decoded.html", l_64=b64_metadata, vt_enabled=vt_enabled, l_type=l_type, type=type, daily_type_chart=daily_type_chart, daily_date=daily_date, + date_from=date_from, date_to=date_to) @base64Decoded.route('/base64Decoded/hash_by_type') def hash_by_type(): @@ -154,6 +173,9 @@ def hash_by_type(): def hash_by_type_json(): type = request.args.get('type') + #retrieve + char + type = type.replace(' ', '+') + num_day_type = 30 date_range_sparkline = get_date_range(num_day_type) @@ -186,6 +208,7 @@ def daily_type_json(): for day_type in daily_type: num_day_type = r_serv_metadata.zscore('base64_type:'+day_type, date) type_value.append({ 'date' : day_type, 'value' : int( num_day_type )}) + return jsonify(type_value) @base64Decoded.route('/base64Decoded/send_file_to_vt', methods=['POST']) diff --git a/var/www/modules/base64Decoded/templates/base64Decoded.html b/var/www/modules/base64Decoded/templates/base64Decoded.html index b11796e6..da07abfd 100644 --- a/var/www/modules/base64Decoded/templates/base64Decoded.html +++ b/var/www/modules/base64Decoded/templates/base64Decoded.html @@ -57,7 +57,7 @@
-
+
{% if type %}
@@ -68,9 +68,37 @@ {% endif %}
-
- - +
+
+
+ Select a date range : +
+
+ + +
+
+ + +
+ File Type : + +
+ + +
+
@@ -126,7 +154,7 @@ {% else %} -

{{daily_date[0:4]}}/{{daily_date[4:6]}}/{{daily_date[6:8]}}, No base64

+

{{ date_from }} to {{ date_to }}, No base64

{% endif %}
diff --git a/var/www/update_thirdparty.sh b/var/www/update_thirdparty.sh index 47b21294..76ae9174 100755 --- a/var/www/update_thirdparty.sh +++ b/var/www/update_thirdparty.sh @@ -15,10 +15,20 @@ wget https://github.com/BlackrockDigital/startbootstrap-sb-admin/archive/v${SBAD wget https://github.com/BlackrockDigital/startbootstrap-sb-admin-2/archive/v${SBADMIN_VERSION}.zip -O temp/${SBADMIN_VERSION}-2.zip wget https://github.com/FortAwesome/Font-Awesome/archive/v${FONT_AWESOME_VERSION}.zip -O temp/FONT_AWESOME_${FONT_AWESOME_VERSION}.zip wget https://github.com/d3/d3/releases/download/v${D3_JS_VERSION}/d3.zip -O temp/d3_${D3_JS_VERSION}.zip + +# dateRangePicker +wget https://github.com/moment/moment/archive/2.22.2.zip -O temp/moment_2.22.2.zip +wget https://github.com/longbill/jquery-date-range-picker/archive/v0.18.0.zip -O temp/daterangepicker_v0.18.0.zip + + unzip temp/${SBADMIN_VERSION}.zip -d temp/ unzip temp/${SBADMIN_VERSION}-2.zip -d temp/ unzip temp/FONT_AWESOME_${FONT_AWESOME_VERSION}.zip -d temp/ unzip temp/d3_${D3_JS_VERSION}.zip -d temp/ + +unzip temp/moment_2.22.2.zip -d temp/ +unzip temp/daterangepicker_v0.18.0.zip -d temp/ + mv temp/startbootstrap-sb-admin-${SBADMIN_VERSION} temp/sb-admin mv temp/startbootstrap-sb-admin-2-${SBADMIN_VERSION} temp/sb-admin-2 mv temp/Font-Awesome-${FONT_AWESOME_VERSION} temp/font-awesome @@ -33,19 +43,17 @@ mv temp/font-awesome/ ./static/ rm -rf ./static/css/plugins/ mv temp/sb-admin/css/* ./static/css/ mv temp/sb-admin-2/dist/css/* ./static/css/ +mv temp/jquery-date-range-picker-0.18.0/dist/daterangepicker.min.css ./static/css/ mv temp/d3.min.js ./static/js/ +mv temp/moment-2.22.2/min/moment.min.js ./static/js/ +mv temp/jquery-date-range-picker-0.18.0/dist/jquery.daterangepicker.min.js ./static/js/ rm -rf temp JQVERSION="1.12.4" wget http://code.jquery.com/jquery-${JQVERSION}.js -O ./static/js/jquery.js -#Ressources for pickerdatarange -wget https://raw.githubusercontent.com/moment/moment/master/min/moment.min.js -O ./static/js/moment.min.js -wget https://raw.githubusercontent.com/longbill/jquery-date-range-picker/master/dist/jquery.daterangepicker.min.js -O ./static/js/jquery.daterangepicker.min.js -wget https://raw.githubusercontent.com/longbill/jquery-date-range-picker/master/dist/daterangepicker.min.css -O ./static/css/daterangepicker.min.css - #Ressources for dataTable wget https://cdn.datatables.net/1.10.12/js/jquery.dataTables.min.js -O ./static/js/jquery.dataTables.min.js wget https://cdn.datatables.net/plug-ins/1.10.7/integration/bootstrap/3/dataTables.bootstrap.css -O ./static/css/dataTables.bootstrap.css