Script source code processing methods and related equipment

By obfuscating and recompiling the Lua virtual machine source code files and encrypting the script files, the risk of script source code leakage when uploaded to the server is resolved, thus improving security.

CN113893550BActive Publication Date: 2025-11-14SHENZHEN TENCENT INFORMATION TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202111179062.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-10-08
Publication Date
2025-11-14
Estimated Expiration
2041-11-14

Smart Images

  • Figure CN113893550B_ABST
    Figure CN113893550B_ABST
Patent Text Reader

Abstract

This application provides a script source code processing method and related equipment. The method downloads the officially released Lua virtual machine source code from the target application platform. Following a preset obfuscation rule, the Lua virtual machine source code file is obfuscated. The obfuscated source code is then compiled to obtain a new Lua virtual machine compiler. This new compiler is then used to compile the target application's Lua source code file, and the resulting bytecode file is encrypted. The resulting script file is then sent to the server. Therefore, even if the server's Lua script file is obtained by a cracker, because the Lua virtual machine compiler used in this application differs from the officially released compiler, the cracker cannot crack the Lua script file using the officially released compiler, thus improving the security of the server's Lua source code file.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of information security applications, specifically to a script source code processing method and related equipment. Background Technology

[0002] Currently, many applications use scripting languages ​​to supplement programming languages. The acquired script source code is uploaded to a local server or a third-party cloud server and embedded into the application on that server, enabling the application's functionality to be extended or updated. Scripting languages ​​are particularly prevalent in the gaming industry.

[0003] In practical applications, the source code of applications deployed to servers, especially third-party cloud servers, poses a high risk of leakage. To address this, developers typically compile the application's source code into binary bytecode on the client side, encrypt it, and then deploy it to the server.

[0004] However, because encryption keys are easily cracked and binary bytecode is easily decompiled into source code, this method of script source code processing cannot reliably and effectively improve the security of script source code. Summary of the Invention

[0005] In view of this, this application provides a script source code processing method, the method comprising:

[0006] Obtain the Lua virtual machine source code file published on the target application platform, as well as the Lua source code file of the target application on the target application platform;

[0007] The contents of the Lua virtual machine source code file are obfuscated according to the preset obfuscation rules;

[0008] The obfuscated virtual machine source code files are compiled to obtain the Lua virtual machine compiler;

[0009] The Lua source code file is compiled using the Lua virtual machine compiler to obtain bytecode files;

[0010] The bytecode file is encrypted to generate a script file to be loaded, and the script file to be loaded is uploaded to the server.

[0011] Optionally, obfuscating the Lua virtual machine source code file content according to a preset obfuscation rule includes at least one of the following:

[0012] Adjust the execution order of virtual machine instruction opcodes in the Lua virtual machine source code file;

[0013] Update the virtual machine source code content in the Lua virtual machine source code file;

[0014] Adjust the correspondence between virtual machine instructions and instruction information in the Lua virtual machine source code file.

[0015] Optionally, the method further includes:

[0016] Compile the obfuscated Lua virtual machine source code files to obtain Lua compiled library files;

[0017] The Lua compilation library file is invoked to execute the Lua source code file of the target application.

[0018] Optionally, the method further includes:

[0019] Obtain the binary file imported by the Lua host process of the target application;

[0020] The binary file is then packed to obtain a packed file;

[0021] By editing the shell feature information of the packed file using binary code editing, a target binary file without shell features is obtained.

[0022] Furthermore, this application also proposes a script source code processing method, the method comprising:

[0023] The system receives a target application's script file to be loaded from a computer device. The script file is obtained by encrypting the resulting bytecode file after the computer device compiles the target application's Lua source code file using a Lua virtual machine compiler. The Lua virtual machine compiler is obtained by obfuscating and recompiling the Lua virtual machine source code file released by the target application platform.

[0024] The received script file to be loaded is decrypted to obtain the corresponding bytecode file;

[0025] Load the decrypted bytecode file and update the Lua source code file of the target application.

[0026] Optionally, the method further includes:

[0027] In response to a hot update signal blocking request, execute a hot update signal blocking script; the hot update signal blocking script is used to instruct that hot updates for any file to be loaded be blocked.

[0028] In response to the hot update signal execution request, stop executing the hot update signal blocking script;

[0029] The hot update signal blocking request is generated in response to the hot update signal blocking operation before the computer device sends the target application's script file to the server.

[0030] The hot update signal execution request is generated by the computer device in response to the hot update signal execution operation, which is executed after the script file to be loaded for the target application is successfully uploaded to the server.

[0031] Optionally, the method further includes:

[0032] In response to sandbox configuration requests from different host processes, configure the corresponding sandbox information; the sandbox information is used to restrict host processes from updating variables in the corresponding script files to be loaded.

[0033] The step of loading the decrypted bytecode file and updating the Lua source code file of the target application includes: loading the decrypted bytecode file and updating the Lua source code file of the target application based on the sandbox information.

[0034] Furthermore, this application also proposes a script source code processing apparatus, the apparatus comprising:

[0035] The file acquisition module is used to acquire the Lua virtual machine source code file published on the target application platform, as well as the Lua source code file of the target application on the target application platform.

[0036] The obfuscation module is used to obfuscate the contents of the Lua virtual machine source code file according to preset obfuscation rules.

[0037] The Lua virtual machine compiler acquisition module is used to compile the obfuscated virtual machine source code files to obtain the Lua virtual machine compiler.

[0038] The bytecode file acquisition module is used to compile the Lua source code file using the Lua virtual machine compiler to obtain the bytecode file;

[0039] The script file to be loaded module is used to encrypt the bytecode file and generate the script file to be loaded.

[0040] The script file transfer module is used to upload the script file to be loaded to the server.

[0041] Furthermore, this application also proposes a script source code processing apparatus, the apparatus comprising:

[0042] The script file receiving module is used to receive the script file to be loaded for the target application sent by the computer device; wherein, the script file to be loaded is obtained by the computer device compiling the Lua source code file of the target application using the Lua virtual machine compiler, and then encrypting the resulting bytecode file; the Lua virtual machine compiler is obtained by obfuscating and recompiling the Lua virtual machine source code file released by the target application platform;

[0043] The decryption module is used to decrypt the received script file to be loaded to obtain the corresponding bytecode file;

[0044] The hot update module is used to load the decrypted bytecode file and update the Lua source code file of the target application.

[0045] In another aspect, this application also proposes a computer device, said computer device comprising:

[0046] Communication interface;

[0047] The memory is used to store programs that implement the script source code processing methods described above;

[0048] A processor is used to load and execute the program stored in the memory, implementing the steps of the script source code processing method described above.

[0049] In another aspect, this application also proposes a computer-readable storage medium having a computer program stored thereon, the computer program being loaded and executed by a processor to implement the script source code processing method described above.

[0050] On the other hand, this application also proposes a computer program product, including computer instructions that are read and executed by a processor to implement the script source code processing method described above.

[0051] Based on the above technical solution, this application provides a script source code processing method and related equipment. This application proposes downloading the officially released Lua virtual machine source code from the target application platform. The Lua virtual machine source code file is obfuscated according to preset obfuscation rules. Then, the obfuscated virtual machine source code file is compiled to obtain a new Lua virtual machine compiler. Subsequently, the new Lua virtual machine compiler is used to compile the target application's Lua source code file, and the resulting bytecode file is encrypted to obtain the script file to be loaded, which is then sent to the server. Therefore, even if the server-side Lua script file is obtained by a cracker, because the Lua virtual machine compiler in this application differs from the officially released Lua virtual machine compiler, the cracker cannot crack the Lua source code file using the officially released Lua virtual machine compiler, thus improving the security of the server script source code. Attached Figure Description

[0052] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of this application. For those skilled in the art, other drawings can be obtained based on the provided drawings without creative effort.

[0053] Figure 1 A schematic diagram of a system architecture for an optional application environment applicable to the script source code processing method provided in this application is shown.

[0054] Figure 2 A flowchart illustrating an optional example of the script source code processing method proposed in this application is shown;

[0055] Figure 3 A flowchart illustrating yet another optional example of the script source code processing method proposed in this application is shown.

[0056] Figure 4 A flowchart illustrating yet another optional example of the script source code processing method proposed in this application is shown.

[0057] Figure 5 A schematic diagram of an optional example of the script source code processing apparatus proposed in this application is shown;

[0058] Figure 6 A schematic diagram of another optional example of the script source code processing apparatus proposed in this application is shown.

[0059] Figure 7 A schematic diagram of another optional example of the script source code processing apparatus proposed in this application is shown.

[0060] Figure 8 A schematic diagram of the hardware structure of an optional example of a computer device suitable for the script source code processing method proposed in this application is shown. Detailed Implementation

[0061] Regarding the background technology description, in order to improve the security of server-distributed script source code and reduce the risk of its leakage, this application proposes a method for processing the script source code of the application's backend server. This method involves performing new script source code obfuscation on the server to reduce the risk of server-side script source code leakage. For the virtual machine source code of the target application to be processed, before compilation, the content of the virtual machine source code can be adjusted according to certain rules or randomly to distinguish it from the source code released by the developer. Then, the updated virtual machine source code is compiled and encrypted to obtain the script file to be released. In this way, even if the script file is stolen, its encryption key is cracked, and its bytecode is decompiled, what is obtained is the modified virtual machine source code, not the original script source code of the target application released by the developer, thus improving the security of the script source code.

[0062] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those of ordinary skill in the art without creative effort are within the scope of protection of this application.

[0063] Reference Figure 1 This is a schematic diagram of a system architecture for an optional application environment applicable to the script source code processing method provided in this application. In this application environment, the system may include a client 11 and a server 12, wherein:

[0064] Client 11 may include an application that provides services to the user. This application may be software that supports human-computer interaction functions, such as various game software, social software, etc. It may be a standalone application that needs to be downloaded and installed on the terminal to run; or it may be a web application that does not require installation. This application does not restrict the operation of the application.

[0065] Taking game software as an example, during game development, developers need to write source code to support the game's operation and functionality. This source code can be written in the host language, and the implementation process will not be detailed here. When maintenance and updates to game functionality are required, scripting languages, such as Lua (an interpreted scripting programming language), can be used to compile the necessary script source code. This script source code serves as a supplement to the game programming language and is embedded into the game program to meet the needs of functional expansion or updates. It is understood that the process for functional expansion and updates of other types of applications besides games is similar, and this application will not elaborate on them individually. Furthermore, this application does not restrict the method of obtaining the script source code.

[0066] Based on the above analysis, the aforementioned client may also include applications used to write host source code and script source code for software such as games. These applications are typically configured with various compilation tools for writing the code. This application does not impose any restrictions on the configuration content of such clients and may be determined as appropriate.

[0067] In this embodiment of the application, for any application such as a game (for ease of description, this application may refer to it as the target application), after writing a Lua script file (i.e. Lua source code) for the target application using the Lua scripting language, it can be processed according to the script source code processing method proposed in this application before being sent to the server, so as to improve the security of the Lua source code file on the server. The processing process can be referred to the description of the corresponding part of the method embodiment below, and will not be repeated in this embodiment.

[0068] Server 12 can be a service device that supports the operation of the corresponding client 11 and realizes human-computer interaction functions. It may include the software developer's own server that matches the software, such as a game server for a certain game. As needed, server 12 may also include a third-party server that can support the operation of the client. This application does not restrict the owner of server 12 and can be determined as appropriate.

[0069] The server 12 can be a standalone physical server, a server cluster integrating multiple physical servers, or a cloud server capable of cloud computing. This application does not limit the type of server 12. In practical applications, the server 12 can interact with the client 11 of the user terminal through a wired or wireless communication network to meet the user's usage needs for the client 11. This application does not describe in detail the communication process between the server 12 and the client 11.

[0070] It should be understood that the system architecture described in the above embodiments does not constitute a limitation on the system of the application environment proposed in the embodiments of this application. In practical applications, the system may include more or fewer devices, such as data storage devices (such as a database server or a terminal with a large storage capacity) for storing various data generated by the client operation; network devices for realizing communication between the server and the terminal, etc., which will not be listed here.

[0071] In some embodiments, for certain important data contained in or generated by the client and / or server, such as the host source code, virtual machine source code (script source code) described above, cloud storage can be used to store them through a distributed cloud storage system (such as a blockchain distributed system). In this case, the various servers listed above can be nodes on the blockchain, facilitating access by developers or users through the corresponding client on the terminal. The implementation process is not detailed in this application.

[0072] Combined with Figure 1 The system structure diagram shown is for reference. Figure 2 The diagram below illustrates an optional example of a script source code processing method for embodiments of this application. The method provided in this embodiment can be executed by a computer device, which may be a server, a network device, or a terminal. Figure 2 As shown, the method may include, but is not limited to, the following steps:

[0073] Step S11: Obtain the Lua virtual machine source code file published on the target application platform, and the Lua source code file of the target application;

[0074] Following the above description, before compiling the Lua source code files of the target application (such as any of the clients described above; this application uses game software as an example) using the officially released Lua virtual machine compiler, in order to improve the security of the Lua source code files uploaded to the server, it is proposed to recompile the Lua virtual machine toolchain, such as the Lua virtual machine compiler, by modifying the officially released Lua virtual machine source code files.

[0075] Therefore, this application allows users to download the C-language level Lua virtual machine source code from the official website. Specifically, it involves logging into the target application platform via a computer and downloading the Lua virtual machine source code files released by that platform. This application does not elaborate on the construction and function of these Lua virtual machine source code files.

[0076] The Lua source code file for the target application can be written by the developer and uploaded to the target application platform, so that other computer devices can download the Lua source code file of the target application from the target application platform and compile and encrypt it according to the method proposed in this application. In some other embodiments, after the developer completes the writing, they obtain the Lua source code file of the target application, and then the computer device they use downloads the Lua virtual machine source code file from the target application platform. This application does not limit the method of obtaining the Lua source code file.

[0077] In some embodiments proposed in this application, for any Lua source code of the target application, some necessary preprocessing operations can be performed according to the application requirements to obtain the Lua source code file to be compiled. The preprocessing operations can be implemented by calling shell script functions, such as deleting BOM, using dos2unix to adjust the code format, etc.; concatenating hive.header_sys, etc. This application does not limit the content of the preprocessing operations and can determine them according to actual needs.

[0078] Step S12: Obfuscate the contents of the Lua virtual machine source code file according to the preset obfuscation rules;

[0079] As described above regarding the technical concept of this application, in order to improve the security of Lua source code files on the server side, this application will obtain a Lua virtual machine compiler that is different from the one officially released (i.e., the target application developer) to compile the Lua script files of the target application. Therefore, after the computer device downloads the released virtual machine source code file from the target application platform, it can trigger the virtual machine source code obfuscation mechanism, that is, respond to the obfuscation request for the virtual machine source code file, and perform obfuscation processing on the officially released virtual machine source code file according to the preset obfuscation rules to obtain the obfuscated virtual machine source code file.

[0080] It should be noted that this application does not limit the content of the obfuscation rules pre-configured for different virtual machine source code files. It may include, but is not limited to, obfuscation processing methods for one or more file contents of virtual machine source code files, such as adjusting the correspondence between virtual machine instructions and instruction information, adjusting the execution order of virtual machine instruction opcodes, modifying the code in virtual machine source code files, etc., depending on the situation, and this application does not limit it.

[0081] Step S13: Compile the obfuscated Lua virtual machine source code file to obtain the Lua virtual machine compiler;

[0082] Step S14: Compile the Lua source code file using the Lua virtual machine compiler to obtain the bytecode file;

[0083] Following the method described above, after obfuscating the officially released virtual machine source code files, a new luac tool and a new lualib.a library file (i.e., a Lua compiled library file) can be obtained for the target application. This new luac tool is different from the officially released Lua virtual machine toolchain. Therefore, when a computer device uses the recompiled Lua virtual machine compiler to compile the Lua source code files, the resulting bytecode file will be different from the bytecode file obtained by compiling the Lua source code files using the officially released Lua virtual machine toolchain. Thus, even if a cracker obtains the Lua virtual machine tool from the official source and decompiles the bytecode file in step S14 of this application, they will not be able to obtain the Lua source code file. This application does not detail how the Lua virtual machine compiler compiles the Lua source code files to obtain the corresponding bytecode file.

[0084] Step S15: Encrypt the bytecode file to generate a script file to be loaded, and upload the script file to be loaded to the server.

[0085] To further enhance the security of bytecode files, this application may employ encryption methods such as symmetric encryption algorithms to encrypt bytecode files and generate script files to be loaded for the target application.

[0086] As can be seen, because the new virtual machine compiler recompiles the Lua source code files in this application, the Lua script files are compiled and encrypted before being sent to the server for updates. In this way, even if the Lua script files are downloaded from the server, the official virtual machine cannot decipher the target application's Lua source code files from the bytecode files it decompiles, thus improving the security of the Lua source code files on the server.

[0087] Reference Figure 3 This is a flowchart illustrating another optional example of the script source code processing method proposed in this application. This method can still be executed by a computer device. This embodiment of the application can be an optional refined implementation of the script source code processing method described above, but is not limited to this refined implementation method. Figure 3 As shown, the method may include:

[0088] Step S21: Obtain the Lua virtual machine source code file published on the target application platform, and the Lua source code file of the target application;

[0089] Step S22: Respond to the virtual machine source code obfuscation request and adjust the execution order of virtual machine instruction opcodes in the Lua virtual machine source code file;

[0090] Step S23: Update the code content of the virtual machine source code in the Lua virtual machine source code file to obtain the obfuscated Lua virtual machine source code file;

[0091] It should be noted that the obfuscation methods for Lua virtual machine source code files include, but are not limited to, the implementation methods of steps S22 and S23 above. Either step S22 or S23 can be used to obfuscate the Lua virtual machine source code files as needed, and this application does not restrict the execution order of steps S22 and S23. In other words, when the obfuscation rules for the Lua virtual machine source code include multiple obfuscation methods, this application can use one or more combined obfuscation methods to obfuscate the Lua virtual machine source code files of the target application, and the execution order of these combined obfuscation methods is not restricted and can be determined as appropriate.

[0092] In some other embodiments, the obfuscation method for Lua virtual machine source code can also be implemented by adjusting the correspondence between virtual machine instructions and instruction information in the Lua virtual machine source code file. The method of adjusting the correspondence and the method of adjusting the execution order of the virtual machine instruction opcodes mentioned above can be implemented according to a preset rule or can be adjusted randomly. This application does not limit this.

[0093] Furthermore, for updating the code content of the Lua virtual machine source code mentioned above, it can be directly replaced by the newly obtained code content, or the code content of different code objects can be swapped, etc. This application does not restrict the implementation method of updating the code content.

[0094] Step 24: Compile the obfuscated Lua virtual machine source code files to obtain the Lua virtual machine compiler;

[0095] Step 25: Use the Lua virtual machine compiler to compile the Lua source code files to obtain script bytecode files;

[0096] Step 26: Perform symmetric encryption on the script bytecode file to obtain the encrypted bytecode file;

[0097] This application does not restrict how to use a recompiled luac tool (i.e., the Lua virtual machine compiler) to compile Lua source code files and obtain the corresponding binary bytecode, i.e., script bytecode files. Regarding the encryption implementation methods for script bytecode files, these include, but are not limited to, symmetric encryption methods.

[0098] Step 27: Encode the encrypted bytecode file using bytecode encoding to obtain the script file to be loaded;

[0099] This application embodiment can use base64 encoding to encode the encrypted bytecode file to obtain the script file to be loaded. Base64 is an encoding method used to transmit 8-bit byte code. It encodes the longer identification information to be transmitted into a string, such as encoding binary data into a character format suitable for inclusion in a URL. Because base64 encoding is unreadable, it improves the security of the script file to be published. This application does not describe the implementation process of base64 encoding in detail.

[0100] It should be noted that the encoding method for the encrypted bytecode file, including but not limited to the base64 encoding method described above, can be determined according to the application requirements, and will not be described in detail in this application.

[0101] Step S28: Upload the script file to be loaded to the server.

[0102] In practical applications of this application, after the server receives the script file to be loaded from the computer device, it can decrypt it. The decryption method corresponds to the encryption method described above, and the bytecode file of the Lua source code file is obtained. Then, the bytecode file can be loaded to update the Lua source code file of the target application on the server. The specific hot update implementation process is not described in detail in this application.

[0103] In summary, in this embodiment of the application, before compiling the Lua source code file of the target application using the officially provided virtual machine tools, this application proposes to adjust the Lua virtual machine source code file, recompile the Lua virtual machine editor, and then use a new Lua virtual machine compiler to compile the Lua source code file to obtain bytecode files. The encrypted script file to be loaded is then uploaded to the server. In this way, the server-side Lua script file is downloaded, decrypted, and translated to obtain the bytecode file. Even using the official virtual machine compiler, the Lua source code file cannot be decompiled, thus improving the security of the server-side Lua source code file.

[0104] In some further embodiments of this application, based on the technical concept of recompiling the virtual machine toolchain described above, this application can also compile the obfuscated Lua virtual machine source code files to obtain new Lua compiled library files, namely new lualib.a library files. Thus, during the execution of the target application, the Lua source code files of the target application will be executed by calling this Lua compiled library file to achieve the corresponding extended functions of the target application. This application does not detail the calling process of Lua compiled library files, such as Lua static / dynamic library files, as appropriate.

[0105] To improve the security of the host process's binary files, this application proposes to acquire the binary files imported by the target application's Lua host process, i.e., the Hive binary files, and then to pack these binary files to obtain a packed file, i.e., a packed binary file. Subsequently, a binary code editing tool such as 010editor is proposed to edit away the packing characteristics at the binary code level of the packed binary file, making the edited binary file a target binary file without the packing characteristics. Thus, even if the binary file is lost, the removal of the packing characteristics prevents it from being deciphered using the packed format, improving the security of the Hive binary files and reducing the risk of leakage of the aforementioned obfuscation mechanism.

[0106] It should be noted that this application does not describe in detail the packing and unpacking process of the packing tool (i.e., the upx tool) for the above-mentioned Hive binary files. The implementation of editing the shell feature information of the packed file through binary code editing to obtain a target binary file without shell features is not limited to the 010editor editing method described above.

[0107] Reference Figure 4 This is a flowchart illustrating another optional example of the script source code processing method proposed in this application. This method can be executed by a server, such as the application server of the target application, or a third-party server, etc. Figure 4 As shown, the method may include:

[0108] Step S31: Respond to the hot update signal blocking request and execute the hot update signal blocking script;

[0109] To avoid hot updates of Lua script files for a target application where the server loads only a portion of the received script file before the server has received the complete file, leading to update failures due to incomplete files, this application proposes a novel Lua hot update mechanism. This mechanism involves the server halting hot updates until all script files have been uploaded, and only then proceeding with the hot update after the entire process is complete.

[0110] Based on this, the server of this application can execute a signal blocking mechanism. When it is determined that the server needs to perform a hot update operation according to the application scenario, in order to improve the reliability of hot update, a hot update signal blocking request can be sent to the server through a computer device to request the server to start the signal blocking mechanism, that is, to start the execution of a pre-configured hot update signal blocking script. The hot update signal blocking script can be used to indicate the blocking of hot updates for any file to be loaded. This application does not limit the content of the hot update signal blocking script or its configuration method.

[0111] As can be seen, the aforementioned hot update signal blocking request is generated in response to the hot update signal blocking operation before the computer device sends the target application's script file to be loaded to the server. This application does not limit its generation method or content. Step S32: Receive the target application's script file to be loaded sent by the computer device;

[0112] When the server activates the signal blocking mechanism, the computer device can upload at least one script file to be loaded to the server. The process of obtaining each script file to be loaded can be referred to, but is not limited to, the description in the above embodiment. This embodiment will not elaborate further.

[0113] As described above, because the server implements a signal blocking mechanism and does not perform hot update operations, the newly received script files to be loaded can be temporarily not loaded, thus enabling hot updates of the corresponding application's Lua source code files.

[0114] Step S33: Respond to the hot update signal execution request and stop executing the hot update signal blocking script;

[0115] In this embodiment of the application, after it is determined that the above-mentioned script file to be loaded has been uploaded, if the computer device outputs an upload progress prompt message, the loading progress can be known. After it is determined that the loading is complete, a hot update signal execution request can be generated and sent to the server so that the server responds to the hot update signal execution request and stops executing the hot update signal blocking script, thereby enabling the server to perform the hot update operation.

[0116] As can be seen, the above-mentioned hot update signal execution operation is performed after the target application's script file to be loaded is successfully uploaded to the server. This application does not limit its generation method or content, and it can be determined as appropriate.

[0117] Step S34: Decrypt the received script file to be loaded to obtain the corresponding bytecode file;

[0118] Step S35: Load the decrypted bytecode file and update the target application's Lua source code file.

[0119] In some embodiments proposed in this application, if the script file to be loaded is obtained by compiling and encrypting multiple Lua source code files in the manner described above and then merging them, then after the server receives each encrypted Lua script file, if it determines that a newly uploaded encrypted Lua script file is being uploaded based on information such as upload time, it can first decrypt the Lua script file to obtain the bytecode file to be loaded. After all the Lua script files uploaded by the target application have been uploaded, the signal shielding mechanism is removed in the manner described above, and the decrypted bytecode file is directly loaded for hot update, thereby improving the reliability and efficiency of hot update.

[0120] In some other embodiments, this application can also, after determining that all Lua script files uploaded by the target application have been uploaded (i.e., the timestamps of the script files to be loaded no longer change), remove the signal blocking mechanism as described above, decrypt each received Lua script file, load the obtained bytecode file, and achieve hot updating of the target application's Lua source code files. Therefore, this application proposes executing a hot update blocking script before all script files to be loaded by the target application have been uploaded, to solve the technical problem of hot update failure caused by the server performing hot updates while receiving script files to be loaded.

[0121] In some embodiments proposed in this application, to improve the reliability and success rate of Lua hot updates, the server detects an update to the upload time of the script file to be loaded, responds to a load signal blocking instruction, and refuses to execute a load signal for a portion of the uploaded, to-be-published script file. This application does not limit the content of this load signal blocking instruction or its configuration implementation method. After determining that the upload time of the script file to be loaded will no longer update and that the script file to be loaded has been uploaded completely, the load signal blocking instruction is cleared, and the script file to be loaded is loaded, thus achieving hot updates of the Lua source code files of the target application.

[0122] In some embodiments, a load signal blocking instruction can be added at the beginning of the script file to be loaded, and a release instruction for the load signal blocking instruction can be added at the end of the script file to be loaded. In this way, when the server first receives the script file to be loaded uploaded by the computer device, it will detect the load signal blocking instruction, respond to the load signal blocking instruction, and block the loading signal, that is, not perform the hot update operation; after the script file to be loaded is uploaded, the server will receive the release instruction for the load signal blocking instruction, execute the release instruction, remove the load signal blocking instruction, and can execute the loading signal, that is, perform the hot update operation.

[0123] In some other embodiments, this application can also obtain the predicted upload time of the script file to be loaded based on information such as the file size and transmission network parameters, and configure the effective duration of the above-mentioned blocking loading signal instruction accordingly. In this way, before the server executes the loading signal and performs a hot update operation, it can determine whether the blocking loading signal instruction is effective based on the effective duration and the actual cumulative upload time of the script file to be loaded. If it is effective, the loading signal can continue to be blocked and the hot update operation can be temporarily suspended; if it is ineffective, the loading signal can be executed and the hot update operation can be performed.

[0124] It should be noted that the configuration implementation methods for blocking the loading signal instruction for the script file to be loaded include, but are not limited to, the several implementation methods described in the above embodiments.

[0125] In some further embodiments of this application, a sandbox mechanism can be employed for the hot-update files described above, i.e., the script files to be loaded, to avoid variable name pollution between different files. Specifically, sandbox information can be configured in response to sandbox configuration requests from different host processes; this sandbox information can be used to restrict variable update requests from host processes to the corresponding script files to be loaded; thus, the server can load the decrypted bytecode file and update the Lua source code file of the target application based on the sandbox information.

[0126] For example, this application can define a custom global import function, which can be used to load the script file to be loaded and return the corresponding table (i.e., sandbox information). This achieves the isolation of variable names between different files and avoids variable name pollution. At the same time, the table can be used to conveniently use the symbols defined in the Lua script file. The implementation process is not described in detail in this application.

[0127] Reference Figure 5 This is a schematic diagram of an optional example of the script source code processing apparatus proposed in this application. This apparatus can be described from the perspective of the aforementioned computer device, such as... Figure 5 As shown, the device may include:

[0128] The file acquisition module 21 is used to acquire the Lua virtual machine source code file published on the target application platform, as well as the Lua source code file of the target application on the target application platform.

[0129] The obfuscation module 22 is used to obfuscate the contents of the Lua virtual machine source code file according to a preset obfuscation rule;

[0130] In some embodiments, the obfuscation processing module 22 may include at least one of the following obfuscation processing units:

[0131] The first obfuscation processing unit is used to adjust the execution order of virtual machine instruction opcodes in the Lua virtual machine source code file;

[0132] The second obfuscation processing unit is used to update the code content of the virtual machine source code in the Lua virtual machine source code file.

[0133] The third obfuscation processing unit is used to adjust the correspondence between virtual machine instructions and instruction information in the Lua virtual machine source code file.

[0134] The Lua virtual machine compiler acquisition module 23 is used to compile the obfuscated virtual machine source code file to obtain the Lua virtual machine compiler.

[0135] The bytecode file acquisition module 24 is used to compile the Lua source code file using the Lua virtual machine compiler to obtain the bytecode file;

[0136] The script file generation module 25 is used to encrypt the bytecode file and generate the script file to be loaded.

[0137] The script file transfer module is used to upload the script file to be loaded to the server.

[0138] In some embodiments proposed in this application, the above-described apparatus may further include:

[0139] The Lua compilation library file acquisition module is used to compile the obfuscated Lua virtual machine source code files to obtain Lua compilation library files;

[0140] The execution module is used to call the Lua compilation library file and execute the Lua source code file of the target application.

[0141] In some other embodiments, the above-described apparatus may further include:

[0142] A binary file acquisition module is used to acquire binary files imported by the Lua host process of the target application;

[0143] The file packing module is used to pack the binary file to obtain a packed file;

[0144] The file unpacking module is used to edit the shell feature information of the packed file through binary code editing to obtain a target binary file that does not contain shell features.

[0145] Reference Figure 6 This is a schematic diagram of another optional example of the script source code processing device proposed in this application. The functionality of this device can be described from the server side, such as... Figure 6 As shown, the device may include:

[0146] The script file receiving module 31 is used to receive the script file to be loaded for the target application sent by the computer device;

[0147] The script file to be loaded is obtained by encrypting the bytecode file after the computer device compiles the Lua source code file of the target application using the Lua virtual machine compiler; the Lua virtual machine compiler is obtained by obfuscating and recompiling the Lua virtual machine source code file released by the target application platform.

[0148] The decryption module 32 is used to decrypt the received script file to be loaded to obtain the corresponding bytecode file;

[0149] The hot update module 33 is used to load the decrypted bytecode file and update the Lua source code file of the target application.

[0150] In some other embodiments, such as Figure 7 As shown, the above-mentioned device may further include:

[0151] Signal blocking module 34 is used to respond to a hot update signal blocking request and execute a hot update signal blocking script; the hot update signal blocking script is used to instruct the blocking of hot updates for any file to be loaded.

[0152] Signal cancellation module 35 is used to respond to hot update signal execution request and stop executing the hot update signal blocking script;

[0153] The hot update signal blocking request is generated in response to the hot update signal blocking operation before the computer device sends the target application's script file to be loaded to the server; the hot update signal execution request is generated by the computer device in response to the hot update signal execution operation, which is executed after the target application's script file to be loaded is successfully uploaded to the server.

[0154] In some other embodiments, such as Figure 7 As shown, the above-mentioned device may further include:

[0155] The sandbox information configuration module 36 is used to respond to sandbox configuration requests from different host processes and configure corresponding sandbox information; the sandbox information is used to restrict host processes from updating variables in the corresponding script files to be loaded.

[0156] Based on this, the aforementioned hot update module 33 may include:

[0157] The update unit 331 is used to load the decrypted bytecode file based on the sandbox information and update the Lua source code file of the target application.

[0158] It should be noted that the various modules and units in the above-mentioned device embodiments can be stored as program modules in the memory of the corresponding side device. The processor of the device executes the above-mentioned program modules stored in the memory to realize the corresponding functions. The functions realized by each program module and its combination, as well as the technical effects achieved, can be referred to the description of the corresponding part of the above-mentioned method embodiments. This embodiment will not repeat it.

[0159] This application also provides a computer-readable storage medium storing a computer program that is executed by a processor to implement the steps of the above-described script source code processing method. The implementation process of the script source code processing method can be referred to the description of the above-described method embodiments, and will not be repeated in this embodiment.

[0160] This application also proposes a computer program product or computer program that includes computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the computer device to perform the methods provided in the various optional implementations of the script source code processing aspect or script source code processing apparatus described above. Specific implementation processes can be referred to the descriptions of the corresponding embodiments above, and will not be repeated here.

[0161] Reference Figure 8 This is a schematic diagram of the hardware structure of an optional example of a computer device suitable for the script source code processing method provided in the embodiments of this application, such as... Figure 8 As shown, the device may include: a communication interface 41, a memory 42, and a processor 43, wherein:

[0162] In practical applications, the number of communication interface 41, memory 42 and processor 43 can be at least one, and the communication interface 41, memory 42 and processor 43 can communicate with each other through a communication bus.

[0163] The communication interface 41 can be an interface for a communication module, such as an interface for a WIFI module, a 5G / 6G (fifth generation mobile communication network / sixth generation mobile communication network) module, a GPRS module, etc. The communication interface 41 can also include a communication interface for realizing data interaction between internal components of a computer device, such as a USB interface, a serial / parallel port, etc. This application does not limit the number and type of the communication interface 41.

[0164] The memory 42 can be used to store a program that implements the script source code processing method executed on the corresponding computer device side; the processor 43 can be used to load and execute the program stored in the memory 42 to implement the script source code processing method executed on the corresponding computer device side. The implementation process can be referred to the description of the corresponding method embodiment above, and will not be repeated in this embodiment.

[0165] In this embodiment, memory 42 may include high-speed random access memory, and may also include non-volatile memory, such as at least one disk storage device or other volatile solid-state storage device. Processor 43 may be a central processing unit (CPU), application-specific integrated circuit (ASIC), digital signal processor (DSP), application-specific integrated circuit (ASIC), off-the-shelf programmable gate array (FPGA), or other programmable logic device.

[0166] It should be understood that Figure 8 The structure of the computer device shown does not constitute a limitation on the computer device in the embodiments of this application. In practical applications, the computer device may include more or fewer components, or combine certain components, which will not be listed here.

[0167] Finally, it should be noted that, regarding the above embodiments, unless the context explicitly indicates an exception, the words "a," "an," "an," and / or "the" do not specifically refer to the singular and may also include the plural. Generally speaking, the terms "comprising" and "including" only indicate the inclusion of explicitly identified steps and elements, and these steps and elements do not constitute an exclusive list; the method or apparatus may also include other steps or elements. An element defined by the phrase "comprising an..." does not exclude the presence of other identical elements in the process, method, product, or apparatus that includes the element.

[0168] In the description of the embodiments of this application, unless otherwise stated, " / " means "or", for example, A / B can mean A or B; "and / or" in this document is merely a description of the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A existing alone, A and B existing simultaneously, and B existing alone. Furthermore, in the description of the embodiments of this application, "multiple" refers to two or more.

[0169] The terms used in this application, such as "first" and "second," are for descriptive purposes only, used to distinguish one operation, unit, or module from another, and do not necessarily require or imply any such actual relationship or order between these units, operations, or modules. Furthermore, they should not be construed as indicating or implying relative importance or implicitly specifying the number of technical features indicated. Therefore, a feature defined with "first" or "second" may explicitly or implicitly include one or more of that feature.

[0170] Furthermore, the various embodiments in this specification are described in a progressive or parallel manner, with each embodiment focusing on its differences from other embodiments. Similar or identical parts between embodiments can be referred to interchangeably. For the apparatus, computer equipment, and systems disclosed in the embodiments, since they correspond to the methods disclosed in the embodiments, the descriptions are relatively simple, and relevant details can be found in the method section.

[0171] The above description of the disclosed embodiments enables those skilled in the art to make or use this application. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the core ideas or scope of this application. Therefore, this application is not to be limited to the embodiments shown herein, but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.

Claims

1. A script source code processing method, characterized in that, The method includes: Obtain the Lua virtual machine source code file published on the target application platform, as well as the Lua source code file of the target application on the target application platform; Update the code content of the virtual machine source code in the Lua virtual machine source code file, and adjust the correspondence between virtual machine instructions and instruction information in the updated Lua virtual machine source code file; the update refers to replacing the old code content with the new code content and / or swapping the code content of different code objects; Compile the adjusted Lua virtual machine source code files to obtain a Lua virtual machine compiler that is incompatible with the officially released Lua virtual machine toolchain; The Lua source code file is compiled using the Lua virtual machine compiler to obtain bytecode files; The bytecode file is encrypted to generate a script file to be loaded. The script file to be loaded is then uploaded to the server. The bytecode file is different from the bytecode file obtained by compiling the Lua source code file using the officially released Lua virtual machine toolchain.

2. The method according to claim 1, characterized in that, The method further includes: Compile the adjusted Lua virtual machine source code files to obtain Lua compiled library files; The Lua compilation library file is invoked to execute the Lua source code file of the target application.

3. The method according to claim 1, characterized in that, The method further includes: Obtain the binary file imported by the Lua host process of the target application; The binary file is then packed to obtain a packed file; By editing the shell feature information of the packed file using binary code editing, a target binary file without shell features is obtained.

4. A script source code processing method, characterized in that, The method includes: The system receives a target application's script file to be loaded from a computer device. The script file to be loaded is obtained by encrypting the bytecode file after the computer device compiles the target application's Lua source code file using a Lua virtual machine compiler. The Lua virtual machine compiler is obtained by obfuscating and recompiling the Lua virtual machine source code file released by the target application platform, and the Lua virtual machine compiler is different from the officially released Lua virtual machine toolchain. The received script file to be loaded is decrypted to obtain the corresponding bytecode file; Load the decrypted bytecode file and update the Lua source code file of the target application. The bytecode file is different from the bytecode file obtained by compiling the Lua source code file using the officially released Lua virtual machine toolchain. The methods for obfuscating the Lua virtual machine source code files released by the target application platform include: Update the code content of the virtual machine source code in the Lua virtual machine source code file; the update refers to replacing the old code content with the new code content and / or swapping the code content of different code objects; Adjust the correspondence between virtual machine instructions and instruction information in the Lua virtual machine source code file.

5. The method according to claim 4, characterized in that, The method further includes: In response to a hot update signal blocking request, execute a hot update signal blocking script; the hot update signal blocking script is used to instruct that hot updates for any file to be loaded be blocked. In response to the hot update signal execution request, stop executing the hot update signal blocking script; The hot update signal blocking request is generated in response to the hot update signal blocking operation before the computer device sends the target application's script file to the server. The hot update signal execution request is generated by the computer device in response to the hot update signal execution operation, which is executed after the script file to be loaded for the target application is successfully uploaded to the server.

6. The method according to claim 4, characterized in that, The method further includes: In response to sandbox configuration requests from different host processes, configure the corresponding sandbox information; the sandbox information is used to restrict host processes from updating variables in the corresponding script files to be loaded. The step of loading the decrypted bytecode file and updating the Lua source code file of the target application includes: loading the decrypted bytecode file and updating the Lua source code file of the target application based on the sandbox information.

7. A script source code processing device, characterized in that, The device includes: The file acquisition module is used to acquire the Lua virtual machine source code file published on the target application platform, as well as the Lua source code file of the target application on the target application platform. The obfuscation module is used to update the code content of the virtual machine source code in the Lua virtual machine source code file and adjust the correspondence between virtual machine instructions and instruction information in the updated Lua virtual machine source code file; the update refers to replacing the old code content with the new code content and / or swapping the code content of different code objects; the Lua virtual machine compiler acquisition module is used to compile the adjusted Lua virtual machine source code file to obtain a Lua virtual machine compiler that is incompatible with the officially released Lua virtual machine toolchain; The bytecode file acquisition module is used to compile the Lua source code file using the Lua virtual machine compiler to obtain the bytecode file; The script file to be loaded module is used to encrypt the bytecode file and generate the script file to be loaded. The bytecode file is different from the bytecode file obtained by compiling the Lua source code file using the officially released Lua virtual machine toolchain. The script file transfer module is used to upload the script file to be loaded to the server.

8. The apparatus according to claim 7, characterized in that, The device further includes: The Lua compilation library file acquisition module is used to compile the adjusted Lua virtual machine source code file to obtain the Lua compilation library file; The execution module is used to call the Lua compilation library file and execute the Lua source code file of the target application.

9. The apparatus according to claim 7, characterized in that, The device further includes: A binary file acquisition module is used to acquire binary files imported by the Lua host process of the target application; The file packing module is used to pack the binary file to obtain a packed file; The file unpacking module is used to edit the shell feature information of the packed file through binary code editing to obtain a target binary file that does not contain shell features.

10. A script source code processing device, characterized in that, The device includes: The script file receiving module is used to receive the script file to be loaded for the target application sent by the computer device. The script file to be loaded is obtained by the computer device compiling the Lua source code file of the target application using the Lua virtual machine compiler, and then encrypting the resulting bytecode file. The Lua virtual machine compiler is obtained by obfuscating and recompiling the Lua virtual machine source code file released by the target application platform. The Lua virtual machine compiler is different from the officially released Lua virtual machine toolchain. The decryption module is used to decrypt the received script file to be loaded to obtain the corresponding bytecode file; The hot update module is used to load the decrypted bytecode file and update the Lua source code file of the target application. The bytecode file is different from the bytecode file obtained by compiling the Lua source code file using the officially released Lua virtual machine toolchain. The methods for obfuscating the Lua virtual machine source code files released by the target application platform include: Update the code content of the virtual machine source code in the Lua virtual machine source code file; the update refers to replacing the old code content with the new code content and / or swapping the code content of different code objects; Adjust the correspondence between virtual machine instructions and instruction information in the Lua virtual machine source code file.

11. The apparatus according to claim 10, characterized in that, The device further includes: A signal blocking module is used to respond to a hot update signal blocking request and execute a hot update signal blocking script; the hot update signal blocking script is used to instruct that hot updates for any file to be loaded be blocked. The signal cancellation module is used to respond to the hot update signal execution request and stop the execution of the hot update signal blocking script; The hot update signal blocking request is generated in response to the hot update signal blocking operation before the computer device sends the target application's script file to be loaded to the server; the hot update signal execution request is generated by the computer device in response to the hot update signal execution operation, which is executed after the target application's script file to be loaded is successfully uploaded to the server.

12. The apparatus according to claim 10, characterized in that, The device further includes: The sandbox information configuration module is used to respond to sandbox configuration requests from different host processes and configure corresponding sandbox information; the sandbox information is used to restrict host processes from updating variables in the corresponding script files to be loaded. The hot update module includes: The update unit is used to load the decrypted bytecode file based on the sandbox information and update the Lua source code file of the target application.

13. A computer device, characterized in that, The computer device includes: Communication interface; A memory for storing programs that implement the script source code processing method as described in claim 1 or 4; A processor is configured to load and execute the program stored in the memory, implementing the script source code processing method as described in claim 1 or 4.

14. A computer-readable storage medium, characterized in that, It stores a computer program, which is loaded and executed by a processor to implement the script source code processing method as described in claim 1 or 4.

15. A computer program product comprising computer instructions, characterized in that, The computer instructions are read and executed by the processor to implement the script source code processing method as described in claim 1 or 4.

Citation Information

Patent Citations

  • Script compiling method, script executing method, and related device and system

    CN108829396A

  • Resource updating method, device and equipment and storage medium

    CN110032384A