Data packet capture method, device, server and storage medium
By assigning IP addresses and writing data forwarding rules through the server and router, the network request data of the client device is forwarded to the packet capture device, which solves the problem of WiFi proxy being unable to capture packets and wasting resources in the existing technology, and realizes directional forwarding packet capture and Optimization of hardware resources.
Patent Information
- Application Number
- CN202310187502.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-02-21
- Publication Date
- 2024-09-27
- Estimated Expiration
- 2043-02-21
AI Technical Summary
Existing data packet capture methods require configuring a WiFi proxy on the customer device or using a dual-network card PC device with wireless functions, resulting in resource waste and packet capture failure.
The IP address is assigned by the server and the IP address of the packet capture device is assigned by the router. Data forwarding rules are written according to the MAC address of the customer device and the network request data of the customer device is forwarded to the packet capture device to achieve directional forwarding and capture of packets and avoid configuring WiFi proxy and Use a dual network card device.
It realizes the directional forwarding and packet capture of network request data of customer devices, solves the problem of WiFi proxy being unable to capture packets, and optimizes the utilization of hardware resources.
Smart Images

Figure CN116155862B
Abstract
Description
Technical Field
[0001] The embodiments of the present invention relate to the technical field of data packet capture, and in particular to a data packet capture method, device, server and storage medium. Background Art
[0002] With the rapid development and popularization of mobile phones, tablets and other client devices, the functions of mobile applications are becoming more and more abundant, and the network requests sent by mobile applications are becoming more and more frequent, and the resulting network security issues are becoming more and more serious. At the same time, data packet capture tools, as a network data monitoring program, can obtain the required information in a targeted manner, use this information to conduct network security analysis and network threat response, and play an important role in network security attack and defense.
[0003] Currently, there are two main ways to capture data packets: Method 1: By configuring a WiFi (Wireless Fidelity) proxy on the client device, the network request data of the network request application (such as Baidu, Sogou) can be captured. Method 2: By opening a hotspot on a PC (Personal Computer) device for the client device to connect, the network request data can be captured.
[0004] For method 1, when the online network request application detects that the user has configured a WiFi proxy, it may refuse to use the application due to security issues, or the underlying native network library does not use the WiFi proxy, and the network request data on the client device cannot be captured through the configured WiFi proxy. For method 2, this solution will cause a waste of device resources. For example, if a multi-person test team implements this method, each person needs to be equipped with a dual-network card device with wireless capabilities. Summary of the invention
[0005] In view of this, the embodiments of the present invention provide a data packet capture method, device, server and storage medium, which can realize the directional forwarding and packet capture of network request data of client devices, without the need to configure a WiFi agent on the client device, and also without the need for all testers to configure dual-network card PC devices with wireless functions to capture data. Therefore, the pain point of being unable to capture packets when configuring a WiFi agent is effectively solved, while optimizing the utilization of hardware resources.
[0006] In a first aspect, an embodiment of the present invention provides a data packet capture method, wherein the method is applied to a server, the server is connected to a client device via a network connector, and the server is also connected to a packet capture device via a router, and the method comprises:
[0007] Sending the first IP address assigned by the server to the client device through the network connector, and triggering the router to assign a second IP address to the packet capture device;
[0008] Obtaining a MAC address of the client device based on the first IP address;
[0009] Compile a first data forwarding rule according to the MAC address, the second IP address and the first port number of the packet capture device;
[0010] The network request data of the client device is forwarded to the packet capture device according to the first data forwarding rule, so as to trigger the packet capture device to perform data packet capture on the network request data.
[0011] In one possible implementation, the method further includes:
[0012] Searching whether a MAC address exists in an address allocation information table; wherein the address allocation information table stores a MAC address corresponding to a client device with historical communications;
[0013] When the MAC address does not exist in the address allocation information table, a second data forwarding rule is written based on the MAC address, the third IP address of the server, and the second port number;
[0014] In response to an opening operation for the network request application, receiving forwarded network request data through a designated port corresponding to the second port number based on a second data forwarding rule; and,
[0015] Sending the forwarding information filling data to the client device corresponding to the first IP address through the designated port, so as to display a filling interface for the forwarding information filling data on the display interface of the client device;
[0016] When the second IP address and the first port number of the packet capture device are correctly filled in the filling interface, the step of writing the first data forwarding rule according to the MAC address, the second IP address and the first port number of the packet capture device is performed.
[0017] In one possible implementation, the method further includes:
[0018] The second data forwarding rule is deleted.
[0019] In one possible implementation, the method further includes:
[0020] Sending the login data to the client device corresponding to the first IP address through the designated port, so as to display a login interface of the login data on a display interface of the client device;
[0021] When the correct login information is filled in on the login interface, the step of sending the filled-in data of the forwarding information to the client device is executed.
[0022] In one possible implementation, the method further includes:
[0023] When there is a MAC address in the address allocation information table, a step is performed to forward the network request data of the client device to the packet capture device according to the first data forwarding rule to trigger the packet capture device to capture the network request data.
[0024] In a possible implementation, a first data forwarding rule is compiled according to the MAC address, the second IP address and the first port number of the packet capture device, including:
[0025] The MAC address is used as the original address of the network request data, and the second IP address and the first port number of the packet capture device are used as the forwarding address of the network request data.
[0026] In a possible implementation, the second data forwarding rule is written based on the MAC address, the third IP address of the server, and the second port number, including:
[0027] The MAC address is used as the original address of the network request data, and the third IP address and the second port number of the server are used as the forwarding address of the network request data.
[0028] In a second aspect, an embodiment of the present invention provides a data packet capture device, wherein the device is applied to a server, a server network connector is connected to a client device, and the server is also connected to the packet capture device through a router, and the device includes:
[0029] an allocation module, used to send the first IP address allocated by the server to the client device through the network connector, and trigger the router to allocate the second IP address to the packet capture device;
[0030] An acquisition module, used to acquire a MAC address of a client device based on the first IP address;
[0031] A writing module, used for writing a first data forwarding rule according to the MAC address, the second IP address and the first port number of the packet capture device;
[0032] The forwarding module is used to forward the network request data of the client device to the packet capture device according to the first data forwarding rule, so as to trigger the packet capture device to perform data packet capture on the network request data.
[0033] In a third aspect, an embodiment of the present invention provides a server, which includes: a processor and a memory, and the processor is used to execute a data packet capture program stored in the memory to implement the above-mentioned data packet capture method.
[0034] In a fourth aspect, an embodiment of the present invention provides a storage medium, wherein the storage medium stores one or more programs, and the one or more programs can be executed by one or more processors to implement the above-mentioned data capture method.
[0035] The data packet capture method, device, server and storage medium provided by the embodiment of the present invention include sending the first IP address assigned by the server to the client device through the network connector, and triggering the router to assign the second IP address to the packet capture device; obtaining the MAC address of the client device based on the first IP address; writing the first data forwarding rule according to the MAC address, the second IP address and the first port number of the packet capture device; forwarding the network request data of the client device to the packet capture device according to the first data forwarding rule, so as to trigger the packet capture device to perform data packet capture on the network request data. Based on the data forwarding rule, the present invention can forward all the network request data of the client device to the packet capture device to realize the packet capture of the network request data, realize the directional forwarding packet capture of the network request data of the client device, and does not need to configure the WiFi agent on the client device, and does not need all the testers to configure the dual network card PC device with wireless function to capture data, therefore, effectively solves the pain point that the WiFi agent cannot capture packets, and optimizes the hardware resource utilization at the same time. BRIEF DESCRIPTION OF THE DRAWINGS
[0036] Figure 1 A schematic diagram of an application scenario of a data packet capture method provided by an embodiment of the present invention;
[0037] Figure 2 A flow chart of an embodiment of a data packet capture method provided by an embodiment of the present invention;
[0038] Figure 3 A flow chart of another embodiment of a data packet capture method provided by an embodiment of the present invention;
[0039] Figure 4 A block diagram of an embodiment of a data packet capture device provided by an embodiment of the present invention;
[0040] Figure 5 A schematic diagram of the structure of a server provided in an embodiment of the present invention. DETAILED DESCRIPTION
[0041] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments 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.
[0042] To facilitate understanding of the embodiments of the present invention, specific embodiments will be further explained below in conjunction with the accompanying drawings. The embodiments do not constitute a limitation on the embodiments of the present invention.
[0043] To facilitate understanding of this embodiment, the following first describes in detail the data packet capture method provided by the embodiment of the present invention. Figure 1 The figure shows an example of an application scenario diagram of the data packet capture method. The server 100 is connected to the client device 102 via a network connector 101. The server 100 is also connected to the packet capture device 104 via a router 103. In actual use, the network connector can be connected to multiple client devices to achieve data packet capture for multiple client devices. Similarly, the router can be connected to multiple packet capture devices to achieve sending the network request data of the client device to one or more packet capture devices for data packet capture. For the convenience of explanation, Figure 1 Only three client devices and three packet capture devices are shown as an example.
[0044] In actual use, the client device can be a mobile device such as a mobile phone or a tablet, the packet capture device can be an electronic device such as a desktop computer or a laptop, and the network connector can be a network communication device such as a wireless switch, a hub, or a network card on a server, which are not limited here.
[0045] In actual use, in order to forward the network request data of the client device to the packet capture device for data capture, the client device and the packet capture device need to be in different network environments, such as Figure 1 As shown in the figure, the left side of the dotted line is the local area network 1 formed by connecting the server to the client device through a network connector, and the right side of the dotted line is the local area network 2 formed by connecting the server to the packet capture device through a router. Figure 1 As shown, the IP address of LAN 1 is 192.168.0.1, and the IP address of LAN 2 is 10.10.1.2. In actual use, the IP addresses of LAN 1 and LAN 2 can be set according to actual needs and are not limited here.
[0046] The following will introduce a data packet capture method in detail in conjunction with the scenario structure diagram. Figure 2 , is a flow chart of an embodiment of a data packet capture method provided by an embodiment of the present invention. Figure 2 As shown, the process may include the following steps:
[0047] Step 201, sending the first IP address assigned by the server to the client device through the network connector, and triggering the router to assign a second IP address to the packet capture device;
[0048] In this embodiment, the server is pre-deployed with the DHCP (Dynamic Host Configuration Protocol) protocol, which allows the server to assign a dynamic first IP address or a static first IP address to the client device. The first IP address assigned by the server is assigned one by one to the corresponding client device through the network connector. The first IP address is a unified address format provided by the IP protocol, which assigns a logical address to each network and each device on the Internet to shield the difference in physical addresses.
[0049] In actual use, in addition to using a router to dynamically allocate a second IP address to the packet capture device, the packet capture device can also statically allocate a second IP address to it. The method of allocating the second IP address to the packet capture device is not limited here.
[0050] like Figure 1 An example of an IP address is shown in Figure 1 As shown, the first IP addresses assigned by the server to the three client devices are: 192.168.0.2, 192.168.0.3, 192.168.0.4, and the second IP addresses assigned by the router to the three packet capture devices are: 10.10.1.3, 10.10.1.4, 10.10.1.5. In actual use, the first IP address assigned by the server to the client device and the second IP address assigned by the router to the packet capture device can be other IP addresses, which are not limited here.
[0051] Step 202, obtaining a MAC address of the client device based on the first IP address;
[0052] For a client device that needs to capture packets, the server can obtain a first IP address corresponding to the client device, and then obtain a MAC (Media Access Control Address) address of the client device according to the first IP address through an ARP (Address Resolution Protocol) protocol.
[0053] Step 203, compile a first data forwarding rule according to the MAC address, the second IP address and the first port number of the packet capture device;
[0054] The content of the first data forwarding rule is specifically: using the MAC address as the original address of the network request data, and using the second IP address and the first port number of the packet capture device as the forwarding address of the network request data. The purpose of the first data forwarding rule is to forward all network request data of the MAC address to the packet capture device with the second IP address and the first port number, wherein the first port number is the port number of the port on the packet capture device that receives the network request data, and can be used to uniquely identify the port.
[0055] In actual use, when the client device is disconnected from the server and then reconnects to the server, the first IP address assigned by the server may be different from the first IP address assigned during the previous connection, but the MAC address of a client device will not change whether the network is disconnected or connected. Therefore, using the MAC address as the original address of the network request data is to enable all network request data on the client device with the MAC address to be forwarded to the corresponding packet capture device.
[0056] Step 204: forward the network request data of the client device to the packet capture device according to the first data forwarding rule, so as to trigger the packet capture device to perform data capture on the network request data.
[0057] The packet capture device can use existing packet capture tools to capture network request data, so as to facilitate the subsequent use of the captured data for network security analysis and network threat response. Among them, using the packet capture tool to capture network request data is an existing technology and will not be described in detail here.
[0058] The data packet capture method provided by the embodiment of the present invention includes sending the first IP address assigned by the server to the client device through the network connector, and triggering the router to assign the second IP address to the packet capture device; obtaining the MAC address of the client device based on the first IP address; writing a first data forwarding rule according to the MAC address, the second IP address and the first port number of the packet capture device; forwarding the network request data of the client device to the packet capture device according to the first data forwarding rule, so as to trigger the packet capture device to perform data packet capture on the network request data. Based on the data forwarding rule, the present invention can forward all the network request data of the client device to the packet capture device to realize the packet capture of the network request data, realize the directional forwarding packet capture of the network request data of the client device, and does not need to configure the WiFi agent on the client device, and does not need all the testers to configure the dual network card PC device with wireless function to capture data, therefore, effectively solves the pain point that the WiFi agent cannot capture packets, and optimizes the hardware resource utilization at the same time.
[0059] See also Figure 3 , is a flow chart of another embodiment of a data packet capture method provided by an embodiment of the present invention. Figure 3 The process shown in the above Figure 2 It is implemented based on the process shown in the figure. Figure 3 As shown, the process may include the following steps:
[0060] Step 301, sending the first IP address assigned by the server to the client device through the network connector, and triggering the router to assign a second IP address to the packet capture device;
[0061] Step 302, obtaining a MAC address of the client device based on the first IP address;
[0062] The process of steps 301-302 in this embodiment can refer to the process of steps 201-202 above, and will not be described in detail here.
[0063] Step 303, searching the address allocation information table to see if the MAC address exists;
[0064] Among them, the address allocation information table stores the MAC address corresponding to the client device with historical communication, that is, not the first time communicating with the server; in this embodiment, if the client device is connected to the server for communication for the first time, the address allocation information table does not have the MAC address of the client device; if the client device is not the first time connecting to the server for communication, the address allocation information table stores the MAC address of the client device; therefore, the MAC address corresponding to the client device that is not the first time connecting to the server can be found from the address allocation information table.
[0065] If the MAC address does not exist in the address allocation information table, execute step 304. If the MAC address exists in the address allocation information table, it means that this is not the first time that the client device is connected to the server for communication. Therefore, the user does not need to fill in the second IP address and the first port number of the packet capture device again, and step 308 can be executed.
[0066] Step 304, compile a second data forwarding rule based on the MAC address, the third IP address of the server, and the second port number;
[0067] Since the MAC address corresponding to the client device does not exist in the address allocation information table, it means that the client device is connecting to the server for communication for the first time. Therefore, the user of the client device needs to fill in the second IP address and the first port number of the packet capture device to realize the directed forwarding of the network request data of the client device to the packet capture device, that is, step 304 needs to be executed.
[0068] The content of the above second data forwarding rule is specifically: use the MAC address as the original address of the network request data, and use the third IP address and the second port number of the server as the forwarding address of the network request data. The purpose of the second data forwarding rule is to forward all network request data of the MAC address to the server with the third IP address and the second port number, wherein the second port number is the port number of the designated port on the server for receiving network request data, which can be used to uniquely identify the designated port. Preferably, the designated port is port 80, and the second port number is 80.
[0069] Step 305, in response to an opening operation for the network request application, receiving the forwarded network request data through a designated port corresponding to the second port number based on a second data forwarding rule;
[0070] When the user opens the network request application, the network request data of the client device is directly forwarded to the server based on the second data forwarding rule.
[0071] Step 306, sending the forwarding information filling data to the client device corresponding to the first IP address through the designated port, so that a filling interface for the forwarding information filling data is displayed on a display interface of the client device;
[0072] After the user opens the network request application, the forwarding information filling data is sent to the client device corresponding to the first IP address through the designated port, so that the filling interface of the forwarding information filling data is displayed on the display interface of the client device, so that the user can fill in the second IP address and the first port number of the packet capture device to which the network request data is to be directed and forwarded on the filling interface. In specific implementation, in response to the opening operation of the network request application, sending the forwarding information filling data to the client device and forwarding the network request data to the server can be performed simultaneously or sequentially, so step 306 and step 305 do not distinguish the execution order.
[0073] For security reasons, there is usually a user security login operation before sending the forwarding information to the client device to fill in the data, that is, sending the login data to the client device corresponding to the first IP address through the designated port to display the login interface of the client device; only when the correct login information is filled in on the login interface, the step of sending the forwarding information to the client device to fill in the data is executed.
[0074] The login information is the user's personal account password and other personal information. In actual use, the user security login operation may not be performed, and the forwarding information filling data may be directly sent to the customer device. Whether to set up a secure login may be determined based on actual needs.
[0075] Step 307, when the second IP address and the first port number of the packet capture device are correctly filled in the filling interface, a first data forwarding rule is written according to the MAC address, the second IP address and the first port number of the packet capture device;
[0076] If the IP address and port number filled in by the user in the filling-in interface are inconsistent with the second IP address assigned by the server to the packet capture device and / or the first port number of the port connected between the packet capture device and the server, it is deemed to be incorrectly filled in and the network request data cannot be forwarded to the packet capture device; only when the IP address and port number filled in by the user are consistent with the second IP address assigned by the server to the packet capture device and the first port number of the port connected between the packet capture device and the server, the first data forwarding rule is written and the second data forwarding rule is deleted, so that the network request data forwarded to the server can be redirected and forwarded to the packet capture device corresponding to the second IP address and the first port number, so as to avoid network request data forwarding errors when multiple data forwarding rules exist.
[0077] Step 308: forward the network request data of the client device to the packet capture device according to the first data forwarding rule, so as to trigger the packet capture device to perform data capture on the network request data.
[0078] like Figure 1 As shown, the router 103 is also connected to the network server 105. In actual use, the client device 103 sends network request data to the network server 105 through the server 100 and the router 103, so that the network server 105 sends network response data corresponding to the network request data to the client device 103, so that the client device 103 can perform network communication.
[0079] See also Figure 4 , is a block diagram of an embodiment of a data packet capture device provided by an embodiment of the present invention, wherein the device is applied to a server, the server is connected to a client device 102 via a network connector 101, and the server is also connected to a packet capture device 104 via a router 103, such as Figure 4 As shown, the device may include:
[0080] The allocation module 401 is used to send the first IP address allocated by the server to the client device through the network connector, and trigger the router to allocate the second IP address to the packet capture device;
[0081] An acquisition module 402 is used to acquire a MAC address of a client device based on the first IP address;
[0082] A writing module 403 is used to write a first data forwarding rule according to the MAC address, the second IP address and the first port number of the packet capture device;
[0083] The forwarding module 404 is used to forward the network request data of the client device to the packet capture device according to the first data forwarding rule, so as to trigger the packet capture device to perform data capture on the network request data.
[0084] The data packet capture device provided by the embodiment of the present invention includes sending the first IP address assigned by the server to the client device through the network connector, and triggering the router to assign the second IP address to the packet capture device; obtaining the MAC address of the client device based on the first IP address; writing a first data forwarding rule according to the MAC address, the second IP address and the first port number of the packet capture device; forwarding the network request data of the client device to the packet capture device according to the first data forwarding rule, so as to trigger the packet capture device to perform data packet capture on the network request data. Based on the data forwarding rule, the present invention can forward all the network request data of the client device to the packet capture device to realize the packet capture of the network request data, realize the directional forwarding packet capture of the network request data of the client device, and does not need to configure the WiFi agent on the client device, and does not need all the testers to configure the dual network card PC device with wireless function to capture data, therefore, effectively solves the pain point that the WiFi agent cannot capture packets, and optimizes the hardware resource utilization at the same time.
[0085] Figure 5 A schematic diagram of the structure of a server provided in an embodiment of the present invention, Figure 5 The server 500 shown includes: at least one processor 501, a memory 502, at least one network interface 504 and other user interfaces 503. The various components in the server 500 are coupled together via a bus system 505. It is understood that the bus system 505 is used to achieve connection and communication between these components. In addition to the data bus, the bus system 505 also includes a power bus, a control bus and a status signal bus. However, for the sake of clarity, the bus system 505 is not described in detail. Figure 5 Various buses are labeled as bus system 505 .
[0086] The user interface 503 may include a display, a keyboard, or a pointing device (eg, a mouse, a trackball, a touch pad, or a touch screen).
[0087] It can be understood that the memory 502 in the embodiment of the present invention can be a volatile memory or a non-volatile memory, or can include both volatile and non-volatile memories. Among them, the non-volatile memory can be a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), or a flash memory. The volatile memory can be a random access memory (RAM), which is used as an external cache. By way of example but not limitation, many forms of RAM are available, such as static random access memory (SRAM), dynamic random access memory (DRAM), synchronous dynamic random access memory (SDRAM), double data rate synchronous dynamic random access memory (DDRSDRAM), enhanced synchronous dynamic random access memory (ESDRAM), synchronous link dynamic random access memory (SLDRAM) and direct RAM bus random access memory (DRRAM). The memory 502 described herein is intended to include, but is not limited to, these and any other suitable types of memory.
[0088] In some implementations, the memory 502 stores the following elements, executable units or data structures, or a subset thereof, or an extended set thereof: an operating system 5021 and an application program 5022 .
[0089] The operating system 5021 includes various system programs, such as a framework layer, a core library layer, a driver layer, etc., which are used to implement various basic services and process hardware-based tasks. The application 5022 includes various application programs, such as a media player (Media Player), a browser (Browser), etc., which are used to implement various application services. The program for implementing the method of the embodiment of the present invention can be included in the application 5022.
[0090] In the embodiment of the present invention, by calling the program or instruction stored in the memory 502, specifically, the program or instruction stored in the application 5022, the processor 501 is used to execute the method steps provided by each method embodiment, for example, including:
[0091] Sending the first IP address assigned by the server to the client device through the network connector, and triggering the router to assign a second IP address to the packet capture device;
[0092] Obtaining a MAC address of the client device based on the first IP address;
[0093] Compile a first data forwarding rule according to the MAC address, the second IP address and the first port number of the packet capture device;
[0094] The network request data of the client device is forwarded to the packet capture device according to the first data forwarding rule, so as to trigger the packet capture device to perform data packet capture on the network request data.
[0095] In one possible implementation, the method further includes:
[0096] Searching whether a MAC address exists in an address allocation information table; wherein the address allocation information table stores a MAC address corresponding to a client device with historical communications;
[0097] When the MAC address does not exist in the address allocation information table, a second data forwarding rule is written based on the MAC address, the third IP address of the server, and the second port number;
[0098] In response to an opening operation for a network request application, receiving forwarded network request data to a designated port through a designated port corresponding to a second port number based on a second data forwarding rule; and,
[0099] Sending the forwarding information filling data to the client device corresponding to the first IP address through the designated port, so as to display a filling interface for the forwarding information filling data on the display interface of the client device;
[0100] When the second IP address and the first port number of the packet capture device are correctly filled in the filling interface, the step of writing the first data forwarding rule according to the MAC address, the second IP address and the first port number of the packet capture device is performed.
[0101] In one possible implementation, the method further includes:
[0102] The second data forwarding rule is deleted.
[0103] In one possible implementation, the method further includes:
[0104] Sending the login data to the client device corresponding to the first IP address through the designated port, so as to display a login interface of the login data on a display interface of the client device;
[0105] When the correct login information is filled in on the login interface, the step of sending the filled-in data of the forwarding information to the client device is executed.
[0106] In one possible implementation, the method further includes:
[0107] When there is a MAC address in the address allocation information table, a step is performed to forward the network request data of the client device to the packet capture device according to the first data forwarding rule to trigger the packet capture device to capture the network request data.
[0108] In a possible implementation, a first data forwarding rule is compiled according to the MAC address, the second IP address and the first port number of the packet capture device, including:
[0109] The MAC address is used as the original address of the network request data, and the second IP address and the first port number of the packet capture device are used as the forwarding address of the network request data.
[0110] In a possible implementation, the second data forwarding rule is written based on the MAC address, the third IP address of the server, and the second port number, including:
[0111] The MAC address is used as the original address of the network request data, and the third IP address and the second port number of the server are used as the forwarding address of the network request data.
[0112] The method disclosed in the above embodiment of the present invention can be applied to the processor 501, or implemented by the processor 501. The processor 501 may be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the above method can be completed by the hardware integrated logic circuit in the processor 501 or the instruction in the form of software. The above processor 501 can be a general processor, a digital signal processor (Digital Signal Processor, DSP), an application specific integrated circuit (Application Specific Integrated Circuit, ASIC), a field programmable gate array (Field Programmable Gate Array, FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components. The methods, steps and logic block diagrams disclosed in the embodiments of the present invention can be implemented or executed. The general processor can be a microprocessor or the processor can also be any conventional processor, etc. The steps of the method disclosed in the embodiment of the present invention can be directly embodied as a hardware decoding processor to execute, or the hardware and software units in the decoding processor can be executed. The software unit can be located in a mature storage medium in the field such as a random access memory, a flash memory, a read-only memory, a programmable read-only memory or an electrically erasable programmable memory, a register, etc. The storage medium is located in the memory 502, and the processor 501 reads the information in the memory 502 and completes the steps of the above method in combination with its hardware.
[0113] It is understood that the embodiments described herein may be implemented in hardware, software, firmware, middleware, microcode, or a combination thereof. For hardware implementation, the processing unit may be implemented in one or more application specific integrated circuits (ASIC), digital signal processors (DSP), digital signal processing devices (DSPDevice, DSPD), programmable logic devices (PLD), field programmable gate arrays (FPGA), general purpose processors, controllers, microcontrollers, microprocessors, other electronic units for performing the functions described in the present application, or a combination thereof.
[0114] For software implementation, the technology described herein can be implemented by a unit that performs the functions described herein. The software code can be stored in a memory and executed by a processor. The memory can be implemented in the processor or outside the processor.
[0115] The server provided in this embodiment may be Figure 5 The server shown in , can execute Figure 2-3 All steps of the data capture method in the Figure 2-3 The technical effect of the data capture method shown is shown in the figure. For details, please refer to Figure 2-3 For the sake of brevity, the relevant description is not repeated here.
[0116] The embodiment of the present invention also provides a storage medium (computer-readable storage medium). The storage medium here stores one or more programs. The storage medium may include a volatile memory, such as a random access memory; the memory may also include a non-volatile memory, such as a read-only memory, a flash memory, a hard disk or a solid-state drive; the memory may also include a combination of the above-mentioned types of memory.
[0117] When one or more programs in the storage medium can be executed by one or more processors, the above-mentioned data packet capture method can be implemented.
[0118] The processor is used to execute the data packet capture program stored in the memory to implement the steps of the data packet capture method:
[0119] Sending the first IP address assigned by the server to the client device through the network connector, and triggering the router to assign a second IP address to the packet capture device;
[0120] Obtaining a MAC address of the client device based on the first IP address;
[0121] Compile a first data forwarding rule according to the MAC address, the second IP address and the first port number of the packet capture device;
[0122] The network request data of the client device is forwarded to the packet capture device according to the first data forwarding rule, so as to trigger the packet capture device to perform data packet capture on the network request data.
[0123] In one possible implementation, the method further includes:
[0124] Searching whether a MAC address exists in an address allocation information table; wherein the address allocation information table stores a MAC address corresponding to a client device with historical communications;
[0125] When the MAC address does not exist in the address allocation information table, a second data forwarding rule is written based on the MAC address, the third IP address of the server, and the second port number;
[0126] In response to an opening operation for the network request application, receiving forwarded network request data through a designated port corresponding to the second port number based on a second data forwarding rule; and,
[0127] Sending the forwarding information filling data to the client device corresponding to the first IP address through the designated port, so as to display a filling interface for the forwarding information filling data on the display interface of the client device;
[0128] When the second IP address and the first port number of the packet capture device are correctly filled in the filling interface, the step of writing the first data forwarding rule according to the MAC address, the second IP address and the first port number of the packet capture device is performed.
[0129] In one possible implementation, the method further includes:
[0130] The second data forwarding rule is deleted.
[0131] In one possible implementation, the method further includes:
[0132] Sending the login data to the client device corresponding to the first IP address through the designated port, so as to display a login interface of the login data on a display interface of the client device;
[0133] When the correct login information is filled in on the login interface, the step of sending the filled-in data of the forwarding information to the client device is executed.
[0134] In one possible implementation, the method further includes:
[0135] When there is a MAC address in the address allocation information table, a step is performed to forward the network request data of the client device to the packet capture device according to the first data forwarding rule to trigger the packet capture device to capture the network request data.
[0136] In a possible implementation, a first data forwarding rule is compiled according to the MAC address, the second IP address and the first port number of the packet capture device, including:
[0137] The MAC address is used as the original address of the network request data, and the second IP address and the first port number of the packet capture device are used as the forwarding address of the network request data.
[0138] In a possible implementation, the second data forwarding rule is written based on the MAC address, the third IP address of the server, and the second port number, including:
[0139] The MAC address is used as the original address of the network request data, and the third IP address and the second port number of the server are used as the forwarding address of the network request data.
[0140] The professionals should further realize that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented by electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in the above description according to the function. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professionals and technicians can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the present invention.
[0141] The steps of the method or algorithm described in conjunction with the embodiments disclosed herein may be implemented using hardware, a software module executed by a processor, or a combination of the two. The software module may be placed in a random access memory (RAM), a memory, a read-only memory (ROM), an electrically programmable ROM, an electrically erasable programmable ROM, a register, a hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.
[0142] The specific implementation methods described above further illustrate the objectives, technical solutions and beneficial effects of the present invention in detail. It should be understood that the above description is only a specific implementation method of the present invention and is not intended to limit the scope of protection of the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present invention should be included in the scope of protection of the present invention.
Claims
1. A data packet capture method, characterized in that: The method is applied to a server, the server is connected to a client device via a network connector, and the server is also connected to a packet capture device via a router, and the method comprises: Sending the first IP address assigned by the server to the client device through the network connector, and triggering the router to assign a second IP address to the packet capture device; Acquire a MAC address of the client device based on the first IP address; Compile a first data forwarding rule according to the MAC address, the second IP address and the first port number of the packet capture device; Forwarding the network request data of the client device to the packet capture device according to the first data forwarding rule, so as to trigger the packet capture device to perform data packet capture on the network request data; The method also includes: searching from an address allocation information table whether the MAC address exists; wherein the address allocation information table stores the MAC address corresponding to the client device of historical communication; in the case that the MAC address does not exist in the address allocation information table, writing a second data forwarding rule based on the MAC address, and the third IP address and the second port number of the server; in response to an open operation for a network request application, receiving the forwarded network request data through a designated port corresponding to the second port number based on the second data forwarding rule; and, sending forwarding information filling data to the client device corresponding to the first IP address through the designated port, so as to display a filling interface for the forwarding information filling data on the display interface of the client device; in the case that the second IP address and the first port number of the packet capture device are correctly filled in on the filling interface, executing the step of writing a first data forwarding rule based on the MAC address, and the second IP address and the first port number of the packet capture device.
2. The method according to claim 1, characterized in that The method further comprises: The second data forwarding rule is deleted.
3. The method according to claim 1, characterized in that The method further comprises: Sending login data to the client device corresponding to the first IP address through the designated port, so as to display a login interface of the login data on a display interface of the client device; When correct login information is filled in on the login interface, a step of sending the forwarding information filled in data to the client device is performed.
4. The method according to claim 1, characterized in that: The method further comprises: When the MAC address exists in the address allocation information table, a step is performed to forward the network request data of the client device to the packet capture device according to the first data forwarding rule to trigger the packet capture device to capture the network request data.
5. The method according to claim 1, characterized in that The step of writing a first data forwarding rule according to the MAC address, the second IP address and the first port number of the packet capture device includes: The MAC address is used as the original address of the network request data, and the second IP address and the first port number of the packet capture device are used as the forwarding address of the network request data.
6. The method according to claim 1, characterized in that The second data forwarding rule is written based on the MAC address, the third IP address and the second port number of the server, including: The MAC address is used as the original address of the network request data, and the third IP address and the second port number of the server are used as the forwarding address of the network request data.
7. A data packet capture device, characterized in that: The device is applied to a server, the server is connected to a client device via a network connector, and the server is also connected to a packet capture device via a router. The device comprises: an allocation module, configured to send the first IP address allocated by the server to the client device through the network connector, and trigger the router to allocate a second IP address to the packet capture device; An acquisition module, configured to acquire a MAC address of the client device based on the first IP address; A writing module, used for writing a first data forwarding rule according to the MAC address, and the second IP address and the first port number of the packet capture device; a forwarding module, configured to forward the network request data of the client device to the packet capture device according to the first data forwarding rule, so as to trigger the packet capture device to perform data packet capture on the network request data; The device is also used to search for the existence of the MAC address in the address allocation information table; wherein the address allocation information table stores the MAC address corresponding to the client device of the historical communication; in the case that the MAC address does not exist in the address allocation information table, a second data forwarding rule is written based on the MAC address, and the third IP address and the second port number of the server; in response to the opening operation of the network request application, the forwarded network request data is received through the designated port corresponding to the second port number based on the second data forwarding rule; and, forwarding information filling data is sent to the client device corresponding to the first IP address through the designated port, so as to display the filling interface of the forwarding information filling data on the display interface of the client device; in the case that the second IP address and the first port number of the packet capture device are correctly filled in on the filling interface, the step of writing the first data forwarding rule according to the MAC address, and the second IP address and the first port number of the packet capture device is executed.
8. A server, characterized in that: include: A processor and a memory, wherein the processor is used to execute a data packet capture program stored in the memory to implement the data packet capture method according to any one of claims 1 to 6.
9. A storage medium, characterized in that: The storage medium stores one or more programs, and the one or more programs can be executed by one or more processors to implement the data packet capture method according to any one of claims 1 to 6.
