mirror of https://github.com/CIRCL/AIL-framework
				
				
				
			chg: [chats] message object template
							parent
							
								
									e0f70c5072
								
							
						
					
					
						commit
						54c57ea35b
					
				|  | @ -17,7 +17,7 @@ r_object = config_loader.get_db_conn("Kvrocks_Objects") | |||
| config_loader = None | ||||
| 
 | ||||
| AIL_OBJECTS = sorted({'chat', 'cookie-name', 'cve', 'cryptocurrency', 'decoded', 'domain', 'etag', 'favicon', 'hhhash', 'item', | ||||
|                       'pgp', 'screenshot', 'title', 'user-account', 'username'}) | ||||
|                       'message', 'pgp', 'screenshot', 'title', 'user-account', 'username'}) | ||||
| 
 | ||||
| def get_ail_uuid(): | ||||
|     ail_uuid = r_serv_db.get('ail:uuid') | ||||
|  |  | |||
|  | @ -329,7 +329,11 @@ def api_get_message(message_id): | |||
|     message = Messages.Message(message_id) | ||||
|     if not message.exists(): | ||||
|         return {"status": "error", "reason": "Unknown uuid"}, 404 | ||||
|     return message.get_meta({'content', 'icon', 'link', 'parent', 'parent_meta', 'user-account'}), 200 | ||||
|     meta = message.get_meta({'chat', 'content', 'icon', 'link', 'parent', 'parent_meta', 'user-account'}) | ||||
|     # if meta['chat']: | ||||
|     #     print(meta['chat']) | ||||
|     #     # meta['chat'] = | ||||
|     return meta, 200 | ||||
| 
 | ||||
| # # # # # # # # # # LATER | ||||
| #                 # | ||||
|  |  | |||
|  | @ -98,8 +98,6 @@ class Message(AbstractObject): | |||
| 
 | ||||
|     def get_chat_id(self):  # TODO optimize -> use me to tag Chat | ||||
|         chat_id = self.get_basename().rsplit('_', 1)[0] | ||||
|         # if chat_id.endswith('.gz'): | ||||
|         #     chat_id = chat_id[:-3] | ||||
|         return chat_id | ||||
| 
 | ||||
|     # TODO get Instance ID | ||||
|  | @ -151,9 +149,9 @@ class Message(AbstractObject): | |||
| 
 | ||||
|     def get_link(self, flask_context=False): | ||||
|         if flask_context: | ||||
|             url = url_for('correlation.show_correlation', type=self.type, id=self.id) | ||||
|             url = url_for('chats_explorer.objects_message', type=self.type, id=self.id) | ||||
|         else: | ||||
|             url = f'{baseurl}/correlation/show?type={self.type}&id={self.id}' | ||||
|             url = f'{baseurl}/objects/message?id={self.id}' | ||||
|         return url | ||||
| 
 | ||||
|     def get_svg_icon(self): | ||||
|  | @ -196,7 +194,7 @@ class Message(AbstractObject): | |||
|         else: | ||||
|             timestamp = float(timestamp) | ||||
|         timestamp = datetime.fromtimestamp(float(timestamp)) | ||||
|         meta['date'] = timestamp.strftime('%Y%m%d') | ||||
|         meta['date'] = timestamp.strftime('%Y%/m/%d') | ||||
|         meta['hour'] = timestamp.strftime('%H:%M:%S') | ||||
|         meta['full_date'] = timestamp.isoformat(' ') | ||||
| 
 | ||||
|  | @ -222,6 +220,8 @@ class Message(AbstractObject): | |||
|             meta['user-account'] = self.get_user_account(meta=True) | ||||
|             if not meta['user-account']: | ||||
|                 meta['user-account'] = {'id': 'UNKNOWN'} | ||||
|         if 'chat' in options: | ||||
|             meta['chat'] = self.get_chat_id() | ||||
| 
 | ||||
|         # meta['encoding'] = None | ||||
|         return meta | ||||
|  |  | |||
|  | @ -1,15 +1,15 @@ | |||
| #!/usr/bin/env python3 | ||||
| # -*-coding:UTF-8 -* | ||||
| 
 | ||||
| ''' | ||||
| """ | ||||
|     Blueprint Flask: crawler splash endpoints: dashboard, onion crawler ... | ||||
| ''' | ||||
| """ | ||||
| 
 | ||||
| import os | ||||
| import sys | ||||
| import json | ||||
| 
 | ||||
| from flask import Flask, render_template, jsonify, request, Blueprint, redirect, url_for, Response, abort, send_file | ||||
| from flask import Flask, render_template, jsonify, request, Blueprint, redirect, url_for, Response, abort | ||||
| from flask_login import login_required, current_user | ||||
| 
 | ||||
| # Import Role_Manager | ||||
|  | @ -19,17 +19,9 @@ sys.path.append(os.environ['AIL_BIN']) | |||
| ################################## | ||||
| # Import Project packages | ||||
| ################################## | ||||
| from lib import chats_viewer | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| ############################################ | ||||
| 
 | ||||
| from lib import ail_core | ||||
| from lib.objects import ail_objects | ||||
| from lib import chats_viewer | ||||
| from lib.objects import Chats | ||||
| from lib.objects import ChatSubChannels | ||||
| from lib import Tag | ||||
| 
 | ||||
| # ============ BLUEPRINT ============ | ||||
| chats_explorer = Blueprint('chats_explorer', __name__, template_folder=os.path.join(os.environ['AIL_FLASK'], 'templates/chats_explorer')) | ||||
|  | @ -112,11 +104,12 @@ def objects_subchannel_messages(): | |||
| @chats_explorer.route("/objects/message", methods=['GET']) | ||||
| @login_required | ||||
| @login_read_only | ||||
| def objects_dashboard_chat(): | ||||
| def objects_message(): | ||||
|     message_id = request.args.get('id') | ||||
|     message = chats_viewer.api_get_message(message_id) | ||||
|     if message[1] != 200: | ||||
|         return create_json_response(message[0], message[1]) | ||||
|     else: | ||||
|         message = message[0] | ||||
|         return render_template('ChatMessage.html', meta=message, bootstrap_label=bootstrap_label) | ||||
|         return render_template('ChatMessage.html', meta=message, bootstrap_label=bootstrap_label, | ||||
|                                modal_add_tags=Tag.get_modal_add_tags(message['id'], object_type='message')) | ||||
|  |  | |||
|  | @ -9,6 +9,8 @@ | |||
| 	<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"> | ||||
|     <link href="{{ url_for('static', filename='css/tags.css') }}" rel="stylesheet" type="text/css" /> | ||||
|     <link href="{{ url_for('static', filename='css/ail-project.css') }}" rel="stylesheet"> | ||||
| 
 | ||||
|   <!-- JS --> | ||||
| 	<script src="{{ url_for('static', filename='js/jquery.js')}}"></script> | ||||
|  | @ -16,6 +18,7 @@ | |||
| 	<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> | ||||
|     <script src="{{ url_for('static', filename='js/tags.js') }}"></script> | ||||
| 
 | ||||
| 	<style> | ||||
|         .chat-message-left, | ||||
|  | @ -27,6 +30,13 @@ | |||
|             flex-direction: row-reverse; | ||||
|             margin-left: auto | ||||
|         } | ||||
|         .divider:after, | ||||
|         .divider:before { | ||||
|             content: ""; | ||||
|             flex: 1; | ||||
|             height: 2px; | ||||
|             background: #eee; | ||||
|         } | ||||
| 	</style> | ||||
| </head> | ||||
| <body> | ||||
|  | @ -50,11 +60,9 @@ | |||
|                                         <table class="table"> | ||||
|                                             <thead> | ||||
|                                                 <tr> | ||||
|                                                     <th>Object subtype</th> | ||||
|                                                     <th>First seen</th> | ||||
|                                                     <th>Last seen</th> | ||||
|                                                     <th></th> | ||||
|                                                     <th>Date</th> | ||||
|                                                     <th>Username</th> | ||||
|                                                     <th>Nb seen</th> | ||||
|                                                 </tr> | ||||
|                                             </thead> | ||||
|                                             <tbody> | ||||
|  | @ -68,14 +76,12 @@ | |||
|                                                         </svg> | ||||
|                                                         {{ meta["subtype"] }} | ||||
|                                                     </td> | ||||
|                                                     <td>{{ meta['first_seen'] }}</td> | ||||
|                                                     <td>{{ meta['last_seen'] }}</td> | ||||
|                                                     <td>{{ meta['full_date'] }}</td> | ||||
|                                                     <td> | ||||
|                                                         {% if 'username' in meta %} | ||||
|                                                             {{ meta['username']['id'] }} | ||||
|                                                         {% if 'username' in meta['user-account'] %} | ||||
|                                                             {{ meta['user-account']['username']['id'] }} | ||||
|                                                         {% endif %} | ||||
|                                                     </td> | ||||
|                                                     <td>{{ meta['nb_seen'] }}</td> | ||||
|                                                 </tr> | ||||
|                                             </tbody> | ||||
|                                         </table> | ||||
|  | @ -85,29 +91,44 @@ | |||
|                                     </div> | ||||
|                                 </div> | ||||
|                             </li> | ||||
|                             <li class="list-group-item py-0"> | ||||
|                                 <br> | ||||
|                                 <div class="mb-3"> | ||||
|                                     Tags: | ||||
|                         </ul> | ||||
| 
 | ||||
|                         <div> | ||||
|                             <h5> | ||||
|                                 <span> | ||||
|                                     {% include 'modals/edit_tag.html' %} | ||||
| 
 | ||||
|                                     {% for tag in meta['tags'] %} | ||||
|                                         <button class="btn btn-{{ bootstrap_label[loop.index0 % 5] }}" data-toggle="modal" data-target="#edit_tags_modal" | ||||
|                                         data-tagid="{{ tag }}" data-objtype="chat" data-objsubtype="{{ meta["subtype"] }}" data-objid="{{ meta["id"] }}"> | ||||
|                                         data-tagid="{{ tag }}" data-objtype="{{ meta['type'] }}" data-objsubtype="" data-objid="{{ meta['id'] }}"> | ||||
|                                             {{ tag }} | ||||
|                                         </button> | ||||
|                                     {%  endfor %} | ||||
|                                     {% include 'modals/add_tags.html' %} | ||||
|                                     <button type="button" class="btn btn-light" data-toggle="modal" data-target="#add_tags_modal"> | ||||
|                                         <i class="far fa-plus-square"></i> | ||||
|                                     </button> | ||||
|                                 </div> | ||||
|                             </li> | ||||
|                         </ul> | ||||
|                                 </span> | ||||
|                             </h5> | ||||
|                         </div> | ||||
| 
 | ||||
|                         {% with obj_type='chat', obj_id=meta['id'], obj_subtype=meta['subtype'] %} | ||||
|                             {% include 'modals/investigations_register_obj.html' %} | ||||
|                         {% endwith %} | ||||
|                         <button type="button" class="btn btn-primary" data-toggle="modal" data-target="#investigations_register_obj_modal"> | ||||
|                             <i class="fas fa-microscope"></i> Investigations | ||||
|                         </button> | ||||
|                         <div class="d-flex flex-row-reverse bd-highlight"> | ||||
|                             <div> | ||||
|                                 <a href="{{ url_for('correlation.show_correlation')}}?type={{ meta['type'] }}&id={{ meta['id'] }}" target="_blank"> | ||||
|                                     <button class="btn btn-lg btn-info"><i class="fas fa-project-diagram"></i> Correlations Graph</button> | ||||
|                                 </a> | ||||
|                             </div> | ||||
|                             <div> | ||||
|                                 {% with obj_type=meta['type'], obj_id=meta['id'], obj_subtype=''%} | ||||
|                                     {% include 'modals/investigations_register_obj.html' %} | ||||
|                                 {% endwith %} | ||||
|                                 <div class="mr-2"> | ||||
|                                     <button type="button" class="btn btn-lg btn-primary" data-toggle="modal" data-target="#investigations_register_obj_modal"> | ||||
|                                         <i class="fas fa-microscope"></i> Investigations | ||||
|                                     </button> | ||||
|                                 </div> | ||||
|                             </div> | ||||
|                           </div> | ||||
| 
 | ||||
|                     </div> | ||||
|                 </div> | ||||
|  | @ -116,7 +137,11 @@ | |||
|                 <div class="position-relative"> | ||||
|                     <div class="chat-messages p-2"> | ||||
| 
 | ||||
|                         <span class="badge badge-secondary mb-2">{{ meta['date'] }}</span> | ||||
|                         <div class="divider d-flex align-items-center mb-4"> | ||||
|                                 <p class="text-center h2 mx-3 mb-0" style="color: #a2aab7;"> | ||||
|                                     <span class="badge badge-secondary mb-2" id="date_section_{{ meta['date'] }}">{{ meta['date'] }}</span> | ||||
|                                 </p> | ||||
|                             </div> | ||||
| 
 | ||||
|                         <div class="chat-message-left pb-1"> | ||||
|                             <div> | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue
	
	 terrtia
						terrtia