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 2623b9f5cf6f99f902a86cc55bba7c4e34dd059c Author: Alexis Guilbaud <guilbaud@codelutin.com> Date: Wed May 6 10:35:05 2015 +0200 nmap tcp scan param on all ports + nmap scan on existing host will replace only nmap data and reconfigure activated modules by this new detection --- README | 2 +- app/module_loader.py | 3 ++ app/modules/nmap_detection.py | 1 + app/modules/storage_modules/shelve_db.py | 67 ++++++++++++++++++-------------- static/js/controllers/hostPageCtrl.js | 4 ++ static/js/controllers/scanCtrl.js | 13 +++++-- static/js/mumApp.js | 4 ++ views/hostpage.html | 5 ++- 8 files changed, 65 insertions(+), 34 deletions(-) diff --git a/README b/README index 7821db3..6e134ba 100644 --- a/README +++ b/README @@ -40,7 +40,7 @@ all avaliable arguments, type : The service will be avaliable by default on 0.0.0.0:1337 -We recommand to parameter the default settings for each modules before adding any hosts. +We recommand to parameter the default settings for each modules before scanning any host. The default parameters that will be applied are : - minor limit at 90% and major limit at 98% for each "%" values - major limit if down for boolean values diff --git a/app/module_loader.py b/app/module_loader.py index dc59d3a..02140a7 100644 --- a/app/module_loader.py +++ b/app/module_loader.py @@ -103,6 +103,9 @@ class ModuleLoader: else: # the parameter is not an IP range, so we considere it as an hostname. ip_range = nmap_mod_instance.launch_detection_with_hostname(param) + for ip in json.loads(ip_range): + #remonving all monitoring instructions for this ip, if rescan + process_monitoring.remove_to_waiting_list(ip, None) return ip_range except modules.HostNotFoundException.HostNotFoundException as hnfe: print hnfe.__str__() diff --git a/app/modules/nmap_detection.py b/app/modules/nmap_detection.py index 85991b4..8a00109 100644 --- a/app/modules/nmap_detection.py +++ b/app/modules/nmap_detection.py @@ -149,6 +149,7 @@ class nmap_detection: #dict_host['date'] = host.getAttribute('endtime') #dict_host['state'] = status.getAttribute('state') dict_host['os'] = 'unknown' # par defaut + dict_host['hostname'] = '' hostnames_elem = host.getElementsByTagName('hostnames')[0] hostnames = hostnames_elem.getElementsByTagName('hostname') diff --git a/app/modules/storage_modules/shelve_db.py b/app/modules/storage_modules/shelve_db.py index 164600a..50315ad 100644 --- a/app/modules/storage_modules/shelve_db.py +++ b/app/modules/storage_modules/shelve_db.py @@ -213,35 +213,44 @@ class shelve_db: self.open_db() addr_host = str(addr_host) # Shelve doesn't support Unicode try: - # Add the nmap detection - self.db["hosts"][addr_host] = {} - self.db["hosts"][addr_host]["detected"] = {} - self.db["hosts"][addr_host]["detected"]["nmap"] = nmap_res - # Preconfiguration - self.db["hosts"][addr_host]["conf"] = {} - nmap_res_data = json.loads(nmap_res) - self.db["hosts"][addr_host]['detected']['nmap'] = json.dumps(nmap_res_data) - self.db["hosts"][addr_host]["conf"]["connections"] = self.init_conn(nmap_res_data, conn_infos) - os_host = nmap_res_data['os'] - self.db["hosts"][addr_host]["conf"]["monitoring"] = {} - for mod in dict_mod_info: - if os_host in dict_mod_info[mod]['compatible_os'] or 'all' in dict_mod_info[mod]['compatible_os']: - self.db["hosts"][addr_host]["conf"]["monitoring"][mod] = self.db['global_conf'][mod] - self.db['hosts'][addr_host]['conf']['idling'] = {} # For reactivation after an idle state - self.db['hosts'][addr_host]['conf']['idling']['modules'] = [] - self.db['hosts'][addr_host]['conf']['idling']['status'] = "" - self.db["hosts"][addr_host]["conf"]["groups"] = ["all"] # Every host is in group "all" - self.db["hosts"][addr_host]["conf"]["subscribers"] = {} - self.db["hosts"][addr_host]["conf"]["custom_info"] = "" - self.db["hosts"][addr_host]["conf"]["interventions"] = [] - # Create structure for monitoring data - self.db["hosts"][addr_host]["monitoring"] = {} - # Create structure for global status of host - self.db["hosts"][addr_host]["status"] = {} - self.db["hosts"][addr_host]["status"]["state"] = "" - # Create structure for archiving data - self.db["hosts"][addr_host]["archive"] = {} - self.db["hosts"][addr_host]["stats"] = {} + if addr_host in self.db['hosts']: + # it's rescan, we update only nmap related results + self.db["hosts"][addr_host]["detected"]["nmap"] = nmap_res + nmap_res_data = json.loads(nmap_res) + self.db["hosts"][addr_host]["conf"]["connections"] = self.init_conn(nmap_res_data, conn_infos) + os_host = nmap_res_data['os'] + for mod in dict_mod_info: + if os_host in dict_mod_info[mod]['compatible_os'] or 'all' in dict_mod_info[mod]['compatible_os']: + self.db["hosts"][addr_host]["conf"]["monitoring"][mod] = self.db['global_conf'][mod] + else: + # Add the nmap detection + self.db["hosts"][addr_host] = {} + self.db["hosts"][addr_host]["detected"] = {} + # Preconfiguration + self.db["hosts"][addr_host]["conf"] = {} + nmap_res_data = json.loads(nmap_res) + self.db["hosts"][addr_host]['detected']['nmap'] = nmap_res + self.db["hosts"][addr_host]["conf"]["connections"] = self.init_conn(nmap_res_data, conn_infos) + os_host = nmap_res_data['os'] + self.db["hosts"][addr_host]["conf"]["monitoring"] = {} + for mod in dict_mod_info: + if os_host in dict_mod_info[mod]['compatible_os'] or 'all' in dict_mod_info[mod]['compatible_os']: + self.db["hosts"][addr_host]["conf"]["monitoring"][mod] = self.db['global_conf'][mod] + self.db['hosts'][addr_host]['conf']['idling'] = {} # For reactivation after an idle state + self.db['hosts'][addr_host]['conf']['idling']['modules'] = [] + self.db['hosts'][addr_host]['conf']['idling']['status'] = "" + self.db["hosts"][addr_host]["conf"]["groups"] = ["all"] # Every host is in group "all" + self.db["hosts"][addr_host]["conf"]["subscribers"] = {} + self.db["hosts"][addr_host]["conf"]["custom_info"] = "" + self.db["hosts"][addr_host]["conf"]["interventions"] = [] + # Create structure for monitoring data + self.db["hosts"][addr_host]["monitoring"] = {} + # Create structure for global status of host + self.db["hosts"][addr_host]["status"] = {} + self.db["hosts"][addr_host]["status"]["state"] = "" + # Create structure for archiving data + self.db["hosts"][addr_host]["archive"] = {} + self.db["hosts"][addr_host]["stats"] = {} except Exception: print traceback.format_exc() finally: diff --git a/static/js/controllers/hostPageCtrl.js b/static/js/controllers/hostPageCtrl.js index bb51ed3..a4e0c31 100644 --- a/static/js/controllers/hostPageCtrl.js +++ b/static/js/controllers/hostPageCtrl.js @@ -52,6 +52,10 @@ mumApp.controller('hostPageCtrl', function($scope, $rootScope, $route, $routePar $scope.selectedAll = false; + $scope.rescan = function(){ + $location.path('/scan/' + $scope.addr_host); + } + $scope.update_nmap_attribute = function(attribute, new_value){ var args = {}; args['attribute'] = attribute; diff --git a/static/js/controllers/scanCtrl.js b/static/js/controllers/scanCtrl.js index d30ae6d..d31609a 100644 --- a/static/js/controllers/scanCtrl.js +++ b/static/js/controllers/scanCtrl.js @@ -1,6 +1,13 @@ -mumApp.controller('scanCtrl', function($scope, $rootScope) { +mumApp.controller('scanCtrl', function($scope, $rootScope, $routeParams) { // Concerning the scan form - $scope.ip_range = "" // la plage d'ip entree dans le champ + + if($routeParams.param == null){ + $scope.ip_range = ""; // la plage d'ip entree dans le champ + } + else{ + $scope.ip_range = $routeParams.param; + } + $scope.state = ""; // l'etat general du scan en cours $scope.ip_scanned = {}; @@ -8,7 +15,7 @@ mumApp.controller('scanCtrl', function($scope, $rootScope) { $scope.show_opt = false; - $scope.nmap_options = "-sU -sS -p U:161,T:1-8080,61209 -A -Pn"; + $scope.nmap_options = "-sU -sS -p U:161,T:1-65535 -A -Pn"; $scope.$on("success", function (event, args) { $scope.state = "Success!"; diff --git a/static/js/mumApp.js b/static/js/mumApp.js index 91e22dd..0e9c994 100644 --- a/static/js/mumApp.js +++ b/static/js/mumApp.js @@ -38,6 +38,10 @@ mumApp.config(function($routeProvider){ templateUrl : 'scan.html', controller : 'scanCtrl' }) + .when('/scan/:param/',{ + templateUrl : 'scan.html', + controller : 'scanCtrl' + }) .when('/settings/',{ templateUrl : 'settings.html', controller : 'settingsCtrl' diff --git a/views/hostpage.html b/views/hostpage.html index 6bfcd42..04b5a7a 100644 --- a/views/hostpage.html +++ b/views/hostpage.html @@ -56,7 +56,8 @@ ng-click="check(itemname)">Check now</button></td> </tr> <tr ng-repeat-end - ng-repeat="(valname, val) in item.value" + ng-repeat="(valname, val) in item.value | + orderBy:val" collapse="collapsed[itemname]"> <td>{{valname}}</td> <td>{{val}} {{get_unit(itemname)}}</td> @@ -65,6 +66,8 @@ </table> <accordion close-others="false"> <accordion-group heading="Essential configuration (nmap detection)"> + <button type="button" class="btn btn-primary btn-xs" + ng-click="rescan()">Scan again</button> <table class="table table-bordered table-hover"> <tr ng-repeat="(key, val) in items.detected.nmap"> <td>{{key}}</td> -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.