def process(self, data, base_response): logger.debug("VAScanner Manager: Processing: %s" % data) response = [] action = Utils.get_var("action=\"([A-Za-z_]+)\"", data) if action == "va_scan": target = Utils.get_vars("target=\"([\s0-9a-fA-F\.:/]+)\"", data) if len(target): if self.__vascanner.status() > 0: logger.info("Scan already in progress: %i" % self.__vascanner.status()) response.append( base_response + ' status="%d" %s ackend\n' % (self.__vascanner.status(), ControlError.get(2001))) else: # set the scan target and start the scan self.__vascanner.set_scan_target(target) self.__vascanner.scan_start() response.append( base_response + ' status="%d" %s ackend\n' % (self.__vascanner.status(), ControlError.get(0))) else: response.append(base_response + ' %s ackend\n' % ControlError.get(2002)) elif action == "va_status": if self.__vascanner.status() == -1: response.append(base_response + ' status="-1" error="%s" ackend\n' % (self.__vascanner.get_error())) else: response.append( base_response + ' status="%d" %s ackend\n' % (self.__vascanner.status(), ControlError.get(0))) elif action == "va_reset": self.__vascanner.reset_status() if self.__vascanner.status() == -1: logger.debug( "Previous scan aborted raising errors, please check your logfile." ) response.append( base_response + ' %s ackend\n' % ControlError.get(1, str(self.__vascanner.get_error()))) else: response.append(base_response + ' %s ackend\n' % ControlError.get(0)) elif action == "va_report_list": report_files = self.__get_report_file_list( self.__vascanner_report_path) for p in report_files: base_response += ' report="%s"' % p response.append(base_response + ' count="%i" %s ackend\n' % (len(report_files), ControlError.get(0))) elif action == "va_report_get": path = Utils.get_var("path=\"([^\"]+)\"", data) # only valid paths should get through if path != "": # ensure we are not after the current working report if path != self.__vascanner.get_working_report_path(): report_response = self.__generate_report( path, base_response) response.extend(report_response) response.append(base_response + ' %s ackend\n' % ControlError.get(0)) else: response.append(base_response + '%s ackend\n' % ControlError.get(2005)) else: response.append(base_response + ' %s ackend\n' % ControlError.get(2003)) elif action == "va_report_raw_get": path = Utils.get_var("path=\"([^\"]+)\"", data) # only valid paths should get through if path != "": report_file = self.__get_report_file(path) report_response = ControlUtil.get_file(report_file, base_response) response.extend(report_response) response.append(base_response + ' %s ackend\n' % ControlError.get(0)) else: response.append(base_response + ' %s ackend\n' % ControlError.get(2003)) elif action == "va_report_delete": path = Utils.get_var("path=\"([^\"]+)\"", data) report_file = self.__get_report_file(path) if path == "*": logger.debug("Deleting all report(s)") report_files = self.__get_report_file_list( self.__vascanner_report_path) for f in report_files: report_file = self.__get_report_file(f) os.unlink(report_file) response.append(base_response + ' %s ackend\n' % ControlError.get(0)) elif report_file != "": logger.debug("Deleting report at: %s" % report_file) os.unlink(report_file) response.append(base_response + ' %s ackend\n' % ControlError.get(0)) else: response.append(base_response + ' %s ackend\n' % ControlError.get(2004)) # send back our response return response
def process(self, data, base_response): logger.debug("Nmap Manager: Processing: %s" % data) response = [] action = Utils.get_var("action=\"([A-Za-z_]+)\"", data) if action == "nmap_scan": target = Utils.get_var("target=\"([\s0-9a-fA-F\.:/\-]+)\"" , data) scan_type = Utils.get_var("type=\"(ping|0|fast|1|normal|2|full|3|custom|4)\"" , data) scan_timming = Utils.get_var("timming=\"(T0|T1|T2|T3|T4|T5)\"" , data) autodect = Utils.get_var("autodetect=\"(enable|disable|enabled|disabled)\"" , data) scan_ports = Utils.get_var("scan_ports=\"([0-9\-\,]+)\"" , data) rdns = Utils.get_var("rdns=\"(enable|disable|enabled|disabled)\"" , data) report_prefix = Utils.get_var("report_prefix=\"([\s0-9a-fA-F\.:/\-]+)\"" , data) if autodect == "": autodect = "enable" if rdns == "": rdns = "disable" if scan_timming == "": scan_timming = "T3" # set the scan type as appropriate if scan_type == "": scan_type = "ping" if report_prefix == "": response.append(base_response + ' status="%d" %s ackend\n' % (self.__nmap.status(), ControlError.get(2007))) return response self.__nmap.set_report_prefix(report_prefix) self.__nmap.set_scan_type(scan_type) self.__nmap.set_scan_timming(scan_timming) self.__nmap.set_scan_autodetect(autodect) self.__nmap.set_scan_ports(scan_ports)#only if custom self.__nmap.set_scan_rdsn(rdns) if scan_type == "custom" and scan_ports=="": response.append(base_response + ' status="%d" %s ackend\n' % (self.__nmap.status(), ControlError.get(2006))) return response if len(target): if self.__nmap.status() > 0: logger.info("Scan already in progress: %i" % self.__nmap.status()) response.append(base_response + ' status="%d" %s ackend\n' % (self.__nmap.status(), ControlError.get(2001))) else: # set the scan target and start the scan self.__nmap.set_scan_target(target) self.__nmap.scan_start() response.append(base_response + ' status="%d" %s ackend\n' % (self.__nmap.status(), ControlError.get(0))) else: response.append(base_response + ' %s ackend\n' % ControlError.get(2002)) elif action == "nmap_status": if self.__nmap.status() == -1: response.append(base_response + ' status="-1" error="%s" ackend\n' % (self.__nmap.get_error())) else: response.append(base_response + ' status="%d" %s ackend\n' % (self.__nmap.status(), ControlError.get(0))) elif action == "nmap_reset": self.__nmap.reset_status() if self.__nmap.status() == -1: logger.debug("Previous scan aborted raising errors, please check your logfile.") response.append(base_response + ' %s ackend\n' % ControlError.get(1, str(self.__nmap.get_error()))) else: response.append(base_response + ' %s ackend\n' % ControlError.get(0)) elif action == "nmap_report_list": report_files = self.__get_report_file_list(self.__nmap_report_path) for p in report_files: base_response += ' report="%s"' % p response.append(base_response + ' count="%i" %s ackend\n' % (len(report_files), ControlError.get(0))) elif action == "nmap_report_get": path = Utils.get_var("path=\"([^\"]+)\"", data) deletestr = Utils.get_var("delete=\"(yes|no|0|1|true\false)\"", data) deletestr = deletestr.lower() delete = False if deletestr in ['yes','1','true']: delete = True # only valid paths should get through if path != "": # ensure we are not after the current working report if path != self.__nmap.get_working_report_path(): report_response = self.__generate_report(path, base_response) response.extend(report_response) response.append(base_response + ' %s ackend\n' % ControlError.get(0)) if delete: self.__deleteReport(path) else: response.append(base_response + '%s ackend\n' % ControlError.get(2005)) else: response.append(base_response + ' %s ackend\n' % ControlError.get(2003)) elif action == "nmap_report_raw_get": path = Utils.get_var("path=\"([^\"]+)\"", data) deletestr = Utils.get_var("delete=\"(yes|no|0|1|true\false)\"", data) deletestr = deletestr.lower() delete = False if deletestr in ['yes','1','true']: delete = True # only valid paths should get through if path != "": report_file = self.__get_report_file(path) report_response = ControlUtil.get_file(report_file, base_response) response.extend(report_response) response.append(base_response + ' %s ackend\n' % ControlError.get(0)) if delete: self.__deleteReport(path) else: response.append(base_response + ' %s ackend\n' % ControlError.get(2003)) elif action == "nmap_report_delete": path = Utils.get_var("path=\"([^\"]+)\"", data) report_file = self.__get_report_file(path) if path == "*": logger.debug("Deleting all report(s)") report_files = self.__get_report_file_list(self.__nmap_report_path) for f in report_files: report_file = self.__get_report_file(f) os.unlink(report_file) response.append(base_response + ' %s ackend\n' % ControlError.get(0)) elif report_file != "": logger.debug("Deleting report at: %s" % report_file) os.unlink(report_file) response.append(base_response + ' %s ackend\n' % ControlError.get(0)) else: response.append(base_response + ' %s ackend\n' % ControlError.get(2004)) # send back our response return response
def process(self, data, base_response): logger.debug("VAScanner Manager: Processing: %s" % data) response = [] action = Utils.get_var("action=\"([A-Za-z_]+)\"", data) if action == "va_scan": target = Utils.get_vars("target=\"([\s0-9a-fA-F\.:/]+)\"" , data) if len(target): if self.__vascanner.status() > 0: logger.info("Scan already in progress: %i" % self.__vascanner.status()) response.append(base_response + ' status="%d" %s ackend\n' % (self.__vascanner.status(), ControlError.get(2001))) else: # set the scan target and start the scan self.__vascanner.set_scan_target(target) self.__vascanner.scan_start() response.append(base_response + ' status="%d" %s ackend\n' % (self.__vascanner.status(), ControlError.get(0))) else: response.append(base_response + ' %s ackend\n' % ControlError.get(2002)) elif action == "va_status": if self.__vascanner.status() == -1: response.append(base_response + ' status="-1" error="%s" ackend\n' % (self.__vascanner.get_error())) else: response.append(base_response + ' status="%d" %s ackend\n' % (self.__vascanner.status(), ControlError.get(0))) elif action == "va_reset": self.__vascanner.reset_status() if self.__vascanner.status() == -1: logger.debug("Previous scan aborted raising errors, please check your logfile.") response.append(base_response + ' %s ackend\n' % ControlError.get(1, str(self.__vascanner.get_error()))) else: response.append(base_response + ' %s ackend\n' % ControlError.get(0)) elif action == "va_report_list": report_files = self.__get_report_file_list(self.__vascanner_report_path) for p in report_files: base_response += ' report="%s"' % p response.append(base_response + ' count="%i" %s ackend\n' % (len(report_files), ControlError.get(0))) elif action == "va_report_get": path = Utils.get_var("path=\"([^\"]+)\"", data) # only valid paths should get through if path != "": # ensure we are not after the current working report if path != self.__vascanner.get_working_report_path(): report_response = self.__generate_report(path, base_response) response.extend(report_response) response.append(base_response + ' %s ackend\n' % ControlError.get(0)) else: response.append(base_response + '%s ackend\n' % ControlError.get(2005)) else: response.append(base_response + ' %s ackend\n' % ControlError.get(2003)) elif action == "va_report_raw_get": path = Utils.get_var("path=\"([^\"]+)\"", data) # only valid paths should get through if path != "": report_file = self.__get_report_file(path) report_response = ControlUtil.get_file(report_file, base_response) response.extend(report_response) response.append(base_response + ' %s ackend\n' % ControlError.get(0)) else: response.append(base_response + ' %s ackend\n' % ControlError.get(2003)) elif action == "va_report_delete": path = Utils.get_var("path=\"([^\"]+)\"", data) report_file = self.__get_report_file(path) if path == "*": logger.debug("Deleting all report(s)") report_files = self.__get_report_file_list(self.__vascanner_report_path) for f in report_files: report_file = self.__get_report_file(f) os.unlink(report_file) response.append(base_response + ' %s ackend\n' % ControlError.get(0)) elif report_file != "": logger.debug("Deleting report at: %s" % report_file) os.unlink(report_file) response.append(base_response + ' %s ackend\n' % ControlError.get(0)) else: response.append(base_response + ' %s ackend\n' % ControlError.get(2004)) # send back our response return response