Пример #1
0
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
Пример #2
0
def create_directory_for_ossec_remote(system_id):

    path = get_base_path_from_system_id(system_id) + "/ossec/"
    success, msg = create_local_directory(path)
    if not success:
        return False, msg

    return True, ""
Пример #3
0
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
Пример #4
0
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