diff --git a/bin/lib/objects/CookiesNames.py b/bin/lib/objects/CookiesNames.py index 57eee5e9..25b87e6d 100755 --- a/bin/lib/objects/CookiesNames.py +++ b/bin/lib/objects/CookiesNames.py @@ -119,7 +119,7 @@ class CookiesNames(AbstractDaterangeObjects): if flask_context: url = url_for('objects_cookie_name.objects_cookies_names') else: - url = f'{baseurl}/objects/cookie-name' + url = f'{baseurl}/objects/cookie-names' return url def sanitize_id_to_search(self, name_to_search): diff --git a/bin/lib/objects/FilesNames.py b/bin/lib/objects/FilesNames.py index 6c88da04..a2fa3366 100755 --- a/bin/lib/objects/FilesNames.py +++ b/bin/lib/objects/FilesNames.py @@ -46,7 +46,7 @@ class FileName(AbstractDaterangeObject): return url def get_svg_icon(self): - return {'style': 'far', 'icon': '\uf249', 'color': '#36F5D5', 'radius': 5} + return {'style': 'far', 'icon': '\uf15b', 'color': '#36F5D5', 'radius': 5} def get_misp_object(self): obj_attrs = [] @@ -91,12 +91,11 @@ class FilesNames(AbstractDaterangeObjects): return {'fa': 'far', 'icon': 'file'} def get_link(self, flask_context=False): - pass - # if flask_context: - # url = url_for('objects_favicon.objects_favicons') - # else: - # url = f'{baseurl}/objects/favicons' - # return url + if flask_context: + url = url_for('objects_file_name.objects_files_names') + else: + url = f'{baseurl}/objects/file-names' + return url def sanitize_id_to_search(self, name_to_search): return name_to_search diff --git a/var/www/Flask_server.py b/var/www/Flask_server.py index 63be442c..978f44ee 100755 --- a/var/www/Flask_server.py +++ b/var/www/Flask_server.py @@ -60,6 +60,7 @@ from blueprints.objects_ocr import objects_ocr from blueprints.objects_barcode import objects_barcode from blueprints.objects_qrcode import objects_qrcode from blueprints.objects_favicon import objects_favicon +from blueprints.objects_file_name import objects_file_name from blueprints.api_rest import api_rest @@ -148,6 +149,7 @@ app.register_blueprint(objects_ocr, url_prefix=baseUrl) app.register_blueprint(objects_barcode, url_prefix=baseUrl) app.register_blueprint(objects_qrcode, url_prefix=baseUrl) app.register_blueprint(objects_favicon, url_prefix=baseUrl) +app.register_blueprint(objects_file_name, url_prefix=baseUrl) app.register_blueprint(api_rest, url_prefix=baseUrl) # ========= =========# diff --git a/var/www/blueprints/objects_cookie_name.py b/var/www/blueprints/objects_cookie_name.py index 0bea4936..4dd76b60 100644 --- a/var/www/blueprints/objects_cookie_name.py +++ b/var/www/blueprints/objects_cookie_name.py @@ -29,7 +29,7 @@ bootstrap_label = ['primary', 'success', 'danger', 'warning', 'info'] # ============ FUNCTIONS ============ -@objects_cookie_name.route("/objects/cookie-name", methods=['GET']) +@objects_cookie_name.route("/objects/cookie-names", methods=['GET']) @login_required @login_read_only def objects_cookies_names(): diff --git a/var/www/blueprints/objects_file_name.py b/var/www/blueprints/objects_file_name.py new file mode 100644 index 00000000..cb930f85 --- /dev/null +++ b/var/www/blueprints/objects_file_name.py @@ -0,0 +1,87 @@ +#!/usr/bin/env python3 +# -*-coding:UTF-8 -* + +''' + Blueprint Flask: crawler splash endpoints: dashboard, onion crawler ... +''' + +import os +import sys + +from flask import render_template, jsonify, request, Blueprint, redirect, url_for, Response, abort +from flask_login import login_required + +# Import Role_Manager +from Role_Manager import login_admin, login_read_only + +sys.path.append(os.environ['AIL_BIN']) +################################## +# Import Project packages +################################## +from lib.objects import FilesNames +from packages import Date + +# ============ BLUEPRINT ============ +objects_file_name = Blueprint('objects_file_name', __name__, template_folder=os.path.join(os.environ['AIL_FLASK'], 'templates/objects/file-name')) + +# ============ VARIABLES ============ +bootstrap_label = ['primary', 'success', 'danger', 'warning', 'info'] + + +# ============ FUNCTIONS ============ +@objects_file_name.route("/objects/file-names", methods=['GET']) +@login_required +@login_read_only +def objects_files_names(): + date_from = request.args.get('date_from') + date_to = request.args.get('date_to') + show_objects = request.args.get('show_objects') + date = Date.sanitise_date_range(date_from, date_to) + date_from = date['date_from'] + date_to = date['date_to'] + + if show_objects: + dict_objects = FilesNames.FilesNames().api_get_meta_by_daterange(date_from, date_to) + print(dict_objects) + else: + dict_objects = {} + + return render_template("FileNameDaterange.html", date_from=date_from, date_to=date_to, + dict_objects=dict_objects, show_objects=show_objects) + +@objects_file_name.route("/objects/file-name/post", methods=['POST']) +@login_required +@login_read_only +def objects_files_names_post(): + date_from = request.form.get('date_from') + date_to = request.form.get('date_to') + show_objects = request.form.get('show_objects') + return redirect(url_for('objects_file_name.objects_files_names', date_from=date_from, date_to=date_to, show_objects=show_objects)) + +@objects_file_name.route("/objects/file-name/range/json", methods=['GET']) +@login_required +@login_read_only +def objects_file_name_range_json(): + date_from = request.args.get('date_from') + date_to = request.args.get('date_to') + date = Date.sanitise_date_range(date_from, date_to) + date_from = date['date_from'] + date_to = date['date_to'] + return jsonify(FilesNames.FilesNames().api_get_chart_nb_by_daterange(date_from, date_to)) + +# @objects_file_name.route("/objects/file-nam/search", methods=['POST']) +# @login_required +# @login_read_only +# def objects_files_names_search(): +# to_search = request.form.get('object_id') +# +# # TODO SANITIZE ID +# # TODO Search all +# cve = Cves.Cve(to_search) +# if not cve.exists(): +# abort(404) +# else: +# return redirect(cve.get_link(flask_context=True)) + +# ============= ROUTES ============== + diff --git a/var/www/templates/objects/file-name/FileNameDaterange.html b/var/www/templates/objects/file-name/FileNameDaterange.html new file mode 100644 index 00000000..2b5bf534 --- /dev/null +++ b/var/www/templates/objects/file-name/FileNameDaterange.html @@ -0,0 +1,602 @@ + + + + + Files Names - AIL + + + + + + + + + + + + + + + + + + + + + + + + {% include 'nav_bar.html' %} + +
+
+ + {% include 'sidebars/sidebar_objects.html' %} + +
+ +
+
+
+ +{# {% include 'file-name/block_file_name_search.html' %}#} + +
+ + +
+ +
+
+
Select a date range :
+
+
+
+ +
+
+
+ +
+
+ + +
+ +
+
+
+ +
+
+
+
+
+
+ + {% if dict_objects %} + {% if date_from|string == date_to|string %} +

{{ date_from }} File Name:

+ {% else %} +

{{ date_from }} to {{ date_to }} File Name:

+ {% endif %} + + + + + + + + + + + + {% for obj_id in dict_objects %} + + + + + + + + {% endfor %} + +
First SeenLast SeenTotalLast days
{{ obj_id }}{{ dict_objects[obj_id]['first_seen'] }}{{ dict_objects[obj_id]['last_seen'] }}{{ dict_objects[obj_id]['nb_seen'] }}
+ + + {% else %} + {% if show_objects %} + {% if date_from|string == date_to|string %} +

{{ date_from }}, No File Name

+ {% else %} +

{{ date_from }} to {{ date_to }}, No File Name

+ {% endif %} + {% endif %} + {% endif %} +
+ +
+
+ + + + + + + + + + + + + + + + + diff --git a/var/www/templates/objects/file-name/block_file_name_search.html b/var/www/templates/objects/file-name/block_file_name_search.html new file mode 100644 index 00000000..e69de29b diff --git a/var/www/templates/objects/file-name/search_file_name_result.html b/var/www/templates/objects/file-name/search_file_name_result.html new file mode 100644 index 00000000..e69de29b diff --git a/var/www/templates/sidebars/sidebar_objects.html b/var/www/templates/sidebars/sidebar_objects.html index f475b9f1..5f07abd2 100644 --- a/var/www/templates/sidebars/sidebar_objects.html +++ b/var/www/templates/sidebars/sidebar_objects.html @@ -81,6 +81,12 @@ Favicon + +