Method, device, TLS communication flow parsing system and machine-readable storage medium for parsing TLS flow

By deploying a TLS communication traffic analysis system on the client, intercepting and replacing the TLS handshake, and parsing TLS traffic, the problem of insufficient versatility in the existing technology is solved, effective parsing and detection of TLS traffic is achieved, and security and concealment are improved. .

CN117834253BActive Publication Date: 2024-09-17BEIJING TOPSEC NETWORK SECURITY TECH +2
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202311864586.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-12-29
Publication Date
2024-09-17
Estimated Expiration
2043-12-29

AI Technical Summary

Technical Problem

The existing technology lacks versatility when parsing TLS traffic and cannot effectively detect and intercept sensitive information transmitted through TLS. This is mainly because it relies on inexhaustible libraries and methods and is difficult to be widely used.

Method used

By deploying a TLS communication traffic analysis system on the client, including a data filtering module, a data injection module, a first session manager and a second session manager, the TLS handshake request is intercepted, the client completes the handshake with the server, and a plaintext session is established, and Forward data between sessions to obtain clear text session data for TLS network sessions.

Benefits of technology

It realizes parsing TLS traffic in a man-in-the-middle manner on the client side, which is universal and does not require additional equipment or network topology changes, improving the concealment and security of the detection mechanism.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117834253B
    Figure CN117834253B
Patent Text Reader

Abstract

The present application discloses a method, device and TLS communication flow parsing system for parsing TLS traffic, which belongs to the field of computer information processing technology and is applied to TLS communication flow parsing system. The method includes: when a client initiates a first handshake request to a server for a TLS network session, a first message carried in the first handshake request is intercepted by a data filtering module; based on the first message, a first session manager, a data filtering module and a data injection module are used to replace the client to complete the handshake with the server to establish a first session; after the first session is established, based on the server certificate, a second session manager is used to replace the server to complete the handshake with the client to establish a second session in combination with the data filtering module and the data injection module; and the plaintext data of the TLS network session is forwarded between the first session and the second session. The present application can implement TLS traffic parsing in a middleman manner on the client side and has universality.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer information processing technology, and in particular to a method and device for parsing TLS traffic and a TLS communication traffic parsing system. Background Art

[0002] Transport Layer Security (TLS) is a protocol used to protect network communications. TLS plays a key role in Internet security, helping to protect sensitive data from unauthorized access and attacks. On the other hand, the widespread use of TLS also poses challenges to information security, for example: malicious code uses the TLS protocol to transmit control commands or sensitive information; users inadvertently upload sensitive information to HTTPS protocol sites; the mail server within the organization uses TLS communication, and users leak sensitive information through emails. Because of the confidential transmission characteristics of TLS, the commonly used packet filtering technology cannot detect the content of the transmission to address these risks. Therefore, with the permission of the organization, it is a common and important requirement to use some technology to parse the plaintext content transmitted through TLS, and then detect and intercept it.

[0003] At present, in the prior art, developers use mature libraries (such as openssl, winhttp) to develop TLS communication applications. In these libraries, there is usually an interface function for plain text input and output. Therefore, by locating the relevant interface function through binary features, and then injecting interception code using hook technology, the plain text of TLS communication can be intercepted. However, the libraries available in this method are not exhaustive, making this method difficult to be universal. Therefore, the prior art has the problem of not having universality. Summary of the invention

[0004] The purpose of the embodiments of the present application is to provide a method, device, processor, TLS communication traffic parsing system and machine-readable storage medium for parsing TLS traffic, so as to solve the problem of lack of universality in the prior art.

[0005] In order to achieve the above-mentioned object, a first aspect of an embodiment of the present application provides a method for parsing TLS communication traffic, which is applied to a TLS communication traffic parsing system. The TLS communication traffic parsing system includes a data filtering module, a data injection module, a first session manager, and a second session manager. The TLS communication traffic parsing system is deployed on a client, and the client communicates with a server. The method includes:

[0006] When the client initiates a first handshake request to the server for a TLS network session, intercepting a first message carried in the first handshake request by a data filtering module;

[0007] Based on the first message, the first session manager replaces the client to complete the handshake with the server to establish a first session, wherein the first session includes a server certificate sent by the server;

[0008] After the first session is established, based on the first message and the server certificate, in combination with the data filtering module and the data injection module, the second session manager replaces the server to complete the handshake with the client to establish the second session;

[0009] After the second session is established, data is forwarded between the first session and the second session to obtain plaintext session data of the TLS network session.

[0010] In an embodiment of the present application, based on a first message, a first session manager is used to replace a client to complete a handshake with a server to establish a first session, including: parsing the first message to obtain a parsing result; setting the first session manager according to the parsing result; after the first session manager is set, outputting the first message to a data injection module through a ciphertext sending port of the first session manager; injecting the first message into a network protocol stack of the client through the data injection module, so that the first message is sent to the server via the network protocol stack; intercepting a server response message sent by the server through a data filtering module, and submitting it to a ciphertext receiving port of the first session manager; completing a handshake between the first session manager and the server according to the first message and the server response message to establish the first session.

[0011] In an embodiment of the present application, after the first session is established, based on the first message and the server certificate, in combination with the data filtering module and the data injection module, the second session manager replaces the server to complete the handshake with the client to establish the second session, including: obtaining a target imitation certificate according to the server certificate; setting the second session manager according to the target imitation certificate; after the second session manager is set, inputting the first message into the second session manager to trigger the handshake process of the second session; outputting the second message to the data injection module through the ciphertext sending port of the second session manager; injecting the second message into the network protocol stack through the data injection module, so that the second message is sent to the client via the network protocol stack; intercepting the client response message sent by the client through the data filtering module, and submitting it to the ciphertext receiving port of the second session manager; completing the handshake between the second session manager and the client according to the second message and the client response message to establish the second session.

[0012] In an embodiment of the present application, obtaining a target imitation certificate based on a server certificate sent by a server includes: obtaining the certificate serial number of the server certificate; searching a pre-stored imitation certificate library based on the certificate serial number to obtain a search result; if the search is successful, determining the certificate chain corresponding to the certificate serial number and the private key corresponding to the end certificate of the certificate chain in the imitation certificate library found as the target imitation certificate.

[0013] In an embodiment of the present application, the method also includes: in the event of a search failure, obtaining an initial counterfeit certificate based on the server certificate copy; regenerating a key pair of the initial counterfeit certificate based on the public key algorithm and key length of the server certificate; and determining a target counterfeit certificate based on the key pair and the initial counterfeit certificate.

[0014] In an embodiment of the present application, after the second session is established, data is forwarded between the first session and the second session to obtain plaintext session data of the TLS network session, including: sending the first plaintext data output by the first session manager to the plaintext input port of the second session manager, so that the second session manager outputs the first ciphertext data corresponding to the first plaintext data; injecting the first ciphertext data into the network protocol stack of the client through the data injection module, so that the first ciphertext data is sent to the client via the network protocol stack; sending the second plaintext data output by the second session manager to the plaintext input port of the first session manager, so that the first session manager outputs the second ciphertext data corresponding to the second plaintext data; injecting the second ciphertext data into the network protocol stack of the client through the data injection module, so that the second ciphertext data is sent to the server via the network protocol stack; obtaining the first plaintext data and the second plaintext data to obtain the plaintext session data of the TLS network session.

[0015] In an embodiment of the present application, the method further includes: when it is detected that a new network session is established, matching the network session with preset filtering rules, wherein the preset filtering rules include IP address information and port information; when the match is successful, monitoring the new network session through a data filtering module.

[0016] A second aspect of an embodiment of the present application provides a processor configured to execute the above-mentioned method for parsing TLS traffic.

[0017] A third aspect of an embodiment of the present application provides a device for parsing TLS traffic, which is applied to a TLS communication traffic parsing system. The TLS communication traffic parsing system includes a data filtering module, a data injection module, a first session manager, and a second session manager. The TLS communication traffic parsing system is deployed on a client, and the client communicates with a server. The device includes:

[0018] A message interception unit, configured to intercept, through a data filtering module, a first message carried in a first handshake request when a client initiates a first handshake request to a server for a TLS network session;

[0019] A first session establishing unit, configured to complete a handshake with the server by replacing the client through a first session manager based on the first message, so as to establish a first session, wherein the first session includes a server certificate sent by the server;

[0020] A second session establishing unit, configured to, after the first session is established, complete a handshake with the client by replacing the server through a second session manager based on the first message and the server certificate in combination with the data filtering module and the data injection module to establish a second session;

[0021] The session data acquisition unit is used to forward data between the first session and the second session after the second session is established, so as to acquire the plaintext session data of the TLS network session.

[0022] A fourth aspect of an embodiment of the present application provides a TLS communication traffic parsing system, comprising: a data filtering module; a data injection module; a first session manager; a second session manager; the above-mentioned processor or the above-mentioned device for parsing TLS traffic.

[0023] A fifth aspect of an embodiment of the present application provides a machine-readable storage medium, on which a program or instruction is stored. When the program or instruction is executed by a processor, the above-mentioned method for parsing TLS traffic is implemented.

[0024] The above technical scheme is applied to a TLS communication traffic analysis system. The TLS communication traffic analysis system includes a data filtering module, a data injection module, a first session manager and a second session manager. The TLS communication traffic analysis system is deployed on a client. The client communicates with a server. When the client initiates a first handshake request to the server for a TLS network session, the first message carried in the first handshake request is intercepted by the data filtering module. Then, based on the first message, the first session manager replaces the client to complete the handshake with the server to establish a first session, wherein the first session includes a server certificate sent by the server. Then, after the first session is established, based on the first message and the server certificate, the second session manager replaces the server to complete the handshake with the client to establish a second session. Finally, after the second session is established, data is forwarded between the first session and the second session to obtain the plaintext session data of the TLS network session. The present application can implement TLS traffic analysis in a middleman manner on the client side, and has universality.

[0025] Other features and advantages of the embodiments of the present application will be described in detail in the subsequent specific implementation section. BRIEF DESCRIPTION OF THE DRAWINGS

[0026] The accompanying drawings are used to provide a further understanding of the embodiments of the present application and constitute a part of the specification. Together with the following specific implementations, they are used to explain the embodiments of the present application, but do not constitute a limitation on the embodiments of the present application. In the accompanying drawings:

[0027] Figure 1 A schematic diagram of the structure of a TLS communication model provided for a specific embodiment of the present application;

[0028] Figure 2 A flowchart of a method for parsing TLS communication traffic provided by an embodiment of the present application;

[0029] Figure 3 A schematic diagram of the structure of a TLS communication traffic parsing system provided in an embodiment of the present application;

[0030] Figure 4 A flowchart of a certificate imitation method provided in a specific embodiment of the present application;

[0031] Figure 5 A schematic diagram of the structure of a device for parsing TLS traffic provided in an embodiment of the present application. DETAILED DESCRIPTION

[0032] In order to make the purpose, technical scheme and advantages of the embodiments of the present application clearer, the technical scheme in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. It should be understood that the specific implementation methods described herein are only used to illustrate and explain the embodiments of the present application, and are not used to limit the embodiments of the present application. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of this application.

[0033] It should be noted that if the embodiments of the present application involve directional indications (such as up, down, left, right, front, back...), the directional indications are only used to explain the relative position relationship, movement status, etc. between the components under a certain specific posture (as shown in the accompanying drawings). If the specific posture changes, the directional indication will also change accordingly.

[0034] In addition, if there are descriptions involving "first", "second", etc. in the embodiments of the present application, the descriptions of "first", "second", etc. are only used for descriptive purposes and cannot be understood as indicating or suggesting their relative importance or implicitly indicating the number of technical features indicated. Therefore, the features defined as "first" and "second" may explicitly or implicitly include at least one of the features. In addition, the technical solutions between the various embodiments can be combined with each other, but they must be based on the ability of ordinary technicians in the field to implement them. When the combination of technical solutions is contradictory or cannot be implemented, it should be deemed that such combination of technical solutions does not exist and is not within the scope of protection required by this application.

[0035] Figure 1 A schematic diagram of the structure of a TLS communication model provided for a specific embodiment of the present application. It can be understood that Figure 1 The TLS communication model after the intervention of the method for parsing TLS communication traffic provided by the embodiment of the present application. Figure 1 As shown, based on the original TLS model, the embodiment of the present application implements TLS communication traffic parsing of the TLS network session between the client and the server by adding a data filtering module, a middleman service program and a data injection module to the client.

[0036] Specifically, the data filtering module and the data injection module work at the upper edge of the client's kernel layer network protocol stack. With the help of the interface provided by the operating system, they can capture the connection established by the transport layer, intercept inbound / outbound session data by connection, and inject outbound / inbound session data by connection.

[0037] The middleman service program will establish a pair of session managers for each hijacked TLS network session, including a first session manager and a second session manager, to implement a middleman proxy at the data level. The middleman service program pumps the data of the network session from the kernel layer and sends it to the corresponding port of the corresponding session manager. For example, the outbound message of the client will be pumped to the ciphertext receiving port (NR2) of the middleman second session manager, and the inbound message of the server will be pumped to the ciphertext receiving port (NR1) of the middleman first session manager. The middleman service program injects the data output by the first session manager and the second session manager back into the network session through the kernel layer data injection module. For example, the data output by the second session manager ciphertext sending port (NT2) will be injected into the network session as inbound data, and the data output by the first session manager ciphertext sending port (NT1) will be injected into the network session as outbound data. It can be understood that the plaintext data transmitted between the first session and the second session (DI-DO) is the plaintext data of the TLS network session. In this way, operations such as detection, interception or modification of the plaintext data of the TLS network session can be implemented based on the first session and the second session.

[0038] Figure 2 A flowchart of a method for parsing TLS communication traffic provided by an embodiment of the present application. Figure 2 As shown, an embodiment of the present application provides a method for parsing TLS communication traffic, which is applied to a TLS communication traffic parsing system. The TLS communication traffic parsing system includes a data filtering module, a data injection module, a first session manager, and a second session manager. The TLS communication traffic parsing system is deployed on a client, and the client communicates with a server. The method may include the following steps.

[0039] Step S101: When a client initiates a first handshake request for a TLS network session to a server, a first message carried in the first handshake request is intercepted by a data filtering module.

[0040] Step S102: Based on the first message, the first session manager replaces the client to complete the handshake with the server to establish a first session, wherein the first session includes a server certificate sent by the server.

[0041] Step S103, after the first session is established, based on the first message and the server certificate, in combination with the data filtering module and the data injection module, the second session manager replaces the server to complete the handshake with the client to establish the second session.

[0042] Step S104: after the second session is established, forward data between the first session and the second session to obtain plaintext session data of the TLS network session.

[0043] In an embodiment of the present application, in order to obtain the plaintext data when the client and the server conduct a TLS network session, the embodiment of the present application implements TLS traffic parsing on the client side in a middleman manner by deploying a TLS communication traffic parsing system on the client. Among them, the TLS communication traffic parsing system includes a data filtering module, a data injection module, a first session manager and a second session manager, and the data filtering module communicates with the first session manager and the second session manager respectively. Specifically, in the initial stage of establishing a TLS network session between the client and the server, a TLS session manager is established for the TLS network session, and the TLS session manager includes a first session manager and a second session manager. The TLS session manager can also be called a middleman module or a middleman service program. In the handshake phase of TLS, the client first initiates a first handshake request to the server to establish a TLS network session, that is, a client handshake request. At this time, the data filtering module intercepts the first message carried in the first handshake request, that is, the client handshake message, and submits the message to the first session manager in the middleman service process. The first session manager will replace the client to complete the handshake with the server to establish the first session. It can be understood that the server certificate sent by the server can be obtained during the establishment of the first session. After the first session is established, based on the server certificate, combined with the data filtering module and the data injection module, the second session manager can replace the server to complete the handshake with the client and establish the second session. In this way, after the handshake is completed, the session manager can obtain the plaintext TLS application layer data in the first session and the second session, and then detect, intercept or modify the data.

[0044] In this way, TLS traffic parsing is implemented on the client side in a man-in-the-middle manner, which is universal. Compared with the man-in-the-middle device connected in series on the physical network, it does not require the introduction of additional devices or changes in the network topology. Compared with the man-in-the-middle implemented on the server side, it is not limited to a specific TLS server.

[0045] The above technical scheme is applied to a TLS communication traffic analysis system. The TLS communication traffic analysis system includes a data filtering module, a data injection module, a first session manager and a second session manager. The TLS communication traffic analysis system is deployed on a client. The client communicates with a server. When the client initiates a first handshake request to the server for a TLS network session, the first message carried in the first handshake request is intercepted by the data filtering module. Then, based on the first message, the first session manager replaces the client to complete the handshake with the server to establish a first session, wherein the first session includes a server certificate sent by the server. Then, after the first session is established, based on the first message and the server certificate, the second session manager replaces the server to complete the handshake with the client to establish a second session. Finally, after the second session is established, data is forwarded between the first session and the second session to obtain the plaintext session data of the TLS network session. The present application can implement TLS traffic analysis in a middleman manner on the client side, and has universality.

[0046] In an embodiment of the present application, the TLS communication traffic parsing system also includes a data injection module, which, based on the first message, replaces the client with the first session manager to complete the handshake with the server to establish a first session, which may include: parsing the first message to obtain a parsing result; setting the first session manager according to the parsing result; after the first session manager is set, outputting the first message to the data injection module through the ciphertext sending port of the first session manager; injecting the first message into the network protocol stack of the client through the data injection module, so that the first message is sent to the server via the network protocol stack; intercepting the server response message sent by the server through the data filtering module, and submitting it to the ciphertext receiving port of the first session manager; completing the handshake between the first session manager and the server according to the first message and the server response message to establish the first session.

[0047] Specifically, during the handshake phase of the TLS network session, the client handshake message (i.e., the first message) sent by the client is intercepted by the data filtering module and submitted to the middleman module, which temporarily stores the message. The middleman module parses the client handshake message and creates a new TLS client session according to the same specifications to obtain the first session manager. The client handshake message output by the NT port of the first session manager is injected into the client's network protocol stack by the data injection module in an outbound manner, and the network protocol stack sends the client handshake message to the server. Further, the inbound message of the server response, i.e., the server response message, is intercepted by the data filtering module and submitted to the ciphertext receiving port of the first session manager to continue the handshake of the first session. The client handshake message output by the ciphertext sending port of the first session manager is injected into the network protocol stack by the data injection module in an outbound manner and sent to the server. The above steps are repeated until the handshake of the first session is completed. In this way, the first session manager replaces the client to complete the handshake with the server to establish the first session.

[0048] In an embodiment of the present application, after the first session is established, based on the first message and the server certificate, in combination with the data filtering module and the data injection module, the second session manager replaces the server to complete the handshake with the client to establish the second session, which may include: obtaining the target imitation certificate according to the server certificate; setting the second session manager according to the target imitation certificate; after the second session manager is set, inputting the first message into the second session manager to trigger the handshake process of the second session; outputting the second message to the data injection module through the ciphertext sending port of the second session manager;

[0049] The second message is injected into the network protocol stack through the data injection module, so that the second message is sent to the client via the network protocol stack; the client response message sent by the client is intercepted by the data filtering module and submitted to the ciphertext receiving port of the second session manager; the handshake between the second session manager and the client is completed according to the second message and the client response message to establish a second session.

[0050] Specifically, in the handshake phase of the TLS network session, in order to implement the second session manager to replace the server to complete the handshake with the client. First, the server certificate is extracted from the first session, and the target imitation certificate is obtained based on the server certificate. The target imitation certificate is an imitation certificate that corresponds to the server certificate and can be verified by the client. In one example, the TLS communication traffic analysis system also includes a certificate manager, which can be called based on the server certificate to obtain the target imitation certificate. The certificate manager will first query the cached imitation certificate through the certificate serial number of the server certificate. If the search is successful, the imitation certificate and its private key will be directly returned; if the search fails, a imitation certificate is issued using the root certificate and its private key as the target imitation certificate, and the imitation certificate and its private key are cached and returned.

[0051] Furthermore, the middleman module uses the forged certificate to create a new TLS server session, i.e., the second session manager, and sends the client handshake message temporarily stored in the first session manager to the ciphertext receiving port of the second session manager to start the handshake of the second session. The second message output by the ciphertext sending port of the second session manager, i.e., the server handshake message, is injected into the network protocol stack by the data injection module in an inbound manner, and the message data will be submitted to the client. The outbound message of the client response, i.e., the client response message, is intercepted by the data filtering module and submitted to the ciphertext receiving port of the second session to continue the handshake. In this process, the server handshake message output by the ciphertext sending port of the second session manager is injected into the network protocol stack of the client by the data injection module in an inbound manner, and the network protocol stack submits the server handshake message to the client. Repeat the above steps until the handshake of the second session is completed. In this way, the second session manager replaces the client to complete the handshake with the server to establish the second session.

[0052] In this way, the middleman is implemented by operating the inbound and outbound data only on the client's network protocol stack, without the help of the usual local network proxy program, without modifying the network configuration, without establishing additional network connections, and making the detection mechanism more covert and more secure.

[0053] In an embodiment of the present application, after the second session is established, forwarding data between the first session and the second session to obtain plaintext session data of the TLS network session may include: sending the first plaintext data output by the first session manager to the plaintext input port of the second session manager, so that the second session manager outputs the first ciphertext data corresponding to the first plaintext data; injecting the first ciphertext data into the network protocol stack of the client through the data injection module, so that the first ciphertext data is sent to the client via the network protocol stack; sending the second plaintext data output by the second session manager to the plaintext input port of the first session manager, so that the first session manager outputs the second ciphertext data corresponding to the second plaintext data; injecting the second ciphertext data into the network protocol stack of the client through the data injection module, so that the second ciphertext data is sent to the server via the network protocol stack; obtaining the first plaintext data and the second plaintext data to obtain the plaintext session data of the TLS network session.

[0054] It can be understood that after the first session and the second session are both established, that is, after the handshake phase is over, data can be forwarded between the first session and the second session to obtain the plaintext session data of the TLS network session, and the plaintext session data of the TLS network session can be checked or modified according to actual needs. Specifically, the plaintext (i.e., the first plaintext data) output of the first session manager is sent to the plaintext input port of the second session manager, and the second session manager will output the corresponding ciphertext (i.e., the first ciphertext data), and the corresponding ciphertext is injected into the network protocol stack through the data injection module, so that the corresponding ciphertext is sent to the client via the network protocol stack. The plaintext (i.e., the second plaintext data) output of the second session manager is sent to the plaintext input port of the first session manager, and the first session manager will output the corresponding ciphertext (i.e., the second ciphertext data), and the corresponding ciphertext is injected into the network protocol stack through the data injection module, so that the corresponding ciphertext is sent to the server via the network protocol stack. The first plaintext data and the second plaintext data in this process are the plaintext session data of the TLS network session established between the client and the server, and the plaintext session data can be detected, modified, and filtered in this process.

[0055] In an embodiment of the present application, the TLS communication traffic parsing system may further include an external filtering module. For application data transmission after the handshake is completed, the middleman module (i.e., the TLS session manager) submits the message to the external filtering module for detection or other processing before forwarding the message between the first session and the second session. In one example, for inbound messages from the server, the data filtering module intercepts the message and submits it to the middleman module, the middleman module sends the message to the NR port of the first session manager, reads the plaintext from the DI port, and submits it to the external filtering module. For the plaintext returned by the external filtering module, which may be modified, it is sent to the DO port of the second session manager, the ciphertext is read from the NT port, and it is injected into the network protocol stack by the data injection module in an inbound manner, and the message will be submitted to the client. In another example, for outbound messages from the client, the data filtering module intercepts the message and submits it to the middleman module, and then the middleman module sends the message to the NR port of the second session manager, reads the plaintext from the DI port, and submits it to the external filtering module. For the plain text returned by the external filtering module and possibly modified, it is sent to the DO port of the first session manager, the cipher text is read from the NT port, and it is injected into the network protocol stack by the data injection module in an outbound manner, and the message is sent to the server. In this way, the plain text data transmitted between the first session and the second session, that is, the plain text data of the TLS session, will be sent to the external filtering module for content filtering, modification or blocking.

[0056] In an embodiment of the present application, obtaining a target imitation certificate based on a server certificate sent by a server may include: obtaining the certificate serial number of the server certificate; searching a pre-stored imitation certificate library based on the certificate serial number to obtain a search result; if the search is successful, determining the certificate chain corresponding to the certificate serial number and the private key corresponding to the end certificate of the certificate chain in the imitation certificate library found as the target imitation certificate.

[0057] It can be understood that before the client and the server establish a network session, the root certificate for issuing the imitation server is installed on the client to add the certificate to the certificate storage area of ​​the operating system (Windows' trusted root certificate), or to the certificate library of the target application (typically a browser), thereby completing the construction of the imitation certificate library. In an embodiment of the present application, the TLS communication flow parsing system also includes a certificate manager, which can obtain the target imitation certificate through the server certificate sent by the server. Specifically, after the certificate manager receives a request to obtain an imitation certificate, it will use the openssl library to load the incoming server certificate chain, extract the serial number of the terminal certificate, and use the serial number to search for the generated imitation certificate in the imitation certificate library. If the search is successful, the certificate chain corresponding to the certificate serial number and the private key corresponding to the terminal certificate in the imitation certificate library found are directly returned to the caller as the target imitation certificate.

[0058] In an embodiment of the present application, the method may further include: in the event of a search failure, obtaining an initial counterfeit certificate based on the server certificate copy; regenerating a key pair of the initial counterfeit certificate based on the public key algorithm and key length of the server certificate; and determining a target counterfeit certificate based on the key pair and the initial counterfeit certificate.

[0059] It can be understood that, in the case where the target imitation certificate is not found in the imitation certificate library, the target imitation certificate can be generated according to the server imitation certificate. Specifically, first a new certificate storage context is created, and the entire server certificate chain is loaded, including the terminal entity certificate, several intermediate certificates and the root certificate. Then, starting from the end of the current certificate chain, the certificates are cloned step by step. The process of cloning certificates mainly includes two situations. In one example, if the original certificate (i.e., the server certificate) has a previous certificate, and the previous certificate is not a root certificate, then this process is recursively performed to obtain the imitation certificate (including the private key) of the previous certificate, and a new certificate is copied from the original certificate, retaining all the information of the original certificate. According to the public key algorithm and key length of the original certificate, a pair of keys is reallocated to the certificate, the public key is set in the certificate, the private key is retained, and the key identifier of the new certificate is recalculated with the newly generated public key, and set to the key identifier extension. In another example, if the original certificate has a previous certificate, it is determined whether the previous certificate is a root certificate. If the previous certificate is a root certificate, the issuer of the new certificate is set to the root certificate of the imitation certificate, and the new certificate is signed with the private key of the root certificate of the imitation certificate. If the previous certificate is not a root certificate but an intermediate certificate, the new certificate is signed with the private key of the imitation certificate of the previous level. Finally, the certificate chain and private key obtained after the cloning is completed are used as the target imitation certificate. Preferably, after each cloning is completed, the imitation certificate chain and private key are added to the imitation certificate library with the certificate serial number as the key.

[0060] In an embodiment of the present application, the method may further include: when it is detected that a new network session is established, matching the network session with preset filtering rules, wherein the preset filtering rules include IP address information and port information; when the match is successful, monitoring the new network session through a data filtering module.

[0061] It can be understood that a new network session refers to a session layer above the transport layer in the OSI layered model. Specifically, in order to achieve targeted processing of TLS network sessions, after a new network session is established, that is, after the establishment of a new network session is detected, the data filtering module of the client kernel layer will match the new network session with the preset filtering rules. If the match is successful, the session data of the new network session is monitored. In one example, the preset filtering rules can be specified by a middleman module (TLS session manager), and the middleman module can specify the preset filtering rules and start the kernel layer data filtering module. The preset filtering rules can include local / remote IP addresses or ports, the name or classification of the client application, and SNI (server name indication) information in the TLS request. In this way, the support for client process conditions in the preset filtering rules, in addition to determining which addresses and ports the connection needs to be resolved, can also determine which processes' TLS traffic needs to be resolved. Thereby improving the flexibility of data processing.

[0062] Figure 3 A schematic diagram of the structure of a TLS communication traffic analysis system provided in an embodiment of the present application. Figure 3 As shown, an embodiment of the present application provides a TLS communication flow parsing system. The TLS communication flow parsing system includes a middleman module, a certificate manager, a data filtering module, a data injection module and an external filtering module. Among them, the middleman module is a TLS network session manager, and the middleman module can communicate with the certificate manager, the data filtering module, the data injection module and the external filtering module respectively.

[0063] Specifically, the certificate manager module is used to implement verification, cloning and caching of server certificates.

[0064] (1) Verification: Verify the validity of the TLS server certificate, including whether the root certificate is credible, the validity period, and whether the purpose matches.

[0065] (2) Cloning: For a TLS original server certificate, a new imitation certificate is issued using a locally trusted root certificate with a known private key. In addition to the issuer, public key and key identifier, the new certificate has the same serial number, subject name, validity period, user and purpose, alternative name and other extensions as the original certificate. Optionally, the entire certificate chain can be cloned level by level for the intermediate certificates on the original certificate chain.

[0066] (3) Cache: The certificate manager can store the issued counterfeit certificates according to the serial number and key identifier of the original certificate.

[0067] The middleman module is mainly used for data pumping, TLS session management and data injection.

[0068] (1) Data pumping: Extract network session data from the kernel layer data filter module according to specified conditions (client application, port number, IP address). The network session refers to the session layer above the transport layer in the OSI layered model, and the network session data is the payload of the transport layer.

[0069] (2) TLS session management: Establish a TLS session manager for each TLS network session

[0070] During the handshake phase of TLS, the session manager completes the handshake with the server on behalf of the client to establish the first session; after the first session is established, the session manager will also obtain a fake certificate from the certificate manager module according to the server certificate, complete the handshake with the client on behalf of the server, and establish the second session.

[0071] After the handshake is completed, the session manager can obtain the plaintext TLS application layer data in the first session and the second session, and submit it to the external filtering module for processing. The external filtering module can detect or modify the session data according to the needs.

[0072] (3) Data injection: The messages generated by the session manager during the handshake phase and the application data transmission phase will be injected back into the TLS network session through the data injection module of the kernel layer. The messages of the first session will be sent to the server, and the messages of the second session will be submitted to the client's receive buffer.

[0073] The data filtering module works at the kernel layer of the operating system and is used to filter data at the session layer. It determines whether it is TLS traffic based on the leading message of each connection session, and then determines whether to submit the session data to the upper-level middleman module based on the specified conditions (application, port number, IP address).

[0074] The data injection module is used to inject the data injected back by the middleman module into the specified TLS session. The data injection module uses the functions provided by the operating system network protocol stack to directly inject session layer data into an existing connection in a certain direction without considering the checksum calculation, fragmentation and reassembly of the transport layer and the layers below.

[0075] In a specific embodiment of the present application, a specific embodiment of the method for parsing TLS communication traffic proposed in the present application is provided and applied to a Winows system. A specific embodiment of the present application uses a kernel layer annotation driver of a Windows Filtering Platform (WFP), and after a TCP connection is established, it is determined whether to filter the TCP stream data according to the conditions specified by the user. Among them, the conditions specified by the user refer to that the user can specify a specific client process, a remote address and / or a remote port. And when the stream data is outbound, it is determined whether the data stream is a TLS client handshake message. If so, the stream data is uploaded to the middleman service process of the user layer through the IO queue. Then, the middleman service uses the openssl library to create two TLS session managers for this TLS session, and completes the handshake and application data forwarding of the first session (middleman to server) and the second session (client to middleman) respectively. During the handshake process, the middleman generates a counterfeit certificate based on the server certificate returned during the handshake process with the TLS server, and uses this counterfeit certificate to complete the handshake of the second session with the client. In the subsequent data transmission process, the plaintext data transmitted between the first session and the second session is sent to the detection module for filtering. During the process, the ciphertext data sent by the session manager is passed to the kernel layer WFP driver through device IO, and the driver then uses the WFP injection support routine to inject the data back into the TLS network session in the inbound and outbound directions.

[0076] Specifically, the workflow of the method for parsing TLS communication traffic after being applied to the Windows system may include the following parts:

[0077] 1. Initial installation process

[0078] During the initial system installation, the root certificate used to generate the imitation certificate will be imported into the "Trusted Root Certificate" storage of the Windows system through the certificate management related API or registry. During the system installation, the TLS data filtering driver will also be installed, which will be automatically started when the TCPIP protocol stack driver is started.

[0079] 2. Driver initialization process

[0080] 1. Create a named device object (i.e., TLS data filtering device object) to provide an IO interface to the upper layer program.

[0081] 2. Determine whether the Windows Basic Filtering Engine (BFE) is ready. If it is ready, perform the following processing. If it is not ready, register a BFE status change callback function, and then perform the following processing in the callback function:

[0082] (1) Create two stream injection handles: the outbound stream injection handle and the inbound stream injection handle, which are used to inject outbound data and inbound data respectively.

[0083] (2) Create a data pumping queue, which contains two subqueues, namely the IRP queue and the stream data queue. The IRP queue is used to queue read requests from the upper layer to pump stream data, and the stream data queue is used to queue and cache stream data when the IRP queue is empty.

[0084] (3) Create a flow ID-flow context mapping to quickly obtain the local address, local port, remote address, remote port (hereinafter referred to as the four-tuple) and process information (process ID, process name, process executable file, etc.) corresponding to the flow ID.

[0085] (4) Add flow establishment annotation callback functions for IPv4 and IPv6 to capture the establishment of TCP connections.

[0086] (5) Add flow data annotation callback functions for IPv4 and IPv6.

[0087] 3. Data Detection Service Startup Process

[0088] 1. Initialize the certificate manager.

[0089] 2. Open the TLS data filtering device object.

[0090] 3. Create multiple TLS session processing threads according to the number of CPUs, and queue multiple read requests for pumping stream data. When no stream data arrives, these read requests are suspended, and the TLS session processing threads will wait for the read requests to complete one by one.

[0091] 4. Create a WFP flow establishment filter with the specified filter conditions. The filter conditions are TCP connections in the outbound direction. In addition, they can also include client process identifiers, mirror paths, remote addresses, remote ports, etc. The filter action is specified as the flow establishment label. According to the WFP layer and IP protocol version, the layer identifiers of the flow establishment filter are FWPM_LAYER_ALE_FLOW_ESTABLISHED_V4 and FWPM_LAYER_ALE_FLOW_ESTABLISHED_V6.

[0092] 4. TLS data processing flow

[0093] 1. A TCP connection that meets the filtering conditions is established and enters the flow establishment annotation callback function.

[0094] 2. Extract the TCP connection information from the inMetaValues ​​parameter of the WFP incoming stream establishment annotation callback function and construct the stream context. The stream context includes the connection's four-tuple information, process information, and stream tracking status.

[0095] 3. Take the flow handle (inMetaValues->flowHandle) of the WFP incoming flow establishment annotation callback function as the flow identifier, and use FwpsFlowAssociateContext to associate the flow identifier, flow context, and flow data annotation. As a result, subsequent flow data will enter the flow data annotation callback function for processing.

[0096] 4. After the first stream data arrives, the stream data annotation callback function determines whether it is in the outbound direction and whether the data format matches the TLS ClientHello message format. Depending on the situation:

[0097] (1) If there is no match, the flow tracking state in the flow context is set to "no tracking" and the data is released without any processing.

[0098] (2) If it matches, the flow tracking state in the flow context is set to "tracking", the data is blocked, and a data packet structure is constructed. The data packet structure contains the flow identifier, data direction (outbound / inbound), flow tag (the setting of several TCP flags, including PUSH, RST, FIN, etc.), flow context, and flow data. Then the data packet structure is queued to the data pump queue. Specifically, if the IRP queue is empty, the data packet will be added to the flow data queue. If the IRP queue is not empty, a pending read request is removed from the head of the queue, and the contents of the data packet are copied to the buffer of the read request to complete the read request.

[0099] 5. Subsequent flow data entering is either released or blocked according to the flow tracking status in the flow context, and the data packet structure is constructed and queued to the data pump queue.

[0100] 6. After the TLS session processing thread pumps the data packet, it searches for the TLS middleman session object based on the flow identifier in the data packet. If it is not found (typically, this happens after the first flow data arrives), it creates a TLS middleman session object and establishes a mapping from the flow identifier to the middleman session.

[0101] 7. After the first ClientHello packet arrives, create a TLS middleman session object and perform the following processing:

[0102] (1) Cache the ClientHello message for subsequent initiation of a second session.

[0103] (2) Parse the ClientHello message and extract information such as the cipher suite and SNI.

[0104] (3) Use the openssl library to create an SSL client context, set the SSL client context options with the cipher suite and SNI extracted from the ClientHello message, create an SSL session from the SSL client context, and start the handshake process with the server as the first session manager.

[0105] (4) The message output by the first session handshake process together with the stream identifier will be sent to the injection module of the TLS data filtering driver through the device IO. After the message is injected into the stream specified by the stream identifier using the outbound stream injection handle, the message will be sent to the server through the TCP / IP protocol stack.

[0106] (5) The message returned by the server will be processed by the flow data labeling callback function. According to step 5, the inbound message will be sent to the TLS session processing thread again along with the data packet and handed over to the first session manager of the TLS middleman session object corresponding to the flow identifier for processing.

[0107] (6) Until the handshake of the first session is completed, the middleman session object will extract the server certificate from the SSL session, call the certificate manager to obtain / generate a fake certificate, and establish a second session from the TLS server to the client.

[0108] 8. The second session establishment process is as follows:

[0109] (1) Use the openssl library to create an SSL server context, set the imitation certificate obtained in process 7-(6) to the SSL server context, and create a new SSL session from this SSL server context as the second session manager.

[0110] (2) The ClientHello message cached in step 7-(1) is sent to the second session manager to start the handshake process of the second session.

[0111] (3) The message output by the second session handshake process together with the stream identifier will be sent to the injection module of the TLS data filtering driver through the device IO. After the message is injected into the stream specified by the stream identifier using the inbound stream injection handle, the message will be submitted to the client process through the TCP / IP protocol stack.

[0112] (4) The message sent by the client process will be processed by the flow data labeling callback function. According to step 5, the outbound message will be sent to the TLS session processing thread along with the data packet and handed over to the second session manager of the TLS middleman session object corresponding to the flow identifier for processing.

[0113] (5) Until the second session is established.

[0114] 9. So far, the first session and the second session of the TLS middleman session object have been successfully established, that is, the entire TLS session has been successfully established. In the subsequent application data transmission process:

[0115] (1) The encrypted message sent from the client process to the server will be processed by the stream data annotation callback function, which is the same as the process in step 8-(4). The outbound message enters the second session manager as input. The plaintext output by the second session manager will be sent to the content detection module for processing. The processed plaintext will be sent to the first session manager. The ciphertext encrypted by the first session will be injected into the stream according to the same process as 7-(4) and sent to the server.

[0116] (2) The message received from the server will also be processed by the stream data annotation callback function, which is the same as the processing in step 7-(5). The inbound message enters the first session manager as input. The plaintext output by the first session manager will be sent to the content detection module for processing. The processed plaintext will be sent to the second session manager. The ciphertext encrypted by the second session will be injected into the stream according to the same processing as 8-(3) and submitted to the client process.

[0117] Figure 4 The following is a flow chart of a method for cloning a certificate provided in a specific embodiment of the present application. Figure 4 As shown, a specific embodiment of the present application provides a method for simulating a certificate, and the method includes the following steps.

[0118] S1: Start.

[0119] S2: Search for a counterfeit certificate from the cache database based on the server certificate.

[0120] S3: Determine whether the search is successful. If yes, go to step S11, otherwise go to step S4.

[0121] S4: Determine whether there is a superior certificate. If yes, proceed to step S5, otherwise proceed to step S6.

[0122] S5: Determine whether the superior certificate is a root certificate, if yes, proceed to step S6, otherwise proceed to step S10.

[0123] S6: Copy a new certificate.

[0124] S7: Create a public key pair and update the key identifier.

[0125] S8: Use the fake root certificate to sign the new certificate.

[0126] S9: Add the counterfeit certificate to the cache database and proceed to step S11.

[0127] S10: Obtain a counterfeit certificate of the superior certificate, recursively starting from step S1.

[0128] S11: Return the imitation certificate and private key. Return the intermediate imitation certificate and proceed to step S12.

[0129] S12: Copy a new certificate.

[0130] S13: Create a public key pair and update the key identifier.

[0131] S14: Use the superior counterfeit intermediate certificate to sign the new certificate. Go to step S9.

[0132] Specifically, based on the above process, after the certificate manager receives a request to obtain a fake certificate, it will use the openssl library to load the incoming server certificate chain, extract the serial number of the terminal certificate, and use the serial number to search for the generated fake certificate in the fake certificate cache database. If the search is successful, the certificate chain and the private key corresponding to the terminal certificate are directly returned to the caller. If the search fails, the certificate manager can use the openssl library to clone the fake certificate. The certificate manager can use the openssl library to clone the fake certificate, including the following steps:

[0133] 1. Create a new certificate storage context and load the entire server certificate chain, including the terminal entity certificate, several intermediate certificates, and the root certificate.

[0134] 2. Starting from the end of the current certificate chain, clone the certificates step by step. The process of cloning certificates mainly includes:

[0135] (1) If the original certificate has a parent certificate, and the parent certificate is not a root certificate, then recurse this process to obtain a counterfeit certificate (including the private key) of the parent certificate.

[0136] (2) Copy a new certificate from the original certificate, retaining all the information of the original certificate.

[0137] (3) Reallocate a pair of keys to the certificate based on the public key algorithm and key length of the original certificate, set the public key to the certificate, and retain the private key.

[0138] (4) Recalculate the key identifier of the new certificate using the newly generated public key and set it to the key identifier extension.

[0139] (5) If the original certificate has a parent certificate, determine whether the parent certificate is a root certificate. If the parent certificate is a root certificate, set the issuer of the new certificate to the root certificate of the imitation certificate, and use the private key of the root certificate of the imitation certificate to sign the new certificate. If the parent certificate is not a root certificate but an intermediate certificate, use the private key of the parent certificate to sign the new certificate.

[0140] 3. After each cloning is completed, the cloned certificate chain and private key are added to the cloned certificate cache database with the certificate serial number as the key, and then returned to the caller.

[0141] In this way, TLS traffic parsing is implemented on the client side in a middleman manner, which is universal. Compared with the middleman device connected in series on the physical network, it does not require the introduction of additional devices, does not require the change of network topology, and is not limited to a specific TLS server compared to the middleman implemented on the server side. In addition, the middleman is implemented only by operating the inbound and outbound data on the client's network protocol stack, without the help of the usual local network proxy program, without modifying the network configuration, without establishing additional network connections, and making the detection mechanism more covert and more secure.

[0142] An embodiment of the present application also provides a processor configured to execute the method for parsing TLS traffic in the above implementation.

[0143] Figure 5 A schematic diagram of the structure of a device for parsing TLS traffic provided by an embodiment of the present application. Figure 5 As shown, the embodiment of the present application also provides a device 500 for parsing TLS traffic, which is applied to a TLS communication traffic parsing system. The TLS communication traffic parsing system includes a data filtering module, a data injection module, a first session manager, and a second session manager. The TLS communication traffic parsing system is deployed on a client, and the client communicates with a server. The device 500 includes:

[0144] The message interception unit 510 is used to intercept a first message carried in the first handshake request through a data filtering module when the client initiates a first handshake request for conducting a TLS network session to the server.

[0145] The first session establishing unit 520 is configured to complete the handshake with the server by replacing the client through the first session manager based on the first message to establish a first session, wherein the first session includes a server certificate sent by the server.

[0146] The second session establishing unit 530 is used to complete the handshake with the client through the second session manager instead of the server to establish the second session based on the first message and the server certificate in combination with the data filtering module and the data injection module after the first session is established.

[0147] The session data acquisition unit 540 is used to forward data between the first session and the second session after the second session is established, so as to acquire plaintext session data of the TLS network session.

[0148] The above-mentioned device 500 for parsing TLS traffic is applied to a TLS communication traffic parsing system, which includes a data filtering module, a data injection module, a first session manager, and a second session manager. The TLS communication traffic parsing system is deployed on a client, and the client communicates with a server. When the client initiates a first handshake request to the server for a TLS network session, the first message carried in the first handshake request is intercepted by the data filtering module, and then based on the first message, the first session manager replaces the client to complete the handshake with the server to establish a first session, wherein the first session includes a server certificate sent by the server, and then after the first session is established, based on the first message and the server certificate, the second session manager replaces the server to complete the handshake with the client to establish a second session, and finally after the second session is established, data is forwarded between the first session and the second session to obtain the plaintext session data of the TLS network session. The present application can implement TLS traffic parsing in a middleman manner on the client side, and has universality.

[0149] In one embodiment, the first session establishing unit 520 is further used to: parse the first message to obtain a parsing result; set the first session manager according to the parsing result; after the first session manager is set, output the first message to the data injection module through the ciphertext sending port of the first session manager; inject the first message into the network protocol stack of the client through the data injection module, so that the first message is sent to the server via the network protocol stack; intercept the server response message sent by the server through the data filtering module, and submit it to the ciphertext receiving port of the first session manager; complete the handshake between the first session manager and the server according to the first message and the server response message to establish the first session.

[0150] In one embodiment, the second session establishing unit 530 is further used to: obtain a target imitation certificate according to the server certificate; set the second session manager according to the target imitation certificate; after the second session manager is set, input the first message into the second session manager to trigger the handshake process of the second session; output the second message to the data injection module through the ciphertext sending port of the second session manager; inject the second message into the network protocol stack through the data injection module, so that the second message is sent to the client via the network protocol stack; intercept the client response message sent by the client through the data filtering module, and submit it to the ciphertext receiving port of the second session manager; complete the handshake between the second session manager and the client according to the second message and the client response message to establish the second session.

[0151] In one embodiment, obtaining a target imitation certificate based on a server certificate sent by a server includes: obtaining the certificate serial number of the server certificate; searching a pre-stored imitation certificate library based on the certificate serial number to obtain a search result; if the search is successful, determining the certificate chain corresponding to the certificate serial number and the private key corresponding to the end certificate of the certificate chain in the imitation certificate library found as the target imitation certificate.

[0152] In one embodiment, the session data acquisition unit 540 is also used to: send the first plaintext data output by the first session manager to the plaintext input port of the second session manager, so that the second session manager outputs the first ciphertext data corresponding to the first plaintext data; inject the first ciphertext data into the network protocol stack of the client through the data injection module, so that the first ciphertext data is sent to the client via the network protocol stack; send the second plaintext data output by the second session manager to the plaintext input port of the first session manager, so that the first session manager outputs the second ciphertext data corresponding to the second plaintext data; inject the second ciphertext data into the network protocol stack of the client through the data injection module, so that the second ciphertext data is sent to the server via the network protocol stack; obtain the first plaintext data and the second plaintext data to obtain the plaintext session data of the TLS network session.

[0153] In one embodiment, the method further includes: in case of search failure, obtaining an initial counterfeit certificate based on the server certificate copy; regenerating the key pair of the initial counterfeit certificate based on the public key algorithm and key length of the server certificate; and determining the target counterfeit certificate based on the key pair and the initial counterfeit certificate.

[0154] In one embodiment, the method further includes: when a new network session is detected to be established, matching the network session with preset filtering rules, wherein the preset filtering rules include IP address information and port information; when the match is successful, monitoring the new network session through a data filtering module.

[0155] An embodiment of the present application also provides a TLS communication traffic parsing system, including: a data filtering module; a data injection module; a first session manager; a second session manager; a processor in the above implementation or a device for parsing TLS traffic in the above implementation.

[0156] An embodiment of the present application also provides a machine-readable storage medium, on which a program or instruction is stored. When the program or instruction is executed by a processor, the method for parsing TLS traffic in the above-mentioned embodiment is implemented.

[0157] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that contain computer-usable program code.

[0158] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems) and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor or other programmable data processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0159] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.

[0160] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.

[0161] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.

[0162] The memory may include non-permanent memory in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. The memory is an example of a computer-readable medium.

[0163] Computer readable media include permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. Information can be computer readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic tape disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer readable media does not include temporary computer readable media (transitory media), such as modulated data signals and carrier waves.

[0164] It should also be noted that the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, commodity or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, commodity or device. In the absence of more restrictions, the elements defined by the sentence "comprises a ..." do not exclude the existence of other identical elements in the process, method, commodity or device including the elements.

[0165] The above are only embodiments of the present application and are not intended to limit the present application. For those skilled in the art, the present application may have various changes and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application should be included within the scope of the claims of the present application.

Claims

1. A method for parsing TLS communication traffic, characterized in that: Applied to a TLS communication flow analysis system, the TLS communication flow analysis system includes a data filtering module, a data injection module, a first session manager and a second session manager, the TLS communication flow analysis system is deployed on a client, the client communicates with a server, and the method includes: When the client initiates a first handshake request to the server for conducting a TLS network session, intercepting a first message carried in the first handshake request by the data filtering module; Based on the first message, the first session manager replaces the client to complete the handshake with the server to establish a first session, wherein the first session includes a server certificate sent by the server; After the first session is established, based on the first message and the server certificate, in combination with the data filtering module and the data injection module, the second session manager replaces the server to complete the handshake with the client to establish a second session; After the second session is established, forwarding data between the first session and the second session to obtain plaintext session data of the TLS network session; The step of replacing the client with the first session manager to complete the handshake with the server based on the first message to establish the first session includes: Parsing the first message to obtain a parsing result; Setting the first session manager according to the parsing result; After the first session manager is set, the first message is output to the data injection module through the ciphertext sending port of the first session manager; Injecting the first message into the network protocol stack of the client through the data injection module, so that the first message is sent to the server via the network protocol stack; intercepting the server response message sent by the server through the data filtering module, and submitting it to the ciphertext receiving port of the first session manager; completing a handshake between the first session manager and the server according to the first message and the server response message to establish the first session; The step of completing the handshake with the client by replacing the server with the second session manager based on the first message and the server certificate in combination with the data filtering module and the data injection module to establish a second session includes: Obtaining a target imitation certificate according to the server certificate; Setting the second session manager according to the target imitation certificate; After the second session manager is set, inputting the first message into the second session manager to trigger a handshake process of the second session; Outputting the second message to the data injection module through the ciphertext sending port of the second session manager; Injecting the second message into the network protocol stack through the data injection module, so that the second message is sent to the client via the network protocol stack; intercepting the client response message sent by the client through the data filtering module, and submitting it to the ciphertext receiving port of the second session manager; completing a handshake between the second session manager and the client according to the second message and the client response message to establish the second session; After the second session is established, forwarding data between the first session and the second session to obtain plaintext session data of the TLS network session includes: Sending the first plaintext data output by the first session manager to the plaintext input port of the second session manager, so that the second session manager outputs the first ciphertext data corresponding to the first plaintext data; Injecting the first ciphertext data into the network protocol stack of the client through the data injection module, so that the first ciphertext data is sent to the client via the network protocol stack; Sending the second plaintext data output by the second session manager to the plaintext input port of the first session manager, so that the first session manager outputs second ciphertext data corresponding to the second plaintext data; Injecting the second ciphertext data into the network protocol stack of the client through the data injection module, so that the second ciphertext data is sent to the server via the network protocol stack; The first plaintext data and the second plaintext data are acquired to obtain plaintext session data of the TLS network session.

2. The method according to claim 1, characterized in that The step of obtaining a target imitation certificate according to the server certificate sent by the server comprises: Obtaining the certificate serial number of the server certificate; Searching a pre-stored counterfeit certificate library based on the certificate serial number to obtain a search result; In the case of successful search, the certificate chain corresponding to the certificate serial number and the private key corresponding to the terminal certificate of the certificate chain found in the imitation certificate library are determined as the target imitation certificate.

3. The method according to claim 2, characterized in that The method further comprises: In case of a search failure, an initial counterfeit certificate is obtained by copying the server certificate; Regenerate the key pair of the initial imitation certificate according to the public key algorithm and key length of the server certificate; The target imitation certificate is determined based on the key pair and the initial imitation certificate.

4. The method according to claim 1, characterized in that: The method further comprises: When detecting that a new network session is established, matching the new network session with a preset filtering rule, wherein the preset filtering rule includes IP address information and port information; In case of a successful match, the new network session is monitored by the data filtering module.

5. A processor, characterized in that: The method is configured to execute the method for parsing TLS traffic according to any one of claims 1 to 4.

6. A device for parsing TLS traffic, characterized in that: Applied to a TLS communication flow analysis system, the TLS communication flow analysis system includes a data filtering module, a data injection module, a first session manager and a second session manager, the TLS communication flow analysis system is deployed on a client, the client communicates with a server, and the device includes: A message interception unit, configured to intercept, by means of the data filtering module, a first message carried in a first handshake request initiated by the client to the server for a TLS network session; a first session establishing unit, configured to complete a handshake with the server by replacing the client with the first session manager based on the first message, so as to establish a first session, wherein the first session includes a server certificate sent by the server; a second session establishing unit, configured to, after the first session is established, complete a handshake with the client by replacing the server through the second session manager based on the first message and the server certificate, in combination with the data filtering module and the data injection module, so as to establish a second session; a session data acquisition unit, configured to forward data between the first session and the second session after the second session is established, so as to acquire plaintext session data of the TLS network session; The step of replacing the client with the first session manager to complete the handshake with the server based on the first message to establish the first session includes: Parsing the first message to obtain a parsing result; Setting the first session manager according to the parsing result; After the first session manager is set, the first message is output to the data injection module through the ciphertext sending port of the first session manager; Injecting the first message into the network protocol stack of the client through the data injection module, so that the first message is sent to the server via the network protocol stack; intercepting the server response message sent by the server through the data filtering module, and submitting it to the ciphertext receiving port of the first session manager; completing a handshake between the first session manager and the server according to the first message and the server response message to establish the first session; The step of completing the handshake with the client by replacing the server with the second session manager based on the first message and the server certificate in combination with the data filtering module and the data injection module to establish a second session includes: Obtaining a target imitation certificate according to the server certificate; Setting the second session manager according to the target imitation certificate; After the second session manager is set, inputting the first message into the second session manager to trigger a handshake process of the second session; Outputting the second message to the data injection module through the ciphertext sending port of the second session manager; Injecting the second message into the network protocol stack through the data injection module, so that the second message is sent to the client via the network protocol stack; intercepting the client response message sent by the client through the data filtering module, and submitting it to the ciphertext receiving port of the second session manager; completing a handshake between the second session manager and the client according to the second message and the client response message to establish the second session; After the second session is established, forwarding data between the first session and the second session to obtain plaintext session data of the TLS network session includes: Sending the first plaintext data output by the first session manager to the plaintext input port of the second session manager, so that the second session manager outputs the first ciphertext data corresponding to the first plaintext data; Injecting the first ciphertext data into the network protocol stack of the client through the data injection module, so that the first ciphertext data is sent to the client via the network protocol stack; Sending the second plaintext data output by the second session manager to the plaintext input port of the first session manager, so that the first session manager outputs second ciphertext data corresponding to the second plaintext data; Injecting the second ciphertext data into the network protocol stack of the client through the data injection module, so that the second ciphertext data is sent to the server via the network protocol stack; The first plaintext data and the second plaintext data are acquired to obtain plaintext session data of the TLS network session.

7. A TLS communication traffic analysis system, characterized in that: include: Data filtering module; Data injection module; a first session manager; a second session manager; A processor according to claim 5 or an apparatus for parsing TLS traffic according to claim 6.

8. A machine-readable storage medium storing a program or instruction, characterized in that: When the program or the instruction is executed by a processor, the method for parsing TLS traffic according to any one of claims 1 to 4 is implemented.