A method and system for detecting the use behavior of a large language model in a Socks5 encrypted proxy channel
By obtaining and filtering network traffic samples in the Socks5 encrypted proxy channel, extracting the spatio-temporal frequency characteristics of the traffic and combining it with the multi-layer perceptron model, the usage behavior of the large language model is identified, which solves the detection problems in the existing technology and realizes the detection of Socks5 proxy. Accurate identification of CUHK language model traffic.
Patent Information
- Application Number
- CN202410654444.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-24
- Publication Date
- 2024-09-24
- Estimated Expiration
- 2044-05-24
AI Technical Summary
The existing technology lacks effective methods to detect large language model usage behavior through Socks5 encrypted proxy channels, especially when faced with complex Socks5 proxy encryption methods and interactive text content transmission of large language models, resulting in difficulty in application type identification.
By obtaining full traffic samples at network traffic collection points, and after reverse screening based on the whitelist IP database and domain name database, the suspicious traffic is screened out using packet load entropy detection, protocol type and packet direction sequence grouping binary entropy mean, and the spatio-temporal frequency characteristics of the traffic are extracted. library, and use multi-layer perceptrons to conduct soft-decision classification model training, construct agent communication probability maps, screen highly suspicious agent nodes, combine inter-session and intra-session behavioral representations, and identify large language model conversation traffic.
It achieves effective detection of the usage behavior of large language models in Socks5 encrypted proxy, improves the accuracy and applicability of detection, and is suitable for session traffic identification in different operating environments and large language models.
Smart Images

Figure CN118250091B
Abstract
Description
Technical Field
[0001] The invention belongs to the field of network traffic analysis, in particular to a method and system for detecting the use behavior of a large language model in a Socks5 encrypted proxy channel. Background Art
[0002] The current encrypted proxy traffic behavior detection mainly targets the identification of encrypted proxy channels and the typical service types they carry. However, for the new type of strongly interactive network services such as the large language model represented by ChatGPT, there is currently a lack of effective identification methods for such traffic after it passes through the encrypted proxy. The encryption methods of the Socks5 proxy are complex and diverse, which makes it more difficult to identify the application type. However, the notable feature of the large language model application is the continuous and intermittent transmission of interactive text content, which makes it possible to identify it based on representation extraction and machine learning. There is currently no public detection method for the use of large language models in Socks5, a mainstream encrypted proxy. Summary of the invention
[0003] The purpose of the present invention is to provide a method and system for detecting the usage behavior of a large language model in a Socks5 encrypted proxy channel, which has good applicability and is suitable for Socks5 proxy large language model session traffic detection in different operating environments and different large language models.
[0004] The technical solution to achieve the purpose of the present invention is: a method for detecting the use behavior of a large language model in a Socks5 encrypted proxy channel, comprising the following steps:
[0005] Step 1: Obtain a full traffic sample at the network traffic collection point, and after reverse screening based on the whitelist IP library and whitelist domain name library, select a suspicious traffic set from the unknown encrypted traffic that has been screened by packet load entropy detection based on protocol type, binary entropy mean of packet direction sequence grouping, and multivariate entropy mean of packet length sequence grouping;
[0006] Step 2: For each flow defined based on the five-tuple in the suspicious traffic set, extract the total number of bytes, the total number of packets, the maximum packet length, the normalized byte distribution matrix, the normalized frequency transfer matrix, and the normalized packet length transfer matrix to form a traffic spatiotemporal frequency feature library;
[0007] Step 3: Based on the labeled Socks5 proxy and non-proxy traffic samples, the traffic spatiotemporal-frequency feature library and multi-layer perceptron are used to train a soft-decision classification model. The model is used to infer the Socks5 proxy detection soft-decision probability of each flow and construct a proxy communication probability graph.
[0008] Step 4: Calculate the mean and variance of the proxy detection soft decision probability gathered at each node in the proxy communication probability graph, obtain the variance and mean joint criterion, and screen highly suspicious proxy nodes based on this;
[0009] Step 5: Perform session segmentation on each flow associated with the highly suspicious proxy node based on the inter-packet delay threshold, extract inter-session behavior representations and intra-session behavior representations to form a comprehensive behavior representation, and use a multi-layer perceptron to identify large language model session traffic.
[0010] A large language model usage behavior detection system in a Socks5 encrypted proxy channel, comprising:
[0011] The first module is used to collect full traffic samples at the network traffic observation point, and then perform entropy detection on the packet payload to filter out unknown encrypted traffic after reverse screening based on the whitelist IP library and whitelist domain name library, and filter out suspicious traffic sets based on the protocol type, the binary entropy mean of the packet direction sequence grouping, and the multivariate entropy mean of the packet length sequence grouping;
[0012] The second module is used to extract the total number of bytes, the total number of packets, the maximum packet length, the normalized byte distribution matrix, the normalized frequency transfer matrix, and the normalized packet length transfer matrix for each flow defined based on the five-tuple in the suspicious traffic set to form a traffic spatiotemporal frequency feature library;
[0013] The third module is used to train a soft decision classification model based on the labeled Socks5 proxy and non-proxy traffic samples using the traffic spatiotemporal frequency feature library and a multi-layer perceptron. The model is used to infer the Socks5 proxy detection soft decision probability of each flow and construct a proxy communication probability graph.
[0014] The fourth module is used to calculate the mean and variance of the proxy detection soft decision probability gathered at each node in the proxy communication probability graph, and obtain the variance and mean joint judgment criteria to screen highly suspicious proxy nodes;
[0015] The fifth module performs session segmentation on each flow associated with a highly suspicious proxy node based on the inter-packet delay threshold, extracts inter-session behavior representations and intra-session behavior representations to form a comprehensive behavior representation, and combines multi-layer perceptron training to build a detection model, thereby achieving identification of large language model traffic and other common encrypted traffic in Socks5 encrypted proxy.
[0016] The present invention provides an electronic device, comprising a memory, a processor and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, the method for detecting the use of a large language model in a Socks5 encrypted proxy channel is implemented.
[0017] The present invention provides a computer-readable storage medium on which a computer program is stored. When the program is executed by a processor, the method for detecting the use behavior of a large language model in a Socks5 encrypted proxy channel is implemented.
[0018] The present invention provides a computer program product, including a computer program, which implements the above-mentioned large language model usage behavior detection method in the Socks5 encrypted proxy channel when executed by a processor.
[0019] Compared with the prior art, the present invention has the following significant advantages: 1) by combining the total number of bytes, the total number of packets, the maximum packet length, the byte distribution matrix, the frequency transfer matrix, and the packet length transfer matrix of suspicious traffic, the problem of inaccurate prediction of single feature support faced by the detection method based on machine learning is solved; 2) based on the data-driven method, the problem of large language model traffic detection in Socks5 encrypted proxy is solved, artificial experience is effectively embedded in the judgment method and characterization design, and the detection method has strong applicability.
[0020] The present invention is further described in detail below in conjunction with the accompanying drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0021] Figure 1 The present invention is a flow chart of a method for detecting behavior using a large language model in a Socks5 encrypted proxy channel.
[0022] Figure 2 This is a flowchart of the preliminary screening program operation of the Socks5 encrypted proxy channel of the present invention.
[0023] Figure 3 This is a flow chart of the program operation for detecting the encrypted proxy large language model conversation behavior of the present invention. DETAILED DESCRIPTION
[0024] The present invention proposes a large language model usage behavior detection method in a Socks5 encrypted proxy channel, comprising the following contents: taking the position encrypted traffic obtained by filtering the observed full traffic through whitelist IP anti-screening, whitelist domain name anti-screening, and packet load entropy detection as the traffic sample to be tested, and using the protocol type, the binary entropy mean of the packet direction sequence grouping, and the multivariate entropy mean of the packet length sequence grouping to screen out a suspicious traffic set from the traffic sample to be tested; for each flow defined based on a five-tuple in the suspicious traffic set, extracting the total number of bytes, the total number of packets, the maximum packet length, the normalized byte distribution matrix, the normalized frequency transfer matrix, and the normalized packet length transfer matrix, and establishing a flow-level spatiotemporal-frequency feature library; The marked Sock5 proxy traffic and non-Socks5 encrypted traffic are used as training samples, and the flow-level spatiotemporal frequency feature library is used as the input of the multi-layer perceptron to train the classification model of the Sock5 proxy. The model is used to infer the Socks5 proxy detection soft decision probability of each flow, thereby constructing a proxy communication probability graph; the mean and variance of the proxy detection soft decision probability gathered by each node in the proxy communication probability graph are calculated to screen highly suspicious proxy nodes; based on the inter-packet delay threshold, each flow associated with the highly suspicious proxy node is segmented into sessions, and the inter-session behavior representation and the intra-session behavior representation are extracted to form a comprehensive behavior representation, and the large language model session traffic is identified in combination with the multi-layer perceptron. The present invention uses the traffic spatiotemporal frequency characteristics and its session behavior representation to detect the Socks5 encrypted proxy large language model session traffic, has good applicability and high accuracy, and is suitable for viewing the large language model usage behavior in various types of encrypted proxy software based on the Socks5 protocol.
[0025] The present invention is described in detail below with reference to the accompanying drawings.
[0026] Combination Figure 1 , a large language model usage behavior detection method in a Socks5 encrypted proxy channel, comprising the following steps:
[0027] Step 1: Obtain a full traffic sample at the network traffic collection point, and after reverse screening based on the whitelist IP library and whitelist domain name library, select a suspicious traffic set from the unknown encrypted traffic screened by packet load entropy detection based on the protocol type, the binary entropy mean of the packet direction sequence grouping, and the multivariate entropy mean of the packet length sequence grouping;
[0028] Step 2: For each flow defined based on the five-tuple in the suspicious traffic set, extract the total flow byte number, total packet number, maximum packet length, normalized byte distribution matrix, normalized frequency transfer matrix, and normalized packet length transfer matrix to form a traffic spatiotemporal frequency feature library;
[0029] Step 3: Based on the labeled Socks5 proxy and non-proxy traffic samples, a binary classification model is trained using the traffic spatiotemporal frequency feature library and a multi-layer perceptron. The model is used to infer the Socks5 proxy detection soft decision probability of each flow and construct a proxy communication probability graph.
[0030] Step 4: Calculate the mean and variance of the proxy detection soft decision probability gathered at each node in the proxy communication probability graph, obtain the variance and mean joint criterion, and screen highly suspicious proxy nodes based on this;
[0031] Step 5: Perform session segmentation on each flow associated with the highly suspicious proxy node based on the inter-packet delay threshold, extract inter-session behavior representations and intra-session behavior representations to form a comprehensive behavior representation, and use a multi-layer perceptron to identify large language model session traffic.
[0032] like Figure 2 As shown, in step 1, for the full traffic samples obtained from the network traffic collection point, after reverse screening based on the whitelist IP library and domain name library, the unknown encrypted traffic that has been screened by the packet load entropy detection is screened out from the suspicious traffic set based on the protocol type, the binary entropy mean of the packet direction sequence grouping, and the multivariate entropy mean of the packet length sequence grouping, specifically:
[0033] Step 1-1, the network traffic collection point obtains the full traffic sample and parses the protocol type of the traffic sample, obtains the IP address and domain name of the traffic sample, if the IP address of the traffic sample belongs to the whitelist IP library or the domain name of the traffic sample belongs to the whitelist domain name library, then the traffic sample belongs to the common encrypted traffic, these encrypted traffic should be excluded from the suspicious traffic set, and calculates the load entropy of the first 10 packets, if the deviation value between the load entropy and the random entropy is less than the set threshold, it is determined to be unknown encrypted traffic, that is, the traffic sample to be tested of the present invention;
[0034] Step 1-2: Filter common Socks5 proxy protocol types according to traffic protocol type;
[0035] Step 1-3: Filter out suspicious traffic sets based on the binary entropy mean of packet direction sequence grouping and the multivariate entropy mean of packet length sequence grouping: First, group packets into groups of 50, and group the directions of every 50 packets into packet direction sequence groups. The packet direction sequence groups are recorded as
[0036]
[0037] in, Indicates packet direction sequence grouping, Indicates the total number of packet direction sequences, Indicates packet direction sequence, Indicates Sequence No. The direction of each packet is defined as 1 for the upper row in the packet direction and 0 for the lower row. Then the binary entropy of the packet direction sequence in each sequence is calculated according to the following formula:
[0038]
[0039] in, represents the binary entropy of the ith sequence packet direction sequence, Indicates The number of packets with direction 1 in the sequence, Indicates The number of packets with direction 0 in the sequence, Indicates The total number of packets with a direction of 1 or 0 in a sequence, and the mean binary entropy of the packet direction sequence grouping are calculated according to the following formula:
[0040]
[0041] in, It represents the mean binary entropy of the packet direction sequence grouping, Indicates the total number of packet direction sequences, represents the binary entropy of the ith sequence packet direction sequence;
[0042] In order to calculate the multivariate entropy of packet length sequence grouping, the packet lengths of all traffic packets are counted and grouped into a sequence of 50 to form a packet length sequence. The packet length sequences of all traffic packets are grouped as
[0043]
[0044] in, Indicates the packet length sequence grouping, Indicates the first A sequence, Indicates the number of sequences in the group, Indicates In the sequence The length of the traffic packets is calculated, the maximum and minimum packet lengths in the sequence are calculated, and the packet lengths in the sequence are divided into multiple equal-length intervals, each of which is
[0045]
[0046] in, represents the dth interval, and They represent the maximum and minimum packet lengths in the sequence respectively. The D value is 10. Given the above packet length interval, the multivariate entropy of the packet length sequence grouping is calculated according to the following formula:
[0047]
[0048] in, Indicates the length of the packet in the i-th group belong , calculate the mean of multivariate entropy of packet length sequence grouping As a traffic characterization, filter out suspicious traffic sets according to the following conditions
[0049]
[0050] in, and They represent the upper and lower thresholds of the mean value of the multivariate entropy of the packet direction sequence grouping, and The upper and lower thresholds represent the mean of the multivariate entropy of the packet length sequence group. If and only if both are between the thresholds at the same time, it will be placed in the suspicious traffic set.
[0051] In step 2, for each flow defined based on the five-tuple in the suspicious traffic set, the total flow byte number, total packet number, maximum packet length, normalized byte distribution matrix, normalized frequency transfer matrix, and normalized packet length transfer matrix are extracted to form a traffic spatiotemporal frequency feature library, specifically:
[0052] Step 2-1: For each flow in the suspicious traffic set defined based on the five-tuple, each flow consists of a five-tuple consisting of source IP, destination IP, source port, destination port, and transport layer communication protocol. The only certainty is that Indicates the source IP, Indicates the destination IP address. Indicates the source port. Indicates the target port, Represents the transport layer communication protocol. To facilitate subsequent calculations, the set of flows is indexed and the flow index set is recorded as , a flow consists of multiple packets, in the following form
[0053]
[0054] in, represents the kth stream, represents the i-th packet of the k-th flow, represents the number of packets of flow k, The indicator set representing the flow is then calculated based on the five-tuple definition of each flow's traffic space-time frequency feature library, including the total flow bytes, total packets, maximum packet length, byte distribution matrix, frequency transfer matrix, and packet length transfer matrix (divide the flow into w blocks, each row represents a block, each column represents an interval range, and the specific value represents the number of blocks belonging to the interval). The total flow bytes, total packets, and maximum packet length are defined as the total bytes, total packets, and maximum packet length in a flow, respectively. The calculation method is as follows
[0055]
[0056] in, Representation Flow The total number of stream bytes, Representation Flow Middle Package The number of bytes, Representation Flow The total number of packets is equal to the previously defined , Representation Flow The maximum packet length, Representation Flow Middle Package The length of byte distribution matrix Each value in represents the number of occurrences of the corresponding value in the stream, that is,
[0057]
[0058] in, Indicates the number of times the byte length appears in the i-th interval; frequency transfer matrix for:
[0059]
[0060] in, That is, the value of the i-th row and j-th column represents the packet time interval between two adjacent packets; the packet length transfer matrix represents the mean packet size of two adjacent packets;
[0061]
[0062] in, The value of row i and column j represents the packet time interval between two adjacent packets;
[0063] Step 2-2: Distribute the bytes into a matrix , frequency transfer matrix and packet length transfer matrix Use the maximum-minimum value to normalize the data. According to the matrix division operation rule, the calculation method is as follows
[0064]
[0065] According to the above formula, the normalized byte distribution matrix, normalized frequency transfer matrix and normalized packet length transfer matrix are obtained, and further combined with the total flow byte number, total packet number and maximum packet length described in step 2-1, the primary flow characterization library is finally formed. In the actual program body function, the pseudo code structure is used to implement the class trafficReprePrimary, and its class member information is shown in Table 1.
[0066] Table 1 TrafficReprePrimary class members
[0067] Member Index Member Name Property Type / Return Type Member Type Actual meaning (member function input parameter type) Membership AA bytesDistriMat Mat[Int] property Byte distribution matrix, not callable private AB freqTransMat Mat[Int] property Frequency distribution matrix, not callable private AC pacSizeMax Int property Maximum packet length, not callable private AD flowBytesAver Int property Average stream bytes, not callable private AE pacCountTot Int property Total number of packages, not callable private AF sizeTransMat Mat[Int] property Packet length transfer matrix, not callable private FA Get_bytesDistriMat Mat[Int] method Used to obtain the byte distribution matrix, no parameters Public FB Get_freqTransMat Mat[Int] method Used to obtain the frequency distribution matrix, no parameters Public FC Get_pacSizeMax Int method Used to obtain the maximum packet length, no parameters Public FD Get_flowBytesAver Int method Used to get the average number of stream bytes, no parameters Public FE Get_pacCountTot Int method Used to obtain the total number of packets, no parameters Public FF Get_sizeTransMat Mat[Int] method Used to obtain the packet length transfer matrix, no parameters Public CA trafficReprePrimary Void method Constructor for the primary traffic characterization library, receiving parameter type vector <flow> < / flow> Public CB ~trafficReprePrimary Void method Destructor for the primary flow characterization library, no parameters Public
[0068] In step 3, based on the labeled Socks5 proxy and non-proxy traffic samples, the traffic spatiotemporal frequency feature library and multi-layer perceptron are used to train the soft decision classification model. The model is used to infer the Socks5 proxy detection soft decision probability of each flow and construct the proxy communication probability map, which is specifically:
[0069] Step 3-1: Primary characterization library for flow Flatten the dimensions and input the trained multi-layer perceptron model. The multi-layer perceptron contains six hidden layers, and the number of hidden neurons in each layer is 160, 320, 320, 160, 80, and 20 respectively. Finally, the output layer outputs the soft decision probability of Socks5 proxy detection for each five-tuple interactive traffic sample. In order to train the multi-layer perceptron, collect network traffic and manually mark whether it is proxy traffic to form a traffic data set as training material, and continuously optimize the loss function until the multi-layer perceptron converges.
[0070] Step 3-2: Construct a Socks5 proxy communication relationship representation graph, and represent the graph as an undirected graph. The nodes of the graph are uniquely identified by their corresponding IP and port numbers. The nodes are recorded as
[0071]
[0072] in, Indicates the total number of nodes, i indicates the source port and source IP address number corresponding to the node, represents the IP address of node i, represents the port of node i. The edge of the graph is defined as the soft decision probability of Socks5 proxy detection calculated in step 3-1, that is,
[0073]
[0074] in, represents the total number of nodes, i and j are the source port, source IP address number, destination address source port and destination address IP number corresponding to the node.
[0075] like Figure 3 As shown in the process, step 4 calculates the mean and variance of the proxy detection soft decision probability gathered at each node in the proxy communication probability graph to screen highly suspicious proxy nodes, specifically:
[0076] Step 4-1, according to the obtained Socks5 proxy communication relationship representation diagram, calculate the proxy suspicion mean and variance of each node as the edge weight connected to the node, that is, the mean and variance of the Socks5 proxy detection soft decision probability. When the mean is greater than 0.75 and the square root of the mean divided by the variance is greater than 3, the node is identified as a high-credibility proxy node;
[0077] Step 4-2, select each interactive traffic sample associated with a high-credibility proxy node, segment the session according to the session quintuple, extract the inter-session behavior features and the intra-session behavior representation to form a comprehensive behavior representation. In order to predict whether it is a large language model traffic, the present invention uses a multilayer perceptron containing eight hidden layers, and uses a data set for large language model traffic discrimination. The data set is trained and the multilayer perceptron is used to identify the large language model session traffic.
[0078] In step 5, each flow associated with a highly suspicious proxy node is segmented based on the inter-packet delay threshold, and inter-session behavior features and intra-session behavior representations are extracted to form a comprehensive behavior representation. The large language model session traffic is identified by combining a multi-layer perceptron, specifically:
[0079] Step 5-1: Perform session segmentation on each flow associated with a highly suspicious proxy node based on the inter-packet delay threshold. When the inter-packet delay of the two most adjacent packets of the same flow is greater than the given threshold, When the two packets are separated by the inter-packet delay threshold, each flow is divided into multiple sessions. In order to conduct a comprehensive flow analysis to better identify the large language model session traffic, the inter-session behavior features and the intra-session behavior representations are extracted to form a comprehensive behavior representation. The inter-session behavior features use the duration of the nearest session and the time interval of the nearest session. The nearest session is defined as the session whose start time is closest to the end time of the current session. If the session is the last session, the session whose end time is closest to the start time of the last session is taken as the nearest session. The duration of the nearest session is the nearest session duration feature used, and the time interval of the nearest session is defined as the nearest session. The meaning is the time interval between the start of the nearest session and the end of the current session under the above definition. For the last session, the time interval from the end of the nearest session to the start of the current session is taken as the nearest session time interval; the intra-session behavior feature described in the present invention specifically refers to the session duration of the current session, which is defined as the time interval between the start time of the earliest transmission packet of the current session and the end time of the last transmission packet in milliseconds. The behavior of the flow can be accurately characterized by using the inter-session behavior feature and intra-session behavior characterization of a flow. The comprehensive behavior characterization described in the present invention can accurately identify the large language model dialogue behavior in the session based on the multi-layer perceptron model described in the subsequent step 5-2;
[0080] Step 5-2, use the multi-layer perceptron model as the large language model conversation behavior detector. This model is a classic deep neural network model. The input of the large language model conversation behavior detection model is the inter-conversation behavior features and intra-conversation behavior features extracted in the previous step. It contains eight hidden layers, and the dimensions of neurons in each hidden layer are 160, 160, 80, 160, 80, 160, 80, 40, and 10, respectively. GeLU is used as the activation function in the model. The model is trained by the gradient descent algorithm, and the minimization of the cross entropy loss function is used as the training optimization goal. Positive and negative traffic samples are collected by talking to the large model and other network activities. The traffic samples are manually labeled to form a large model conversation traffic behavior detection data set, and the data set is divided into training set, validation set, and test set according to 6:3:1. The training set is used for model training, the validation set is used for model hyperparameter adjustment and optimization, and the test set is used for model testing. Finally, the classification loss curve converges during the training process and the accuracy rate in the test set reaches 91%, indicating that a good conversation classification effect has been achieved.
[0081] Based on the same inventive concept, the present invention also provides a large language model usage behavior detection system in a Socks5 encrypted proxy channel, comprising:
[0082] The first module is used to collect full traffic samples at the network traffic observation point, and then perform entropy detection on the packet payload to filter out unknown encrypted traffic after reverse screening based on the whitelist IP library and whitelist domain name library, and filter out suspicious traffic sets based on the protocol type, the binary entropy mean of the packet direction sequence grouping, and the multivariate entropy mean of the packet length sequence grouping;
[0083] The second module is used to extract the total number of bytes, the total number of packets, the maximum packet length, the normalized byte distribution matrix, the normalized frequency transfer matrix, and the normalized packet length transfer matrix for each flow defined based on the five-tuple in the suspicious traffic set to form a traffic spatiotemporal frequency feature library;
[0084] The third module is used to train a soft decision classification model based on the labeled Socks5 proxy and non-proxy traffic samples using the traffic spatiotemporal frequency feature library and a multi-layer perceptron. The model is used to infer the Socks5 proxy detection soft decision probability of each flow and construct a proxy communication probability graph.
[0085] The fourth module is used to calculate the mean and variance of the proxy detection soft decision probability gathered at each node in the proxy communication probability graph, and obtain the variance and mean joint judgment criteria to screen highly suspicious proxy nodes;
[0086] The fifth module performs session segmentation on each flow associated with a highly suspicious proxy node based on the inter-packet delay threshold, extracts inter-session behavior representations and intra-session behavior representations to form a comprehensive behavior representation, and combines multi-layer perceptron training to build a detection model, thereby achieving identification of large language model traffic and other common encrypted traffic in Socks5 encrypted proxy.
[0087] The specific implementation methods of the above-mentioned first to fifth modules are the same as the steps of the large language model usage behavior detection method in the aforementioned Socks5 encrypted proxy channel, and the present invention will not repeat them again.
[0088] The above 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 as the protection scope of the present invention. All components not specified in this embodiment can be implemented by existing technologies.
Claims
1. A method for detecting the use of a large language model in a Socks5 encrypted proxy channel, characterized in that: The following steps are involved: Step 1: Collect full traffic samples at the network traffic observation point, and perform entropy detection on the packet payload to filter out unknown encrypted traffic after reverse screening based on the whitelist IP library and whitelist domain name library. Filter out suspicious traffic sets based on protocol type, binary entropy mean of packet direction sequence grouping, and multivariate entropy mean of packet length sequence grouping. Specifically: Step 1-1: The network traffic observation point obtains the full traffic sample and parses the protocol type of the traffic sample, obtains the IP address and domain name of the traffic sample, and if the IP address of the traffic sample belongs to the whitelist IP library or the domain name of the traffic sample belongs to the whitelist domain name library, the traffic sample belongs to common encrypted traffic, excludes these encrypted traffic from the suspicious traffic set, and calculates the load entropy of the first 10 packets. If the deviation value between the load entropy and the random entropy is less than the set threshold, it is determined to be unknown encrypted traffic, that is, the traffic sample to be tested; Step 1-2: Filter non-target protocols according to the common protocol types of Socks5 encrypted proxy; Step 1-3, based on the binary entropy mean of packet direction sequence grouping and the multivariate entropy mean of packet length sequence grouping, select the suspicious traffic set: first, group the packets into groups of 50, and group the directions of every 50 packets into packet direction sequence groups, and record the packet direction sequence groups as: ; in, Indicates packet direction sequence grouping, Indicates the total number of packet direction sequences, Indicates packet direction sequence, Indicates Sequence No. The direction of each packet is defined as 1 for the upper row in the packet direction and 0 for the lower row. Then the binary entropy of the packet direction sequence in each sequence is calculated according to the following formula: ; in, represents the binary entropy of the ith sequence packet direction sequence, Indicates The number of packets with direction 1 in the sequence, Indicates The number of packets with direction 0 in the sequence, Indicates The total number of packets with a direction of 1 or 0 in a sequence, and the mean binary entropy of the packet direction sequence grouping are calculated according to the following formula: ; in, It represents the mean binary entropy of the packet direction sequence grouping, Indicates the total number of packet direction sequences, represents the binary entropy of the ith sequence packet direction sequence; In order to calculate the multivariate entropy of packet length sequence grouping, the packet lengths of all traffic packets are counted and grouped into a sequence of 50 to form a packet length sequence. The packet length sequences of all traffic packets are grouped as follows: ; in, Indicates the packet length sequence grouping, Indicates the first A sequence, Indicates the number of sequences in the group, Indicates In the sequence The length of the traffic packets is calculated, the maximum and minimum packet lengths in the sequence are calculated, and the packet lengths in the sequence are divided into multiple equal-length intervals, each of which is ; in, represents the dth interval, and Respectively represent the maximum and minimum values of the packet length in the sequence. Given a packet length interval, the multivariate entropy of the packet length sequence grouping is calculated according to the following formula: ; in, Indicates the length of the packet in the i-th group belong , calculate the mean of multivariate entropy of packet length sequence grouping As a traffic characterization, the suspicious traffic set is filtered out according to the following conditions: ; in, and They represent the upper and lower thresholds of the mean value of the multivariate entropy of the packet direction sequence grouping, and The upper and lower thresholds represent the mean of the multivariate entropy of the packet length sequence group. If and only if both are between the thresholds, the packet will be placed in the suspicious traffic set. Step 2: For each flow defined based on the five-tuple in the suspicious traffic set, extract the total number of bytes, total number of packets, maximum packet length, normalized byte distribution matrix, normalized frequency transfer matrix, and normalized packet length transfer matrix to form a traffic spatiotemporal frequency feature library, specifically: Step 2-1: For each flow in the suspicious traffic set defined based on the five-tuple, each flow consists of a five-tuple consisting of source IP, destination IP, source port, destination port, and transport layer communication protocol. The only certainty is that Indicates the source IP, Indicates the destination IP address. Indicates the source port. Indicates the destination port, Represents the transport layer communication protocol, indexes the set of streams and records the index set of the stream as , a flow consists of multiple packets, in the following form ; in, represents the kth stream, represents the i-th packet of the k-th flow, represents the number of packets of flow k, The indicator set representing the flow is then calculated based on the five-tuple definition of each flow’s traffic space-time frequency feature library, including the total number of bytes, the total number of packets, the maximum packet length, the byte distribution matrix, the frequency transfer matrix, and the packet length transfer matrix. The total number of bytes, the total number of packets, and the maximum packet length are defined as the total number of bytes, the total number of packets, and the maximum packet length in a flow, respectively. The calculation method is as follows: ; in, Representation Flow The total number of stream bytes, Representation Flow Middle Package The number of bytes, Representation Flow The total number of packets is equal to , Representation Flow The maximum packet length, Representation Flow Middle Package The length of byte distribution matrix Each value in represents the number of occurrences of the corresponding value in the stream, that is, ; in, Indicates the number of times the byte length appears in the i-th interval; frequency transfer matrix for: ; in, That is, the value of the i-th row and j-th column represents the packet time interval between two adjacent packets; the packet length transfer matrix represents the mean packet size of two adjacent packets; ; in, The value of row i and column j represents the packet time interval between two adjacent packets; Step 2-2: Distribute the bytes into a matrix , frequency transfer matrix and packet length transfer matrix Use the maximum-minimum value to normalize the data. According to the matrix division operation rule, the calculation method is as follows ; According to the above formula, the normalized byte distribution matrix, normalized frequency transfer matrix and normalized packet length transfer matrix are obtained, and further combined with the total flow byte number, total packet number and maximum packet length described in step 2-1, the primary flow characterization library is finally formed. ; Step 3: Based on the labeled Socks5 proxy and non-proxy traffic samples, the traffic spatiotemporal frequency feature library and multi-layer perceptron are used to train the soft decision classification model. The model is used to infer the Socks5 proxy detection soft decision probability of each flow and construct the proxy communication probability map, which is as follows: Step 3-1: Primary characterization library for flow Flatten the dimensions and input the trained multi-layer perceptron model. The multi-layer perceptron contains six hidden layers, and the number of hidden neurons in each layer is 160, 320, 320, 160, 80, and 20 respectively. Finally, the output layer outputs the soft decision probability of Socks5 proxy detection for each five-tuple interactive traffic sample. In order to train the multi-layer perceptron, collect network traffic and manually mark whether it is proxy traffic to form a traffic data set as training material, and continuously optimize the loss function until the multi-layer perceptron converges. Step 3-2: Construct a Socks5 proxy communication relationship representation graph, and represent the graph as an undirected graph. The nodes of the graph are uniquely identified by their corresponding IP addresses and port numbers. The nodes are recorded as ; in, Indicates the total number of nodes, i indicates the source port and source IP address number corresponding to the node, represents the IP address of node i, represents the port of node i; the relationship between the edges in the graph is defined according to the soft decision probability of Socks5 proxy detection calculated in step 3-1, that is: ; in, represents the total number of nodes, i and j are the source port, source IP address number, destination address source port and destination address IP number corresponding to the node; Step 4: Calculate the mean and variance of the proxy detection soft decision probability gathered at each node in the proxy communication probability graph, and obtain the variance and mean joint criterion to screen highly suspicious proxy nodes, specifically: Step 4-1, according to the obtained Socks5 proxy communication relationship representation diagram, calculate the proxy suspicion mean and variance of each node as the edge weight connected to the node, that is, the mean and variance of the Socks5 proxy detection soft decision probability. When the mean is greater than 0.75 and the square root of the mean divided by the variance is greater than 3, the node is identified as a high-credibility proxy node; Step 4-2, select each interactive traffic sample associated with a high-confidence proxy node, segment the session according to the session quintuple, extract the inter-session behavior features and the intra-session behavior representation to form a comprehensive behavior representation, and use a multi-layer perceptron with eight hidden layers to predict whether it is a large language model session traffic. The data set for discrimination of the large language model session traffic is used for training, and the multi-layer perceptron is used to identify the large language model session traffic; Step 5: Perform session segmentation on each flow associated with the highly suspicious proxy node based on the inter-packet delay threshold, extract inter-session behavior representation and intra-session behavior representation to form a comprehensive behavior representation, and identify the large language model session traffic in combination with a multi-layer perceptron. Specifically: Step 5-1: Perform session segmentation on each flow associated with a highly suspicious proxy node based on the inter-packet delay threshold. When the inter-packet delay of the two most adjacent packets of the same flow is greater than the given threshold, , it is determined that the two packets belong to different sessions. Each flow is divided into multiple sessions by separating them by the inter-packet delay threshold. The inter-session behavior features and the intra-session behavior representations are extracted to form a comprehensive behavior representation. The inter-session behavior features use the nearest session duration and the nearest session time interval. The nearest session is defined as the session whose start time is closest to the end time of the current session. If the session is the last session, the session whose end time is closest to the start time of the last session is taken as the nearest session. The duration of the nearest session is the nearest session duration feature used. The nearest session time interval is defined as the time interval between the start of the nearest session and the end of the current session under the above definition. For the last session, the time interval from the end of the nearest session to the start of the current session is taken as the nearest session time interval. Step 5-2, use a multilayer perceptron model as a large language model conversation behavior detector. The input of the large language model conversation behavior detection model is the inter-conversation behavior features and intra-conversation behavior features extracted in the previous step. It contains eight hidden layers in total. The neuron dimensions of each hidden layer are 160, 160, 80, 160, 80, 160, 80, 40, and 10, respectively. GeLU is used as the activation function in the model. The model is trained by the gradient descent algorithm, and the minimization of the cross entropy loss function is used as the training optimization goal. Positive and negative traffic samples are collected by dialogue with the large model and other network activities. The traffic samples are manually labeled to form a large model conversation traffic behavior detection data set, and the data set is divided into training set, validation set, and test set according to 6:3:
1. The training set is used for model training, the validation set is used for model hyperparameter adjustment and optimization, and the test set is used for model testing.
2. A large language model usage behavior detection system in a Socks5 encrypted proxy channel, characterized in that: For implementing the method described in claim 1, the system comprises: The first module is used to collect full traffic samples at the network traffic observation point, and then perform entropy detection on the packet payload to filter out unknown encrypted traffic after reverse screening based on the whitelist IP library and whitelist domain name library, and filter out suspicious traffic sets based on the protocol type, the binary entropy mean of the packet direction sequence grouping, and the multivariate entropy mean of the packet length sequence grouping; The second module is used to extract the total number of bytes, the total number of packets, the maximum packet length, the normalized byte distribution matrix, the normalized frequency transfer matrix, and the normalized packet length transfer matrix for each flow defined based on the five-tuple in the suspicious traffic set to form a traffic spatiotemporal frequency feature library; The third module is used to train a soft decision classification model based on the labeled Socks5 proxy and non-proxy traffic samples using the traffic spatiotemporal frequency feature library and a multi-layer perceptron. The model is used to infer the Socks5 proxy detection soft decision probability of each flow and construct a proxy communication probability graph. The fourth module is used to calculate the mean and variance of the proxy detection soft decision probability gathered at each node in the proxy communication probability graph, and obtain the variance and mean joint judgment criteria to screen highly suspicious proxy nodes; The fifth module performs session segmentation on each flow associated with a highly suspicious proxy node based on the inter-packet delay threshold, extracts inter-session behavior representations and intra-session behavior representations to form a comprehensive behavior representation, and combines multi-layer perceptron training to build a detection model, thereby achieving identification of large language model traffic and other common encrypted traffic in Socks5 encrypted proxy.
3. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the program, the steps of the method according to claim 1 are implemented.
4. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the steps of the method as claimed in claim 1 are implemented.
5. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the method according to claim 1 are implemented.
