Method and device for transmitting dynamic execution code based on public warehouse
By generating the corresponding relationship between the random dictionary number and the dynamic link library function on the client, uploading it to the server to replace the calling method, and using the mapped memory space to protect the dynamic link library function, the security problem of the dynamic link library calling process is solved, and malicious programs are protected defense and plug-in prevention.
Patent Information
- Application Number
- CN202410579984.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-11
- Publication Date
- 2024-08-27
AI Technical Summary
In the existing technology, the interception of the dynamic link library calling process by malicious programs leads to information leakage and application plug-in problems, and there is a lack of effective security measures.
By generating a random dictionary number on the client and establishing a one-to-one correspondence with the dynamic link library function, uploading it to the server, replacing the original calling method, generating execution code, and executing it on the client, using mapped memory space to protect the dynamic link library function. Make sure to generate a different dictionary number each time you go online.
It improves the security of the dynamic link library function calling process, prevents human analysis and plug-ins, and enhances the security of the code.
Smart Images

Figure CN118550602A
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer application technology, and in particular to a method and device for transmitting dynamic execution code based on a public repository. Background Art
[0002] With the continuous development of Internet technology, Internet information security has received more and more attention. At present, most function calls are implemented based on dynamic link library (DLL) files. There are existing malicious programs that intercept the DLL call process and analyze the call process, resulting in information leakage, application plug-ins and other problems. Summary of the invention
[0003] The technical problem to be solved by the present invention is to provide a method and device for transmitting dynamic execution code based on a public warehouse to improve code security.
[0004] In order to solve the above technical problems, the technical solution adopted by the present invention is:
[0005] A method for transmitting dynamic execution code based on a public repository, comprising:
[0006] Get the system dynamic link library function;
[0007] Randomly generate a dictionary number, and establish a one-to-one correspondence between the dictionary number and the dynamic link library function to obtain a function dictionary;
[0008] Uploading the function dictionary to a server;
[0009] Instruct the server to obtain the corresponding dynamic link library function and dictionary number according to the function dictionary, replace the original calling method of the dynamic link library function with the dictionary number to obtain an execution code, and issue the execution code;
[0010] The execution code is received and executed.
[0011] In order to solve the above technical problems, another technical solution adopted by the present invention is:
[0012] A device for transmitting dynamic execution code based on a public repository, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the following steps when executing the computer program:
[0013] Get the system dynamic link library function;
[0014] Randomly generate a dictionary number, and establish a one-to-one correspondence between the dictionary number and the dynamic link library function to obtain a function dictionary;
[0015] Uploading the function dictionary to a server;
[0016] Instruct the server to obtain the corresponding dynamic link library function and dictionary number according to the function dictionary, replace the original calling method of the dynamic link library function with the dictionary number to obtain an execution code, and issue the execution code;
[0017] The execution code is received and executed.
[0018] The beneficial effects of the present invention are as follows: a function dictionary is established based on the system dynamic link library function, a one-to-one correspondence is established between the dynamic link library function and the randomly generated dictionary number, and the dictionary number is uploaded to the server, and the server obtains the corresponding function function according to the dictionary number and replaces the original calling method of the function function to obtain the execution code and then sends it down, so that the client performs the corresponding operation based on the code sent by the server, and executes the code according to the dictionary number instead of executing the function function. It is necessary to match the corresponding function function through the dictionary number before executing it, and because the dictionary number is randomly generated, it can prevent human analysis and improve the security of the dynamic link library function calling process. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] Figure 1 A flowchart of a method for transmitting dynamic execution code based on a public repository in an embodiment of the present invention;
[0020] Figure 2 Another step flow chart of a method for transmitting dynamic execution code based on a public repository in an embodiment of the present invention;
[0021] Figure 3 A system dynamic link library function list in a method for transmitting dynamic execution code based on a public repository in an embodiment of the present invention;
[0022] Figure 4 The figure is a schematic diagram of the structure of a device for transmitting dynamic execution code based on a public repository in an embodiment of the present invention. DETAILED DESCRIPTION
[0023] In order to explain the technical content, achieved objectives and effects of the present invention in detail, the following is an explanation in combination with the implementation modes and the accompanying drawings.
[0024] Please refer to Figure 1 , a method for transmitting dynamic execution code based on a public repository, comprising:
[0025] Get the system dynamic link library function;
[0026] Establishing a function dictionary according to the dynamic link library function, and generating a one-to-one correspondence between a random dictionary number and a dynamic link library function;
[0027] The client uploads the dictionary number of the target dynamic link library function to the server;
[0028] The server obtains the corresponding target dynamic link library function according to the dictionary number, replaces the original calling method of the target dynamic link library function with the dictionary number to obtain an execution code, and sends the execution code to the client;
[0029] The client receives and executes the execution code.
[0030] From the above description, it can be seen that the beneficial effects of the present invention are: establishing a function dictionary based on the system dynamic link library function, a one-to-one correspondence between the dynamic link library function and the randomly generated dictionary number, and uploading the dictionary number to the server, the server obtains the corresponding function function according to the dictionary number and replaces the original calling method of the function function to obtain the execution code and then sends it down, so that the client performs the corresponding operation based on the code sent by the server, and executes the code according to the dictionary number instead of executing the function function. It is necessary to match the corresponding function function through the dictionary number before execution, and because the dictionary number is randomly generated, it can prevent human analysis and improve the security of the dynamic link library function call process.
[0031] Further, the obtaining of the system dynamic link library function includes:
[0032] Acquire a mapped memory space, and use the mapped memory space as an execution space;
[0033] Obtaining the function name and function address of the dynamic link library function;
[0034] The dynamic link library function is mirrored to the mapped memory space according to the function name and function address.
[0035] From the above description, it can be seen that by mapping the function name and function address of the dynamic link library function to the mapped memory space, and using the mapped memory space as the execution space, the dynamic link library function in the original memory is protected, thereby improving security.
[0036] Further, establishing a one-to-one correspondence between the dictionary number and the dynamic link library function includes:
[0037] A dictionary number is randomly generated, and the dictionary number is associated with the function name and function address of each of the dynamic link library functions in the mapping space.
[0038] From the above description, it can be seen that by associating the dictionary number with the function name and function address in the mapping space, that is, calling the function is based on calling the dynamic link library function in the mapping space, which does not affect the original dynamic link library function of the system.
[0039] Furthermore, after obtaining the function dictionary, the step of:
[0040] Constructing the header address of the function dictionary;
[0041] The header address is encrypted using the function name as a key.
[0042] It can be seen from the above description that by encrypting the dynamic link library function, the security of the dynamic link library function is improved.
[0043] Further, the obtaining of the mapped memory space includes:
[0044] Determine whether a user online notification is received, and if so, create the mapping memory space;
[0045] Determine whether a user offline notification is received, and if so, reclaim the mapped memory space.
[0046] From the above description, it can be seen that the mapped memory space is recycled after the user goes offline, that is, the corresponding mapped memory space disappears after the user goes offline, and the mapped memory space needs to be recreated after the user goes online again. The dictionary number is randomly generated, so the dictionary number generated by the user is different each time the user goes online, and the dictionary number generated by the terminal corresponding to each user is also different, which further increases the randomness of the dictionary number and improves security.
[0047] Another embodiment of the present invention provides an apparatus for transmitting dynamic execution code based on a public repository, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the following steps when executing the computer program:
[0048] Get the system dynamic link library function;
[0049] Establishing a function dictionary according to the dynamic link library function, and generating a one-to-one correspondence between a random dictionary number and a dynamic link library function;
[0050] The client uploads the dictionary number of the target dynamic link library function to the server;
[0051] The server obtains the corresponding target dynamic link library function according to the dictionary number, replaces the original calling method of the target dynamic link library function with the dictionary number to obtain an execution code, and sends the execution code to the client;
[0052] The client receives and executes the execution code.
[0053] From the above description, it can be seen that a function dictionary is established based on the system dynamic link library function, and a one-to-one correspondence is established between the dynamic link library function and the randomly generated dictionary number, and the dictionary number is uploaded to the server. The server obtains the corresponding function function according to the dictionary number and replaces the original calling method of the function function to obtain the execution code and then sends it down, so that the client performs the corresponding operation based on the code sent by the server. When executing the code, it is executed according to the dictionary number instead of executing the function function. It is necessary to match the corresponding function function through the dictionary number before execution. Moreover, since the dictionary number is randomly generated, it can prevent human analysis and improve the security of the dynamic link library function call process.
[0054] Further, the obtaining of the system dynamic link library function includes:
[0055] Acquire a mapped memory space, and use the mapped memory space as an execution space;
[0056] Obtaining the function name and function address of the dynamic link library function;
[0057] The dynamic link library function is mirrored to the mapped memory space according to the function name and function address.
[0058] From the above description, it can be seen that by mapping the function name and function address of the dynamic link library function to the mapped memory space, and using the mapped memory space as the execution space, the dynamic link library function in the original memory is protected, thereby improving security.
[0059] Further, establishing a one-to-one correspondence between the dictionary number and the dynamic link library function includes:
[0060] A dictionary number is randomly generated, and the dictionary number is associated with the function name and function address of each of the dynamic link library functions in the mapping space.
[0061] From the above description, it can be seen that by associating the dictionary number with the function name and function address in the mapping space, that is, calling the function is based on calling the dynamic link library function in the mapping space, which does not affect the original dynamic link library function of the system.
[0062] Furthermore, after obtaining the function dictionary, the step of:
[0063] Constructing the header address of the function dictionary;
[0064] The header address is encrypted using the function name as a key.
[0065] It can be seen from the above description that by encrypting the dynamic link library function, the security of the dynamic link library function is improved.
[0066] Further, the obtaining of the mapped memory space includes:
[0067] Determine whether a user online notification is received, and if so, create the mapping memory space;
[0068] Determine whether a user offline notification is received, and if so, reclaim the mapped memory space.
[0069] From the above description, it can be seen that the mapped memory space is recycled after the user goes offline, that is, the corresponding mapped memory space disappears after the user goes offline, and the mapped memory space needs to be recreated after the user goes online again. The dictionary number is randomly generated, so the dictionary number generated by the user is different each time the user goes online, and the dictionary number generated by the terminal corresponding to each user is also different, which further increases the randomness of the dictionary number and improves security.
[0070] The method for transmitting dynamic execution code based on a public warehouse provided by the present invention can be applied to the scenario of function loading to realize dynamic loading of temporary functions and encryption, which is described below through specific implementation methods:
[0071] Embodiment 1
[0072] Please refer to Figure 1 as well as Figure 2 , a method for transmitting dynamic execution code based on a public repository, comprising:
[0073] S1. Get the system dynamic link library function; please refer to Figure 3 , export dynamic link library functions from the system dynamic link library, each dynamic link library function has a corresponding function name and function address, and each dynamic link library function has its own function, that is, as a functional function; for example, obtain the memory space function list and function address corresponding to the system DLL function list required in the current process, and obtain all the function names of the original system DLL and the function addresses corresponding to the function names; in a specific example, such as the server generates a function template, obtain the system DLL call function required by the function template and the existence form of the function template in the memory.
[0074] S2, randomly generate a dictionary number, and establish a one-to-one correspondence between the dictionary number and the dynamic link library function to obtain a function dictionary, specifically including the following steps:
[0075] S21, obtaining a mapped memory space, and using the mapped memory space as an execution space; wherein the mapped memory space needs to be created after receiving a notification that the client is online; for example, when the player is online at the client, the mapped memory space required for this time is created;
[0076] S22, obtaining a function name and a function address of a dynamic link library function; for example, the obtained function name is: AnyPopup, and the function address is: address: 0x8E0000 of the dynamic link library function;
[0077] S23. Mirror the dynamic link library function to the mapped memory space according to the function name and function address to obtain a function dictionary; that is, map the function AnyPopup to the mapped memory space, for example, the new mapping address: function name: AnyPopup, mapping address: 0x10E0000; the purpose of the mirroring is to obtain a data memory block in the memory that is consistent with the original memory for dictionary access to the mirror memory; wherein steps S21-S23 can be performed after step S1.
[0078] S24, randomly generate a dictionary number, and associate the dictionary number with the function name and function address of each dynamic link library function in the mapping space; the purpose of random non-repetitive numbering is to prevent human analysis to achieve data randomization, thereby increasing the cost of confrontation; for example, the dictionary number is A578, and the function name and function address of the dynamic link library function are combined to obtain a dictionary: A578: AnyPopup: 0x10E0000; the purpose of randomizing the dictionary is to make the dictionary number different each time, and to establish a connection with the mapping space function and function address; that is, when the dictionary is used for the execution sent by the server during the actual transmission process, the identifier of the function corresponding to the dictionary is used as the basis. Among them, it is also necessary to construct the header address of the function dictionary, and encrypt the header address with the function name as the key; then fill the mirror function address into the dictionary memory one by one.
[0079] S3. Upload the function dictionary to the server; for example, upload the DLL name and address content to the server, and upload the content to the server for parsing.
[0080] S4, instruct the server to obtain the corresponding dynamic link library function and dictionary number according to the function dictionary, and replace the original calling method of the dynamic link library function with the dictionary number to obtain the execution code, and issue the execution code, specifically:
[0081] S41. The server restores data according to the DLL name and the memory it carries; that is, the server and the client are in the same system and can obtain the same dynamic link library function in the system; dynamic execution of code is achieved through interaction between the server and the client.
[0082] S42, obtaining a code block to be dynamically executed, and obtaining the name of the DLL called therein and DLL-related functions;
[0083] S43, query the function name to obtain the corresponding dictionary number;
[0084] S44, replace the original function access function address method; the traditional method is: there is immediate addressing (CALL / JMP+API address) in the code issued by Shellcode; that is, replace the original CALL: system API, or JMP: system API, etc. with CALL: dictionary number, or JMP: dictionary number;
[0085] S44, issuing the code after replacing the function;
[0086] S5. Receive the execution code and execute it; that is, after the client executes it, the dictionary is sent from the client to the server, and the server assembles, combines and replaces it before sending it to the client. When the client executes the code, it executes according to the dictionary, rather than the original execution function, and matches the original function through the dictionary; at the same time, when the client goes offline, the mapped memory space is recycled; for example, when the player goes offline, the created mapped memory space disappears, that is, when the player goes online again, the mapped memory space needs to be recreated, so the dictionary also needs to be recreated, which improves security.
[0087] This embodiment provides a specific application scenario to illustrate the above steps:
[0088] For example, a certain game requires a temporary activity function, and no additional data will be generated after the online players go offline, that is, no DLL and other data can be generated in the user's disk space, to prevent players from analyzing the activity function and using plug-ins; by adding the corresponding temporary activity function code on the server, only the dictionary uploaded by the player can complete the corresponding function matching and production, that is, the client (the client obtains the activity function, the DLL name and function to be called: the function address, uploads it to the server, and the server is equipped with a new calling method to send it) executes the sending function to allow online users to execute the temporary activity function game; when the player goes offline, the client will destroy the memory. Even if the player intercepts the dictionary, since the dictionary content is different every time it goes online, the plug-in is only temporary, and each plug-in requires analysis time, which effectively prevents the use of plug-ins.
[0089] Embodiment 2
[0090] Please refer to Figure 4 , a device for transmitting dynamic execution code based on a public repository, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the following steps when executing the computer program:
[0091] S1, obtain system dynamic link library function;
[0092] S2, randomly generate a dictionary number, and establish a one-to-one correspondence between the dictionary number and the dynamic link library function to obtain a function dictionary, specifically including the following steps:
[0093] S21, obtaining a mapped memory space, and using the mapped memory space as an execution space; wherein the mapped memory space needs to be created after receiving a notification that the client is online;
[0094] S22, obtaining the function name and function address of the dynamic link library function;
[0095] S23, mirroring the dynamic link library function to the mapped memory space according to the function name and function address, and obtaining a function dictionary;
[0096] S24, randomly generate a dictionary number, and associate the dictionary number with the function name and function address of each dynamic link library function in the mapping space; wherein, it is also necessary to construct a header address of the function dictionary, and encrypt the header address using the function name as a key; then fill the mirror function address into the dictionary memory one by one.
[0097] S3, upload the function dictionary to the server;
[0098] S4, instructing the server to obtain the corresponding dynamic link library function and the dictionary number according to the function dictionary, and replace the original calling method of the dynamic link library function with the dictionary number to obtain the execution code, and issue the execution code;
[0099] S5. Receive the execution code and execute it; at the same time, reclaim the mapped memory space when the client goes offline.
[0100] In summary, the present invention provides a method and device for transmitting dynamic execution code based on a public warehouse, which realizes the randomized dynamic encryption calling API of each client terminal dictionary by mirroring the system API and reconstructing the system API call warehouse. After uploading it to the server in a random dictionary mode, the server reassembles the function and issues it for execution. Since the dictionary number randomly generated each time online is different and the dictionary is encrypted, and the mapped memory space is used as the execution space, that is, the original system memory space is no longer used, the anti-plug-in capability is enhanced; at the same time, the DLL call execution is stripped, and the dynamic code transmission execution is used to leave no storage traces, and it is released immediately after use, realizing the flexible execution of random code function.
[0101] The above descriptions are merely embodiments of the present invention and are not intended to limit the patent scope of the present invention. Any equivalent transformations made using the contents of the present invention's specification and drawings, or directly or indirectly applied in related technical fields, are also included in the patent protection scope of the present invention.
Claims
1. A method for transmitting dynamic execution code based on a public repository, characterized in that: include: Get the system dynamic link library function; Randomly generate a dictionary number, and establish a one-to-one correspondence between the dictionary number and the dynamic link library function to obtain a function dictionary; Uploading the function dictionary to a server; Instruct the server to obtain the corresponding dynamic link library function and dictionary number according to the function dictionary, replace the original calling method of the dynamic link library function with the dictionary number to obtain an execution code, and issue the execution code; The execution code is received and executed.
2. According to claim 1, a method for transmitting dynamic execution code based on a public repository is characterized in that: The acquisition of the system dynamic link library function includes: Acquire a mapped memory space, and use the mapped memory space as an execution space; Obtaining the function name and function address of the dynamic link library function; The dynamic link library function is mirrored to the mapped memory space according to the function name and function address.
3. According to claim 2, a method for transmitting dynamic execution code based on a public repository is characterized in that: The establishing of a one-to-one correspondence between the dictionary number and the dynamic link library function comprises: A dictionary number is randomly generated, and the dictionary number is associated with the function name and function address of each of the dynamic link library functions in the mapping space.
4. According to claim 2, a method for transmitting dynamic execution code based on a public repository is characterized in that: After obtaining the function dictionary, the following steps are also included: Constructing the header address of the function dictionary; The header address is encrypted using the function name as a key.
5. The method for transmitting dynamic execution code based on a public repository according to claim 2, characterized in that: The obtaining of the mapped memory space comprises: Determine whether a user online notification is received, and if so, create the mapping memory space; Determine whether a user offline notification is received, and if so, reclaim the mapped memory space.
6. A device for transmitting dynamic execution code based on a public repository, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the following steps are performed: Get the system dynamic link library function; Randomly generate a dictionary number, and establish a one-to-one correspondence between the dictionary number and the dynamic link library function to obtain a function dictionary; Uploading the function dictionary to a server; Instruct the server to obtain the corresponding dynamic link library function and dictionary number according to the function dictionary, replace the original calling method of the dynamic link library function with the dictionary number to obtain an execution code, and issue the execution code; The execution code is received and executed.
7. The apparatus for transmitting dynamic execution code based on a public repository according to claim 6, characterized in that: The acquisition of the system dynamic link library function includes: Acquire a mapped memory space, and use the mapped memory space as an execution space; Obtaining the function name and function address of the dynamic link library function; The dynamic link library function is mirrored to the mapped memory space according to the function name and function address.
8. The apparatus for transmitting dynamic execution code based on a public repository according to claim 7, characterized in that: The establishing of a one-to-one correspondence between the dictionary number and the dynamic link library function comprises: A dictionary number is randomly generated, and the dictionary number is associated with the function name and function address of each of the dynamic link library functions in the mapping space.
9. The apparatus for transmitting dynamic execution code based on a public repository according to claim 7, characterized in that: After obtaining the function dictionary, the following steps are also included: Constructing the header address of the function dictionary; The header address is encrypted using the function name as a key.
10. The apparatus for transmitting dynamic execution code based on a public repository according to claim 7, characterized in that: The obtaining of the mapped memory space comprises: Determine whether a user online notification is received, and if so, create the mapped memory space; determine whether a user offline notification is received, and if so, reclaim the mapped memory space.
