Malicious URL (Uniform Resource Locator) detection method based on data driving and related system

The malicious URL detection method, which employs adversarial training and multi-level feature extraction, addresses the problem of insufficient true positive rate under low false positive rate in existing technologies. It achieves efficient and accurate malicious URL detection, improving the robustness and sensitivity of the model.

CN121786832APending Publication Date: 2026-04-03NANJING UNIV OF POSTS & TELECOMM
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-12-26
Publication Date
2026-04-03

AI Technical Summary

Technical Problem

Existing malicious URL detection methods struggle to improve the true positive rate when the false positive rate is low, resulting in limited effectiveness in practical applications and impacting the overall performance of malicious URL detection systems.

Method used

We adopt a data-driven malicious URL detection method, which combines multi-level feature extraction and adversarial training strategies. By standardizing the length of the input URL, decomposing it at the character level and word level, we extract multi-level features using the CharBERT model and generate perturbation features through FreeLB adversarial training. We then combine layer attention mechanism and spatial pyramid pooling module for feature fusion and finally optimize the model parameters through a comprehensive loss function.

Benefits of technology

It significantly improves the accuracy and robustness of malicious URL detection, effectively identifies subtle malicious changes, enhances the model's recall capability with a low false positive rate, and strengthens the sensitivity and real-time application efficiency of malicious URL detection.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121786832A_ABST
    Figure CN121786832A_ABST
Patent Text Reader

Abstract

The invention discloses a malicious URL detection method based on data driving and a related system, and belongs to the technical field of artificial intelligence and network security. Firstly, length standardization processing is carried out, and then decomposition is carried out to generate embedded features. Then, the disturbance intensity is dynamically adjusted based on the disturbance sensitivity of each sample, an adversarial disturbance vector is generated through multi-step iteration, disturbed features are input into a CharBERT model, and semantic features in a multi-layer Transform structure are extracted; further, a layer attention mechanism is adopted to carry out weighted fusion on the features of each layer, and a spatial pyramid pooling module is introduced to realize multi-scale feature integration. According to the method, the recall capability of the model at a low false alarm rate can be remarkably improved, so that the recognition capability and actual combat robustness of a malicious URL detection system on key attack samples are enhanced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the fields of artificial intelligence and cybersecurity technology, and more specifically, to a method and system for detecting malicious URLs based on deep learning and adversarial training. Background Technology

[0002] Malicious Uniform Resource Locators (URLs), as a core tool in cyberattacks, are widely used in phishing, malware propagation, and data theft, posing a serious cybersecurity threat. With the widespread adoption of the internet, the number of malicious URLs has increased dramatically, bringing unprecedented challenges to user privacy and data security. Attackers deceive users into clicking on malicious URLs disguised as trusted websites or services, thereby carrying out attacks. Especially in the modern network environment, the methods of malicious URL disguise are becoming increasingly sophisticated, posing a significant challenge to traditional detection methods.

[0003] Currently, malicious URL detection mainly relies on blacklists, heuristic rules, and machine learning-based algorithms. Traditional blacklist and rule-based methods are inefficient in dealing with new types of attacks and are prone to false positives or false negatives. Deep learning-based detection methods, such as convolutional neural networks (CNNs), can improve detection accuracy, but they still have limitations when processing detailed URL features, especially character-level information. These methods often struggle to maintain stable efficiency when facing variant attacks or more complex attack forms.

[0004] In recent years, Transformer-based pre-trained models (such as BERT) have made significant progress in multiple tasks. Although Transformer performs well in long sequence modeling, its token-based input mechanism makes it difficult for the model to effectively capture subtle local changes in URLs, posing a challenge to the detection of malicious URLs. At the same time, traditional detection methods often fail to effectively improve the true positive rate (TPR) while maintaining a low false positive rate (FPR), which directly affects their accuracy and sensitivity in practical applications.

[0005] Therefore, existing malicious URL detection methods struggle to improve the true positive rate when false positive rates are low, limiting their effectiveness in practical applications and impacting the overall performance of malicious URL detection systems. To address these issues, more efficient and robust detection methods are needed that can guarantee both a low false positive rate and accurate identification of potentially malicious URLs. Summary of the Invention

[0006] Purpose of the invention: To address the limitation of existing malicious URL detection methods in improving the true positive rate under low false positive rates, which restricts their effectiveness in practical applications and affects the overall performance of malicious URL detection systems, this invention provides a data-driven malicious URL detection method. This method combines multi-level feature extraction, adversarial training, and other strategies to effectively overcome the limitations of traditional models and significantly improve the accuracy, robustness, and adaptability of malicious URL detection.

[0007] Technical solution: To achieve the above objectives, the technical solution adopted by this invention is as follows: A data-driven method for detecting malicious URLs includes the following steps: Step 1: Standardize the length of the input malicious Uniform Resource Locator (URL) to meet the predetermined input length requirement, and obtain the segmented malicious URL.

[0008] Step 2: Perform character-level and phrase-level decomposition on the segmented malicious Uniform Resource Locator (URL).

[0009] Step 3: Generate embedded features by representing the semantic information of the URL through word vectors or character vectors based on character-level decomposition and phrase-level decomposition.

[0010] Step 4: Based on perturbation sensitivity, perform dynamic adversarial perturbation training on URL samples using FreeLB to obtain perturbation features. Step 5: Input the perturbed features into the CharBERT model and extract multi-level features through a deep learning model based on a self-attention mechanism.

[0011] Step 6: Extract all intermediate layers and perform weighted processing on multi-level features using a layer attention mechanism.

[0012] Step 7: Use the spatial pyramid pooling module to achieve multi-scale feature fusion.

[0013] Step 8: Based on the fused features, calculate the classification results and optimize the model parameters using the loss function.

[0014] Step 9: Output the detection results of malicious URLs.

[0015] Preferred: The loss function in step 8 is:

[0016] in, For the total loss, For the sample size, For the first i The dynamic weighting factor for each sample. Let cross-entropy be the loss function. For the model in the first i Predicted output on each sample For the first i The input embedding features of each sample, For real labels, These are the weighting coefficients for the KL divergence loss. KL Let KL divergence be the KL divergence. This is the model's predicted output on perturbed samples. This is the final perturbation vector after the Kth step of optimization.

[0017] Dynamic sample weighting factor The method for determining it is as follows:

[0018] in, Based on the weights of the samples, To dynamically compensate for the increment, The threshold for TPR@FPR, where TPR@FPR is the false positive rate given a fixed true positive rate. This indicates that the sample is a positive sample.

[0019] Preferably, in step 6, a layer attention mechanism is used to weight the features, and the weights are calculated as follows:

[0020] in, Indicates the channel attention value. Indicates the input feature map, Represents the set of real numbers. C It is the number of channels. This represents the sigmoid function. This represents the global average pooling feature. This represents the max pooling feature. , This represents two weights shared by the input. After obtaining the attention values ​​for each layer, the attention map is multiplied by the original feature matrix to obtain the final result.

[0021] Preferred method: In step 7, the spatial pyramid pooling module divides the input feature map into regions at different scales, performs pooling operations on each region, and concatenates the multi-scale pooled features into the final vector.

[0022] in, This represents the result of pyramid pooling. This represents vector concatenation. This represents the result after dividing the original matrix into 1×1 blocks and pooling. This represents the result after dividing the original matrix into 2×2 blocks and pooling. This represents the result after dividing the original matrix into 3×3 blocks and pooling.

[0023] Preferred method: Step 5 uses the CharBERT model for multi-layer feature extraction, including character-level channels and word-level channels, which are used to capture fine-grained features and contextual semantic features, respectively.

[0024] Preferred method: Step 4 employs a sensitivity-based FreeLB adversarial training strategy to dynamically add adversarial perturbations to the embedded features, generating perturbed features, including the following steps: Step 41, for each input sample First, calculate the loss under clean input:

[0025] in, Loss under clean input, Let i be the input embedding features of the i-th sample. Let i be the true label of the i-th sample. This is the prediction function for the current model, with the following parameters: , This is the cross-entropy loss function.

[0026] Step 42, Initialize the perturbation vector And calculate the loss under the initial disturbance. :

[0027] Step 43, calculate the disturbance sensitivity index :

[0028] And calculate the average value of the entire phrase. :

[0029] Step 44, based on and The comparison dynamically sets the perturbation radius for each sample. With step size :

[0030] in: and Given the initial perturbation radius and step size, and This represents the disturbance adjustment amplitude.

[0031] Step 45: Perform K-step FreeLB perturbation iterative optimization for each sample:

[0032] in: Let be the disturbance vector for round t. For projection operations, ensure that the perturbation norm does not exceed a threshold. , The gradient of the perturbation vector.

[0033] Step 46, in the final perturbation result Based on this, a consistency regularization term is introduced to encourage stable distributions in model predictions:

[0034] in: KL Let KL divergence be defined as follows:

[0035] in, and These are two distributions in the th... j Predicted probabilities for each class.

[0036] Preferred method: Step 1: Standardize the length of the input malicious Uniform Resource Locator (URL) by adding a length constraint to the malicious URL. For malicious URLs exceeding 200 characters, only the first 200 characters are taken. For malicious URLs less than 200 characters, zeros are used to pad them after embedding.

[0037] Another objective of this invention is to provide a data-driven malicious URL detection system, employing the aforementioned data-driven malicious URL detection method, comprising an input unit, a length normalization unit, an embedded feature generation unit, a perturbation addition unit, a multi-level feature extraction unit, a weighted processing unit, a feature fusion unit, a classification loss optimization unit, and an output unit, wherein: The input unit is used to input a malicious Uniform Resource Locator (URL).

[0038] The length standardization unit is used to standardize the length of the input malicious Uniform Resource Locator (URL) to meet the predetermined input length requirement, thereby obtaining the segmented malicious URL.

[0039] The decomposition unit is used to perform character-level and phrase-level decomposition on the segmented malicious Uniform Resource Locator (URL).

[0040] The embedding feature generation unit is used to generate embedding features by representing the semantic information of the URL through word vectors or character vectors based on character-level decomposition and phrase-level decomposition.

[0041] The perturbation addition unit, based on perturbation sensitivity, uses the FreeLB adversarial training strategy to add dynamic adversarial perturbations to the embedded features of URL samples, generating perturbed features.

[0042] The multi-level feature extraction unit is used to input perturbed features into the CharBERT model and extract multi-level features through a deep learning model based on a self-attention mechanism.

[0043] The weighted processing unit is used to extract all intermediate layers and perform weighted processing on multi-level features through a layer attention mechanism.

[0044] The feature fusion unit is used to achieve multi-scale feature fusion using the spatial pyramid pooling module.

[0045] The classification loss optimization unit is used to calculate the classification result based on the fused features and optimize the model parameters through the loss function.

[0046] The output unit is used to output the detection results of malicious URLs.

[0047] Another object of the present invention is to provide an electronic device comprising: at least one processor, at least one memory, and a communication interface. The processor, memory, and communication interface communicate with each other. The memory stores program instructions executable by the processor, which invokes the program instructions to execute the data-driven malicious URL detection method described above.

[0048] Another object of the present invention is to provide a non-transitory computer-readable storage medium storing computer instructions that cause the computer to execute the data-driven malicious URL detection method described above.

[0049] Compared with the prior art, the present invention has the following advantages: (1) This invention introduces an adversarial training strategy, significantly improving the performance of TPR under low FPR conditions, thus verifying the robustness of the model under low false positive rates. (2) This invention adopts an end-to-end detection method, simplifying the malicious URL identification process, improving detection efficiency, and ensuring high efficiency in real-time applications. Simultaneously, the character-aware Transformer structure enables fine-grained feature extraction, automatically learning and extracting complex URL features at the token and character levels, enhancing the accuracy and sensitivity of malicious URLs. This method can effectively identify subtle malicious changes, especially exhibiting excellent performance when facing highly variable URLs. Attached Figure Description

[0050] Figure 1 This is a flowchart illustrating a data-driven malicious URL detection method according to the present invention.

[0051] Figure 2 This is the overall network architecture diagram of the FL-CharBERT model of this invention.

[0052] Figure 3 This is a comparison chart of the experimental results of this invention on different datasets when TPR@FPR=0.01%. Detailed Implementation

[0053] The present invention will be further illustrated below with reference to the accompanying drawings and specific embodiments. It should be understood that these examples are for illustrative purposes only and are not intended to limit the scope of the invention. After reading this invention, any modifications of the invention in various equivalent forms by those skilled in the art will fall within the scope defined by the appended claims.

[0054] Example 1 This embodiment provides a data-driven malicious URL detection method. First, the input Uniform Resource Locator (URL) is standardized to a fixed length segment, then decomposed to generate embedded features. Subsequently, the perturbation intensity is dynamically adjusted based on the perturbation sensitivity of each sample, generating an adversarial perturbation vector through multi-step iterations. The perturbed features are then input into a CharBERT model to extract semantic features from the multi-layer Transformer structure. Further, a layer attention mechanism is used to weightedly fuse features from each layer, and a spatial pyramid pooling module is introduced to achieve multi-scale feature integration. In the classification stage, a comprehensive loss function is constructed, including cross-entropy loss, perturbation consistency regularization (KL divergence), and a TPR@FPR feedback dynamic weighting mechanism to optimize the model training process. Figure 1 , 2 As shown, the specific steps include: Step 1: Standardize the length of the input malicious Uniform Resource Locator (URL) to meet the predetermined input length requirement, and obtain the segmented malicious URL.

[0055] In another embodiment, the method for length standardization of the input malicious Uniform Resource Locator (URL) is as follows: a length constraint is added to the malicious URL, and only the first 200 characters are taken for malicious URLs exceeding 200 characters, while malicious URLs less than 200 characters are padded with 0 after embedding.

[0056] Step 2: Perform character-level decomposition and phrase-level decomposition (token-level decomposition) on the segmented malicious Uniform Resource Locator (URL).

[0057] Step 3: Generate embedded features by representing the semantic information of the URL through word vectors or character vectors based on character-level decomposition and phrase-level decomposition.

[0058] Step 4: Based on perturbation sensitivity, the FreeLB adversarial training strategy (Free Large-Batch, an adversarial training algorithm for natural language processing (NLP)) is used to add dynamic adversarial perturbations to the embedded features of the URL samples, generating perturbation-laden features.

[0059] In another embodiment, step 4, which involves using a FreeLB adversarial training strategy based on perturbation sensitivity to add dynamic adversarial perturbations to the embedded features of URL samples and generate perturbed features, includes the following steps: Step 41, for each input sample First, calculate the loss under clean input:

[0060] in, Loss under clean input, Let i be the input embedding features of the i-th sample. Let i be the true label of the i-th sample. This is the prediction function for the current model, with the following parameters: , This is the cross-entropy loss function.

[0061] Step 42, Initialize the perturbation vector And calculate the loss under the initial disturbance. :

[0062] Step 43, calculate the disturbance sensitivity index :

[0063] And calculate the average value of the entire phrase. :

[0064] Step 44, based on and The comparison dynamically sets the perturbation radius for each sample. With step size :

[0065] in: and Given the initial perturbation radius and step size, and This represents the disturbance adjustment amplitude.

[0066] Step 45: Perform K-step FreeLB perturbation iterative optimization for each sample:

[0067] in: Let be the disturbance vector for round t. For projection operations, ensure that the perturbation norm does not exceed a threshold. , The gradient of the perturbation vector.

[0068] Step 46, in the final perturbation result Based on this, a consistency regularization term is introduced to encourage stable distributions in model predictions:

[0069] in: KL Let KL divergence be defined as follows:

[0070] in, and These are two distributions in the th... j Predicted probabilities for each class.

[0071] Step 5: Input the perturbed features into the CharBERT model (a character-aware pre-trained language model), and extract multi-level features through a deep learning model (multi-layer Transformer structure) based on self-attention mechanism.

[0072] In another embodiment, step 5 uses the CharBERT model to perform multi-layer feature extraction, which includes character-level channels and word-level channels, used to capture fine-grained features and contextual semantic features, respectively.

[0073] Step 6: Extract all intermediate layers and perform weighted processing on multi-level features using a layer attention mechanism.

[0074] In another embodiment, step 6 employs a layer attention mechanism to weight the features, wherein the weights are calculated as follows:

[0075] in, Indicates the channel attention value. Indicates the input feature map, Represents the set of real numbers. C It is the number of channels. This represents the sigmoid function. This represents the global average pooling feature. This represents the max pooling feature. , This represents two weights shared by the input; after obtaining the attention values ​​for each layer, the attention map is multiplied by the original feature matrix to obtain the final result.

[0076] Step 7: Use the spatial pyramid pooling module to achieve multi-scale feature fusion.

[0077] While maintaining overall classification performance stability, this invention can significantly improve the model's recall capability (TPR@FPR) at low false positive rates, thereby enhancing the malicious URL detection system's ability to identify key attack samples and its practical robustness. This invention effectively improves key performance indicators in security detection tasks and has broad engineering application value and promotion prospects. In another embodiment, in step 7, the spatial pyramid pooling module divides the input feature map into regions at different scales (pooling window sizes are set to 1x1, 2x2, and 3x3), performs pooling operations on each region, and concatenates the multi-scale pooled features into the final vector:

[0078] in, This represents the result of pyramid pooling. This represents vector concatenation. This represents the result after dividing the original matrix into 1×1 blocks and pooling. This represents the result after dividing the original matrix into 2×2 blocks and pooling. This represents the result after dividing the original matrix into 3×3 blocks and pooling.

[0079] Step 8: Based on the fused features, calculate the classification results and optimize the model parameters using the loss function.

[0080] The loss function is:

[0081] in, For the total loss, For the sample size, For the first i The dynamic weighting factor for each sample. The cross-entropy loss function is used to supervise the main classification task. For the model in the first i Predicted output on each sample For the first i The input embedding features of each sample, For real labels, These are the weighting coefficients for the KL divergence loss. KL For KL divergence, specifically, KL ( A||B The Kullback-Leibler divergence is an asymmetric measure of the difference between two probability distributions A and B. This is the model's predicted output on perturbed samples. This is the final perturbation vector after the Kth step optimization; Dynamic sample weighting factor The method for determining it is as follows:

[0082] in, Based on the weights of the samples, To dynamically compensate for the increment, The threshold for TPR@FPR, where TPR@FPR is the false positive rate given a fixed true positive rate. This indicates that the sample is a positive sample.

[0083] Step 9: Output the detection results of malicious URLs.

[0084] Example 2 This embodiment provides a data-driven malicious URL detection system, employing the aforementioned data-driven malicious URL detection method, such as... Figure 2 As shown, it includes an input unit, a length normalization unit, an embedded feature generation unit, a perturbation addition unit, a multi-level feature extraction unit, a weighted processing unit, a feature fusion unit, a classification loss optimization unit, and an output unit, wherein: The input unit is used to input a malicious Uniform Resource Locator (URL).

[0085] The length standardization unit is used to standardize the length of the input malicious Uniform Resource Locator (URL) to meet the predetermined input length requirement, thereby obtaining the segmented malicious URL.

[0086] The decomposition unit is used to perform character-level and phrase-level decomposition on the segmented malicious Uniform Resource Locator (URL).

[0087] The embedding feature generation unit is used to generate embedding features by representing the semantic information of the URL through word vectors or character vectors based on character-level decomposition and phrase-level decomposition.

[0088] The perturbation addition unit, based on perturbation sensitivity, uses the FreeLB adversarial training strategy to add dynamic adversarial perturbations to the embedded features of URL samples, generating perturbed features.

[0089] The multi-level feature extraction unit is used to input perturbed features into the CharBERT model and extract multi-level features through a deep learning model based on a self-attention mechanism.

[0090] The weighted processing unit is used to extract all intermediate layers and perform weighted processing on multi-level features through a layer attention mechanism.

[0091] The feature fusion unit is used to achieve multi-scale feature fusion using the spatial pyramid pooling module.

[0092] The classification loss optimization unit is used to calculate the classification result based on the fused features and optimize the model parameters through the loss function.

[0093] The output unit is used to output the detection results of malicious URLs.

[0094] Example 3 This embodiment provides an electronic device, including: at least one processor, at least one memory, and a communication interface. The processor, memory, and communication interface communicate with each other. The memory stores program instructions executable by the processor, which invokes the program instructions to execute the data-driven malicious URL detection method.

[0095] Example 4 This embodiment provides a non-transitory computer-readable storage medium that stores computer instructions that cause the computer to execute the data-driven malicious URL detection method described above.

[0096] like Figure 3The figure shows a comparison of the experimental results of the present invention on different datasets when TPR@FPR=0.01%. As can be seen from the figure, when the false positive rate is fixed at 0.01%, the model FL-CharBert using the method of this patent has a significantly higher true positive rate than other model architectures, whether on the Grambedding, Mendelley, or Grambedding_adv datasets.

[0097] This invention performs token-level and character-level embedding on malicious URLs; it uses the FreeLB method to add perturbations to the embedding results, generating robust feature representations; it inputs the features with dynamic adversarial perturbations into a CharBERT model to extract features from each layer; it calculates the feature importance of different layers through a channel attention mechanism to establish a layer-aware model; it uses a pyramid convolution module to extract multi-dimensional features; it calculates the classification results and optimizes the loss; it adjusts the model parameters based on the optimization results and outputs the final classification result. Through these methods, this invention significantly improves the TPR@FPR value, effectively enhancing the accuracy and robustness of malicious URL detection, and has broad application prospects.

[0098] The above description is only a preferred embodiment of the present invention. It should be noted that for those skilled in the art, several improvements and modifications can be made without departing from the principle of the present invention, and these improvements and modifications should also be considered within the scope of protection of the present invention.

Claims

1. A data-driven malicious URL detection method, characterized in that, Includes the following steps: Step 1: Standardize the length of the input malicious Uniform Resource Locator (URL) to meet the predetermined input length requirement, and obtain the segmented malicious URL. Step 2: Perform character-level and phrase-level decomposition on the segmented malicious Uniform Resource Locator (URL); Step 3: Generate embedding features by representing the semantic information of the URL using word vectors or character vectors based on character-level decomposition and phrase-level decomposition; Step 4: Based on perturbation sensitivity, perform dynamic adversarial perturbation training on URL samples using FreeLB to obtain perturbation features. Step 5: Input the perturbed features into the CharBERT model and extract multi-level features through a deep learning model based on a self-attention mechanism. Step 6: Extract all intermediate layers and perform weighted processing on multi-level features using a layer attention mechanism; Step 7: Utilize the spatial pyramid pooling module to achieve multi-scale feature fusion; Step 8: Based on the fused features, calculate the classification results and optimize the model parameters using the loss function; Step 9: Output the detection results of malicious URLs.

2. The data-driven malicious URL detection method according to claim 1, characterized in that: The loss function in step 8 is: in, For the total loss, For the sample size, For the first i The dynamic weighting factor for each sample. Let cross-entropy be the loss function. For the model in the first i Predicted output on each sample For the first i The input embedding features of each sample, For real labels, These are the weighting coefficients for the KL divergence loss. KL Let KL divergence be the KL divergence. This is the model's predicted output on perturbed samples. This is the final perturbation vector after the Kth step optimization; Dynamic sample weighting factor The method for determining it is as follows: in, Based on the weights of the samples, To dynamically compensate for the increment, The threshold for TPR@FPR, where TPR@FPR is the false positive rate given a fixed true positive rate. This indicates that the sample is a positive sample.

3. The data-driven malicious URL detection method according to claim 2, characterized in that: Step 6 employs a layer attention mechanism to weight the features, where the weights are calculated as follows: in, Indicates the channel attention value. Indicates the input feature map, Represents the set of real numbers. C It is the number of channels. This represents the sigmoid function. This represents the global average pooling feature. This represents the max pooling feature. , This represents two weights shared by the input; after obtaining the attention values ​​for each layer, the attention map is multiplied by the original feature matrix to obtain the final result.

4. The data-driven malicious URL detection method according to claim 3, characterized in that: In step 7, the spatial pyramid pooling module divides the input feature map into regions at different scales, performs pooling operations on each region, and concatenates the multi-scale pooled features into the final vector: in, This represents the result of pyramid pooling. This represents vector concatenation. This represents the result after dividing the original matrix into 1×1 blocks and pooling. This represents the result after dividing the original matrix into 2×2 blocks and pooling. This represents the result after dividing the original matrix into 3×3 blocks and pooling.

5. The data-driven malicious URL detection method according to claim 4, characterized in that: Step 5 uses the CharBERT model for multi-layer feature extraction, including character-level channels and word-level channels, which are used to capture fine-grained features and contextual semantic features, respectively.

6. The data-driven malicious URL detection method according to claim 5, characterized in that: Step 4 employs a sensitivity-based FreeLB adversarial training strategy to dynamically add adversarial perturbations to the embedded features, generating perturbed features. This method includes the following steps: Step 41, for each input sample First, calculate the loss under clean input: in, Loss under clean input, Let i be the input embedding features of the i-th sample. Let i be the true label of the i-th sample. This is the prediction function for the current model, with the following parameters: , This is the cross-entropy loss function. Step 42, Initialize the perturbation vector And calculate the loss under the initial disturbance. : Step 43, calculate the disturbance sensitivity index : And calculate the average value of the entire phrase. : Step 44, based on and The comparison dynamically sets the perturbation radius for each sample. With step size : in: and Given the initial perturbation radius and step size, and This refers to the disturbance adjustment amplitude; Step 45: Perform K-step FreeLB perturbation iterative optimization for each sample: in: Let t be the disturbance vector in round t. For projection operations, ensure that the perturbation norm does not exceed a threshold. , The gradient of the perturbation vector; Step 46, in the final perturbation result Based on this, a consistency regularization term is introduced to encourage stable distributions in model predictions: in: KL Let KL divergence be defined as follows: in, and These are two distributions in the th... j Predicted probabilities for each class.

7. The data-driven malicious URL detection method according to claim 8, characterized in that: Step 1 involves standardizing the length of the input malicious Uniform Resource Locator (URL): A length constraint is added to the malicious URL. For URLs exceeding 200 characters, only the first 200 characters are used; for URLs less than 200 characters, zeros are used to pad the URL after embedding.

8. A data-driven malicious URL detection system, characterized in that: The data-driven malicious URL detection method described in claim 1 includes an input unit, a length normalization unit, an embedded feature generation unit, a perturbation addition unit, a multi-level feature extraction unit, a weighted processing unit, a feature fusion unit, a classification loss optimization unit, and an output unit, wherein: The input unit is used to input a malicious Uniform Resource Locator (URL); The length standardization unit is used to standardize the length of the input malicious Uniform Resource Locator (URL) to meet the predetermined input length requirement, thereby obtaining the segmented malicious URL. The decomposition unit is used to perform character-level and phrase-level decomposition on the segmented malicious Uniform Resource Locator URLs. The embedding feature generation unit is used to generate embedding features by representing the semantic information of the URL through word vectors or character vectors based on character-level decomposition and phrase-level decomposition. The perturbation addition unit, based on perturbation sensitivity, uses the FreeLB adversarial training strategy to add dynamic adversarial perturbations to the embedded features of URL samples, generating perturbed features. The multi-level feature extraction unit is used to input perturbed features into the CharBERT model and extract multi-level features through a deep learning model based on a self-attention mechanism. The weighted processing unit is used to extract all intermediate layers and perform weighted processing on multi-level features through a layer attention mechanism; The feature fusion unit is used to achieve multi-scale feature fusion using the spatial pyramid pooling module; The classification loss optimization unit is used to calculate the classification result based on the fused features and optimize the model parameters through the loss function; The output unit is used to output the detection results of malicious URLs.

9. An electronic device, characterized in that, include: At least one processor, at least one memory, and a communication interface; The processor, memory, and communication interface communicate with each other; The memory stores program instructions that can be executed by the processor, which invokes the program instructions to execute the data-driven malicious URL detection method according to any one of claims 1-7.

10. A non-transitory computer-readable storage medium, characterized in that, The non-transitory computer-readable storage medium stores computer instructions that cause the computer to execute the data-driven malicious URL detection method according to any one of claims 1 to 7.