Neural Network
dynamic_loader("nauthilus_neural")
local nauthilus_neural = require("nauthilus_neural")
add_additional_features
Adds custom features to the authentication state for neural network processing. These features can be used by the neural network for more accurate brute force detection.
Syntax
nauthilus_neural.add_additional_features(features_table, encoding_type)
Parameters
features_table
(table): A table containing key-value pairs of features to addencoding_type
(string, optional): The encoding type to use for string features. Valid values are:"one-hot"
(default): Uses one-hot encoding for string features"embedding"
: Uses embedding encoding for string features
Notes
- The function does not return any values
- Features with keys "ClientIP", "client_ip", "Username", or "username" are automatically skipped
- If called multiple times, new features are merged with existing ones
- This function is available from Nauthilus version 1.7.7
- The experimental_ml feature must be enabled for these features to be used
Example
dynamic_loader("nauthilus_neural")
local nauthilus_neural = require("nauthilus_neural")
-- Add custom features with default one-hot encoding
nauthilus_neural.add_additional_features({
user_agent = request.headers["User-Agent"],
login_time = os.time(),
device_type = "mobile",
location = "office"
})
-- Add features with embedding encoding for string values
nauthilus_neural.add_additional_features({
browser_info = request.headers["User-Agent"],
referrer = request.headers["Referer"]
}, "embedding")
set_learning_mode
Toggles the neural network learning mode on or off. When learning mode is enabled, the system collects data but does not use the neural network for predictions. When disabled, the system uses the trained neural network for predictions.
Syntax
local learning_mode_state, error_message = nauthilus_neural.set_learning_mode(enabled)
Parameters
enabled
(boolean): Whether to enable learning mode (true) or disable it (false)
Returns
learning_mode_state
(boolean): The new learning mode state (true if in learning mode, false otherwise)error_message
(string or nil): Error message if the operation failed, nil otherwise
Example
dynamic_loader("nauthilus_neural")
local nauthilus_neural = require("nauthilus_neural")
-- Enable learning mode
local is_learning, error = nauthilus_neural.set_learning_mode(true)
if error then
print("Failed to enable learning mode: " .. error)
else
print("Learning mode is now: " .. (is_learning and "enabled" or "disabled"))
end
-- Disable learning mode
local is_learning, error = nauthilus_neural.set_learning_mode(false)
if not error then
print("Learning mode is now: " .. (is_learning and "enabled" or "disabled"))
end
Notes
- This function is available from Nauthilus version 1.7.7
- The experimental_ml feature must be enabled for this function to work
- Learning mode affects how the system handles authentication attempts:
- In learning mode: The system collects data for training but does not use the neural network for predictions
- When not in learning mode: The system uses the trained neural network for predictions
train_neural_network
Manually trains the neural network model used for brute force detection.
Syntax
local success, error_message = nauthilus_neural.train_neural_network(maxSamples, epochs)
Parameters
maxSamples
(number, optional): Maximum number of training samples to use. Default: 5000epochs
(number, optional): Number of training epochs. Default: 50
Returns
success
(boolean): True if training was successful, false otherwiseerror_message
(string or nil): Error message if training failed, nil otherwise
Example
dynamic_loader("nauthilus_neural")
local nauthilus_neural = require("nauthilus_neural")
-- Train with default parameters (5000 samples, 50 epochs)
local success, error = nauthilus_neural.train_neural_network()
if not success then
print("Training failed: " .. error)
else
print("Training completed successfully")
end
-- Train with custom parameters
local success, error = nauthilus_neural.train_neural_network(10000, 100)
Notes
- This function is available from Nauthilus version 1.7.7
- Training the neural network requires the experimental_ml feature to be enabled
- Training is a resource-intensive operation and may take some time to complete
- The function uses data collected from previous authentication attempts
provide_feedback
Provides feedback on neural network predictions to improve detection accuracy. This function allows administrators or security systems to correct false positives or false negatives, creating a feedback loop that continuously improves the neural network's performance.
Syntax
local success, error_message = nauthilus_neural.provide_feedback(is_brute_force, request_id, client_ip, username)
Parameters
is_brute_force
(boolean): Whether the login attempt was actually part of a brute force attack (true) or not (false)request_id
(string): The request ID of the login attempt to provide feedback forclient_ip
(string): The client IP address of the login attemptusername
(string): The username of the login attempt