add: base64 date and type selector

This commit is contained in:
Terrtia 2018-07-05 13:58:40 +02:00
parent b6d855b963
commit f7d38bea16
No known key found for this signature in database
GPG key ID: 1E1B1F50D84613D0
3 changed files with 72 additions and 13 deletions

View file

@ -49,6 +49,13 @@ def one():
return 1 return 1
# ============= ROUTES ============== # ============= 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']) @base64Decoded.route("/base64Decoded/", methods=['GET'])
def base64Decoded_page(): def base64Decoded_page():
@ -59,8 +66,11 @@ def base64Decoded_page():
#date_from = '20180628' #date_from = '20180628'
#date_to = '20180628' #date_to = '20180628'
if type not in r_serv_metadata.smembers('hash_all_type'): if type is not None:
type = None #retrieve + char
type = type.replace(' ', '+')
if type not in r_serv_metadata.smembers('hash_all_type'):
type = None
date_range = [] date_range = []
if date_from is not None and date_to is not None: if date_from is not None and date_to is not None:
@ -72,6 +82,12 @@ def base64Decoded_page():
if not date_range: if not date_range:
date_range.append(datetime.date.today().strftime("%Y%m%d")) 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 # display day type bar chart
if len(date_range) == 1 and type is None: 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) ) 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') @base64Decoded.route('/base64Decoded/hash_by_type')
def hash_by_type(): def hash_by_type():
@ -154,6 +173,9 @@ def hash_by_type():
def hash_by_type_json(): def hash_by_type_json():
type = request.args.get('type') type = request.args.get('type')
#retrieve + char
type = type.replace(' ', '+')
num_day_type = 30 num_day_type = 30
date_range_sparkline = get_date_range(num_day_type) date_range_sparkline = get_date_range(num_day_type)
@ -186,6 +208,7 @@ def daily_type_json():
for day_type in daily_type: for day_type in daily_type:
num_day_type = r_serv_metadata.zscore('base64_type:'+day_type, date) num_day_type = r_serv_metadata.zscore('base64_type:'+day_type, date)
type_value.append({ 'date' : day_type, 'value' : int( num_day_type )}) type_value.append({ 'date' : day_type, 'value' : int( num_day_type )})
return jsonify(type_value) return jsonify(type_value)
@base64Decoded.route('/base64Decoded/send_file_to_vt', methods=['POST']) @base64Decoded.route('/base64Decoded/send_file_to_vt', methods=['POST'])

View file

@ -57,7 +57,7 @@
<!-- /.col-lg-12 --> <!-- /.col-lg-12 -->
<div class="row"> <div class="row">
<div class="col-md-6"> <div class="col-md-10">
{% if type %} {% if type %}
<div id="barchart_type"> <div id="barchart_type">
</div> </div>
@ -68,9 +68,37 @@
{% endif %} {% endif %}
</div> </div>
<div class="col-md-6"> <div class="col-md-2">
<input id="date-range-from" size="40" value=""> <div class="panel panel-info" style="text-align:center;">
<input id="date-range-to" size="40" value=""> <div class="panel-heading">
Select a date range :
<form action="/base64Decoded/all_base64_search" id="base64_selector_form" method='post'>
<div class="input-group">
<span class="input-group-addon"><i class="fa fa-calendar fa" aria-hidden="true"></i></span>
<input class="form-control" id="date-range-from" placeholder="yyyy-mm-dd" value="{{ date_from }}" name="date_from">
</div>
<div class="input-group">
<span class="input-group-addon"><i class="fa fa-calendar fa" aria-hidden="true"></i></span>
<input class="form-control" id="date-range-to" placeholder="yyyy-mm-dd" value="{{ date_to }}" name="date_to">
</div>
File Type :
<select class="form-control" name="type" style="width=100%;">
<option></option>
{% for typ in l_type %}
{% if type|string() == typ|string() %}
<option selected>{{ typ }}</option>
{% else %}
<option>{{ typ }}</option>
{% endif %}
{% endfor %}
</select>
<br>
<button class="btn btn-primary" style="text-align:center;">
<i class="fa fa-files-o"></i> Base64
</button>
<form>
</div>
</div>
</div> </div>
</div> </div>
</div> </div>
@ -126,7 +154,7 @@
</tbody> </tbody>
</table> </table>
{% else %} {% else %}
<h3>{{daily_date[0:4]}}/{{daily_date[4:6]}}/{{daily_date[6:8]}}, No base64</h3> <h3>{{ date_from }} to {{ date_to }}, No base64</h3>
{% endif %} {% endif %}
</div> </div>

View file

@ -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/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/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 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}.zip -d temp/
unzip temp/${SBADMIN_VERSION}-2.zip -d temp/ unzip temp/${SBADMIN_VERSION}-2.zip -d temp/
unzip temp/FONT_AWESOME_${FONT_AWESOME_VERSION}.zip -d temp/ unzip temp/FONT_AWESOME_${FONT_AWESOME_VERSION}.zip -d temp/
unzip temp/d3_${D3_JS_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-${SBADMIN_VERSION} temp/sb-admin
mv temp/startbootstrap-sb-admin-2-${SBADMIN_VERSION} temp/sb-admin-2 mv temp/startbootstrap-sb-admin-2-${SBADMIN_VERSION} temp/sb-admin-2
mv temp/Font-Awesome-${FONT_AWESOME_VERSION} temp/font-awesome mv temp/Font-Awesome-${FONT_AWESOME_VERSION} temp/font-awesome
@ -33,19 +43,17 @@ mv temp/font-awesome/ ./static/
rm -rf ./static/css/plugins/ rm -rf ./static/css/plugins/
mv temp/sb-admin/css/* ./static/css/ mv temp/sb-admin/css/* ./static/css/
mv temp/sb-admin-2/dist/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/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 rm -rf temp
JQVERSION="1.12.4" JQVERSION="1.12.4"
wget http://code.jquery.com/jquery-${JQVERSION}.js -O ./static/js/jquery.js 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 #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/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 wget https://cdn.datatables.net/plug-ins/1.10.7/integration/bootstrap/3/dataTables.bootstrap.css -O ./static/css/dataTables.bootstrap.css