Data acquisition method and device, terminal equipment and storage medium
By injecting hook functions into the target process to obtain Protobuf protocol files and data, the problem of cumbersome and inefficient access to Protobuf data in the existing technology is solved, and an automated and simplified data acquisition process is realized.
Patent Information
- Application Number
- CN202410937043.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-12
- Publication Date
- 2024-11-15
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
In the fields of software reverse engineering, security monitoring and data traffic analysis, when obtaining Protobuf protocol files and Protobuf data, the existing technology requires packet capture through network communication, which is cumbersome and inefficient.
By finding the function location of the hook function in the target process and injecting the hook function into the target process, we obtain the proto protocol file and Protobuf data.
It realizes automatic acquisition of proto protocol files and Protobuf data, which is simple to operate and efficient, avoiding the tedious process of manual analysis.
Smart Images

Figure CN118963827A_ABST
Abstract
Description
Technical Field
[0001] The present application belongs to the field of data processing technology, and in particular, relates to a data acquisition method, device, terminal equipment and storage medium. Background Art
[0002] In the fields of software reverse engineering, security monitoring, and data flow analysis, it is often necessary to obtain Protobuf protocol files and Protobuf data. In related technologies, it is necessary to capture packets through network communication and manually perform data analysis to obtain Protobuf protocol files and Protobuf data, which is cumbersome and inefficient. Summary of the invention
[0003] The embodiments of the present application provide a data acquisition method, apparatus, terminal device and storage medium, which can solve the problem of cumbersome operation and low acquisition efficiency when acquiring Protobuf protocol files and Protobuf data in the related art.
[0004] In a first aspect, an embodiment of the present application provides a method for acquiring data, including:
[0005] According to the target process, find the function location of the hook function;
[0006] Injecting the hook function into the target process according to the function position;
[0007] Get the proto protocol file through the hook function;
[0008] Protobuf data is obtained through the hook function.
[0009] In a second aspect, an embodiment of the present application provides a data acquisition device, including:
[0010] The search module is used to find the function location of the hook function according to the target process;
[0011] An injection module, used for injecting the hook function into the target process according to the function position;
[0012] A first acquisition module is used to obtain a proto protocol file through the hook function;
[0013] The second acquisition module is used to obtain Protobuf data through the hook function.
[0014] In a third aspect, an embodiment of the present application provides a terminal device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the above-mentioned data acquisition method when executing the computer program.
[0015] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the above-mentioned data acquisition method are implemented.
[0016] In a fifth aspect, an embodiment of the present application provides a computer program product, which, when executed on a terminal device, enables the terminal device to execute the above-mentioned method for acquiring data.
[0017] Compared with the prior art, the embodiment of the present application has the following beneficial effects: the embodiment of the present application searches for the function position of the hook function according to the target process, obtains the hook function according to the function position, obtains the proto protocol file through the hook function, and obtains the Protobuf data through the hook function. The embodiment of the present application can automatically obtain the proto protocol file and the Protobuf data, and the operation is simple and the acquisition efficiency is high. BRIEF DESCRIPTION OF THE DRAWINGS
[0018] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.
[0019] Figure 1 It is a schematic diagram of the implementation flow of a method for acquiring data provided in an embodiment of the present application;
[0020] Figure 2 It is a structural schematic diagram of a data acquisition device provided in an embodiment of the present application;
[0021] Figure 3 It is a schematic diagram of the structure of the terminal device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0022] In order to make the purpose, technical solutions and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not intended to limit the present application. Based on the embodiments of the present application, all other embodiments obtained by those skilled in the art without making creative work are protected by the present application.
[0023] It should be noted that the terms "include", "comprises" and "have" and any variations thereof in the specification and claims of the present application and the above-mentioned drawings are intended to cover non-exclusive inclusions. For example, a process, method, terminal, product or device that includes a series of steps or units is not limited to the listed steps or units, but may optionally include steps or units that are not listed, or may optionally include other steps or units that are inherent to these processes, methods, products or devices. In the claims, specification and drawings of the present application, relational terms such as "first" and "second" are merely used to distinguish one entity / operation / object from another entity / operation / object, and do not necessarily require or imply any such real-time relationship or order between these entities / operations / objects.
[0024] Reference to "embodiments" herein means that a particular feature, structure, or characteristic described in conjunction with the embodiments may be included in at least one embodiment of the present application. The appearance of the phrase in various locations in the specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment that is mutually exclusive with other embodiments. It is explicitly and implicitly understood by those skilled in the art that the embodiments described herein may be combined with other embodiments.
[0025] In the fields of software reverse engineering, security monitoring, and data flow analysis, it is often necessary to obtain Protobuf protocol files and Protobuf data. In related technologies, it is necessary to capture packets through network communication and manually perform data analysis to obtain Protobuf protocol files and Protobuf data, which is cumbersome and inefficient.
[0026] In view of this, the embodiment of the present application can automatically obtain the proto protocol file and Protobuf data, with simple operation and high acquisition efficiency.
[0027] In order to illustrate the technical solution of the present application, a specific embodiment is provided below for illustration.
[0028] Figure 1 The present invention provides a data acquisition method according to an embodiment of the present invention, which can be applied to a terminal device, such as a mobile phone, a tablet computer, a notebook computer, an ultra-mobile personal computer (UMPC), a netbook, etc.
[0029] Specifically, the method for acquiring the above data may include the following steps S101 to S104.
[0030] Step S101, searching for the function location of the hook function according to the target process.
[0031] In the implementation mode of the present application, the terminal device can determine the Protobuf library and its version being used by the target process by analyzing the memory image or debugging information of the target process. And according to the implementation details of the Protobuf library, select a suitable function as the hook point. By reading the symbol table of the target process or using a debugging tool, search for the address of the hook function in the memory image of the target process.
[0032] Step S102, injecting the hook function into the target process according to the function position.
[0033] In the implementation mode of the present application, after determining the function location of the hook function, the terminal device can write the hook code and inject the hook code at the function location. Specifically, the terminal device can modify the function instructions or insert jump instructions into the custom hook processing function to write code to intercept and modify the execution of the target function, and use appropriate techniques (such as memory patching, DLL injection, etc.) to inject the hook code into the target process.
[0034] Step S103, obtaining the proto protocol file through the hook function.
[0035] Among them, the proto protocol file can be used to define the structure of the Protobuf message. The proto protocol file is a text file that contains the data structure definition used to generate code.
[0036] In an implementation manner of the present application, the terminal device may intercept the loading or initialization process of the Protobuf library in the hook function, and when the Protobuf library is loaded or initialized, the terminal device may read the .proto file from the file or resource.
[0037] Step S104, obtaining Protobuf data through the hook function.
[0038] Among them, Protobuf data is binary data serialized by Protobuf and is used for transmission or storage in the network.
[0039] In an implementation manner of the present application, the terminal device may intercept the parsing process of the Protobuf data in the hook function, and when the Protobuf data is parsed, the hook function may capture the data.
[0040] Compared with the prior art, the embodiment of the present application has the following beneficial effects: the embodiment of the present application searches for the function position of the hook function according to the target process, obtains the hook function according to the function position, obtains the proto protocol file through the hook function, and obtains the Protobuf data through the hook function. The embodiment of the present application can automatically obtain the proto protocol file and the Protobuf data, and the operation is simple and the acquisition efficiency is high.
[0041] In some implementations of the present application, the above-mentioned obtaining of the proto protocol file through the hook function may specifically include step S401 and step S402.
[0042] Step S401, obtaining protocol description data parameters through a hook function.
[0043] The protocol description data parameter (encoded_file_descriptor) is a pointer to the protocol description data, which contains all the description information of the .proto protocol file.
[0044] In the implementation of the present application, the hook function can be triggered under a specific event or condition, such as when a network request is initiated, when a file is read, etc. When the hook function is triggered, the terminal device can perform predefined operations through the hook function, including intercepting data, modifying data, or recording logs, etc. In the implementation of the present application, the hook function can obtain protocol description data parameters related to the proto protocol.
[0045] Step S402, parse the protocol description data parameters to obtain the proto protocol file.
[0046] In an implementation manner of the present application, after acquiring the protocol description data parameters, the terminal device may parse these parameters according to the specific protocol format and data structure.
[0047] In some specific implementations of the present application, the above-mentioned parsing of the protocol description data parameters to obtain the proto protocol file may specifically include steps S501 and S502.
[0048] Step S501, converting the protocol description data parameters into a FileDescriptorProto object.
[0049] Among them, FileDescriptorProto is a message type defined by Protocol Buffers, which is used to describe the structure and content of .proto files.
[0050] In an implementation manner of the present application, the terminal device may use a parsing function or method provided by the protobuf library to convert the protocol description data parameters into a FileDescriptorProto object according to the serialization rules of protobuf.
[0051] Step S502, parse the FileDescriptorProto object to obtain the proto protocol file.
[0052] In an implementation manner of the present application, the terminal device can access the properties and methods of the FileDescriptorProto object to extract the message type definition, field information, service definition, etc., and construct the content of the complete proto protocol file to obtain the proto protocol file.
[0053] In some specific implementations of the present application, the above parsing of the FileDescriptorProto object to obtain the proto protocol file may specifically include steps S601 to S604.
[0054] Step S601, define the ST_FileDescriptorProto structure.
[0055] Step S602, parse the FileDescriptorProto object to obtain a parsing result.
[0056] Step S603, save the parsing result to the ST_FileDescriptorProto structure.
[0057] Step S604, export the ST_FileDescriptorProto structure and generate a proto protocol file.
[0058] In the implementation mode of the present application, the terminal device can define a corresponding custom structure ST_FileDescriptorProto according to the structure and content of the FileDescriptorProto object. It should be noted that this structure contains the same fields and properties as the FileDescriptorProto object so as to be able to store the information extracted from the FileDescriptorProto object. The terminal device can traverse or access the FileDescriptorProto object, extract all the information it contains, such as the name of the message type, the type and name of the field, the name and method of the service, etc., and organize this information into a form that is convenient for subsequent processing as the parsing result. Then fill the parsing result into the ST_FileDescriptorProto structure, and ensure that each field is correctly assigned a value so that the content of the FileDescriptorProto object can be accurately represented later. Finally, convert the filled ST_FileDescriptorProto structure into a string or other format, and write the generated string into a file to obtain a complete proto protocol file.
[0059] In some implementations of the present application, the above-mentioned obtaining of Protobuf data through the hook function may specifically include step S701 and step S702.
[0060] Step S701, obtaining Protobuf binary data through a hook function.
[0061] Among them, Protobuf binary data is the result of serialization of Protobuf data structure. It is a compact binary format used to represent Protobuf messages in network transmission or file storage.
[0062] In an embodiment of the present application, when Protobuf data is generated or ready to be sent, the hook function may be triggered and capture the Protobuf binary data from the source data.
[0063] Step S702, parse the Protobuf binary data to obtain Protobuf data.
[0064] In the implementation manner of the present application, after obtaining the Protobuf binary data, the terminal device can parse it using the parsing function or method provided by the Protobuf library. Specifically, the binary data can be converted back to its original Protobuf message structure to obtain Protobuf data that can be understood and operated.
[0065] In some specific implementations of the present application, the above-mentioned parsing of Protobuf binary data to obtain Protobuf data may specifically include steps S801 to S803.
[0066] Step S801, parse the Protobuf binary data, and deserialize the Protobuf binary data into a Protobuf message object.
[0067] Among them, the Protobuf message object can be a class instance, which is created according to the message structure defined in the .proto file and is used to store and access the data of the Protobuf message.
[0068] In the implementation of the present application, the terminal device can use the deserialization function or method provided by the Protobuf library to convert the captured Protobuf binary data into a Protobuf message object in a programming language. Specifically, the binary data can be mapped to the corresponding message structure, and an instance of the message object is created, and the corresponding field values are filled.
[0069] Step S802, serialize the Protobuf message object into a string or a byte array.
[0070] In an implementation manner of the present application, the terminal device may use a serialization function or method provided by the Protobuf library to convert a message object into a specified format (such as a JSON string or a byte array).
[0071] Step S803, saving the character string or byte array as Protobuf data.
[0072] In an implementation manner of the present application, the terminal device can write the serialized string or byte array into a file, save it to a database, and finally obtain Protobuf data.
[0073] In some implementations of the present application, the above-mentioned searching for the function location of the hook function according to the target process may specifically include steps S901 to S904.
[0074] Step S901, determining the version number of the code base of the target process.
[0075] The target process refers to the program instance that needs to perform data acquisition or hook operations. The version number of the code library (such as a library file or SDK) is used to identify different versions of the code library. It usually contains information when the version is released, such as the release date, fixed issues, new features, etc. It should be understood that when looking for the location of the hook function, it is crucial to determine the version number of the code library used by the target process, because different versions of the code library may contain different function addresses or layouts.
[0076] In the implementation of the present application, the terminal device can analyze the binary file (such as an executable file or a library file) of the target process, and extract the version number of the code library by reading the file header information, string resources, or calling a specific API. In the case of using the Protobuf static library, the DLL binary signature code introduced into the static library can be analyzed, and the version number can be determined by comparing the differences between different versions of the official Protobuf source code.
[0077] Step S902: If the code library is a static library, compile a static library with the same version number.
[0078] Among them, a static library is an archive file containing precompiled object files, which are directly integrated into the final executable file when linking. Unlike dynamic libraries, static libraries are completely copied into the executable file when compiling, so they do not rely on the existence of external library files.
[0079] In an embodiment of the present application, if the target process uses a static library, the terminal device can find the source code with the same version number as the target process, and use the corresponding compiler and build system (such as Makefile, CMake, etc.) to compile a static library of the same version as the target process.
[0080] Step S903, generating a sig file.
[0081] Among them, the sig file can be used to identify the characteristics of binary files (such as executable files or library files). In reverse engineering or binary analysis, the sig file can help identify specific binary files or code segments for subsequent analysis or operation.
[0082] In the implementation mode of the present application, the terminal device can use a special tool or script to scan and analyze the binary file to extract the features (such as function entry points, specific strings or data segments, etc.) for identification to generate a sig file. The sig file usually contains the feature information of the target binary file.
[0083] Step S904, copy the sig file to the sig / pc directory, and import the sig file into the IDA tool to obtain the function location of the hook function.
[0084] In an embodiment of the present application, the terminal device can copy the generated sig file to a directory that the IDA tool can recognize, such as the sig / pc directory. Then open the IDA tool, load the binary file of the target process, and import the previously copied sig file in IDA, so that IDA can recognize and load the symbols and function information related to the target process. Finally, through the analysis function of IDA, the function location of the hook function (usually a specific function name or address) is found.
[0085] Figure 2 The schematic diagram of the structure of a data acquisition device provided in an embodiment of the present application is shown. The data acquisition device 2 can be configured on a terminal device. Specifically, the data acquisition device 2 can include:
[0086] A search module 201 is used to search for the function location of the hook function according to the target process;
[0087] An injection module 202, used for injecting the hook function into the target process according to the function position;
[0088] The first acquisition module 203 is used to obtain the proto protocol file through the hook function;
[0089] The second acquisition module 204 is used to acquire Protobuf data through the hook function.
[0090] Compared with the prior art, the embodiment of the present application has the following beneficial effects: the embodiment of the present application searches for the function position of the hook function according to the target process, obtains the hook function according to the function position, obtains the proto protocol file through the hook function, and obtains the Protobuf data through the hook function. The embodiment of the present application can automatically obtain the proto protocol file and the Protobuf data, and the operation is simple and the acquisition efficiency is high.
[0091] In some implementations of the present application, the first acquisition module 203 is further used to: obtain protocol description data parameters through the hook function; parse the protocol description data parameters to obtain the proto protocol file.
[0092] In some implementations of the present application, the first acquisition module 203 is further used to: convert the protocol description data parameters into a FileDescriptorProto object; and parse the FileDescriptorProto object to obtain the proto protocol file.
[0093] In some embodiments of the present application, the first acquisition module 203 is also used to: define the ST_FileDescriptorProto structure; parse the FileDescriptorProto object to obtain the parsing result; save the parsing result to the ST_FileDescriptorProto structure; export the ST_FileDescriptorProto structure to generate the proto protocol file.
[0094] In some implementations of the present application, the second acquisition module 204 is further used to: obtain Protobuf binary data through the hook function; and parse the Protobuf binary data to obtain the Protobuf data.
[0095] In some embodiments of the present application, the second acquisition module 204 is further used to: parse the Protobuf binary data, deserialize the Protobuf binary data into a Protobuf message object; serialize the Protobuf message object into a string or a byte array; and save the string or the byte array as the Protobuf data.
[0096] In some embodiments of the present application, the search module 201 is also used to: determine the version number of the code library of the target process; if the code library is a static library, compile a static library of the same version as the version number; generate a sig file; copy the sig file to the sig / pc directory, and import the sig file in the IDA tool to obtain the function location of the hook function.
[0097] like Figure 3 FIG. 3 is a schematic diagram of a terminal device provided in an embodiment of the present application. The terminal device 3 may include: a processor 301, a memory 302, and a computer program 303 stored in the memory 302 and executable on the processor 301, such as a data acquisition program. When the processor 301 executes the computer program 303, the steps in the above-mentioned data acquisition method embodiments are implemented, such as Figure 1 Alternatively, when the processor 301 executes the computer program 303, the functions of each module / unit in the above-mentioned device embodiments are realized, for example Figure 2 The search module 201, injection module 202, first acquisition module 203, and second acquisition module 204 are shown.
[0098] The computer program may be divided into one or more modules / units, which are stored in the memory 302 and executed by the processor 301 to complete the present application. The one or more modules / units may be a series of computer program instruction segments capable of completing specific functions, which are used to describe the execution process of the computer program in the terminal device.
[0099] The terminal device may include, but is not limited to, a processor 301 and a memory 302. Those skilled in the art will appreciate that Figure 3 It is only an example of a terminal device and does not constitute a limitation of the terminal device. It may include more or fewer components than shown in the figure, or a combination of certain components, or different components. For example, the terminal device may also include input and output devices, network access equipment, buses, etc.
[0100] The processor 301 may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or any conventional processor, etc.
[0101] The memory 302 may be an internal storage unit of the terminal device, such as a hard disk or memory of the terminal device. The memory 302 may also be an external storage device of the terminal device, such as a plug-in hard disk, a smart media card (SMC), a secure digital (SD) card, a flash card, etc. equipped on the terminal device. Further, the memory 302 may also include both an internal storage unit of the terminal device and an external storage device. The memory 302 is used to store the computer program and other programs and data required by the terminal device. The memory 302 may also be used to temporarily store data that has been output or is to be output.
[0102] It should be noted that, for the convenience and brevity of description, the structure of the above-mentioned terminal device can also refer to the specific description of the structure in the method embodiment, which will not be repeated here.
[0103] The technicians in the relevant field can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional units and modules is used as an example for illustration. In practical applications, the above-mentioned function allocation can be completed by different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiment can be integrated in a processing unit, or each unit can exist physically separately, or two or more units can be integrated in one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of software functional units. In addition, the specific names of the functional units and modules are only for the convenience of distinguishing each other, and are not used to limit the scope of protection of this application. The specific working process of the units and modules in the above-mentioned system can refer to the corresponding process in the aforementioned method embodiment, which will not be repeated here.
[0104] An embodiment of the present application further provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps in the above-mentioned data acquisition method can be implemented.
[0105] An embodiment of the present application provides a computer program product. When the computer program product is run on a mobile terminal, the steps in the above-mentioned data acquisition method can be implemented when the mobile terminal executes the computer program product.
[0106] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described or recorded in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0107] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel 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 this application.
[0108] In the embodiments provided in the present application, it should be understood that the disclosed devices / terminal equipment and methods can be implemented in other ways. For example, the device / terminal equipment embodiments described above are only schematic. For example, the division of the modules or units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0109] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0110] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0111] If the integrated module / unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the present application implements all or part of the processes in the above-mentioned embodiment method, and can also be completed by instructing the relevant hardware through a computer program. The computer program can be stored in a computer-readable storage medium, and the computer program can implement the steps of the above-mentioned various method embodiments when executed by the processor. Among them, the computer program includes computer program code, and the computer program code can be in source code form, object code form, executable file or some intermediate form. The computer-readable medium may include: any entity or device capable of carrying the computer program code, recording medium, U disk, mobile hard disk, disk, optical disk, computer memory, read-only memory (ROM), random access memory (RAM), electric carrier signal, telecommunication signal and software distribution medium. It should be noted that the content contained in the computer-readable medium can be appropriately increased or decreased according to the requirements of legislation and patent practice in the jurisdiction. For example, in some jurisdictions, according to legislation and patent practice, computer-readable media do not include electric carrier signals and telecommunication signals.
[0112] The embodiments described above are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, a person skilled in the art should understand that the technical solutions described in the aforementioned embodiments may still be modified, or some of the technical features may be replaced by equivalents. Such 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 application, and should all be included in the protection scope of the present application.
Claims
1. A method for acquiring data, characterized in that: include: According to the target process, find the function location of the hook function; Injecting the hook function into the target process according to the function position; Get the proto protocol file through the hook function; Protobuf data is obtained through the hook function.
2. The data acquisition method according to claim 1, characterized in that: The proto protocol file is obtained through the hook function, including: Obtaining protocol description data parameters through the hook function; The protocol description data parameters are parsed to obtain the proto protocol file.
3. The data acquisition method according to claim 2, characterized in that: The protocol description data parameters are parsed to obtain the proto protocol file, including: Convert the protocol description data parameters into a FileDescriptorProto object; Parse the FileDescriptorProto object to obtain the proto protocol file.
4. The method for acquiring data according to claim 3, characterized in that: The parsing of the FileDescriptorProto object to obtain the proto protocol file includes: Define the ST_FileDescriptorProto structure; Parse the FileDescriptorProto object to obtain a parsing result; Save the parsing result to the ST_FileDescriptorProto structure; Export the ST_FileDescriptorProto structure and generate the proto protocol file.
5. The method for acquiring data according to claim 1, characterized in that: The obtaining of Protobuf data through the hook function includes: Obtain Protobuf binary data through the hook function; The Protobuf binary data is parsed to obtain the Protobuf data.
6. The method for acquiring data according to claim 5, characterized in that: The parsing of the Protobuf binary data to obtain the Protobuf data includes: Parsing the Protobuf binary data, and deserializing the Protobuf binary data into a Protobuf message object; Serialize the Protobuf message object into a string or byte array; Save the string or the byte array as the Protobuf data.
7. The method for acquiring data according to claim 1, characterized in that: The method of searching the function location of the hook function according to the target process includes: Determine the version number of the code base of the target process; If the code library is a static library, compile a static library with the same version number as the version number; Generate sig file; Copy the sig file to the sig / pc directory, and import the sig file into the IDA tool to obtain the function location of the hook function.
8. A data acquisition device, characterized in that: include: The search module is used to find the function location of the hook function according to the target process; An injection module, used for injecting the hook function into the target process according to the function position; A first acquisition module is used to obtain a proto protocol file through the hook function; The second acquisition module is used to obtain Protobuf data through the hook function.
9. A terminal device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the method for acquiring data as claimed in any one of claims 1 to 7 when executing the computer program.
10. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the steps of the method for acquiring data according to any one of claims 1 to 7 are implemented.
Citation Information
Patent Citations
Domain name resolution record acquisition method and device, computer equipment and storage medium
CN110417931A
Data format conversion method and device
CN110941655A
Method and apparatus for serialization and deserialization of message structure
US20210028970A1
