Campus network security monitoring method and system based on situation awareness

Through the situational awareness method based on GAN, adversarial samples are generated and network security health is analyzed, and the problem of traditional network security systems insufficient prediction capabilities for new attack modes is solved, more accurate and dynamic network security protection is achieved, and overall security is improved Sex and responsiveness.

CN118784372BActive Publication Date: 2024-11-26CHANGCHUN QICHEN TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411251663.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-09-09
Publication Date
2024-11-26
Estimated Expiration
2044-09-09

AI Technical Summary

Technical Problem

Traditional network security protection systems lack the predictive ability and adaptability to new attack modes, and cannot effectively monitor and early warning network security incidents, resulting in insufficient detection and early warning capabilities.

Method used

Adopt situation awareness method based on the Generative Adversarial Network (GAN) model, form adversarial generation networks through generators and discriminators, generate adversarial samples, analyze network security and health status, identify potential vulnerabilities and evaluate the impact of attacks, and achieve more accurate and dynamic Network security protection.

Benefits of technology

It improves the protection capabilities of the network security system, can identify types of attacks that have not been encountered, significantly improves the overall network security and response capabilities, and realizes the transformation from passive protection to active protection.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118784372B_ABST
    Figure CN118784372B_ABST
Patent Text Reader

Abstract

The present invention belongs to the field of network security technology, and specifically relates to a campus network security monitoring method and system based on situational awareness. An adversarial generation network is formed through a generator and a discriminator, and adversarial samples are generated according to the number of all known vulnerabilities in the network, the number of attacks suffered by the current network, the intensity of attacks suffered by the current network, and the effects of attacks on the system; the established situational awareness model analyzes the overall security health of the network through the output of the discriminator of the adversarial generation network and key security indicators, and finally outputs a continuous score representing the current network security status; to help identify potential vulnerabilities, evaluate the impact of attacks and predict security threats. The present invention can efficiently solve the problem that network security can only be passively protected in the prior art.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the technical field of network security, and in particular relates to a campus network security monitoring method and system based on situation awareness. Background Art

[0002] In the field of network security technology, facing the increasingly complex and changeable means of network attacks, traditional security protection systems can usually only provide static, rule-based protection measures. These systems often lack the ability to predict new attack patterns and the adaptability to unknown threats. Most of the existing technologies focus on protection, detection, response and recovery, including security routers, firewall technology and disaster recovery. Despite this, these systems have insufficient detection and early warning capabilities, and have obvious shortcomings in situational awareness, and are unable to effectively monitor and warn of network security incidents.

[0003] Combining modern artificial intelligence technology, especially the Generative Adversarial Network (GAN) model, can bring revolutionary changes to network security protection systems. The GAN model consists of a generator and a discriminator. Through adversarial learning between the two, it can not only generate new, seemingly real attack data for training, but also continuously improve the detection ability of the discriminator. Such a system can learn from dynamic data and adapt to new threat patterns, thus transforming into a dynamic adaptive learning system.

[0004] The GAN-based network security situational awareness method can achieve a shift from traditional passive protection to active protection. It not only improves the defense capability against known attack patterns, but also can identify and respond to previously unseen attack types. Through active learning and early warning, this method improves the security and reliability of network systems and effectively solves the challenges facing current network security technologies. Summary of the invention

[0005] The present invention provides a campus network security monitoring method based on situation awareness, which can effectively solve the problem that network security can only be passively protected in the prior art.

[0006] The present invention provides a campus network security monitoring system based on situation awareness, which is used to implement a campus network security monitoring method based on situation awareness to achieve active protection.

[0007] The present invention is achieved through the following technical solutions:

[0008] A campus network security monitoring method based on situation awareness, the method comprising:

[0009] The adversarial generative network is formed through the generator and the discriminator to generate adversarial samples based on the number of all known vulnerabilities in the network, the number of attacks suffered by the current network, the intensity of the attacks suffered by the current network, and the effect of the attacks on the system;

[0010] The established situational awareness model analyzes the overall security health of the network by adversarially generating the output of the discriminator and key security indicators of the network, and finally outputs a continuous score representing the current network security status; it helps to identify potential vulnerabilities, assess the impact of attacks and predict security threats.

[0011] Furthermore, the method comprises the following steps:

[0012] Step 1: Preprocess the acquired data;

[0013] Step 2: Build the adversarial network GAN model;

[0014] Step 3: Build a situation awareness model based on the model in step 2;

[0015] Step 4: Use the data preprocessed in step 1 to train and verify the model constructed in step 3;

[0016] Step 5: Use the situation awareness model to conduct situation awareness of network security and achieve more accurate and dynamic network security protection.

[0017] Furthermore, the step 1 is specifically:

[0018] Step 1.1: Integrate data from different sources;

[0019] Step 1.2: Preprocess the data integrated in step 1.1, where preprocessing includes removing irrelevant or useless information, correcting errors in data collection and transmission, and filling or eliminating missing values ​​in the data set;

[0020] Step 1.3: Extract key features from network traffic; login information, command usage, and system call information from system logs;

[0021] Step 1.4: In the feature engineering stage of cybersecurity data, including encoding and data normalization or standardization;

[0022] Step 1.5: Through expert evaluation, the collected data is accurately classified into labels representing normal behavior or abnormal, aggressive behavior;

[0023] Step 1.6: Since attack samples are usually much less than normal samples, oversample the minority class and undersample the majority class; or use synthetic minority class oversampling technology to provide a more balanced training dataset by generating synthetic attack samples.

[0024] Furthermore, the step 2 is specifically as follows:

[0025] Step 2.1: Import the dataset into the PyTorch library;

[0026] Step 2.2: Define the Generator class in the PyTorch library and the constructor of the Generator class; call the constructor of the base class through super() and use nn.Sequential to create a sequential model; execute each layer in sequence;

[0027] Step 2.3: Define the network's forward propagation logic;

[0028] Step 2.4: Based on the previous steps, gradually reduce the number of features of the fully connected layer to 1; compress the output of the activation function to the interval [0, 1], and output the probability of judging whether the generated sample is true or false;

[0029] Step 2.5: Process the input data x, process it through steps 2.2-2.4 and output the discrimination result.

[0030] Furthermore, the step 3 also includes:

[0031] Step 3.1: Create a generator object and a discriminator object;

[0032] Step 3.2: Define the loss function as binary cross entropy loss;

[0033] Step 3.3: Construct a comprehensive feature vector based on steps 3.1 and 3.2;

[0034] Step 3.4: Generate labels for 1000 samples based on the feature vectors in step 3.3;

[0035] Step 3.5: Use TensorDataset to combine the feature vectors from step 3.3 and the labels from step 3.4 into a dataset;

[0036] Step 3.6: Create a DataLoader for iterative access to the dataset.

[0037] Furthermore, the step 4 is specifically as follows:

[0038] Step 4.1: Set the total number of training rounds to 50 rounds;

[0039] Step 4.2: for data in dataloader is to iteratively retrieve each batch of data from the data loader;

[0040] Step 4.3: Create labels for real data and fake data, and train the discriminator with real data so that it can accurately distinguish between real data and fake data generated by the generator;

[0041] Step 4.4: Generate fake data by inputting noise and use the fake data to further train the discriminator; the generator then learns to generate more realistic data through back-propagation, making it difficult for the discriminator to distinguish between real and generated data;

[0042] Step 4.5: Through adversarial training, the generator gradually learns to generate realistic data, while the discriminator continuously improves its ability to distinguish true and false data until the two reach a dynamic balance;

[0043] Step 4.6: Import the PyTorch library and then the NumPy library; generate an array of shape (100, 50) containing random numbers drawn from a standard normal distribution;

[0044] Step 4.7: Randomly generate an array of (50, 1) with elements of 0 or 1; convert the NumPy array labels to a PyTorch tensor;

[0045] Step 4.8: Define NetworkSecurityModel as the base class for all neural network modules;

[0046] Step 4.9: Define the forward propagation function of the model;

[0047] Step 4.10: Define the validate function and execute the validate function to evaluate the performance of the model on the validation set.

[0048] Furthermore, the step 5 is specifically as follows:

[0049] Step 5.1: Calculate the network security situation coefficient;

[0050] Step 5.2: Dynamically enhance GAN network training;

[0051] Step 5.3: Return the new state, reward, and end flag; adjust the learning rate of the generator and discriminator to ensure that the learning rate does not fall below a minimum value; use the discriminator to evaluate the generated data and the randomly generated "real" data and calculate the reward; the reward is based on the discriminator's prediction accuracy for fake data and real data; finally reset the environment and generate a new initial state;

[0052] Step 5.4: Dynamically adjust the situation coefficient;

[0053] Step 5.5: Calculate the correlation coefficient between each feature and security_event, and adjust the weight according to the correlation;

[0054] Step 5.6: Based on historical data analysis and the standard deviation of the frequency of security incidents, the threshold e is determined. e1 and e2 are two critical values ​​of the threshold e.

[0055] A campus network security monitoring system based on situational awareness, the system uses the campus network security monitoring method based on situational awareness as described above, the system comprises:

[0056] A data preprocessing module is used to preprocess the acquired data;

[0057] GAN model construction module, building adversarial network GAN model;

[0058] Situation awareness model building module, building a situation awareness model based on the model;

[0059] Model training module, which uses preprocessed data to train and verify the constructed model;

[0060] The situation awareness module uses the situation awareness model to conduct situation awareness of network security, achieving more accurate and dynamic network security protection.

[0061] A computer device comprises a memory, a processor and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the above method is implemented.

[0062] A computer-readable storage medium stores a computer program, and the computer program implements the above method when executed by a processor.

[0063] The beneficial effects of the present invention are:

[0064] The present invention effectively combines key security indicators such as known vulnerabilities, attack times, attack intensity, and system impact to generate highly realistic adversarial samples. These samples are used to test and improve the protection capabilities of network security systems, so that security systems can better adapt to and respond to the ever-changing network threat environment. Through this method, more accurate and dynamic network security protection can be achieved, thereby significantly improving overall network security and response capabilities. BRIEF DESCRIPTION OF THE DRAWINGS

[0065] Figure 1 It is a schematic diagram of the Gan network training process of the present invention.

[0066] Figure 2 It is a flow chart of the method of the present invention. DETAILED DESCRIPTION

[0067] In the following description, specific details such as specific system structures, technologies, etc. are provided for the purpose of illustration rather than limitation, so as to provide a thorough understanding of the embodiments of the present application. However, it should be clear to those skilled in the art that the present application may also be implemented in other embodiments without these specific details. In other cases, detailed descriptions of well-known systems, devices, circuits, and methods are omitted to prevent unnecessary details from obstructing the description of the present application.

[0068] It should be understood that when used in this specification and the appended claims, the term "comprising" indicates the presence of described features, integers, steps, operations, elements and / or components, but does not exclude the presence or addition of one or more other features, integers, steps, operations, elements, components and / or groups thereof.

[0069] It should also be understood that the terms used in this application specification are only for the purpose of describing specific embodiments and are not intended to limit the application. As used in this application specification and the appended claims, the singular forms "a", "an" and "the" are intended to include plural forms unless the context clearly indicates otherwise.

[0070] The following is attached to this application specification Figure 1-2 , the technical solutions in the embodiments of the present application are clearly and completely described. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present application.

[0071] In the following description, many specific details are set forth to facilitate a full understanding of the present application, but the present application may also be implemented in other ways different from those described herein, and those skilled in the art may make similar generalizations without violating the connotation of the present application. Therefore, the present application is not limited to the specific embodiments disclosed below.

[0072] Implementation Method 1

[0073] This embodiment provides a campus network security monitoring method based on situational awareness, which forms an adversarial generation network through a generator (G) and a discriminator (D), and generates adversarial samples according to the number of all known vulnerabilities in the network, the number of attacks suffered by the current network, the intensity of attacks suffered by the current network, and the effect of the attacks on the system; the generator fine-tunes the samples with the assistance of a feature constraint mechanism to maintain their basic functions, while the discriminator imitates an intrusion detection system to ensure that the generated samples are functionally indistinguishable from real normal samples; the entire process includes data preparation, model training, adversarial sample testing, and iterative optimization based on test results, thereby continuously improving the quality of adversarial samples and the accuracy of the discriminator;

[0074] The established situational awareness model analyzes the overall security health of the network by adversarially generating the output of the discriminator and key security indicators of the network, and finally outputs a continuous score representing the current network security status; it helps to identify potential vulnerabilities, assess the impact of attacks and predict security threats.

[0075] Specifically, the method also includes: step 1: preprocessing the acquired data;

[0076] Step 1: Preprocess the acquired data;

[0077] Step 2: Build the adversarial network GAN model;

[0078] Step 3: Build a situation awareness model based on the model in step 2;

[0079] Step 4: Use the data preprocessed in step 1 to train and verify the model constructed in step 3;

[0080] Step 5: Use the situation awareness model to conduct situation awareness of network security and achieve more accurate and dynamic network security protection.

[0081] Furthermore, the step 1 is specifically:

[0082] Step 1.1: Integrate data from different sources (such as network traffic monitoring tools, system logs, and security event management systems); the integration includes unification of data formats and time synchronization to ensure consistency of all data on the timeline.

[0083] Step 1.2: First, remove irrelevant or useless information, such as health check reports and log information not related to security, to streamline the data set and improve processing efficiency. Next, correct errors that may occur during data collection and transmission to ensure data accuracy and reliability. Finally, use appropriate strategies to fill or remove missing values ​​in the data set.

[0084] Step 1.3: Extract key features from network traffic, such as IP address, port number, transport protocol, packet size, and session duration. Meanwhile, login information, command usage, and system call information in system logs can help detect unauthorized access and other suspicious behaviors. Features such as event type, severity, and impact scope in security incident reports can help assess the urgency and priority of incidents.

[0085] Step 1.4: In the feature engineering phase of cybersecurity data, features are processed and transformed to optimize the training and prediction effects of machine learning models. First, encoding is performed, including converting categorical features, such as attack types, into a format that the model can effectively process. Then, in order to ensure the fairness and effectiveness of different features in the model, data normalization or standardization is performed so that all data features are at the same level, thereby preventing certain features from dominating the results during model training due to their numerical size.

[0086] Step 1.5: Through expert evaluation, the collected data is accurately classified into labels representing normal behavior or abnormal, aggressive behavior;

[0087] Step 1.6: Since attack samples are usually much less than normal samples, we can use oversampling of minority classes, i.e. increasing the number of attack samples, to enhance the model’s learning of attack behaviors; undersampling of majority classes, i.e. reducing the number of normal samples, to reduce their dominance during training; or use synthetic minority oversampling technique (SMOTE), which provides a more balanced training dataset by generating synthetic attack samples.

[0088] The following three methods were used:

[0089] Oversampling the minority class:

[0090] Increase the number of attack samples and increase their number by duplicating minority samples to achieve a relative balance with majority samples.

[0091] Undersample the majority class:

[0092] Reduce the number of normal samples by randomly deleting majority class samples to reduce their number and achieve a relative balance with minority class samples.

[0093] Synthetic Minority Oversampling Technique (SMOTE):

[0094] Generate synthetic minority class samples, generate new minority class samples through interpolation method, and increase the number of minority class samples.

[0095] Oversampling the minority class is used simultaneously with undersampling the majority class to achieve a more balanced dataset.

[0096] Furthermore, the step 2 is specifically as follows:

[0097] Step 2.1: Import the PyTorch library, import the nn module in PyTorch and rename it to nn; import the optim module in PyTorch and rename it to optim; import the DataLoader and TensorDataset classes from the torch.utils.data module;

[0098] Step 2.2: Define a class called Generator, which inherits from nn.Module; nn.Module is the base class of all neural network modules in PyTorch; is the constructor of the Generator class; calls the base class constructor through super() to ensure that the neural network infrastructure is initialized correctly; creates a sequential model using nn.Sequential; this container executes each layer in sequence; nn.Linear(50, 128) is a fully connected layer with 50 input features and 128 output features;

[0099] nn.ReLU() is a nonlinear activation function, which is used to add nonlinear characteristics to help the network learn complex patterns;

[0100] nn.Linear(128, 256) and nn.Linear(256, 512) are more fully connected layers, gradually increasing the complexity of the model;

[0101] nn.Linear(512, 1024) and nn.Linear(1024, 50) are the final fully connected layers, and the output feature vector length is 50, which usually corresponds to a flattened image data;

[0102] nn.Tanh() is a hyperbolic tangent activation function with an output range of [-1, 1], which is usually used to generate the last layer of image data;

[0103] Step 2.3: Define the network’s forward propagation logic; z is the input noise vector, and the network returns the generated data after processing; define a class called Discriminator, which also inherits from nn.Module; also initialize it by calling the base class constructor through super();

[0104] nn.Linear(50, 512) is a fully connected layer that starts processing from the input 50 feature vectors;

[0105] nn.LeakyReLU(0.2) is the LeakyReLU activation function, which allows a small negative slope and avoids the dead neuron problem of ReLU;

[0106] nn.Dropout(0.3) randomly drops 30% of nodes to prevent overfitting;

[0107] Step 2.4: Based on the previous steps, nn.Linear(512, 256) and nn.Linear(256, 1) are further fully connected layers, gradually reducing the number of features to 1 for binary classification; nn.Sigmoid(): Sigmoid is an activation function that compresses the output to the interval [0, 1] for binary classification tasks, and outputs the probability of judging whether the generated sample is true or false;

[0108] Step 2.5: Process the input data x, process it through steps 2.2-2.4 and output the discrimination result.

[0109] Furthermore, the step 3 also includes:

[0110] Step 3.1: Instantiate the Generator class and create a generator object; this generator will be used to generate fake data that is as close to the real data as possible; instantiate the Discriminator class and create a discriminator object; the task of the discriminator is to distinguish whether the data input to it is real or generated by the generator;

[0111] Step 3.2: Define the loss function as Binary Cross-Entropy Loss, which is a commonly used loss function in training generative adversarial networks. In GAN, the goal of the discriminator is to correctly classify real data and generated data, while the goal of the generator is to deceive the discriminator as much as possible. The Adam optimization algorithm is used to handle machine learning tasks with large-scale data and parameters, with a learning rate of 0.0002 and a gradient decay rate of 0.9.

[0112] Step 3.3: Based on steps 3.1 and 3.2, a comprehensive feature vector is constructed. The feature vector is a tensor containing 1000 samples, each of which is 50-dimensional. The features are randomly generated and follow a standard normal distribution (mean 0, standard deviation 1). The 50 here may represent a comprehensive feature vector that integrates data from multiple data sources (such as network traffic monitoring tools, system logs, and security event management systems).

[0113] Step 3.4: Generate labels for 1000 samples based on the feature vector in step 3.3; here, the torch.cat function is used to concatenate the two tensors together, where the first 500 samples are labeled as 1 (positive samples) and the last 500 samples are labeled as 0 (negative samples);

[0114] Step 3.5: Use TensorDataset to combine the feature vectors from step 3.3 and the labels from step 3.4 into a dataset; TensorDataset is a class in PyTorch that is accessed by index;

[0115] Step 3.6: Create a DataLoader to iteratively access the dataset;

[0116] DataLoader is an iterator that can effectively manage operations such as batch loading and shuffling of data;

[0117] batch_size=64 loads 64 samples for each batch, which is a common batch size in neural network training, which helps with memory management and can increase training speed;

[0118] shuffle=True shuffles the data at the beginning of each training cycle, which helps reduce bias during model training and improves the generalization ability of the model.

[0119] Furthermore, the step 4 is specifically as follows:

[0120] Step 4.1: Set the total number of training rounds to 50 rounds, which means the entire training data set will be traversed 50 times.

[0121] Step 4.2: for data in dataloader is to iteratively retrieve each batch of data from the data loader;

[0122] real_data, _ = data is to decompose the retrieved data into the actual data real_data and labels (the labels are not used here and are replaced by _);

[0123] batch_size = real_data.size(0) is to obtain the size of the current batch, that is, the number of samples in real_data;

[0124] Step 4.3: real_labels = torch.ones(batch_size, 1) creates labels for the real data, all set to 1 (indicating "true");

[0125] fake_labels = torch.zeros(batch_size, 1) creates labels for the generated fake data, all set to 0 (indicating "fake");

[0126] discriminator.zero_grad() clears all old gradients in the discriminator network;

[0127] outputs = discriminator(real_data) is to input the real data into the discriminator to obtain the discrimination result;

[0128] d_loss_real = criterion(outputs, real_labels) is to calculate the loss of the discriminator for real data;

[0129] d_loss_real.backward() is to back propagate the real data loss and calculate the gradient;

[0130] Step 4.4: noise = torch.randn(batch_size, 100) generates random noise as the input of the generator;

[0131] fake_data = generator(noise) generates fake data using noise for the generator;

[0132] outputs = discriminator(fake_data.detach()) is to input fake data into the discriminator (use .detach() to prevent the gradient from being passed to the generator);

[0133] d_loss_fake = criterion(outputs, fake_labels) is used to calculate the loss of the discriminator for fake data;

[0134] d_loss_fake.backward() is used to back-propagate the fake data loss;

[0135] optimizer_D.step() is to update the weight of the discriminator;

[0136] Step 4.5: generator.zero_grad() clears all old gradients in the generator network;

[0137] outputs = discriminator(fake_data) is to input fake data into the discriminator again;

[0138] g_loss = criterion(outputs, real_labels) is used to calculate the loss of the generator. The goal of the generator is to make the fake data be considered real by the discriminator (so real_labels is used);

[0139] g_loss.backward() is to back-propagate the loss of the generator;

[0140] optimizer_G.step() is to update the weight of the generator;

[0141] Step 4.6: Import the PyTorch library and import the DataLoader and TensorDataset classes from the PyTorch library; DataLoader is used to create an iterable data loader, and TensorDataset is used as a dataset; then import the NumPy library, which is the basic library for scientific computing in Python, providing a large number of mathematical functions and multidimensional array operations; generate an array of shape (100, 50) containing random numbers drawn from a standard normal distribution (mean 0, variance 1); here it is assumed that each sample has 50 features;

[0142] Step 4.7: Randomly generate an array of (50, 1) with elements of 0 or 1; these represent the labels of the samples, which are used for classification tasks in supervised learning; convert the NumPy array labels to a PyTorch tensor, and specify the data type as torch.float32; create a TensorDataset object using features_tensor and labels_tensor; this object encapsulates the tensor into a dataset, which is suitable for use with DataLoader to provide data when training or testing a model; create a DataLoader object to load data from dataset in batches; the parameter batch_size=10 means that each batch contains 10 samples, and shuffle=True means that the data is randomly shuffled at the beginning of each epoch; this helps generalization performance during model training;

[0143] Step 4.8: Define a class called NetworkSecurityModel that inherits from nn.Module; nn.Module is the base class for all neural network modules in PyTorch;

[0144] nn.Sequential creates a sequential container and executes each operation in the order in which it is added;

[0145] nn.Linear(50, 256) adds a linear layer with 784 input features and 256 output features; this layer is often used to perform feature conversion from input data;

[0146] nn.ReLU() adds a ReLU activation function after the first linear layer to introduce nonlinearity and help the network learn complex patterns;

[0147] nn.Linear(256, 64) adds another linear layer, this time reducing the features from 256 to 64;

[0148] nn.ReLU() adds a ReLU activation function again;

[0149] nn.Linear(64, 1) is the last linear layer, which reduces the features from 64 to 1. This output is used to represent the final classification result;

[0150] nn.Sigmoid() adds a Sigmoid activation function at the end, which compresses the output to between 0 and 1. It is suitable for binary classification tasks. The output can be interpreted as probability or decision boundary.

[0151] Step 4.9: Define the forward propagation function of the model; this is a function that must be implemented, PyTorch will call it when training and evaluating the model; x is the model input data, self.layers(x) processes the input data through the defined layer sequence and returns the output; Instantiate the NetworkSecurityModel class and create a model object named model; This object can now be used for training, evaluation, or prediction;

[0152] Step 4.10: Define a function named validate that receives two parameters: model (the model to be evaluated) and dataloader (the data loader containing the validation dataset); Set the model to evaluation mode and initialize two variables total and correct; total is used to record the total number of samples, and correct is used to record the number of samples predicted correctly; Open a context manager torch.no_grad() that does not calculate gradients; During the model evaluation and inference phases, turning off gradient calculation can reduce memory usage and speed up the processing process; Iterate to access the data in the dataloader; Each loop, data contains a batch of data and the corresponding labels; Pass the input data inputs to the model and get the model output outputs; Round the model output outputs to the nearest integer and accumulate the number of samples in this batch to the total variable;

[0153] labels.size(0) returns the number of samples in the current batch; calculate the number of samples predicted correctly in this batch and accumulate them to the correct variable; predicted == labels creates a Boolean tensor in which the correctly predicted position is True; use .sum() to calculate the number of True, and .item() to convert it to a Python integer; calculate the accuracy on the entire dataset; the accuracy is the ratio of the number of correctly predicted samples to the total number of samples.

[0154] Furthermore, the step 5 is specifically as follows:

[0155] Step 5.1: Calculate the network security posture coefficient.

[0156] Safety factor = (w1 * number of attacks + w2 * attack duration + w3 * attack intensity + w4 * attack frequency + w5 * GAN output) / total weight,

[0157] According to the expert evaluation model, the weight coefficients of W1, W2, W3, W4, and W5 are initially assigned as 0.1, 0.1, 0.3, 0.2, and 0.3;

[0158] Step 5.2: Dynamically enhance GAN network training; Combine GAN with reinforcement learning to adjust the GAN training process based on real-time feedback from the network environment; This approach allows the model to continuously adapt to new security threats and network behaviors, enhancing its application effect in dynamic environments; Establish a GANEnv class inherited from gym.Env to create an environment that contains a generative adversarial network (GAN) for reinforcement learning tasks;

[0159] super(GANEnv, self).__init__() is the initialization method that calls the parent class gym.Env;

[0160] self.generator and self.discriminator are used to store the generator and discriminator objects passed in;

[0161] self.action_space is used to define the action space. Here, the action is a two-element vector, each element of which is between -0.1 and 0.1, indicating the adjustment of the learning rate of the generator and the discriminator.

[0162] self.observation_space is used to define the observation space. Here, the observation result is a vector of length 50, representing the data output by the generator.

[0163] self.gen_optimizer and self.disc_optimizer initialize the Adam optimizer for the generator and discriminator;

[0164] self._take_action(action) is to execute the action, that is, adjust the learning rate;

[0165] Step 5.3: generated_state = self.generator(torch.randn(1, 100)).detach() generates a new state, that is, generates a new output from the generator; reward = self._get_reward(generated_state) calculates the reward based on the generated state; done = False: In this environment, there is generally no end condition (that is, done is always False) unless a specific situation requires the interaction to end; return the new state, reward, and end flag; adjust the learning rate of the generator and discriminator to ensure that the learning rate is not less than a minimum value (here is 0.00001) to avoid zero or negative learning rates; use the discriminator to evaluate the generated data and randomly generated "real" data and calculate the reward; the reward is based on the discriminator's prediction accuracy for fake data and real data; finally, reset the environment and generate a new initial state;

[0166] Step 5.4: Dynamically adjust the situation coefficient;

[0167] Specifically, read the historical security event related data, calculate the correlation between the GAN network model output, the number of attacks, the attack duration, the attack intensity, the attack frequency and the implementation, and adjust the weight value of each indicator according to the correlation; use the pandas read_csv function to load the data file named historical_security_data.csv into the data DataFrame; define a list columns containing the columns to be analyzed in the data set; these columns include the number of attacks, duration, intensity, frequency, GAN model output and the label of the security event; initialize an empty dictionary correlations to store the correlation coefficient between each feature and the security event;

[0168] Step 5.5: Use a for loop to loop through each column (feature) except security_event; Check if the data type of the column is an integer (int64) or a floating point number (float64) to ensure that the data type is suitable for correlation calculation; Use the pearsonr function to calculate the correlation coefficient between each feature and security_event and store the result in the correlations dictionary; Use dictionary derivation to initialize the weight dictionary weights and give each feature an initial weight of 1.0; Iterate through the correlations dictionary and adjust the weight according to the absolute value of the correlation coefficient between each feature and the security event; Accumulate all adjusted weights into the total_weight variable; Normalize the weights to ensure that the sum of all weights is 1;

[0169] Step 5.6: Based on the historical data analysis and the standard deviation of the frequency of security incidents, the threshold e is determined. e1 and e2 are the two critical values ​​of the threshold e. When e1>safety factor sa>0, the network is secure. At the threshold or lower output, the incidence of security issues in history is extremely low. When the security situation coefficient is between e1 and e2, it is determined that the network may have security issues. This range can be regarded as a warning area or an area that requires further monitoring and evaluation. In the interval from e1 to e2, the network may not be completely secure, but it is not in immediate danger. When the safety factor is greater than e2 and less than 1, there is a higher security risk.

[0170] Specifically, this implementation adopts an advanced generative adversarial network (GAN) model. This model is specifically used to generate adversarial samples. It uses key network security indicators, including the impact of key features such as IP addresses, port numbers, transmission protocols, packet sizes, and session durations in the network on the system. Through these data, the model can generate more confusing samples for testing and improving the defense capabilities of network security systems.

[0171] This paper develops a network security situation awareness method by using a generative adversarial network (GAN), which effectively combines key security indicators such as known vulnerabilities, attack times, attack intensity, and system impact to generate highly realistic adversarial samples. These samples are used to test and improve the protection capabilities of network security systems, so that security systems can better adapt to and respond to the ever-changing network threat environment. Through this method, more accurate and dynamic network security protection can be achieved, thereby significantly improving overall network security and response capabilities.

[0172] Implementation Method 2

[0173] This embodiment provides a campus network security monitoring system based on situational awareness. This embodiment uses the campus network security monitoring method based on situational awareness as described in embodiment 1. The system includes:

[0174] A data preprocessing module is used to preprocess the acquired data;

[0175] GAN model construction module, building adversarial network GAN model;

[0176] Situation awareness model building module, building a situation awareness model based on the model;

[0177] Model training module, which uses preprocessed data to train and verify the constructed model;

[0178] The situation awareness module uses the situation awareness model to conduct situation awareness of network security, achieving more accurate and dynamic network security protection.

[0179] Furthermore, the working principle of the data preprocessing module is specifically as follows:

[0180] Integrate data from different sources (such as network traffic monitoring tools, system logs, and security event management systems); the integration includes unification of data formats and time synchronization to ensure consistency of all data on the timeline.

[0181] First, remove irrelevant or useless information, such as health check reports and log information not related to security, to streamline the data set and improve processing efficiency. Next, correct errors that may occur during data collection and transmission to ensure data accuracy and reliability. Finally, use appropriate strategies to fill or remove missing values ​​in the data set.

[0182] Extract key features such as IP address, port number, transport protocol, packet size and session duration from network traffic; meanwhile, login status, command usage and system call information in system logs can help detect unauthorized access and other suspicious behaviors, while features such as event type, severity and impact scope in security incident reports can help assess the urgency and priority of incidents;

[0183] In the feature engineering stage of cybersecurity data, features are processed and converted to optimize the training and prediction effects of machine learning models. First, encoding is performed, including converting categorical features, such as attack types, into a format that can be effectively processed by the model. Then, in order to ensure the fairness and effectiveness of different features in the model, data normalization or standardization is performed so that all data features are at the same level, thereby avoiding certain features dominating the results due to their numerical size during model training.

[0184] Through expert evaluation, the collected data is accurately classified into labels representing normal behavior or abnormal, aggressive behavior;

[0185] Since attack samples are usually far less than normal samples, we can use oversampling of minority classes, i.e. increasing the number of attack samples, to enhance the model's learning of attack behaviors; undersampling of majority classes, i.e. reducing the number of normal samples, to reduce their dominance during training; or use synthetic minority oversampling technology (SMOTE), which provides a more balanced training data set by generating synthetic attack samples.

[0186] The following three methods were used to expand the dataset and balance the number of samples:

[0187] Oversampling the minority class:

[0188] Increase the number of attack samples and duplicate minority samples to increase their number and achieve a relative balance with majority samples.

[0189] Undersample the majority class:

[0190] Reduce the number of normal samples by randomly deleting majority class samples to reduce their number and achieve a relative balance with minority class samples.

[0191] Synthetic Minority Oversampling Technique (SMOTE):

[0192] Generate synthetic minority class samples, generate new minority class samples through interpolation method, and increase the number of minority class samples.

[0193] Oversampling the minority class is used simultaneously with undersampling the majority class to achieve a more balanced dataset.

[0194] Furthermore, the working principle of the GAN model construction module is specifically as follows:

[0195] Import the PyTorch library, import the nn module in PyTorch and rename it to nn; import the optim module in PyTorch and rename it to optim; import the DataLoader and TensorDataset classes from the torch.utils.data module;

[0196] Define a class named Generator, which inherits from nn.Module; nn.Module is the base class of all neural network modules in PyTorch; is the constructor of the Generator class; calls the base class constructor through super() to ensure that the neural network infrastructure is initialized correctly; creates a sequential model using nn.Sequential; this container executes each layer in sequence; nn.Linear(50, 128) is a fully connected layer with 50 input features and 128 output features;

[0197] nn.ReLU() is a nonlinear activation function, which is used to add nonlinear characteristics to help the network learn complex patterns;

[0198] nn.Linear(128, 256) and nn.Linear(256, 512) are more fully connected layers, gradually increasing the complexity of the model;

[0199] nn.Linear(512, 1024) and nn.Linear(1024, 50) are the final fully connected layers, and the output feature vector length is 50, which usually corresponds to a flattened image data;

[0200] nn.Tanh() is a hyperbolic tangent activation function with an output range of [-1, 1], which is usually used to generate the last layer of image data;

[0201] The network's forward propagation logic is defined; z is the input noise vector, and the network returns the generated data after processing; a class called Discriminator is defined, which also inherits from nn.Module; it is also initialized by calling the base class constructor through super();

[0202] nn.Linear(50, 512) is a fully connected layer that starts processing from the input 50 feature vectors;

[0203] nn.LeakyReLU(0.2) is the LeakyReLU activation function, which allows a small negative slope and avoids the dead neuron problem of ReLU;

[0204] nn.Dropout(0.3) randomly drops 30% of nodes to prevent overfitting;

[0205] Based on the previous steps, nn.Linear(512, 256) and nn.Linear(256, 1) are further fully connected layers, gradually reducing the number of features to 1 for binary classification; nn.Sigmoid(): Sigmoid is an activation function that compresses the output to the interval [0, 1] for binary classification tasks, and outputs the probability of judging whether the generated sample is true or false;

[0206] Process the input data x, process it through steps 2.2-2.4 and output the discrimination result.

[0207] Furthermore, the working principle of the situation awareness model building module also includes

[0208] Instantiate the Generator class and create a generator object; this generator will be used to generate fake data that is as close to real data as possible; instantiate the Discriminator class and create a discriminator object; the task of the discriminator is to distinguish whether the data input to it is real or generated by the generator;

[0209] The loss function is defined as Binary Cross-Entropy Loss, which is a commonly used loss function in training generative adversarial networks. In GAN, the goal of the discriminator is to correctly classify real data and generated data, while the goal of the generator is to deceive the discriminator as much as possible. The Adam optimization algorithm is used to handle machine learning tasks with large-scale data and parameters, with a learning rate of 0.0002 and a gradient decay rate of 0.9.

[0210] Based on steps 3.1 and 3.2, a comprehensive feature vector is constructed. The feature vector is a tensor containing 1000 samples, each of which is 50-dimensional. The features are randomly generated and follow a standard normal distribution (mean is 0 and standard deviation is 1). The 50 here may represent a comprehensive feature vector that integrates data from multiple data sources (such as network traffic monitoring tools, system logs, and security event management systems).

[0211] Generate labels for 1000 samples based on the feature vector from step 3.3; here we use the torch.cat function to concatenate the two tensors together, where the first 500 samples are labeled as 1 (positive samples) and the last 500 samples are labeled as 0 (negative samples);

[0212] Use TensorDataset to combine the feature vectors from step 3.3 and the labels from step 3.4 into a dataset; TensorDataset is a class in PyTorch that is accessed by index;

[0213] Create a DataLoader for iterative access to the dataset;

[0214] DataLoader is an iterator that can effectively manage operations such as batch loading and shuffling of data;

[0215] batch_size=64 loads 64 samples for each batch, which is a common batch size in neural network training, which helps with memory management and can increase training speed;

[0216] shuffle=True shuffles the data at the beginning of each training cycle, which helps reduce bias during model training and improves the generalization ability of the model.

[0217] Furthermore, the working principle of the model training module is specifically as follows:

[0218] Set the total number of training rounds to 50, which means the entire training data set will be traversed 50 times.

[0219] for data in dataloader is to iteratively retrieve each batch of data from the data loader;

[0220] real_data, _ = data is to decompose the retrieved data into the actual data real_data and labels (the labels are not used here and are replaced by _);

[0221] batch_size = real_data.size(0) is to obtain the size of the current batch, that is, the number of samples in real_data;

[0222] real_labels = torch.ones(batch_size, 1) creates labels for real data, all set to 1 (indicating "true");

[0223] fake_labels = torch.zeros(batch_size, 1) creates labels for the generated fake data, all set to 0 (indicating "fake");

[0224] discriminator.zero_grad() clears all old gradients in the discriminator network;

[0225] outputs = discriminator(real_data) is to input the real data into the discriminator to obtain the discrimination result;

[0226] d_loss_real = criterion(outputs, real_labels) is to calculate the loss of the discriminator for real data;

[0227] d_loss_real.backward() is to back propagate the real data loss and calculate the gradient;

[0228] noise = torch.randn(batch_size, 100) generates random noise as input to the generator;

[0229] fake_data = generator(noise) generates fake data using noise for the generator;

[0230] outputs = discriminator(fake_data.detach()) is to input fake data into the discriminator (use .detach() to prevent the gradient from being passed to the generator);

[0231] d_loss_fake = criterion(outputs, fake_labels) is used to calculate the loss of the discriminator for fake data;

[0232] d_loss_fake.backward() is used to back-propagate the fake data loss;

[0233] optimizer_D.step() is to update the weight of the discriminator;

[0234] generator.zero_grad() clears all old gradients in the generator network;

[0235] outputs = discriminator(fake_data) is to input fake data into the discriminator again;

[0236] g_loss = criterion(outputs, real_labels) is used to calculate the loss of the generator. The goal of the generator is to make the fake data be considered real by the discriminator (so real_labels is used);

[0237] g_loss.backward() is to back-propagate the loss of the generator;

[0238] optimizer_G.step() is to update the weight of the generator;

[0239] Import the PyTorch library, and import the DataLoader and TensorDataset classes from the PyTorch library; DataLoader is used to create an iterable data loader, and TensorDataset is used as a dataset; then import the NumPy library, which is the basic library for scientific computing in Python, providing a large number of mathematical functions and multidimensional array operations; generate an array of shape (100, 50) containing random numbers drawn from a standard normal distribution (mean 0, variance 1); here it is assumed that each sample has 50 features;

[0240] Randomly generate an array of (50, 1) with elements of 0 or 1; these represent the labels of the samples, which are used for classification tasks in supervised learning; convert the NumPy array labels to a PyTorch tensor, and the data type is also specified as torch.float32; create a TensorDataset object using features_tensor and labels_tensor; this object encapsulates the tensor into a dataset, which is suitable for use with DataLoader to provide data when training or testing a model; create a DataLoader object to load data from dataset in batches; the parameter batch_size=10 means that each batch contains 10 samples, and shuffle=True means that the data is randomly shuffled at the beginning of each epoch; this helps generalization performance during model training;

[0241] Define a class called NetworkSecurityModel that inherits from nn.Module; nn.Module is the base class for all neural network modules in PyTorch;

[0242] nn.Sequential creates a sequential container and executes each operation in the order in which it is added;

[0243] nn.Linear(50, 256) adds a linear layer with 784 input features and 256 output features; this layer is often used to perform feature conversion from input data;

[0244] nn.ReLU() adds a ReLU activation function after the first linear layer to introduce nonlinearity and help the network learn complex patterns;

[0245] nn.Linear(256, 64) adds another linear layer, this time reducing the features from 256 to 64;

[0246] nn.ReLU() adds a ReLU activation function again;

[0247] nn.Linear(64, 1) is the last linear layer, which reduces the features from 64 to 1. This output is used to represent the final classification result;

[0248] nn.Sigmoid() adds a Sigmoid activation function at the end, which compresses the output to between 0 and 1. It is suitable for binary classification tasks. The output can be interpreted as probability or decision boundary.

[0249] The forward propagation function of the model is defined; this is a function that must be implemented and PyTorch will call it when training and evaluating the model; x is the model input data, self.layers(x) processes the input data through the defined layer sequence and returns the output; instantiate the NetworkSecurityModel class and create a model object named model; this object can now be used for training, evaluation, or prediction;

[0250] Define a function named validate, which receives two parameters: model (the model to be evaluated) and dataloader (the data loader containing the validation dataset); set the model to evaluation mode and initialize two variables total and correct; total is used to record the total number of samples, and correct is used to record the number of samples predicted correctly; open a context manager torch.no_grad() that does not calculate gradients; turning off gradient calculations during model evaluation and inference can reduce memory usage and speed up the processing; iterate to access the data in the dataloader; in each loop, data contains a batch of data and the corresponding labels; pass the input data inputs to the model and get the model output outputs; round the model output outputs to the nearest integer and accumulate the number of samples in this batch to the total variable;

[0251] labels.size(0) returns the number of samples in the current batch; calculate the number of samples predicted correctly in this batch and accumulate them to the correct variable; predicted == labels creates a Boolean tensor in which the correctly predicted position is True; use .sum() to calculate the number of True, and .item() to convert it to a Python integer; calculate the accuracy on the entire dataset; the accuracy is the ratio of the number of correctly predicted samples to the total number of samples.

[0252] Furthermore, the working principle of the situation awareness module is specifically as follows:

[0253] Calculate the network security posture coefficient.

[0254] Safety factor = (w1 * number of attacks + w2 * attack duration + w3 * attack intensity + w4 * attack frequency + w5 * GAN output) / total weight,

[0255] According to the expert evaluation model, the weight coefficients of W1, W2, W3, W4, and W5 are initially assigned as 0.1, 0.1, 0.3, 0.2, and 0.3;

[0256] Dynamically enhance GAN network training; combine GAN with reinforcement learning to adjust the GAN training process based on real-time feedback from the network environment; this method can enable the model to continuously adapt to new security threats and network behaviors, enhancing its application effect in dynamic environments; establish the GANEnv class inherited from gym.Env to create an environment that contains a generative adversarial network (GAN) for reinforcement learning tasks;

[0257] super(GANEnv, self).__init__() is the initialization method that calls the parent class gym.Env;

[0258] self.generator and self.discriminator are used to store the generator and discriminator objects passed in;

[0259] self.action_space is used to define the action space. Here, the action is a two-element vector, each element of which is between -0.1 and 0.1, indicating the adjustment of the learning rate of the generator and the discriminator.

[0260] self.observation_space is used to define the observation space. Here, the observation result is a vector of length 50, representing the data output by the generator.

[0261] self.gen_optimizer and self.disc_optimizer initialize the Adam optimizer for the generator and discriminator;

[0262] self._take_action(action) is to execute the action, that is, adjust the learning rate.

[0263] generated_state = self.generator(torch.randn(1, 100)).detach() generates a new state, that is, generates a new output from the generator; reward = self._get_reward(generated_state) calculates the reward based on the generated state; done = False: In this environment, there is generally no end condition (that is, done is always False) unless the interaction needs to be ended in a specific situation; return the new state, reward, and end flag; adjust the learning rate of the generator and discriminator to ensure that the learning rate is not less than a minimum value (here is 0.00001) to avoid zero or negative learning rate; use the discriminator to evaluate the generated data and randomly generated "real" data and calculate the reward; the reward is based on the discriminator's prediction accuracy for false data and true data; finally, reset the environment and generate a new initial state;

[0264] Dynamically adjust the situation coefficient;

[0265] Specifically, read the historical security event related data, calculate the correlation between the GAN network model output, the number of attacks, the attack duration, the attack intensity, the attack frequency and the implementation, and adjust the weight value of each indicator according to the correlation; use the pandas read_csv function to load the data file named historical_security_data.csv into the data DataFrame; define a list columns containing the columns to be analyzed in the data set; these columns include the number of attacks, duration, intensity, frequency, GAN model output and the label of the security event; initialize an empty dictionary correlations to store the correlation coefficient between each feature and the security event;

[0266] Use a for loop to iterate over each column (feature) except security_event; Check if the data type of the column is an integer (int64) or a floating point number (float64) to ensure that the data type is suitable for correlation calculation; Use the pearsonr function to calculate the correlation coefficient between each feature and security_event and store the result in the correlations dictionary; Use dictionary derivation to initialize the weight dictionary weights and give each feature an initial weight of 1.0; Iterate over the correlations dictionary and adjust the weight according to the absolute value of the correlation coefficient between each feature and the security event; Accumulate all adjusted weights to the total_weight variable; Normalize the weights to ensure that the sum of all weights is 1;

[0267] Based on historical data analysis and the standard deviation of the frequency of security incidents, the threshold e is determined. e1 and e2 are two critical values ​​of the threshold e. When e1>safety factor sa>0, the network is secure. At the threshold or lower output, the incidence of security issues in history is extremely low. When the security situation coefficient is between e1 and e2, it is determined that the network may have security issues. This range can be regarded as a warning area or an area that requires further monitoring and evaluation. In the interval from e1 to e2, the network may not be completely secure, but it is not in immediate danger. When the safety factor is greater than e2 and less than 1, there is a higher security risk.

[0268] Implementation Method 3

[0269] An embodiment of the present invention provides an electronic device, which includes a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the memory is used to store software programs and modules, and the processor executes various functional applications and data processing by running the software programs and modules stored in the memory. The memory and the processor are connected via a bus. Specifically, the processor implements any step in the first embodiment above by running the computer program stored in the memory.

[0270] It should be understood that in the embodiments of the present invention, the processor may be a central processing unit (CPU), and the processor may also be other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or the processor may also be any conventional processor, etc.

[0271] The memory may include a read-only memory, a flash memory, and a random access memory, and provides instructions and data to the processor. A part or all of the memory may also include a nonvolatile random access memory.

[0272] It should be understood that if the above-mentioned integrated module / unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the present invention implements all or part of the processes in the above-mentioned implementation method, and can also be completed by instructing the relevant hardware through a computer program. The above-mentioned computer program can be stored in a computer-readable storage medium. When the computer program is executed by the processor, the steps of the above-mentioned method implementation can be implemented. Among them, the above-mentioned computer program includes computer program code, and the above-mentioned computer program code can be in source code form, object code form, executable file or some intermediate form. The above-mentioned computer-readable medium may include: any entity or device capable of carrying the above-mentioned computer program code, recording medium, U disk, mobile hard disk, disk, optical disk, computer memory, read-only memory (ROM), random access memory (RAM), electric carrier signal, telecommunication signal and software distribution medium. It should be noted that the content contained in the above-mentioned computer-readable storage medium can be appropriately increased or decreased according to the requirements of legislation and patent practice in the jurisdiction.

[0273] The above description of the disclosed embodiments enables one skilled in the art to implement or use the present invention. Various modifications to these embodiments will be apparent to one skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present invention. Therefore, the present invention will not be limited to the embodiments shown herein, but rather to the widest range consistent with the principles and novel features disclosed herein.

[0274] Those skilled in the art can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional units and modules is used as an example for illustration. In actual applications, the above-mentioned function allocation can be completed by different functional units and modules as needed, that is, the internal structure of the above-mentioned device can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the implementation method can be integrated into a processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of software functional units. In addition, the specific names of the functional units and modules are only for the convenience of distinguishing each other, and are not used to limit the scope of protection of the present invention. The specific working process of the units and modules in the above-mentioned system can refer to the corresponding process in the aforementioned method implementation method, which will not be repeated here.

[0275] It should be noted that the methods and detailed examples provided in the above embodiments can be combined with the devices and equipment provided in the embodiments, and references can be made to each other, and no further details will be given.

[0276] Those skilled in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the present invention.

[0277] In the embodiments provided by the present invention, it should be understood that the disclosed device / terminal equipment and method can be implemented in other ways. For example, the device / equipment implementation described above is only illustrative, for example, the division of the above modules or units is only a logical function division, and in actual implementation, there may be other division methods, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed.

[0278] The above-mentioned embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit them. Although the present invention has been described in detail with reference to the above-mentioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the above-mentioned embodiments, or replace some of the technical features therein by equivalents. These modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the various embodiments of the present invention, and should all be included in the protection scope of the present invention.

Claims

1. A campus network security monitoring method based on situational awareness, characterized in that: The method is to form an adversarial generative network through a generator and a discriminator, and generate adversarial samples according to the number of all known vulnerabilities in the network, the number of attacks suffered by the current network, the intensity of attacks suffered by the current network, and the effects of the attacks on the system; The established situational awareness model analyzes the overall security health of the network by adversarially generating the output of the discriminator of the network and key security indicators, and finally outputs a continuous score representing the current network security status; to help identify potential vulnerabilities, assess the impact of attacks, and predict security threats; The method comprises the following steps, Step 1: Preprocess the acquired data; Step 2: Build the adversarial network GAN model; Step 3: Build a situation awareness model based on the model in step 2; Step 4: Use the data preprocessed in step 1 to train and verify the model constructed in step 3; Step 5: Use the situation awareness model to conduct situation awareness of network security and achieve more accurate and dynamic network security protection; The step 2 is specifically as follows: Step 2.1: Import the dataset into the PyTorch library; Step 2.2: Define the Generator class in the PyTorch library and the constructor of the Generator class; call the constructor of the base class through super() and use nn.Sequential to create a sequential model; execute each layer in sequence; Step 2.3: Define the network's forward propagation logic; Step 2.4: Based on the previous steps, gradually reduce the number of features of the fully connected layer to 1; compress the output of the activation function to the interval [0,1], and output the probability of judging whether the generated sample is true or false; Step 2.5: Process the input data x, process it through steps 2.2-2.4 and output the discrimination result; The step 3 also includes: Step 3.1: Create a generator object and a discriminator object; Step 3.2: Define the loss function as binary cross entropy loss; Step 3.3: Construct a comprehensive feature vector based on steps 3.1 and 3.2; Step 3.4: Generate labels for 1000 samples based on the feature vectors in step 3.3; Step 3.5: Use TensorDataset to combine the feature vectors from step 3.3 and the labels from step 3.4 into a dataset; Step 3.6: Create a DataLoader to iteratively access the dataset; The step 4 is specifically as follows: Step 4.1: Set the total number of training rounds to 50 rounds; Step 4.2: for data in dataloader is to iteratively retrieve each batch of data from the data loader; Step 4.3: Create labels for real data and fake data, and train the discriminator with real data so that it can accurately distinguish between real data and fake data generated by the generator; Step 4.4: Generate fake data by inputting noise and use the fake data to further train the discriminator; the generator then learns to generate more realistic data through back-propagation, making it difficult for the discriminator to distinguish between real and generated data; Step 4.5: Through adversarial training, the generator gradually learns to generate realistic data, while the discriminator continuously improves its ability to distinguish true and false data until the two reach a dynamic balance; Step 4.6: Import the PyTorch library and then the NumPy library; Generate an array of shape (100,50) containing random numbers drawn from a standard normal distribution; Step 4.7: Randomly generate a (50,1) array with elements of 0 or 1; convert the NumPy array labels to a PyTorch tensor; Step 4.8: Define NetworkSecurityModel as the base class for all neural network modules; Step 4.9: Define the forward propagation function of the model; Step 4.10: Define the validate function and execute the validate function to evaluate the performance of the model on the validation set.

2. The campus network security monitoring method according to claim 1, characterized in that: The step 1 specifically comprises: Step 1.1: Integrate data from different sources; Step 1.2: Preprocess the data integrated in step 1.1, where preprocessing includes removing irrelevant or useless information, correcting errors in data collection and transmission, and filling or eliminating missing values ​​in the data set; Step 1.3: Extract key features from network traffic; login information, command usage, and system call information from system logs; Step 1.4: In the feature engineering stage of cybersecurity data, including encoding and data normalization or standardization; Step 1.5: Through expert evaluation, the collected data is accurately classified into labels representing normal behavior or abnormal, aggressive behavior; Step 1.6: Since attack samples are usually much less than normal samples, oversample the minority class and undersample the majority class; or use synthetic minority class oversampling technology to provide a more balanced training dataset by generating synthetic attack samples.

3. The campus network security monitoring method according to claim 1, characterized in that: The step 5 is specifically as follows: Step 5.1: Calculate the network security situation coefficient; Step 5.2: Dynamically enhance GAN network training; Step 5.3: Return the new state, reward, and end flag; adjust the learning rate of the generator and discriminator to ensure that the learning rate is not lower than a minimum value; Use the discriminator to evaluate the generated data and randomly generated "real" data, and calculate the reward; the reward is based on the discriminator's prediction accuracy for fake data and real data; finally reset the environment to generate a new initial state; Step 5.4: Dynamically adjust the situation coefficient; Step 5.5: Calculate the correlation coefficient between each feature and security_event, and adjust the weight according to the correlation; Step 5.6: Based on historical data analysis and the standard deviation of the frequency of security incidents, the threshold e is determined. e1 and e2 are two critical values ​​of the threshold e.

4. A campus network security monitoring system based on situational awareness, characterized in that: The system uses the campus network security monitoring method based on situational awareness as described in any one of claims 1 to 3, and the system includes: A data preprocessing module preprocesses the acquired data; GAN model construction module, building adversarial network GAN model; Situation awareness model building module, building a situation awareness model based on the model; Model training module, which uses preprocessed data to train and verify the constructed model; The situation awareness module uses the situation awareness model to conduct situation awareness of network security, achieving more accurate and dynamic network security protection.

5. A computer device, characterized in that: The method comprises a memory, a processor and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the method according to any one of claims 1 to 3 is implemented.

6. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method according to any one of claims 1 to 3 is implemented.