This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository mum. See http://git.chorem.org/mum.git commit af8cce63ab5284bb60c00d48e8cacbdd7e4a1895 Author: Alexis Guilbaud <guilbaud@codelutin.com> Date: Wed Jun 17 11:35:54 2015 +0200 modal for logs on dashboard + nmap scan exception handling for range + copyright file corrected --- app/module_loader.py | 14 +++++++++++++- app/modules/nmap_detection.py | 14 +++++++------- app/websocket_func.py | 7 ++++++- debian/copyright | 20 ++++++++++---------- static/js/controllers/dashboardCtrl.js | 27 +++++++++++++++++++++++++++ static/js/controllers/headCtrl.js | 3 +++ views/dashboard.html | 20 ++++++++++++++++++++ 7 files changed, 86 insertions(+), 19 deletions(-) diff --git a/app/module_loader.py b/app/module_loader.py index a77ee7a..17a2973 100644 --- a/app/module_loader.py +++ b/app/module_loader.py @@ -18,6 +18,7 @@ import sys import os import traceback import logging +import pexpect class ModuleLoader: @@ -623,4 +624,15 @@ class ModuleLoader: """ host_info = self.db.get_host_informations(addr_host) host_info['compatible_os_list'] = self.compatible_os_list - return host_info \ No newline at end of file + return host_info + + def get_logs(self, log_size): + """ + Will exec the tail on the log file and return the content. + :param log_size: the n last number of the file to get + :return: the log_size last lines of the log file + """ + log_location = self.conf['log_location'] + child = pexpect.spawn('tail', [log_location, '-n', str(log_size)]) + child.expect(pexpect.EOF) + return child.before diff --git a/app/modules/nmap_detection.py b/app/modules/nmap_detection.py index f3c75c0..6b9d036 100644 --- a/app/modules/nmap_detection.py +++ b/app/modules/nmap_detection.py @@ -3,6 +3,7 @@ __author__ = 'aguilbaud' from xml.dom import minidom import pexpect import json +import logging from random import choice from string import letters @@ -17,6 +18,7 @@ class nmap_detection: self.list_mod_conn = list_mod_conn self.dict_mod_monitoring = dict_mod_monitoring self.HostNotFoundException = hnfe + self.logger = logging.getLogger("mum_log") # function for splitting the different ranges of the IP adress # launch the nmap detection of each ip under this range @@ -65,7 +67,11 @@ class nmap_detection: for byte_2 in range(int(split_byte_2[0]), int(split_byte_2[1]) + 1): for byte_3 in range(int(split_byte_3[0]), int(split_byte_3[1]) + 1): for byte_4 in range(int(split_byte_4[0]), int(split_byte_4[1]) + 1): - self.launch_detection(byte_1, byte_2, byte_3, byte_4) + try: + self.launch_detection(byte_1, byte_2, byte_3, byte_4) + except self.HostNotFoundException as hnfe: + self.logger.warning(hnfe.__str__()) + self.ws.send(json.dumps({"ERROR": hnfe.__str__()})) # once finished, returns the list of scanned ip return json.dumps(self.scanned_ip) @@ -92,10 +98,7 @@ class nmap_detection: while child.isalive(): child.expect('Completed', timeout=None) except pexpect.EOF: - #try: self.parse_res(ip) - #except: - # self.ws.send(json.dumps({"40": "Database error"})) except pexpect.TIMEOUT: self.ws.send(json.dumps({"ERROR": "Timeout on nmap execution"})) except pexpect.ExceptionPexpect: @@ -108,11 +111,8 @@ class nmap_detection: while child.isalive(): child.expect('Completed', timeout=None) except pexpect.EOF: - #try: self.parse_res(hostname) return json.dumps(self.scanned_ip) - #except: - # self.ws.send(json.dumps({"40": "Database error"})) except pexpect.TIMEOUT: self.ws.send(json.dumps({"ERROR": "Timeout on nmap execution"})) except pexpect.ExceptionPexpect: diff --git a/app/websocket_func.py b/app/websocket_func.py index 83bd05b..39c8f4f 100644 --- a/app/websocket_func.py +++ b/app/websocket_func.py @@ -153,4 +153,9 @@ def TASK_LIST(msg, ws, ml): def GET_SCAN_OPTIONS(msg, ws, ml): - ws.send(json.dumps({"RES_GET_SCAN_OPTIONS": ml.get_scan_options()})) \ No newline at end of file + ws.send(json.dumps({"RES_GET_SCAN_OPTIONS": ml.get_scan_options()})) + + +def GET_LOGS(msg, ws, ml): + log_size = msg['GET_LOGS'] + ws.send(json.dumps({'RES_GET_LOGS': ml.get_logs(log_size)})) \ No newline at end of file diff --git a/debian/copyright b/debian/copyright index 677c2d2..a75fb76 100644 --- a/debian/copyright +++ b/debian/copyright @@ -6,42 +6,42 @@ Files: debian/* Copyright: 2015 Alexis Guilbaud License: AGPL -Files: debian/bower_components/angular/* +Files: debian/mum/usr/lib/bower_components/angular/* Copyright: 2010-2014 Google, Inc. License: MIT -Files: debian/bower_components/angular-bootstrap/* +Files: debian/mum/usr/lib/bower_components/angular-bootstrap/* Copyright: 2015 License: MIT -Files: debian/bower_components/angular-charts/* +Files: debian/mum/usr/lib/bower_components/angular-charts/* Copyright: 2013 Chinmay License: MIT -Files: debian/bower_components/angular-file-upload/* +Files: debian/mum/usr/lib/bower_components/angular-file-upload/* Copyright: 2013 nerv. License: MIT -Files: debian/bower_components/angular-route/* +Files: debian/mum/usr/lib/bower_components/angular-route/* Copyright: 2010-2014 Google, Inc. License: MIT -Files: debian/bower_components/angular-sanitize/* +Files: debian/mum/usr/lib/bower_components/angular-sanitize/* Copyright: 2010-2014 Google, Inc. License: MIT -Files: debian/bower_components/angular-ui-select/* +Files: debian/mum/usr/lib/bower_components/angular-ui-select/* Copyright: 2013-2014 AngularUI License: MIT -Files: debian/bower_components/bootstrap/* +Files: debian/mum/usr/lib/bower_components/bootstrap/* Copyright: 2011-2014 Twitter, Inc License: MIT -Files: debian/bower_components/d3/* +Files: debian/mum/usr/lib/bower_components/d3/* Copyright: 2013 Michael Bostock License: MIT -Files: debian/bower_components/es5-shim/* +Files: debian/mum/usr/lib/bower_components/es5-shim/* Copyright: 2009-2014 Kristopher Michael Kowal and contributors License: MIT \ No newline at end of file diff --git a/static/js/controllers/dashboardCtrl.js b/static/js/controllers/dashboardCtrl.js index fe65277..a210f3d 100644 --- a/static/js/controllers/dashboardCtrl.js +++ b/static/js/controllers/dashboardCtrl.js @@ -140,6 +140,14 @@ mumApp.controller('dashboardCtrl', function ($scope, $routeParams, $location, $r }); }; + $scope.open_modal_log = function () { + var modalInstance = $modal.open({ + templateUrl: 'modal_log_label.html', + controller: 'ModalLogInstanceCtrl', + size: 'lg' + }); + }; + /* Group view functions */ $scope.group_obj = {}; /* {group_name:{"hosts":[addr1, ...],"status":"success"}, ...} */ @@ -294,4 +302,23 @@ mumApp.controller('ModalNotifInstanceCtrl', function ($scope, $rootScope, $modal $scope.close = function () { $modalInstance.close(); }; +}); + +mumApp.controller('ModalLogInstanceCtrl', function ($scope, $rootScope, $modalInstance, $route, $timeout) { + $scope.log_content = ""; + $scope.nb_lines = 50; + + $scope.update = function(){ + $rootScope.$broadcast("sendViaWs", JSON.stringify({"GET_LOGS": $scope.nb_lines})); + }; + + $scope.$on("resGetLogs", function (event, args) { + $timeout(function () { + $scope.log_content = args; + }, 0); + }); + + $scope.close = function () { + $modalInstance.close(); + }; }); \ No newline at end of file diff --git a/static/js/controllers/headCtrl.js b/static/js/controllers/headCtrl.js index fe29e22..4e30dde 100644 --- a/static/js/controllers/headCtrl.js +++ b/static/js/controllers/headCtrl.js @@ -117,6 +117,9 @@ mumApp.controller('headCtrl', function ($scope, $rootScope, toastr, $interval, $ $scope.task_list = obj[key]; }); break; + case "RES_GET_LOGS": + $rootScope.$broadcast("resGetLogs", obj[key]); + break; case "DEACTIVATION_NOTIF": $scope.pop_warning("A module cannot be activated by Mum", obj[key]); break; diff --git a/views/dashboard.html b/views/dashboard.html index 69be444..a0b7946 100644 --- a/views/dashboard.html +++ b/views/dashboard.html @@ -188,6 +188,7 @@ </p> </div> + <button type="button" class="btn btn-default" ng-click="open_modal_log()">See the logs...</button> <script type="text/ng-template" id="modal_notif_label.html"> <div class="modal-header"> @@ -266,4 +267,23 @@ </div> </script> + <script type="text/ng-template" id="modal_log_label.html"> + <div class="modal-header"> + <h3 class="modal-title">Logs from Mum Service</h3> + </div> + + <div class="modal-body"> + <label for="lines_nb_log">Number of lines to get from log</label> + <input type="number" id="lines_nb_log" min="1" ng-model="nb_lines"/> + + <button type="button" class="btn btn-info" data-dismiss="modal" ng-click="update()">Update</button> + + <textarea class="form-control" rows="20" ng-model="log_content"></textarea> + </div> + <div class="modal-footer"> + <button type="button" class="btn btn-default" data-dismiss="modal" ng-click="close()">Close</button> + <!--<button type="button" class="btn btn-primary" ng-click="save()">Save changes</button>--> + </div> + </script> + </div> \ No newline at end of file -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.