mirror of https://github.com/CIRCL/AIL-framework
chg: [chats explorer] add chat monitoring request
parent
34d64e74d3
commit
24046734c1
|
@ -17,6 +17,7 @@ sys.path.append(os.environ['AIL_BIN'])
|
||||||
##################################
|
##################################
|
||||||
# Import Project packages
|
# Import Project packages
|
||||||
##################################
|
##################################
|
||||||
|
from lib.ail_core import generate_uuid
|
||||||
from lib.ConfigLoader import ConfigLoader
|
from lib.ConfigLoader import ConfigLoader
|
||||||
from lib.objects import Chats
|
from lib.objects import Chats
|
||||||
from lib.objects import ChatSubChannels
|
from lib.objects import ChatSubChannels
|
||||||
|
@ -592,6 +593,64 @@ def get_message_report(l_mess): # TODO Force language + translation
|
||||||
|
|
||||||
return chats, messages
|
return chats, messages
|
||||||
|
|
||||||
|
# # # # # # # # # # # # # #
|
||||||
|
# #
|
||||||
|
# ChatMonitoringRequest #
|
||||||
|
# #
|
||||||
|
# # # # # # # # # # # # # #
|
||||||
|
|
||||||
|
def get_chats_monitoring_requests():
|
||||||
|
return r_obj.smembers(f'chats:requests')
|
||||||
|
|
||||||
|
def get_chats_monitoring_requests_metas():
|
||||||
|
requests = []
|
||||||
|
for r in get_chats_monitoring_requests():
|
||||||
|
cr = ChatsMonitoringRequest(r)
|
||||||
|
requests.append(cr.get_meta())
|
||||||
|
return requests
|
||||||
|
|
||||||
|
class ChatsMonitoringRequest:
|
||||||
|
def __init__(self, r_uuid):
|
||||||
|
self.uuid = r_uuid
|
||||||
|
|
||||||
|
def _get_field(self, name):
|
||||||
|
return r_obj.hget(f'chats:request:{self.uuid}', name)
|
||||||
|
|
||||||
|
def _set_field(self, name, value):
|
||||||
|
r_obj.hset(f'chats:request:{self.uuid}', name, value)
|
||||||
|
|
||||||
|
def exists(self):
|
||||||
|
r_obj.exists(f'chats:request:{self.uuid}')
|
||||||
|
|
||||||
|
def get_meta(self):
|
||||||
|
return {'uuid': self.uuid,
|
||||||
|
'date': self._get_field('date'),
|
||||||
|
'creator': self._get_field('creator'),
|
||||||
|
'chat_type': self._get_field('chat_type'),
|
||||||
|
'invite': self._get_field('invite'),
|
||||||
|
'username': self._get_field('username'),
|
||||||
|
'description': self._get_field('description'),
|
||||||
|
}
|
||||||
|
|
||||||
|
def create(self, creator, chat_type, invite, username, description):
|
||||||
|
self._set_field('chat_type', chat_type)
|
||||||
|
self._set_field('creator', creator)
|
||||||
|
self._set_field('date', datetime.now().strftime('%Y-%m-%d %H:%M:%S'))
|
||||||
|
if invite:
|
||||||
|
self._set_field('invite', invite)
|
||||||
|
if username:
|
||||||
|
self._set_field('username', username)
|
||||||
|
if description:
|
||||||
|
self._set_field('description', description)
|
||||||
|
r_obj.sadd(f'chats:requests', self.uuid)
|
||||||
|
|
||||||
|
def create_chat_monitoring_requests(creator, chat_type, invite, username, description):
|
||||||
|
r_uuid = generate_uuid()
|
||||||
|
chat_request = ChatsMonitoringRequest(r_uuid)
|
||||||
|
chat_request.create(creator, chat_type, invite, username, description)
|
||||||
|
return r_uuid
|
||||||
|
|
||||||
|
|
||||||
#### FIX ####
|
#### FIX ####
|
||||||
|
|
||||||
def fix_correlations_subchannel_message():
|
def fix_correlations_subchannel_message():
|
||||||
|
|
|
@ -221,6 +221,35 @@ def objects_thread_messages_download():
|
||||||
|
|
||||||
#### ####
|
#### ####
|
||||||
|
|
||||||
|
@chats_explorer.route("/chats/explorer/chat/monitoring/request", methods=['GET', 'POST'])
|
||||||
|
@login_required
|
||||||
|
@login_user_no_api
|
||||||
|
def chat_monitoring_request():
|
||||||
|
if request.method == 'POST':
|
||||||
|
user_id = current_user.get_user_id()
|
||||||
|
chat_type = request.form.get('type')
|
||||||
|
username = request.form.get('username')
|
||||||
|
invite = request.form.get('invite')
|
||||||
|
description = request.form.get('description')
|
||||||
|
if chat_type not in ['discord', 'telegram']:
|
||||||
|
return create_json_response({"status": "error", "reason": "Invalid Chat Type"}, 400)
|
||||||
|
if not username and not invite and not description:
|
||||||
|
return create_json_response({"status": "error", "reason": "Please provide a username/username/invite/comment"}, 400)
|
||||||
|
cm_uuid = chats_viewer.create_chat_monitoring_requests(user_id, chat_type, invite, username, description)
|
||||||
|
return render_template('request_chat_monitoring.html', uuid=cm_uuid)
|
||||||
|
else:
|
||||||
|
return render_template('request_chat_monitoring.html')
|
||||||
|
|
||||||
|
|
||||||
|
@chats_explorer.route("/chats/explorer/chat/monitoring/request/admin", methods=['GET'])
|
||||||
|
@login_required
|
||||||
|
@login_admin
|
||||||
|
def chat_monitoring_requests():
|
||||||
|
metas = chats_viewer.get_chats_monitoring_requests_metas()
|
||||||
|
return render_template('chat_monitoring_requests.html', metas=metas)
|
||||||
|
|
||||||
|
#### ####
|
||||||
|
|
||||||
|
|
||||||
@chats_explorer.route("/objects/message", methods=['GET'])
|
@chats_explorer.route("/objects/message", methods=['GET'])
|
||||||
@login_required
|
@login_required
|
||||||
|
|
Binary file not shown.
After Width: | Height: | Size: 542 KiB |
|
@ -0,0 +1,85 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>AIL-Framework</title>
|
||||||
|
<link rel="icon" href="{{ url_for('static', filename='image/ail-icon.png')}}">
|
||||||
|
<!-- Core CSS -->
|
||||||
|
<link rel="stylesheet" type="text/css" href="{{ url_for('static', filename='css/ail-project.css') }}" />
|
||||||
|
<link href="{{ url_for('static', filename='css/bootstrap4.min.css') }}" rel="stylesheet">
|
||||||
|
<link href="{{ url_for('static', filename='css/font-awesome.min.css') }}" rel="stylesheet">
|
||||||
|
<link href="{{ url_for('static', filename='css/dataTables.bootstrap.min.css') }}" rel="stylesheet">
|
||||||
|
|
||||||
|
<!-- JS -->
|
||||||
|
<script src="{{ url_for('static', filename='js/jquery.js')}}"></script>
|
||||||
|
<script src="{{ url_for('static', filename='js/popper.min.js')}}"></script>
|
||||||
|
<script src="{{ url_for('static', filename='js/bootstrap4.min.js')}}"></script>
|
||||||
|
<script src="{{ url_for('static', filename='js/jquery.dataTables.min.js')}}"></script>
|
||||||
|
<script src="{{ url_for('static', filename='js/dataTables.bootstrap.min.js')}}"></script>
|
||||||
|
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
|
||||||
|
{% include 'nav_bar.html' %}
|
||||||
|
|
||||||
|
<div class="container-fluid">
|
||||||
|
<div class="row">
|
||||||
|
|
||||||
|
{% include 'sidebars/sidebar_objects.html' %}
|
||||||
|
|
||||||
|
<div class="col-12 col-lg-10" id="core_content">
|
||||||
|
|
||||||
|
<h3>Monitoring Requests:</h3>
|
||||||
|
|
||||||
|
<table id="table_investigation" class="table table-striped border-primary">
|
||||||
|
<thead class="bg-dark text-white">
|
||||||
|
<tr>
|
||||||
|
<th>UUID</th>
|
||||||
|
<th>Date</th>
|
||||||
|
<th>Creator</th>
|
||||||
|
<th>Type</th>
|
||||||
|
<th>Username</th>
|
||||||
|
<td>Invite</td>
|
||||||
|
<th>Description</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody style="font-size: 15px;">
|
||||||
|
{% for meta in metas %}
|
||||||
|
<tr class="border-color: blue;">
|
||||||
|
<td>
|
||||||
|
{{ meta['uuid'] }}
|
||||||
|
</td>
|
||||||
|
<td>{{ meta['date'] }}</td>
|
||||||
|
<td>{{ meta['creator'] }}</td>
|
||||||
|
<td>{{ meta['chat_type'] }}</td>
|
||||||
|
<td>{{ meta['username'] }}</td>
|
||||||
|
<td>{{ meta['invite'] }}</td>
|
||||||
|
<td>{{ meta['description'] }}</td>
|
||||||
|
</tr>
|
||||||
|
{% endfor %}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
$(document).ready(function(){
|
||||||
|
$('#nav_investigation').removeClass("text-muted");
|
||||||
|
$("#nav_add_investigation").addClass("active");
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
$('#table_investigation').DataTable({
|
||||||
|
"aLengthMenu": [[5, 10, 15, -1], [5, 10, 15, "All"]],
|
||||||
|
"iDisplayLength": 10,
|
||||||
|
"order": [[ 2, "desc" ]]
|
||||||
|
});
|
||||||
|
|
||||||
|
</script>
|
|
@ -51,6 +51,25 @@
|
||||||
<h4>No Protocol/Chats Imported</h4>
|
<h4>No Protocol/Chats Imported</h4>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
<br>
|
||||||
|
<br>
|
||||||
|
<br>
|
||||||
|
<br>
|
||||||
|
<br>
|
||||||
|
<div class="text-center">
|
||||||
|
{# <img src="{{ url_for('static', filename='image/tm.png') }}" style="max-width: 400px">#}
|
||||||
|
<div>
|
||||||
|
<a class="btn btn-light border-secondary" style="" href="{{ url_for('chats_explorer.chat_monitoring_request') }}">
|
||||||
|
<div class="card-body">
|
||||||
|
<h4 class="card-title">
|
||||||
|
<img src="{{ url_for('static', filename='image/tm.png') }}" style="max-width: 200px">
|
||||||
|
<b>Request Chat Monitoring</b>
|
||||||
|
</h4>
|
||||||
|
</div>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -0,0 +1,106 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>AIL-Framework</title>
|
||||||
|
<link rel="icon" href="{{ url_for('static', filename='image/ail-icon.png')}}">
|
||||||
|
<!-- Core CSS -->
|
||||||
|
<link rel="stylesheet" type="text/css" href="{{ url_for('static', filename='css/ail-project.css') }}" />
|
||||||
|
<link href="{{ url_for('static', filename='css/bootstrap4.min.css') }}" rel="stylesheet">
|
||||||
|
<link href="{{ url_for('static', filename='css/font-awesome.min.css') }}" rel="stylesheet">
|
||||||
|
|
||||||
|
<!-- JS -->
|
||||||
|
<script src="{{ url_for('static', filename='js/jquery.js')}}"></script>
|
||||||
|
<script src="{{ url_for('static', filename='js/popper.min.js')}}"></script>
|
||||||
|
<script src="{{ url_for('static', filename='js/bootstrap4.min.js')}}"></script>
|
||||||
|
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
|
||||||
|
{% include 'nav_bar.html' %}
|
||||||
|
|
||||||
|
<div class="container-fluid">
|
||||||
|
<div class="row">
|
||||||
|
|
||||||
|
{% include 'sidebars/sidebar_objects.html' %}
|
||||||
|
|
||||||
|
<div class="col-12 col-lg-10" id="core_content">
|
||||||
|
|
||||||
|
<div class="card my-3">
|
||||||
|
<div class="card-header">
|
||||||
|
<h4 class="card-title">
|
||||||
|
<img src="{{ url_for('static', filename='image/tm.png') }}" style="max-width: 200px">
|
||||||
|
<b>Request Chat Monitoring</b>
|
||||||
|
</h4>
|
||||||
|
</div>
|
||||||
|
<div class="card-body">
|
||||||
|
|
||||||
|
{% if uuid %}
|
||||||
|
<h1>Chat Monitoring Request {{ uuid }} Created</h1>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
<form action="{{ url_for('chats_explorer.chat_monitoring_request') }}" method='post'>
|
||||||
|
|
||||||
|
<label class="mt-3" for="level_selector">Type</label>
|
||||||
|
<select class="custom-select" id="level_selector" name="type">
|
||||||
|
<option value="telegram" selected>Telegram</option>
|
||||||
|
<option value="discord">Discord</option>
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="username"><b>Chat Username</b></label>
|
||||||
|
<input type="text" class="form-control" id="username" name="username">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="invite"><b>Chat Invite</b></label>
|
||||||
|
<input type="text" class="form-control" id="invite" name="invite">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="description"><b>Comments</b></label>
|
||||||
|
<textarea class="form-control" id="paste_content" name="description" rows="5"></textarea>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<button class="btn btn-info" type="submit" value=Upload><i class="fas fa-plus"></i> Request Monitoring</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
</form>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
$(document).ready(function(){
|
||||||
|
$("#page-Decoded").addClass("active");
|
||||||
|
$("#nav_explorer_chat").addClass("active");
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
function toggle_sidebar(){
|
||||||
|
if($('#nav_menu').is(':visible')){
|
||||||
|
$('#nav_menu').hide();
|
||||||
|
$('#side_menu').removeClass('border-right')
|
||||||
|
$('#side_menu').removeClass('col-lg-2')
|
||||||
|
$('#core_content').removeClass('col-lg-10')
|
||||||
|
}else{
|
||||||
|
$('#nav_menu').show();
|
||||||
|
$('#side_menu').addClass('border-right')
|
||||||
|
$('#side_menu').addClass('col-lg-2')
|
||||||
|
$('#core_content').addClass('col-lg-10')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
</script>
|
Loading…
Reference in New Issue