Data packet capture method and data packet transmission method
By configuring the root certificate and hypertext transmission security protocol proxy, disguising itself as a target server, intercepting data packets between mobile applications and servers, the problem of the inability to crawl mobile application data packets in the existing technology is solved, and the mobile application is realized packet crawling and transmission, easy to develop, debug and test.
Patent Information
- Application Number
- CN202311678997.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-12-08
- Publication Date
- 2024-12-10
- Estimated Expiration
- 2043-12-08
AI Technical Summary
The prior art cannot directly crawl data packets of mobile applications, and it is difficult to simulate their requests, resulting in the inability to perform effective data crawl.
By configuring the root certificate and setting up a hypertext transmission security protocol proxy, disguising itself as a target server, establishing a man-in-the-middle connection with the mobile application and the server, intercepting and intercepting data packets, generating network security configuration files, and adding them to the application configuration. Implement the crawling and transmission of data packets.
It realizes intercept and transmission of data packets between mobile applications and servers, which facilitates developers to view network requests and responses in real time, simplifies the debugging and testing process, reduces debugging costs, and improves efficiency.
Smart Images

Figure CN117749672B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of network technology, and in particular to a data packet capture method and a data packet transmission method. Background Art
[0002] A data packet is a unit of data in network data transmission. By capturing and analyzing data packets, we can understand the usage of related networks and pages.
[0003] Currently, there are many open source frameworks for data crawling, such as Scrapy, Nutch, etc. These frameworks use the URL of the web page as the entry address to crawl data. However, for mobile applications, it is impossible to directly specify the entry URL for crawling data, and the request data packet between the mobile application and the server contains many parameters. It is difficult for existing frameworks to simulate these requests and cannot crawl the data of mobile applications.
[0004] Therefore, how to capture data packets of mobile applications has become a technical problem that needs to be solved urgently. Summary of the invention
[0005] The present invention provides a data packet capture method and a data packet transmission method, which are used to solve the defect that the mobile application data packet cannot be captured in the prior art, and realize the capture of the mobile application data packet.
[0006] In a first aspect, the present invention provides a data packet capture method, comprising:
[0007] Based on the certificate configuration instruction, configure a root certificate and add the root certificate to a trust store;
[0008] Configure HTTP Security proxy based on SSL proxy directive;
[0009] After receiving the data packet capture instruction, based on the Hypertext Transfer Protocol Security agent, the data packet of the application program to be tested on the mobile terminal is captured.
[0010] According to the data packet capture method provided by the present invention, after receiving the data packet capture instruction, before capturing the data packet of the mobile terminal application to be tested based on the Hypertext Transfer Protocol Security agent, it also includes:
[0011] After receiving the certificate storage instruction, the root certificate is exported into a certificate file in a corresponding format based on the format parameters in the certificate storage instruction.
[0012] According to a data packet capture method provided by the present invention, after receiving the certificate storage instruction, based on the format parameters in the certificate storage instruction, the root certificate is exported as a certificate file of a corresponding format, and further includes:
[0013] Based on user input, add the certificate file to the resource file of the application to be tested to generate a network security configuration file;
[0014] Add the network security configuration file to the configuration of the application to be tested.
[0015] In a second aspect, the present invention further provides a data packet transmission method, comprising:
[0016] Based on the network proxy configuration instructions, configure the IP and port number of the network service;
[0017] Based on the certificate trust configuration instruction, configure the root certificate corresponding to the certificate file as a trusted certificate;
[0018] Based on user input, data packets are transmitted using the application to be tested, wherein the network security configuration file of the application to be tested includes the certificate file.
[0019] According to a data packet transmission method provided by the present invention, the configuration of the IP and port number of the network service based on the network proxy configuration instruction includes:
[0020] Based on the network proxy configuration instruction, the server host name of the wireless LAN to be configured is set to the IP, and the server port of the wireless LAN to be configured is set to the port number. The IP is the IP address of the server for data packet capture, and the port number is the port number of the server for Hypertext Transfer Protocol proxy.
[0021] In a third aspect, the present invention further provides a data packet capture device, comprising:
[0022] The certificate configuration module is used to: configure a root certificate based on the certificate configuration instruction and add the root certificate to the trust store;
[0023] The proxy configuration module is used to: configure the HTTP security protocol proxy based on the secure socket layer proxy instruction;
[0024] The data capture module is used to capture the data packet of the application program to be tested on the mobile terminal based on the Hypertext Transfer Protocol Security agent after receiving the data packet capture instruction.
[0025] A data packet capture device provided according to the present invention further includes a certificate export module, which is used to:
[0026] After receiving the certificate storage instruction, the root certificate is exported into a certificate file in a corresponding format based on the format parameters in the certificate storage instruction.
[0027] A data packet capture device provided by the present invention further includes a program configuration module for:
[0028] Based on user input, add the certificate file to the resource file of the application to be tested to generate a network security configuration file;
[0029] Add the network security configuration file to the configuration of the application to be tested.
[0030] In a fourth aspect, the present invention further provides a data packet transmission device, comprising:
[0031] The network configuration module is used to: configure the IP and port number of the network service based on the network proxy configuration instructions;
[0032] The certificate configuration module is used to: configure the root certificate corresponding to the certificate file as a trusted certificate based on the certificate trust configuration instruction;
[0033] The data transmission module is used to: based on user input, use the application to be tested to transmit data packets, and the network security configuration file of the application to be tested includes the certificate file.
[0034] According to a data packet transmission device provided by the present invention, the network configuration module is further specifically used for:
[0035] Based on the network proxy configuration instruction, the server host name of the wireless LAN to be configured is set to the IP, and the server port of the wireless LAN to be configured is set to the port number. The IP is the IP address of the server for data packet capture, and the port number is the port number of the server for Hypertext Transfer Protocol proxy.
[0036] In a fifth aspect, 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 processor implements the steps of any of the above-described data packet capture methods, or implements the steps of any of the above-described data packet transmission methods.
[0037] In a sixth aspect, the present invention further provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of any of the above-described data packet capture methods, or implements the steps of any of the above-described data packet transmission methods.
[0038] In the seventh aspect, the present invention also provides a data packet capture system, which includes a first device and a second device, wherein the first device uses any of the data packet capture methods described above to capture data packets, and the second device uses any of the data packet transmission methods described above to transmit data packets.
[0039] The data packet capture method, data packet transmission method, device, electronic device and storage medium provided by the present invention configure a root certificate based on a certificate configuration instruction and add the root certificate to a trust store, configure a Hypertext Transfer Protocol Security agent based on a Secure Sockets Layer proxy instruction, and after receiving the data packet capture instruction, capture the data packet of the mobile application to be tested based on the Hypertext Transfer Protocol Security agent, and / or configure the IP and port number of the network service based on the network proxy configuration instruction, configure the root certificate corresponding to the certificate file as a trusted certificate based on the certificate trust configuration instruction, and use the application to be tested for data packet transmission based on user input, and the network security configuration file of the application to be tested includes the certificate file. By configuring the root certificate and HTTPS proxy on the server side, the server side can act as a middleman between the mobile application configured with the same root certificate and the target server, that is, disguise itself as the target server, establish a connection with the mobile terminal, and establish another connection with the target server, intercept the data packets sent by the mobile application and disguise itself as the mobile terminal sending data packets to the target server, intercept the data packets returned by the target server and disguise itself as the target server returning data packets to the mobile application, thereby intercepting the data packets between the mobile application and the target server, making it easier for developers to view network requests and responses in real time, and facilitating the debugging and testing of mobile applications. BRIEF DESCRIPTION OF THE DRAWINGS
[0040] In order to more clearly illustrate the technical solutions in the present invention or the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0041] Figure 1 It is a flow chart of the data packet capture method provided by the present invention;
[0042] Figure 2 It is a flow chart of the data packet transmission method provided by the present invention;
[0043] Figure 3 It is a structural schematic diagram of the data packet capture device provided by the present invention;
[0044] Figure 4 It is a structural schematic diagram of a data packet transmission device provided by the present invention;
[0045] Figure 5 It is a structural schematic diagram of the electronic device provided by the present invention. DETAILED DESCRIPTION
[0046] In order to make the purpose, technical solution and advantages of the present invention clearer, the technical solution of the present invention will be clearly and completely described below in conjunction with the drawings of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0047] It should be noted that in the description of the embodiments of the present invention, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article 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, article or device. In the absence of further restrictions, the elements defined by the sentence "include one..." do not exclude the existence of other identical elements in the process, method, article or device including the elements. The orientation or position relationship indicated by the terms "upper", "lower" and the like is based on the orientation or position relationship shown in the drawings, which is only for the convenience of describing the present invention and simplifying the description, rather than indicating or implying that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation, and therefore cannot be understood as a limitation on the present invention. Unless otherwise clearly specified and limited, the terms "installed", "connected" and "connected" should be understood in a broad sense, for example, it can be a fixed connection, a detachable connection, or an integral connection; it can be a mechanical connection or an electrical connection; it can be directly connected, or indirectly connected through an intermediate medium, or it can be a connection between two elements. For those skilled in the art, the specific meanings of the above terms in the present invention can be understood according to specific circumstances.
[0048] The terms "first", "second", etc. in this application are used to distinguish similar objects, and are not used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present application can be implemented in an order other than those illustrated or described here, and the objects distinguished by "first", "second", etc. are generally of one type, and the number of objects is not limited. For example, the first object can be one or more. In addition, "and / or" represents at least one of the connected objects, and the character " / " generally indicates that the objects associated with each other are in an "or" relationship.
[0049] In the process of mobile application development, front-end developers, back-end developers, Android developers, and testers need to work together, but the current front-end and client local debugging technologies have the following problems:
[0050] During the front-end development process, it is necessary to jointly debug the local development environment for real-machine debugging, which requires modifying WebView to point to the local IP or development and testing environment, which is cumbersome.
[0051] During the backend development process, a real device is used to send network requests, and the backend checks the logs of network requests and debugs based on the sent parameters and request results, which is not convenient.
[0052] In the process of Android development, APK (Android Application Package) needs to be packaged multiple times. Most debugging needs to be solved by the developer through the proxy network, but the existing technology cannot meet this demand.
[0053] During the testing process, it is necessary to analyze front-end and back-end problems, simulate weak network environments, build abnormal test scenarios, etc. In the existing technology, the network is usually restricted by routers to build a weak network environment, which is time-consuming and requires excluding other network requests initiated on the real machine background, which is relatively cumbersome.
[0054] In view of the above problems, the present application proposes the following embodiments. Figure 1-Figure 4 The present invention describes a data packet capture method, a data packet transmission method and a device provided in an embodiment of the present invention.
[0055] Figure 1 It is a flow chart of the data packet capture method provided by the present invention, such as Figure 1 As shown, including but not limited to the following steps:
[0056] S110: Based on the certificate configuration instruction, configure a root certificate and add the root certificate to a trust store.
[0057] It should be noted that the execution entity server of the data packet capture method provided in the embodiment of the present application can be a server, a computer device, such as a laptop computer, a PDA, an ultra-mobile personal computer (UMPC), a netbook or a personal digital assistant (PDA).
[0058] Here, the server monitors and intercepts the communication between the mobile terminal and the target server based on the proxy server. For ease of understanding, the various embodiments of this application are explained by taking the server as a PC and the proxy server as Charles as an example. Charles is a powerful network proxy server.
[0059] Here, the root certificate is the certificate issued by the CA (Certificate Authority), which is the starting point of the trust chain. The browser will determine whether the root certificate is trusted, mainly by checking whether it exists in the browser's root certificate library trusted list. If it exists, the browser will trust the root certificate. Currently, some browsers build their own root certificate library, and some browsers use the root certificate library of other browsers or call the root certificate library of the operating system.
[0060] Here, after downloading and installing the Charles root certificate through SSL Proxying in Charles, the root certificate is added to the PC's trust store. The trust store includes one or more certificates, or the trust store records trusted certificates by referencing the certificate store, thereby achieving server or signature verification and ensuring the security of communication data.
[0061] Here, the downloaded root certificate is not trusted by default. For PCs with OSX operating system, double-click the downloaded root certificate to set the trust status of the root certificate. Specifically, in the keychain, set the fields such as "When using this certificate", "Secure Sockets Layer (SSL)", "Secure Mail (S / MIME)", "Extensible Authentication Protocol (EAP)", "IP Security (IPsec)", "Code Signing", "Timestamp", and "X.509 Basic Policy" to "Always Trust", so as to ensure that data can be transmitted between the PC and the mobile terminal and the target server through the Charles root certificate; for Windows operating system, after downloading the root certificate through Install Charles Root Certificate in SSLProxying, click the certificate to install it, and set the certificate storage of the root certificate to "Trusted Root Certification Authorities". In other words, after installing the root certificate, it will be imported into the trust store corresponding to the "Trusted Root Certification Authorities".
[0062] In addition, after the root certificate is installed and configured, the corresponding port number needs to be configured based on the user's input. Specifically, the user configures the port number (Port) of the HTTP Proxy through the proxy settings (Proxy Seetings). It can be understood that the port number can be adaptively set according to usage requirements, for example, set to 8888. In addition, when configuring the proxy, not only does it need to enable the HTTP proxy (check "Enable transparent HTTP proxying"), but in order to support HTTP / 2 (Hypertext Transfer Protocol / 2, Hypertext Transfer Protocol Version 2), it is also necessary to configure "SuppportHTTP / 2".
[0063] S120: Based on the secure socket layer proxy instruction, configure the HTTP security protocol proxy.
[0064] Here, Secure Socket Layer (SSL) is a security protocol implemented on the transmission communication protocol TCP / IP to ensure the privacy of communication.
[0065] In order to proxy HTTPS (Hypertext Transfer Protocol Secure), you need to configure the Hypertext Transfer Protocol Secure proxy (HTTPS proxy). Specifically, enable SSL proxy (Enable SSL Proxying) in Charles' SSL Proxying Settings. Only addresses that match the pre-stored addresses will be proxied. You can set the pre-stored addresses according to actual usage requirements. If you need to proxy all web browsing requests, add the address: Host: *, Port: 443, where Host is the host name, the wildcard * means "all", and Port is the port. Port 443 is the web browsing port. By adding this address, all requests from hosts accessing port 443 will be proxied.
[0066] It is understandable that the execution order of S110 and S120 is not limited. In other words, S110 may be executed first and then S120, or S120 may be executed first and then S110, or S110 and S120 may be executed simultaneously.
[0067] S130: After receiving the data packet capture instruction, based on the HTTP security protocol proxy, capture the data packet of the mobile terminal application to be tested.
[0068] Here, for Charles, the user clicks the record button, and the server receives the packet capture instruction and performs packet capture.
[0069] Here, the HTTPS request is made through the HTTPS proxy. That is, if the mobile terminal installs and trusts the Charles root certificate, the server can act as a middleman proxy to obtain the symmetric key of the HTTPS connection and the public key of the target server's certificate, and proxy the HTTPS communication between the mobile terminal and the target server, so that the data packets transmitted between the two can be received and saved.
[0070] In an optional embodiment, after receiving the data packet capture instruction, before capturing the data packet of the mobile terminal application to be tested based on the HTTP security protocol proxy, it also includes:
[0071] After receiving the certificate storage instruction, the root certificate is exported into a certificate file in a corresponding format based on the format parameters in the certificate storage instruction.
[0072] Here, the certificate storage instruction means that the user downloads the root certificate through the Save Charles Root Certificate of SSL Proxying in Charles. When exporting the root certificate, the user assigns a value to the format parameter by selecting the format, and the server exports the certificate file according to the format parameter. The format of the certificate file includes but is not limited to .cer (certificate encoded in binary DER) and .pem (certificate encoded in ASCII).
[0073] The data packet capture method provided in the embodiment of the present application exports the root certificate into a certificate file of a specified format, which facilitates the transmission of the certificate file of the corresponding format according to the needs of the mobile terminal, thereby facilitating the configuration of the corresponding certificate file by the mobile terminal that needs to capture the packet.
[0074] Further, after receiving the certificate storage instruction, based on the format parameters in the certificate storage instruction, exporting the root certificate into a certificate file of a corresponding format, it also includes:
[0075] Based on user input, add the certificate file to the resource file of the application to be tested to generate a network security configuration file;
[0076] Add the network security configuration file to the configuration of the application to be tested.
[0077] Here, in Android development, the certificate file is configured through an extensible markup language (xml) file. Specifically, in the resource folder res, create a new Android resource folder (Android ResourceDirectory) of the raw resource type (Resource type), and then copy the certificate file to the Android resource folder; create a new network security configuration xml file, and add the network security configuration xml file to the mobile application to be tested.
[0078] For example, create a new res / xml / network_security_config.xml as follows:
[0079]
[0080] Add the following network security configuration file to the configuration of the application under test:
[0081] <? xml version="1.0" encoding="utf-8"? >
[0082] <manifest......>
[0083] <application
[0084] android:networkSecurityConfig="@xml / network_security_conf
[0085] ig"
[0086] ......> ...... ......
[0089] <application>
[0090] <manifest>
[0091] In addition, it should be noted that when debugging the application to be tested, you may need to connect to a local development server that does not provide an SSL certificate for the production server. In order to connect to the local development server without modifying the code of the application to be tested, you can specify a debug-only CA that is only trusted when android:debuggable is true through the debug-overrides tag. Usually IDE (Integrated Development Environment) and build tools automatically set this tag for non-release builds. Due to security considerations, the app store does not accept applications marked as debuggable, so this is safer than general conditional code.
[0092] The application to be tested is packaged into an apk and installed on the mobile terminal. After receiving the data packet capture instruction, the server opens the corresponding application on the mobile terminal to operate, and the server can capture the data packet of the application.
[0093] The data packet capture method provided in the embodiment of the present application configures a certificate file in the application to be tested, so that the server can capture the data packets of the application to be tested, thereby facilitating the developer to test and debug the application based on the captured data packets. In other words, within the local area network, the original URL request is directed to the developer's local (server) service request through the proxy network, and there is no need to repeatedly send packets. Each time debugging is required, the developer's local service is restarted and the URL request is refreshed on the real machine for debugging. There is no need to package the apk multiple times, which reduces debugging costs and improves debugging efficiency.
[0094] In an optional embodiment, the IP of the mobile terminal is added to the "Access control settings" in the "Proxy" of Charles, thereby ensuring that the mobile terminal can access the Internet normally after configuring the corresponding root certificate.
[0095] In summary, the data packet capture method provided by the present invention configures the root certificate based on the certificate configuration instruction and adds the root certificate to the trust store, configures the Hypertext Transfer Protocol Security agent based on the Secure Sockets Layer agent instruction, and after receiving the data packet capture instruction, captures the data packet of the mobile terminal application to be tested based on the Hypertext Transfer Protocol Security agent. By configuring the root certificate and the HTTPS agent on the server side, the server side can act as an intermediary between the mobile terminal application configured with the same root certificate and the target server, that is, disguised as the target server, establish a connection with the mobile terminal, and establish another connection with the target server, intercept the data packet sent by the mobile terminal application and disguise it as the mobile terminal sending a data packet to the target server, intercept the data packet returned by the target server and disguise it as the target server returning the data packet to the mobile terminal application, thereby realizing the interception of the data packet between the mobile application and the target server, which is convenient for developers to view network requests and responses in real time, and facilitates the debugging and testing of mobile applications.
[0096] Figure 2 is a flow chart of the data packet transmission method provided by the present invention, such as Figure 2 As shown, including but not limited to the following steps:
[0097] S210: Based on the network proxy configuration instruction, configure the IP and port number of the network service.
[0098] The execution subject of the data packet transmission method provided in the embodiment of the present application can be a mobile electronic device such as a mobile phone, a tablet computer, a laptop computer, a PDA, a vehicle-mounted electronic device, a wearable device, etc. For ease of understanding, the following description is made by taking a mobile terminal as an example.
[0099] Here, the network proxy configuration instruction is the input when the user manually configures the network. Specifically, for mobile phones using the Android operating system, long press the corresponding network in the mobile phone's WiFi settings, select "Modify Network", select "Manual" in the advanced options, and then modify the "Server Host Name" and "Server Port"; for mobile phones using the iOS operating system, click the reverse exclamation mark behind the corresponding network in the wireless LAN to enter the configuration interface, click "Configure Proxy", select "Manual" and then fill in the "Server" and "Port".
[0100] S220: Based on the certificate trust configuration instruction, configure the root certificate corresponding to the certificate file as a trusted certificate.
[0101] Here, after the mobile terminal obtains the certificate file of the corresponding server, it needs to install the corresponding certificate and configure it as a trusted certificate.
[0102] Optionally, send the server certificate file via WeChat or other communication tools, download and open it, verify your identity and install it, fill in the name of the certificate according to your needs, and select the purpose of the certificate as "VPN and Applications".
[0103] Optionally, on the server side, in the SSL proxy in Charles, select Install Charles Root Certificate on a Mobile Device or Remote Browser, then open a browser on the mobile side and access chls.pro / ssl through the browser to download the certificate.
[0104] Here, the downloaded certificate needs to be configured as a trusted certificate on the mobile terminal. Specifically, for Huawei phones, in Settings → Security → More security settings → Encryption and credentials → Install from storage, find the downloaded certificate file, click the certificate file, and install it after identity verification; for Xiaomi phones, in Settings, go to Encryption and credentials → Install certificate → Certificate, select the corresponding certificate file to install; for Apple phones, in Settings → Profiles and device management, click the certificate file to install, and after successful installation, check the certificate file in General → About this device → Certificate trust settings.
[0105] In addition, after the installation is complete, you can check whether the certificate installation on the mobile terminal is successful. Specifically, for Huawei phones, select "Trusted Credentials" in Settings → Security → More Security Settings → Encryption and Credentials, and switch to "User" to check whether the corresponding certificate is successfully installed; for Apple phones, you can check whether the corresponding certificate is successfully installed in Settings → General → About this device → Certificate Trust Settings.
[0106] It is understandable that the execution order of S210 and S220 is not limited, and S210 may be executed first and then S220, or S220 may be executed first and then S210, or S210 and S220 may be executed simultaneously.
[0107] S230: Based on user input, use the application to be tested to transmit data packets, and the network security configuration file of the application to be tested includes the certificate file.
[0108] In an optional embodiment, configuring the IP and port number of the network service based on the network proxy configuration instruction includes:
[0109] Based on the network proxy configuration instruction, the server host name of the wireless LAN to be configured is set to the IP, and the server port of the wireless LAN to be configured is set to the port number. The IP is the IP address of the server for data packet capture, and the port number is the port number of the server for Hypertext Transfer Protocol proxy.
[0110] Specifically, taking the above-mentioned data packet capture embodiment as an example, when configuring the proxy port number, the server sets the HTTP Proxy port number in ProxySettings to 8888. Here, the network of the mobile terminal needs to be configured with a port number of 8888.
[0111] For the IP address of the server, click SSL Proxying → Install Charles Root Certificate on a Mobile Device or Remote Browser on the server, and the pop-up prompt box will display the IP address of the server. For example, if the IP address is 192.168.2.17, the mobile terminal needs to configure the network server host name as 192.168.2.17. It is understandable that the way to obtain the IP address of the server is not limited to this method, and can also include but not limited to viewing it in the PC settings, querying it through the cmd command line, etc.
[0112] It should be noted that the wireless LAN used by the mobile terminal needs to be the same as the wireless LAN used by the server.
[0113] The data packet transmission method provided in the embodiment of the present application configures the mobile terminal and the server terminal on the same network, so that the mobile terminal requests services from the server terminal, thereby realizing the capture of data packets of the mobile terminal application on the server terminal, and realizing the joint debugging of the local development environment for real machine debugging without modifying the WebView to point to the local IP or development and testing environment.
[0114] In summary, the data packet transmission method provided by the present invention configures the IP and port number of the network service based on the network proxy configuration instruction, configures the root certificate corresponding to the certificate file as a trusted certificate based on the certificate trust configuration instruction, and uses the application to be tested for data packet transmission based on user input, and the network security configuration file of the application to be tested includes the certificate file. By configuring the certificate file of the server on the mobile terminal, the server can act as an intermediary between the mobile terminal application configured with the same root certificate and the target server, that is, disguised as the target server, establish a connection with the mobile terminal, and establish another connection with the target server, intercept the data packet sent by the mobile terminal application and disguise it as the mobile terminal sending a data packet to the target server, intercept the data packet returned by the target server and disguise it as the target server returning the data packet to the mobile terminal application, thereby intercepting the data packet between the mobile application and the target server, facilitating developers to view network requests and responses in real time, repeating the operation in the mobile terminal application to resend the network request, and resending the network request is simple, which is convenient for back-end developers to debug. In addition, it is also easy to simulate a weak network environment, build an abnormal test scenario, and facilitate the debugging and testing of mobile applications.
[0115] The data packet capturing device provided by the present invention is described below. The data packet capturing device described below and the data packet capturing method described above can be referenced to each other.
[0116] Figure 3 is a schematic diagram of the structure of the data packet capture device provided by the present invention, such as Figure 3 As shown, the data packet capture device comprises:
[0117] The certificate configuration module 310 is used to: configure a root certificate based on the certificate configuration instruction and add the root certificate to the trust store;
[0118] The proxy configuration module 320 is used to: configure the HTTP security protocol proxy based on the secure socket layer proxy instruction;
[0119] The data capture module 330 is used to capture the data packet of the mobile terminal application to be tested based on the HTTP security protocol proxy after receiving the data packet capture instruction.
[0120] It should be noted that the data packet capture device provided in the embodiment of the present invention can execute the data packet capture method described in any of the above embodiments during specific operation, which will not be elaborated in this embodiment.
[0121] The data packet transmission device provided by the present invention is described below. The data packet transmission device described below and the data packet transmission method described above can be referenced to each other.
[0122] Figure 4 Schematic diagram of the structure of the data packet transmission device provided by the present invention. Figure 4 As shown, the data packet transmission device comprises:
[0123] The network configuration module 410 is used to: configure the IP and port number of the network service based on the network proxy configuration instruction;
[0124] The certificate configuration module 420 is used to: configure the root certificate corresponding to the certificate file as a trusted certificate based on the certificate trust configuration instruction;
[0125] The data transmission module 430 is used to: based on user input, use the application to be tested to transmit data packets, and the network security configuration file of the application to be tested includes the certificate file.
[0126] It should be noted that the data packet transmission device provided in the embodiment of the present invention can execute the data packet transmission method described in any of the above embodiments during specific operation, which will not be described in detail in this embodiment.
[0127] Figure 5 is a schematic diagram of the structure of the electronic device provided by the present invention, such as Figure 5 As shown, the electronic device may include: a processor 510, a communication interface 520, a memory 530 and a communication bus 540, wherein the processor 510, the communication interface 520 and the memory 530 communicate with each other via the communication bus 540. The processor 510 may call the logic instructions in the memory 530 to execute the data packet capture method of any of the above embodiments, or execute the data packet transmission method of any of the above embodiments.
[0128] In addition, the logic instructions in the above-mentioned memory 530 can be implemented in the form of a software functional unit and can be stored in a computer-readable storage medium when it is sold or used as an independent product. Based on such an understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk, etc. Various media that can store program codes.
[0129] On the other hand, the present invention also provides a computer program product, which includes a computer program stored on a non-transitory computer-readable storage medium, and the computer program includes program instructions. When the program instructions are executed by a computer, the computer can execute the data packet capture method or data packet transmission method provided in the above-mentioned embodiments.
[0130] On the other hand, the present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which is implemented when the computer program is executed by a processor to execute the data packet capture method or data packet transmission method provided in the above-mentioned embodiments.
[0131] On the other hand, the present invention also provides a data packet capture system, which includes a first device and a second device: the first device uses the data packet capture method provided in the above embodiments to capture data packets; the second device uses the data packet transmission method provided in the above embodiments to transmit data packets.
[0132] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Ordinary technicians in this field can understand and implement it without paying creative labor.
[0133] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a necessary general hardware platform, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.
[0134] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.< / manifest> < / application>
Claims
1. A data packet capture method, characterized in that: include: The server configures the root certificate based on the certificate configuration instruction and adds the root certificate to the trust store; The server configures the HTTP security protocol proxy based on the secure socket layer proxy instruction to proxy the data request of the specified address and port; After receiving the data packet capture instruction, the server captures the data packet of the application to be tested on the mobile terminal based on the HTTP security protocol proxy; After receiving the data packet capture instruction, before capturing the data packet of the mobile terminal application to be tested based on the HTTP security protocol proxy, it also includes: After receiving the certificate storage instruction, the server exports the root certificate into a certificate file of a corresponding format based on the format parameters in the certificate storage instruction; The server adds the certificate file to the resource file of the application to be tested based on the user input, and generates a network security configuration file, wherein the network security configuration file includes debugging attribute configuration information, the debugging attribute configuration information indicates whether the application to be tested is debuggable, and the value of the debugging attribute configuration information in the network security configuration file indicates that the application to be tested is debuggable; The server adds the network security configuration file to the configuration of the application to be tested; The data packet capture method also includes: The server adds the IP address of the mobile terminal in the access control settings.
2. The data packet capture method according to claim 1, characterized in that: include: The mobile terminal configures the IP and port number of the network service based on the network proxy configuration instructions; The mobile terminal configures the root certificate corresponding to the certificate file as a trusted certificate based on the certificate trust configuration instruction; The mobile terminal transmits data packets using the application to be tested based on user input, and the network security configuration file of the application to be tested includes the certificate file.
3. The data packet capture method according to claim 2, characterized in that: The configuration of the IP and port number of the network service based on the network proxy configuration instruction includes: Based on the network proxy configuration instruction, the server host name of the wireless LAN to be configured is set to the IP, and the server port of the wireless LAN to be configured is set to the port number. The IP is the IP address of the server for data packet capture, and the port number is the port number of the server for Hypertext Transfer Protocol proxy.
4. A data packet capture device, characterized in that: The method for capturing data packets according to claim 1 includes: The certificate configuration module is used to: configure a root certificate based on the certificate configuration instruction and add the root certificate to the trust store; The proxy configuration module is used to: configure the HTTP security protocol proxy based on the secure socket layer proxy instruction to proxy the data request of the specified address; A data capture module is used to: after receiving a data packet capture instruction, based on the Hypertext Transfer Protocol Security agent, capture the data packet of the application to be tested on the mobile terminal; A security configuration module is used to: after receiving a certificate storage instruction, based on the format parameters in the certificate storage instruction, export the root certificate into a certificate file of a corresponding format; based on user input, add the certificate file to the resource file of the application to be tested, and generate a network security configuration file, wherein the network security configuration file contains debugging attribute configuration information, the debugging attribute configuration information indicates whether the application to be tested is debuggable, and the value of the debugging attribute configuration information in the network security configuration file indicates that the application to be tested is debuggable; and add the network security configuration file to the configuration of the application to be tested.
5. 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 computer program, the steps of the data packet capture method as claimed in claim 1 are implemented.
6. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the data packet capture method as claimed in claim 1 are implemented.
7. A data packet capture system, characterized in that: The first device and the second device include: The first device is a server device, which implements the execution steps of the server in the data packet capture method according to any one of claims 1 to 3; The second device is a mobile terminal device, which implements the execution steps of the mobile terminal in the data packet capture method as described in any one of claims 1-3.
Citation Information
Patent Citations
Packet capture supporting method, device and equipment, and medium
CN112398654A
