def apimethod_get_agentless_passlist(sensor_id): (success, system_ip) = get_sensor_ip_from_sensor_id(sensor_id) if not success: return False, "Invalid sensor id %s" % sensor_id success, base_path = get_base_path_from_sensor_id(sensor_id) if not success: return False, "Can't retrieve the destination path: %s" % base_path destination_path = base_path + "/ossec/agentless/" success, msg = create_local_directory(destination_path) if not success: api_log.error(str(msg)) return False, "Error creating directory '%s'" % destination_path dst_filename = destination_path+".passlist" success, msg = ans_ossec_get_agentless_passlist(system_ip=system_ip, destination_path=dst_filename) if not success: if str(msg).find('the remote file does not exist') > 0: if touch_file(dst_filename): success = True msg = dst_filename success, result = set_ossec_file_permissions(dst_filename) if not success: return False, str(result) return success, msg
def apimethod_put_agentless_passlist(sensor_id): (success, system_ip) = get_sensor_ip_from_sensor_id(sensor_id) if not success: return False, "Invalid sensor id %s" % sensor_id success, base_path = get_base_path_from_sensor_id(sensor_id) if not success: return False, "Can't retrieve the destination path: %s" % base_path src_file = base_path + "/ossec/agentless/.passlist" return ans_ossec_put_agentless_passlist(system_ip=system_ip, local_passfile=src_file)
def apimethod_put_ossec_configuration_file(sensor_id, filename): if filename not in ['local_rules.xml', 'rules_config.xml']: return False, "Invalid configuration file to put: %s" % str(filename) (success, system_ip) = get_sensor_ip_from_sensor_id(sensor_id) if not success: return False, "Invalid sensor id %s" % sensor_id success, base_path = get_base_path_from_sensor_id(sensor_id) if not success: return False, "Can't retrieve the destination path: %s" % base_path src_file = base_path + "/ossec/rules/%s" % filename return ans_ossec_put_configuration_rule_file(system_ip=system_ip, local_rule_filename=src_file, remote_rule_name=filename)
def get_ossec_directory(sensor_id): success, base_path = get_base_path_from_sensor_id(sensor_id) if not success: return False, "Can't retrieve the destination path: %s" % base_path destination_path = base_path + "/ossec/" # Create directory if not exists success, msg = create_local_directory(destination_path) if not success: api_log.error(str(msg)) return False, "Error creating directory '%s'" % destination_path return True, destination_path
def get_nmap_directory(sensor_id): """Returns the nmap folder for the given sensor ID Args: sensor_id(str): Canonical Sensor ID Returns: destination_path: is an string containing the nmap folder when the method works properly or an error string otherwise. Raises: APINMAPScanCannotRetrieveBaseFolder APINMAPScanCannotCreateLocalFolder """ success, base_path = get_base_path_from_sensor_id(sensor_id) if not success: raise APINMAPScanCannotRetrieveBaseFolder(base_path) destination_path = base_path + "/nmap/" # Create directory if not exists success, msg = create_local_directory(destination_path) if not success: api_log.error(str(msg)) raise APINMAPScanCannotCreateLocalFolder(msg) return destination_path