A location target-oriented self-attention website fingerprinting method
By combining convolutional neural networks and self-attention mechanisms to extract and optimize the location-oriented features of Tor network traffic, the problems of high overhead and low efficiency in existing technologies are solved, and efficient identification and management of Tor network access websites are achieved.
Patent Information
- Application Number
- CN202411670754.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-21
- Publication Date
- 2025-10-24
- Estimated Expiration
- 2044-11-21
AI Technical Summary
Existing website fingerprint defense technology has high time and bandwidth overhead and poor defense effect when facing the Tor anonymous communication system. Attackers can identify the website information visited by users by monitoring traffic data.
A position-target-oriented self-attention website fingerprint recognition method is adopted, combined with convolutional neural networks and attention mechanisms. Traffic features are extracted through two-dimensional and one-dimensional convolution models, a position-oriented feature matrix is generated, and self-attention calculation is performed to optimize the weights to improve the representativeness of feature representation.
It improves the accuracy and efficiency of website fingerprint recognition, reduces misclassification, and realizes intelligent monitoring and management of anonymous network access.
Smart Images

Figure CN119675906B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to network security technology, and in particular relates to a location-target-oriented self-attention website fingerprint recognition method. Background Art
[0002] As people become increasingly aware of cybersecurity and personal privacy, numerous anonymous communication technologies have emerged. The Tor network, a highly anonymous communication system, is experiencing increasing usage. Tor utilizes multi-hop links, including entry, intermediate, and exit nodes, to provide anonymity within the network. Therefore, even if a user gains partial control of the network, it is impossible to simultaneously obtain information about both the client and server. Furthermore, the complex Tor protocol designed for the network makes it difficult for attackers to accurately reconstruct Tor data.
[0003] However, website fingerprinting attacks against Tor have significantly undermined Tor's anonymity. Attackers passively monitor the link between the client and the entry point, training a classifier based on traffic data to analyze the websites visited by users. In response to increasingly powerful attack techniques, corresponding website fingerprinting defense methods have emerged. Some of these methods are based on packet padding, others on packet regularization, and others on the concept of adversarial examples. These methods typically have very high time and bandwidth costs, but the emergence of these defenses significantly reduces the accuracy of the attacks. Consequently, various defense methods strive to reduce defense costs and achieve better protection against attacks. Summary of the Invention
[0004] To address the impact of website fingerprinting defense technology on recognition, this method uses a convolutional neural network and an attention mechanism to extract more representative website fingerprint features based on the traffic generated by users visiting the website. By using these features to train a classifier, better recognition results are achieved.
[0005] The present invention discloses a location-target-oriented self-attention website fingerprint recognition method, comprising the following steps:
[0006] Step (1), two-dimensional convolution flow preprocessing;
[0007] Collect network traffic: Use packet capture tools to collect traffic, convert the captured traffic into a usable format, and label each flow with the corresponding website.
[0008] Preliminary representation of data packet features in traffic: Count the specific number of data packets in both the inbound and outbound directions per unit time, and use a two-dimensional convolutional neural network for feature extraction. This neural network consists of multiple convolutional layers, pooling layers, activation layers, and batch processing layers to obtain a preliminary representation of traffic data packets.
[0009] Step (2), position target oriented attention weight calculation
[0010] The feature vector obtained by step 1 is compressed, and two one-dimensional convolution models are used to shorten the vector length of the target dimension. The neural network here includes a convolution layer, a batch processing layer, and a one-dimensional maximum pooling layer. For the new feature vector, according to the actual deployment requirements, a Position_Target vector is generated, and a matrix PT for attention calculation is determined. The data of the matrix is calculated by self-attention, and the self-attention weight is optimized to obtain the final website fingerprint feature representation.
[0011] The length of the feature vector will affect the performance of the model. Too long input will increase the model training overhead and increase the performance requirements of the hardware. Too short input will reduce the effective information received by the model and the degree of feature extraction will be insufficient. Therefore, reasonable feature compression and transfer can improve the performance of the classifier.
[0012] Convolutional neural networks can effectively extract local features, and attention mechanisms can effectively extract the relationship between data. The combination of the two complements each other, and the extracted traffic fingerprint is more representative, which is beneficial to the performance of the classifier. Specifically as follows:
[0013] S2.1 Data information compression
[0014] For the vector (denoted as x) from step 1, the size of x is considered as [m*n*k], and the last dimension data k can represent the statistical information of the original vector data. Two different one-dimensional convolution modules are used to shorten the vector length of the target dimension. The neural network here includes a convolution layer, a batch processing layer, and a maximum pooling layer. Through the one-dimensional convolution model, the kth dimension data is compressed.
[0015] S2.2 Generate a position target oriented vector Position_Target: [p1, p2, p3, …, p n ]
[0016] First, let the step 2 convolution kernel be [c1, c2, c3, …, c k ], and the convolution calculation is denoted as Q. Then the corresponding calculation is denoted as [Q c1 , Q c2 , Q c3 , …, Q ck ].
[0017] Let Every d Q operation constitutes a group of generators, that is:
[0018]
[0019] Each element in the Position_Target vector is determined by the weighted operation of d Q operations.
[0020] Let the compressed vector of step 2 be s_feature∈C m×n
[0021] s_feature can generate multiple Position_Target feature vectors according to the above rules, and the matrix PT oriented by position can be generated after arranging them in rows.
[0022]
[0023] The PT matrix has i rows of elements, each row has j columns.
[0024] S2.3 Generate PT-Mask matrix
[0025] At_temp=(PT) T ·PT
[0026] First, calculate the value of each element in the matrix At_temp. For any ith row data, calculate the Top array and the Bottom array respectively. Among them, the Top array stores a set of high-dimensional coordinates corresponding to the position coordinates of the attention weight ranked in the top k1 among all positive numbers of [A i1 ,A i2 ,…,A ij ]. Similarly, the Bottom array stores the position coordinates of the attention weight ranked in the last k2 among all negative numbers. Then initialize the attention mechanism mask vector (the last two-dimensional data):
[0027]
[0028] Then, based on the multi-dimensional coordinate information in the Top array and the Bottom array, the PT-Mask matrix replaces the corresponding position data with (1+m%) or (1+n%) on the basis of the initial mask matrix, and then participates in the attention mechanism operation. Among them, the above m, n, k1, k2 are set as hyperparameters.
[0029] S2.4 Calculate position target oriented attention weight
[0030]
[0031] As shown in the accompanying Figure 5 , wherein the PT matrix is used as the input of Q, K, and V, and θ() is the PT-Mask mechanism. The position target oriented attention weight calculation formula is as shown above.
[0032] Step (3), hyperparameter tuning
[0033] According to different specific tasks, the attacker needs to tune the model parameters to improve the model recognition accuracy.
[0034] The tuning step 1 inputs the traffic trajectory length, the data length reflects the richness of the basic information characteristics of the traffic trajectory, and the time interval of the tuning statistical packet quantity, the time interval reflects the fineness of the original traffic division, and simultaneously determines the overall length of the vector in the subsequent step; the vector length of Position_Target in the tuning step 2, the vector length needs to refer to the hardware GPU performance, the number of feature headers and the key feature optimization ratio in the attention weight calculation in the tuning step 2.
[0035] Based on the feature representation of step 2 and the model parameters tuned in step 3, ten-fold cross-validation is used to judge whether the feature vector in step 3 can effectively identify the target website. If the identification efficiency is low, return to step 1; if the identification efficiency is high, retain the model parameters and save the related model information to the related file, and end the process.
[0036] The beneficial effects of the present application are:
[0037] 1. In view of the limitations of the current website fingerprint defense technology, the correlation of the defense traffic is ignored when the traffic is interacted, the present application designs a new network structure for traffic analysis, better utilizes the performance of the convolutional neural network, increases the correlation of the local traffic features and the context traffic features, makes the attack more efficient when facing the website fingerprint defense, and reduces the misclassification.
[0038] 2. The present application proves the effectiveness of the self-attention mechanism for anonymous traffic analysis, and the self-attention technology fully utilizes the correlation between the segments and the local features.
[0039] 3. In the processing process based on the attention mechanism, the generated fingerprint feature vector has both time and space features, and the correlation between the two is also established, and the classifier also improves the classification accuracy. The present application can realize the intelligent identification of website traffic, and has important significance for the monitoring and management of anonymous network website access. BRIEF DESCRIPTION OF DRAWINGS
[0040] Figure 1 The overall flowchart of the present application is shown in the figure;
[0041] Figure 2 The step flowchart S2.1 of the present application is shown in the figure;
[0042] Figure 3 The step flowchart S2.2 of the present application is shown in the figure;
[0043] Figure 4 The step flowchart S2.3 of the present application is shown in the figure;
[0044] Figure 5 For the S2.4 process chart of the present application;
[0045] Figure 6 For the step 2 general process chart of the present application;
[0046] Figure 7 For the step process chart of the embodiment of the present application. DETAILED DESCRIPTION
[0047] The present application will be further clarified by the following examples and drawings, it should be understood that the following examples are only used to illustrate the present application and not used to limit the scope of the present application. It should be noted that the words "front", "back", "left", "right", "up" and "down" used in the following description refer to the directions in the drawings, and the words "in" and "out" refer to the directions towards or away from the geometric center of a particular component.
[0048] The present application is a Position_Target Attention website fingerprint identification method based on position target orientation. The method generates a fingerprint feature vector of a website to be classified based on an attention mechanism through a neural network for network traffic generated by network users. For a traffic data set to be classified, a two-dimensional convolution model is used to preprocess the traffic, and then the extracted features are reorganized into a feature matrix oriented by position. The new website fingerprint feature vector obtained is input into a classifier for classification. In the processing based on the attention mechanism, the generated fingerprint feature vector has both temporal and spatial features, and the correlation between the two is established, and the classifier also improves the classification accuracy. The present application can realize intelligent identification of website traffic, and has important significance for monitoring and management of anonymous network website access.
[0049] The present application realizes effective website fingerprint identification through the following technical features:
[0050] 1. The present application designs a feature vector oriented by position, which makes the extraction of website fingerprint vectors more efficient.
[0051] 2. The present application uses a Position_Target Attention mechanism to calculate weights, which makes the fingerprint feature vector more position-related and improves the classification performance of the classifier.
[0052] The specific steps of the embodiment are as follows:
[0053] Step (1), two-dimensional convolution traffic preprocessing
[0054] Collect network traffic: Use packet capture tools to collect traffic, convert the captured traffic to a usable format, and label each traffic with the corresponding website.
[0055] Preliminary representation of data packet features in traffic: Count the number of specific data packets in and out of the two directions in a unit of time, and use a two-dimensional convolutional neural network for feature extraction. This neural network is composed of multiple convolutional layers, pooling layers, activation layers, and batch processing layers, to obtain the preliminary representation of traffic data packets.
[0056] Step (2), position target oriented attention weight calculation
[0057] Compress the feature vector obtained from step 1, and use two one-dimensional convolutional models to shorten the vector length of the target dimension. The model here includes convolutional layers, batch processing layers, and one-dimensional max pooling layers. For the new feature vector, generate a Position_Target vector according to actual deployment requirements, and determine the matrix PT for attention calculation. Perform self-attention calculation on the data of this matrix, and optimize the self-attention weights to obtain the final website fingerprint feature representation.
[0058] Step (3), hyperparameter tuning
[0059] Hyperparameter tuning involves the unit time and input traffic length in step 1, the vector length of the Position_Target model in step 2, and the number of feature heads and the key feature optimization ratio in the attention weight calculation in step 3. Based on the feature representation in step 2 and the model parameters after step 3 tuning, use ten-fold cross-validation to determine whether the feature vector in step 2 effectively identifies the target website. If the identification efficiency is low, return to step 1; if the identification efficiency is high, retain the model parameters and save the relevant model information to a related file, and end the process.
[0060] The detailed process of the embodiment is shown in the attached Figure 7 .
[0061] Embodiment:
[0062] This embodiment is based on the above technical solution and uses Tor, one of the most popular Internet privacy enhancement technologies, as the carrier for traffic generation and acquisition to perform website fingerprint identification.
[0063] Step (1), two-dimensional convolution traffic preprocessing
[0064] Collect network traffic: Use packet capture tools to collect traffic, convert the captured traffic to a usable format, and label each traffic with the corresponding website.
[0065] Traffic data packet feature preliminary representation: the specific data packet quantity in and out of two directions in the statistical unit time, using a two-dimensional convolutional neural network for feature extraction, the neural network is composed of multiple convolutional layers, pooling layers, activation layers, batch processing layers, so as to obtain the preliminary representation of the traffic data packet.
[0066] Step (2), position target oriented attention weight calculation
[0067] The feature vector obtained by step 1 is compressed, and two one-dimensional convolution models are used to shorten the vector length of the target dimension. Here, the neural network includes convolutional layers, batch processing layers, and one-dimensional maximum pooling layers. For the new feature vector, according to the actual deployment requirements, the Position_Target vector is generated, and the matrix PT for attention calculation is determined. The data of the matrix is calculated by self-attention, and the self-attention weight is optimized to obtain the final website fingerprint feature representation.
[0068] S2.1 Data information compression
[0069] As shown in the accompanying Figure 2 , for the vector from step 1 (denoted as x), the size of x is considered as [m*n*k], and the last dimension data k can represent the original vector data statistical information. Two different one-dimensional convolution modules are used to shorten the vector length of the target dimension. Here, the neural network includes convolutional layers, batch processing layers, and maximum pooling layers. Through the one-dimensional convolution model, the kth dimension data is compressed.
[0070] S2.2 Generate position target oriented vector Position_Target: [p1, p2, p3, …, p n ]
[0071] As shown in the accompanying Figure 3 , first, record the step 2 convolution kernel: [c1, c2, c3, …, c k ], and the convolution calculation is denoted as Q, then the corresponding calculation is denoted as [Q c1 , Q c2 , Q c3 , …, Q ck ].
[0072] Let each d Q operation form a group of generators, that is:
[0073]
[0074] Each element in the Position_Target vector is determined by the weighted operation of d Q operations.
[0075] Record the compressed vector after step 2 as s_feature∈C m×n
[0076] Then s_feature can generate multiple Position_Target feature vectors according to the above rules, and after arranging them in rows, a position-targeted matrix PT is generated:
[0077]
[0078] The PT matrix has i rows of elements and each row has j columns.
[0079] S2.3 Generate PT-Mask Matrix
[0080] At_temp = (PT) T ·PT
[0081] As attached Figure 4 As shown, first calculate the value of each element in the matrix At_temp, and for any i-th row of data, calculate the Top array and Bottom array respectively. Among them, the Top array stores a set of high-dimensional coordinates, corresponding to [A i1 ,A i2 ,…,A ij ], the position coordinates of the attention weights of the first k1 are arranged by numerical value; similarly, the Bottom array stores the position coordinates of the attention weights of the last k2 are arranged by numerical value among all negative numbers. Then initialize the attention mechanism Mask vector (the last two dimensions):
[0082]
[0083] Based on the initial mask matrix, the PT-Mask matrix replaces the corresponding position data with (1+m%) or (1+n%) according to the multi-dimensional coordinate information in the Top and Bottom arrays, and then participates in the attention mechanism operation. Among them, m, n, k1, and k2 are set as hyperparameters.
[0084] S2.4 Calculating the position target-oriented attention weight
[0085]
[0086] As attached Figure 5 As shown, the PT matrix is used as the input of Q, K, V, and θ() is the PT-Mask mechanism.
[0087] Step (3), hyperparameter tuning
[0088] The tuning step 1 inputs the length of the traffic trajectory, which represents the richness of the basic information characteristics of the traffic trajectory, and the time interval of the number of statistical data packets, which represents the fineness of the original traffic division and determines the overall length of the vector in the subsequent steps; the tuning step 2 optimizes the length of the vector of the dimension of the model channel, which needs to refer to the performance of the hardware GPU; and the tuning step 3 optimizes the number of feature heads and the proportion of key features in the multi-head attention weight calculation.
[0089] Based on the feature representation of step 2 and the model parameters optimized in step 3, ten-fold cross-validation is used to determine whether the feature vector in step 2 effectively identifies the target website. If the identification accuracy is less than 90%, return to step 1; if the identification accuracy is higher than 90%, keep the model parameters and save the relevant model information to the related file, and end the process. The specific reference indicators are as follows:
[0090]
[0091] After the above steps, the original traffic trajectory has been successfully classified, the neural network has extracted the traffic fingerprint feature vector belonging to each website, and the classifier identification accuracy has been improved.
[0092] The above examples show that the new network structure of the traffic analysis designed by the application better utilizes the performance of the convolutional neural network, increases the relevance of local traffic features and context traffic features, makes the attack more efficient when facing website fingerprint defense, and reduces misclassification. The application can realize intelligent identification of website traffic, and has important significance for monitoring and management of anonymous network website access.
[0093] The technical means disclosed in the application scheme is not limited to the technical means disclosed in the above embodiments, but also includes technical solutions composed of any combination of the above technical features.
Claims
1. A location-based target-oriented self-attention website fingerprinting method, characterized in that, For any network traffic w s , the location-target-oriented self-attention website fingerprinting method can generate a feature vector w d representing the website traffic, and train a classifier with the feature vector for website classification; The website fingerprinting process comprises: Step 1, two-dimensional convolution traffic preprocessing, collecting network traffic: using a packet capture tool to collect traffic, converting the captured traffic into a usable format, and labeling each traffic with the corresponding website; Step 2, position target oriented attention weight calculation, compressing the feature vector obtained from step 1, using two one-dimensional convolution models to shorten the vector length of the target dimension, the one-dimensional convolution model here includes a convolution layer, a batch processing layer, and a one-dimensional maximum pooling layer; for the new feature vector, generate a Position_Target vector according to the actual deployment requirements, and determine the matrix PT for attention calculation, perform self-attention calculation on the data of the matrix, and optimize the self-attention weight to obtain the final website fingerprint feature representation; the specific process of position target oriented attention weight calculation in step 2 is as follows: S2.1 data information compression; The vector from step 1 is denoted as x, and the size of x is considered as [m*n*k], where the last dimension k represents the original vector data statistical information, and two different one-dimensional convolution modules are used to shorten the vector length of the target dimension, where the neural network includes a convolution layer, a batch processing layer, and a maximum pooling layer; through the one-dimensional convolution model, the kth dimension data is compressed; S2.2 Generate a position-target-oriented vector Position_Target: [p1, p2, p3, …, p n ] First, record step 2 convolution kernel: [c1, c2, c3, …, c k ], convolution calculation is recorded as Q, then the corresponding calculation is recorded as [Q c1 , Q c2 , Q c3 , …, Q ck ]; Let Each d Q operation constitutes a set of generators, namely: Each element in the Position_Target vector is determined by a weighted operation of d Q operations; let the compressed vector after step 2 be s_feature∈C m×n Then s_feature can generate multiple Position_Target feature vectors according to the above rules, and after arranging them in rows, a matrix PT oriented to the position is generated: The PT matrix has i rows of elements, and each row has j columns; S2.3 generate PT-Mask matrix At_temp = (PT) T • PT; First, the value of each element in the matrix At_temp is calculated, and for any ith row data, Top array and Bottom array are calculated respectively; wherein, the Top array stores a set of high-dimensional coordinates corresponding to the position coordinates of the attention weight ranked in the top k1 among all positive numbers of [A i1 ,A i2 ,…,A ij ]; and the Bottom array stores a set of high-dimensional coordinates corresponding to the position coordinates of the attention weight ranked in the last k2 among all negative numbers; then, the last two-dimensional data of the attention mechanism Mask vector are initialized: Then, based on the initial mask matrix, according to the multi-dimensional coordinate information in the Top array and the Bottom array, the corresponding position data is replaced with 1+m% or 1+n%, and then participates in the attention mechanism operation; wherein, the above m, n, k1, k2 are set as hyperparameters; S2.4 calculate position target oriented attention weight; Wherein, the PT matrix is used as the input of Q, K, and V, and θ() is the PT-Mask mechanism; the position target oriented attention weight calculation formula is as shown above; Step 3, hyperparameter tuning, which involves the unit time and input traffic length in step 1; involves the vector length of Position_Target in step 2 model; involves the number of feature heads and the key feature optimization ratio in the attention weight calculation in step 2; based on the feature representation in step 2 and the model parameters after step 3 tuning, ten-fold cross-validation is used to determine whether the feature vector in step 2 effectively identifies the target website; Step 4, if the recognition accuracy is less than 90%, return to step 1; if the recognition accuracy is higher than 90%, keep the model parameters and save the relevant model information to the related file, and end the process.
2. The location-targeted self-attention web fingerprinting method of claim 1, wherein, In step 1, the collected traffic packet information is used for preliminary feature representation: the number of data packets in and out of the unit time is counted, and a two-dimensional convolution neural network is used for feature extraction, which is composed of a convolution layer, a pooling layer, an activation layer, and a batch processing layer, thereby obtaining a preliminary representation of the traffic packet.
3. The location-targeted self-attention web fingerprinting method of claim 1, wherein, The specific process of hyperparameter tuning in Step 3 is as follows: tuning the input flow trajectory length in Step 1, tuning the time interval of the number of statistical data packets; tuning the vector length of the model Position_Target in Step 2, tuning the number of feature heads and the optimization ratio of key features in the attention weight calculation in Step 2; the evaluation indexes include accuracy Accuracy, recall Recal l, precision Precision, and F1 value F1-Score; the specific process is as follows:
Citation Information
Patent Citations
Tor website fingerprint identification method based on attention mechanism and LSTM
CN114584372A
Network traffic classification method and system based on multi-head attention and deep metric learning
CN116582303A