CN114925338A - Compiling method, device, equipment, medium and product - Google Patents

Compiling method, device, equipment, medium and product Download PDF

Info

Publication number
CN114925338A
CN114925338A CN202210506072.8A CN202210506072A CN114925338A CN 114925338 A CN114925338 A CN 114925338A CN 202210506072 A CN202210506072 A CN 202210506072A CN 114925338 A CN114925338 A CN 114925338A
Authority
CN
China
Prior art keywords
code
bytecode
link library
encrypted
original
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202210506072.8A
Other languages
Chinese (zh)
Inventor
傅泽楠
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing ByteDance Network Technology Co Ltd
Original Assignee
Beijing ByteDance Network Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing ByteDance Network Technology Co Ltd filed Critical Beijing ByteDance Network Technology Co Ltd
Priority to CN202210506072.8A priority Critical patent/CN114925338A/en
Publication of CN114925338A publication Critical patent/CN114925338A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F21/00Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
    • G06F21/10Protecting distributed programs or content, e.g. vending or licensing of copyrighted material ; Digital rights management [DRM]
    • G06F21/12Protecting executable software
    • G06F21/121Restricting unauthorised execution of programs
    • G06F21/125Restricting unauthorised execution of programs by manipulating the program code, e.g. source code, compiled code, interpreted code, machine code
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F21/00Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
    • G06F21/60Protecting data
    • G06F21/602Providing cryptographic facilities or services
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/41Compilation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/445Program loading or initiating
    • G06F9/44521Dynamic linking or loading; Link editing at or after load time, e.g. Java class loading

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Computer Security & Cryptography (AREA)
  • Computer Hardware Design (AREA)
  • General Health & Medical Sciences (AREA)
  • Bioethics (AREA)
  • Health & Medical Sciences (AREA)
  • Multimedia (AREA)
  • Technology Law (AREA)
  • Stored Programmes (AREA)

Abstract

The present disclosure discloses a compiling method, apparatus, device, medium, and product. The method comprises the following steps: compiling a pre-acquired original source code into an original byte code, wherein the original source code is an interpreted language; generating a corresponding dynamic link library or a static link library according to the original bytecode encryption bytecode and a pre-acquired native code template; reading and decrypting the encrypted bytecode in the dynamic link library or the static link library in response to the running operation of the program to obtain a decrypted bytecode; and calling a pre-created code runner to run the decrypted bytecode. According to the technical scheme, the original source code of the interpreted language is compiled into the original byte code in advance and encrypted, code decryption and code operation logic are realized in a dynamic link library or a static link library which is created in advance, and a code operator is called to operate the decrypted byte code, so that an attacker cannot obtain the source code and the program logic and cannot read and tamper illegally.

Description

Compiling method, device, equipment, medium and product
Technical Field
The present disclosure relates to the field of computer technologies, and in particular, to a compiling method, apparatus, device, medium, and product.
Background
As computers continue to evolve, applications may be developed in different types of languages (e.g., interpreted languages, compiled languages, etc.).
When an application program is developed by adopting an interpreted language, the method means that source code needs to be carried at the time of program distribution. The application program is cracked by reading the source code, so that great risk is brought to the product. Therefore, how to avoid reading and tampering the source code is an urgent problem to be solved.
Disclosure of Invention
The present disclosure provides a compiling method, apparatus, device, medium, and product to solve the problem in the prior art that a source code is read and tampered with, and to compile, encrypt, and hide the source code in advance, thereby preventing the source code from being read and tampered with.
According to an aspect of the present disclosure, there is provided a compiling method including:
compiling the pre-acquired original source code into a corresponding original byte code; wherein the original source code is an interpreted language;
generating a corresponding dynamic link library or a static link library according to the encrypted bytecode corresponding to the original bytecode and a pre-acquired native code template;
reading and decrypting the encrypted bytecode in the dynamic link library or the static link library in response to the running operation of a program to obtain a decrypted bytecode;
and calling a pre-created code runner to run the decrypted bytecode.
According to another aspect of the present disclosure, there is provided a compiling apparatus including:
the compiling module is used for compiling the pre-acquired original source code into a corresponding original byte code; wherein the original source code is an interpreted language;
the generating module is used for generating a corresponding dynamic link library or a corresponding static link library according to the encrypted bytecode corresponding to the original bytecode and a pre-acquired native code template;
the decryption module is used for reading and decrypting the encrypted byte codes in the dynamic link library or the static link library in response to the running operation of a program to obtain decrypted byte codes;
and the calling operation module is used for calling a pre-established code operator to operate the decryption bytecode.
According to another aspect of the present disclosure, there is provided an electronic device including:
at least one processor; and
a memory communicatively coupled to the at least one processor; wherein,
the memory stores a computer program executable by the at least one processor, the computer program being executable by the at least one processor to enable the at least one processor to perform the compiling method according to any of the embodiments of the disclosure.
According to another aspect of the present disclosure, a computer-readable storage medium is provided, which stores computer instructions for causing a processor to implement a compiling method according to any embodiment of the present disclosure when executed.
According to another aspect of the present disclosure, there is provided a computer program product comprising a computer program which, when executed by a processor, implements the compiling method according to any one of the embodiments of the present disclosure.
According to the technical scheme of the embodiment of the disclosure, original source codes of an interpreted language are compiled into corresponding original byte codes in advance, then the original byte codes are encrypted, and corresponding dynamic link libraries or static link libraries are generated according to the encrypted byte codes and pre-obtained native code templates; and then, the logic of code decryption and code operation is realized in the dynamic link library or the static link library, and a code operator is called to operate the decryption byte code, so that an attacker cannot acquire the source code and the program logic and cannot illegally read and tamper the source code and the program logic.
It should be understood that the statements in this section do not necessarily identify key or critical features of the embodiments of the present disclosure, nor do they limit the scope of the present disclosure. Other features of the present disclosure will become apparent from the following description.
Drawings
In order to more clearly illustrate the technical solutions in the embodiments of the present disclosure, the drawings required to be used in the description of the embodiments are briefly introduced below, and it is apparent that the drawings in the description below are only some embodiments of the present disclosure, and it is obvious for those skilled in the art that other drawings may be obtained according to the drawings without creative efforts.
Fig. 1 is a flowchart of a compiling method provided by an embodiment of the present disclosure;
FIG. 2 is a flow chart of another compiling method provided by the embodiments of the present disclosure;
fig. 3 is a schematic structural diagram of a compiling apparatus according to an embodiment of the disclosure;
fig. 4 is a schematic structural diagram of an electronic device provided in an embodiment of the present disclosure.
Detailed Description
In order to make the technical solutions of the present disclosure better understood by those skilled in the art, the technical solutions of the embodiments of the present disclosure will be clearly and completely described below with reference to the drawings in the embodiments of the present disclosure, and it is obvious that the described embodiments are only some embodiments of the present disclosure, not all embodiments. All other embodiments obtained by a person of ordinary skill in the art based on the embodiments in the present disclosure without making creative efforts shall fall within the protection scope of the present disclosure.
It should be noted that the terms "original", "encrypted", "decrypted", etc. in the description and claims of the present disclosure and the above-mentioned drawings are used for distinguishing similar objects and are not necessarily used for describing a specific order or sequence. It is to be understood that the data so used is interchangeable under appropriate circumstances such that the embodiments of the disclosure described herein are capable of operation in other sequences than those illustrated or described herein. Furthermore, the terms "comprises," "comprising," and "having," and any variations thereof, are intended to cover a non-exclusive inclusion, such that a process, method, system, article, or apparatus that comprises a list of steps or elements is not necessarily limited to those steps or elements expressly listed, but may include other steps or elements not expressly listed or inherent to such process, method, article, or apparatus.
In an embodiment, fig. 1 is a flowchart of a compiling method provided by an embodiment of the present disclosure, where the embodiment is applicable to a case of protecting a source code, and the method may be executed by a compiling apparatus, where the compiling apparatus may be implemented in a form of hardware and/or software, and the compiling apparatus may be configured in an electronic device. As shown in fig. 1, the method includes:
s110, compiling the pre-acquired original source code into a corresponding original byte code.
Wherein the original source code is an interpreted language. In an embodiment, the source code refers to an uncompiled text file written according to a certain programming language specification, and is a readable computer language instruction. In an embodiment, the original source code may be an interpreted language. In an embodiment, the original source code may be pre-compiled by a pre-configured compiling module to obtain a corresponding bytecode, which is used as an original bytecode. Of course, in the actual compiling process, the running environment of the original source code may be different, and the corresponding adopted compiling module may also be different. Exemplarily, if the running environment corresponding to the original source code is environment 1, the original source code may be compiled by using the compiling module 1 to obtain a corresponding bytecode; for another example, if the running environment corresponding to the original source code is environment 2, the compiling module 2 may be adopted to compile the original source code to obtain the corresponding bytecode. It should be noted that, in different operating environments, the adopted compiling modules may be the same type of compiling module, or may be different types of compiling modules.
And S120, generating a corresponding dynamic link library or a corresponding static link library according to the encrypted bytecode corresponding to the original bytecode and the pre-acquired native code template.
The encrypted bytecode refers to a bytecode obtained by encrypting an original bytecode. It can be understood that the original bytecode is encrypted by using a preset encryption algorithm to obtain a corresponding encrypted bytecode. In the actual encryption process, the encryption algorithm can be customized according to the service corresponding to the original source code, and the original bytecode is encrypted through the encryption algorithm to obtain the corresponding encrypted bytecode.
Where a native code template refers to a native code file that may be used to store bytecode. Illustratively, the native code template may be a code file of C language, and may also be a code file of other programming languages. In the embodiment, a native code template is obtained in advance, then all data of files corresponding to all encrypted bytecodes corresponding to an original bytecode is inserted into the native code template obtained in advance, and a corresponding dynamic link library or static link library is obtained through compiling. Wherein, the dynamic link library refers to a DLL file; statically linked libraries refer to lib files.
In an embodiment, a pre-configured native code generator may be used to compile a native code template to obtain a corresponding dynamic link library or static link library.
And S130, reading and decrypting the encrypted byte codes in the dynamic link library or the static link library in response to the running operation of the program to obtain decrypted byte codes.
In the embodiment, the encrypted bytecode in the dynamic link library or the static link library is read, and the encrypted bytecode is decrypted by adopting a preset decryption algorithm to obtain a corresponding decrypted bytecode. It should be noted that the preset encryption algorithm used for the original bytecode and the preset decryption algorithm used for the encrypted bytecode may be a symmetric key, and may also be reversible encryption algorithms such as an asymmetric key, which is not limited herein. It can be understood that when symmetric keys are used for decryption, the encryption key and the decryption key are the same; when the asymmetric key is used for decryption, the encryption key and the decryption key are different.
And S140, calling a pre-created code runner to run the decrypted bytecode.
Wherein, the code runner refers to a module which can load a dynamic link library or a static link library. In an embodiment, a dynamic link library or a static link library may be loaded in the code runner to call a run function to run the decrypted bytecode.
According to the technical scheme of the embodiment of the disclosure, original source codes of an interpretation type language are compiled into corresponding original byte codes in advance, then the original byte codes are encrypted, and the encrypted byte codes are stored in a dynamic link library or a static link library; and then, the logic of code decryption and code operation is realized in the dynamic link library or the static link library, and a code operator is called to operate the decrypted byte code, so that an attacker cannot acquire the source code and the program logic and cannot illegally read and tamper the source code and the program logic.
In an embodiment, fig. 2 is a flowchart of another compiling method provided by the embodiment of the disclosure, and the embodiment further describes the above steps based on the above embodiment. As shown in fig. 2, the method includes:
s210, compiling the pre-acquired original source code through a pre-configured byte code compiler to obtain a corresponding original byte code.
The original source code is source code corresponding to one or more original source code files. In an embodiment, a bytecode compiler is used for a tool to compile all source code into bytecode. It should be noted that the bytecode compiler may also be a code runner, where the code runner is used as a tool for loading and running a dynamic link library or a static link library. It will be appreciated that in the case of a code runner with compilation functionality, the code runner may be referred to as a bytecode compiler. In an embodiment, the original source code files may be compiled one by one to obtain corresponding original byte codes; or combining a plurality of original source code files into one file to be compiled to obtain the corresponding original byte codes. In the embodiment, the original source code is compiled by using the compiling function carried in the bytecode compiler or the code runner of the used language, so as to obtain the corresponding original bytecode.
It should be noted that, when the operating environment corresponding to the original source code is a special environment (for example, node. js), the original source code may be compiled by using a code operator to obtain a corresponding original bytecode; when the running environment corresponding to the original source code is a conventional environment, the original source code can be compiled directly by adopting a byte code compiler to obtain the corresponding original byte code.
S220, determining an array statement expression of the preset element type corresponding to the encrypted bytecode.
Wherein the preset element type refers to a preconfigured element type. Illustratively, the preset element type may be a char type. In an embodiment, data corresponding to the encrypted bytecode may be read into a memory, an array having an element type of char type may be obtained, and the array may be stored in an array declaration expression. Illustratively, the encrypted bytecode may be converted into a character string of [1,2,3,4], and then the character string is taken as a code fragment, and a corresponding data declaration expression is generated using the code fragment.
And S230, processing the unique identification name of the bytecode corresponding to the array declaration expression and the encrypted bytecode, and generating a corresponding code segment.
In one embodiment, S230 includes:
s2301, using the character string of the unique identification name of the bytecode corresponding to the encrypted bytecode as a key, and using the tuple created by the tuple declaration expression as a value.
The unique identification name of the byte code is used for representing the unique identification of each byte code. Illustratively, the unique identifying name of the bytecode may be a file relative path of the bytecode. The file relative path refers to a path relationship with other files caused by a path where the file is located. In an embodiment, the unique identification name of the bytecode corresponding to the encrypted bytecode is used as a key, and the tuple created by the tuple declaration expression is used as a value.
S2302, combining the keys and the values according to preset data types to obtain corresponding code segments.
Wherein, the preset data type refers to a Hash Map structure. Illustratively, the preset data type may be std: map in a C + + standard library, or dit in Python. In the embodiment, a character string of the unique identification name of the bytecode corresponding to the encrypted bytecode is used as a key, an array created by the array declaration expression is used as a value to obtain a key value pair, and the key and the value are combined according to a preset data type to obtain a corresponding code segment.
Illustratively, assuming C + + as an example, the bytecode is saved in HashMap, and the following code fragments are generated:
std::map<std::string,
std::vector<char>>map;
map [ "bytecode 1 unique identifier" ] ═ bytecode 1 content;
map [ "bytecode 2 unique identifier" ] ═ bytecode 2 content;
and S240, inserting the code segments into the pre-acquired native code template, and compiling to obtain a corresponding dynamic link library or a corresponding static link library.
In one embodiment, the native code template includes at least the following functions: an obtaining function of the encrypted byte code; an acquisition function to decrypt the bytecode. In an embodiment, the native code template needs to have the function of obtaining the encrypted bytecode, and the function of obtaining the decrypted bytecode. In an embodiment, the functions of acquiring the encrypted bytecode and the decrypted bytecode can be realized by customizing an acquisition function, that is, a function of acquiring the encrypted bytecode and a function of acquiring the decrypted bytecode are customized.
Inserting the code segments into the area of the native code template in which the codes can be dynamically inserted, calling a native code compiler, and compiling the native code template into which the code segments are dynamically inserted to obtain a corresponding dynamic link library or a corresponding static link library.
And S250, determining a corresponding reading mode according to the position of the encrypted byte code in the dynamic link library or the static link library.
The reading mode refers to a mode of reading the encrypted byte codes from a dynamic link library or a static link library. In the actual operation process, the encrypted bytecode may be stored at different locations, and correspondingly, the reading mode of the encrypted bytecode may also be different. Illustratively, the encrypted bytecode may be stored in the PE resource table, or may be stored as a constant in the executable file.
And S260, reading the encrypted byte codes in the dynamic link library or the static link library according to the reading mode.
In an embodiment, in the case that the encrypted bytecode is stored in the PE resource table, the decrypted bytecode may be read by using a LoadResource method; when the encrypted bytecode is stored in the executable file as a constant, the constant can be directly accessed, and the encrypted bytecode can be acquired.
S270, decrypting the encrypted byte code by adopting a preset decryption algorithm to obtain a decrypted byte code.
The preset decryption algorithm and the preset encryption algorithm may be symmetric keys or asymmetric keys. Certainly, if the preset decryption algorithm and the preset encryption algorithm use symmetric keys, the key for decrypting the encrypted bytecode is the same as the key for encrypting the original bytecode; if the preset decryption algorithm and the preset encryption algorithm use asymmetric keys, the key for decrypting the encrypted bytecode is different from the key for encrypting the original bytecode.
S280, the code acquisition runner loads a running function of the dynamic link library or the static link library.
In an embodiment, when a code runner is used to load a dynamically linked library or statically linked library, the code runner may expose some of the run functions back to the loaded dynamically linked library or statically linked library.
And S290, operating the decryption bytecode through the operating function.
In an embodiment, the decryption bytecode is run through an exposed run function. Of course, the source code may also be run by a run function.
According to the technical scheme of the embodiment, on the basis of the embodiment, the steps of reading, decrypting and running the encrypted bytecode are triggered by the running function exposed while the code runner loads the dynamic link library or the static link library, so that the logic of code decryption and code running in the dynamic link library or the static link library is realized, and the code runner is called to run the decrypted bytecode, so that an attacker cannot acquire the source code and the program logic and cannot illegally read and tamper the source code and the program logic.
In one embodiment, an implementation of a code loader is described. In embodiments, the code loader refers to a dynamically linked library or a statically linked library developed in a native language (e.g., C + +). The method has two functions of storing the encrypted byte codes; decrypts and runs the bytecode.
In an embodiment, a specific implementation process of the code loader includes:
and S10, reading the encrypted byte codes stored by the self.
In the embodiment, there are many ways to read the encrypted bytecode, for example, for a dynamic link library under a Windows platform, if the encrypted bytecode is stored in a PF Resource table, the bytecode can be read by using a Load Resource method; if the encrypted bytecode is stored as a constant in the native program code by using the code generator, the encrypted bytecode can be obtained by only directly accessing the constant.
And S11, after the encrypted byte code is read, decrypting the encrypted byte code to obtain a decrypted byte code.
In the embodiment, there are many Encryption and decryption methods, in the scheme, the user can customize the Encryption method according to the service, such as simple xor Encryption, and complex Advanced Encryption Standard (AES) Encryption.
And S12, calling a code runner to run the decryption bytecode.
In embodiments, the interpreted language is run by a code runner, which may load dynamically linked libraries or statically linked libraries at compile time, which typically exposes functions to the dynamically linked libraries or statically linked libraries that it loads for running source code or bytecode. In this embodiment, the decrypted bytecode is run using the exposed run function.
In an embodiment, the code loader is distributed in the form of a dynamically linked library or a statically linked library, and usually exposes a run function for triggering the above steps of reading, decrypting, and running the bytecode. In an embodiment, the program logic can be run by simply loading a "code loader" in a program run host (a runner for running an interpreted language like Electron or node. js) and executing the above-mentioned run function.
In one embodiment, a process of compiling a program is described. A compiler refers to a tool that compiles program source code into a usable code loader. In an embodiment, the compiler consists of three modules, a bytecode compiler; a native code generator; a compilation tool or a machining tool of a code loader.
First, the function of the bytecode compiler is to compile all source code files into bytecode. Specifically, the implementation process of the bytecode compiler includes:
s21, if there are multiple source code files, the codes can be combined into one file for compiling, or the files can be compiled one by one.
And S22, compiling all source codes into byte codes by using a self-contained code compiler of the used language or a compiling function carried in a runner.
In an embodiment, compiling source code into bytecode is generally the work of a code compiler, except that some special execution environments, such as node.
In one embodiment, the native code is automatically generated based on a bytecode file generated by a bytecode compiler. The implementation of the native code generator is explained. Specifically, the implementation process of obtaining the dynamic link library or the static link library by using the native code generator includes:
first, a native code template storing bytecode is obtained.
In an embodiment, the native code template is generally a code file in C language, and may also be a file in other programming languages, and the content of the template is as follows in the corresponding programming language:
firstly, a function for acquiring the encrypted byte code is defined, and the internal implementation is as follows:
defining a hash table; a region capable of dynamically inserting codes, wherein the code content is that a key-value pair is added into a hash table; returning to the hash table.
Secondly, a function for acquiring the decrypted byte code is defined, and the internal implementation is as follows:
calling a function for acquiring the encrypted bytecode, and acquiring the encrypted bytecode; decrypting the byte code by using a decryption method to obtain an original byte code; returning original bytecode
Wherein the other code content is implementation code of a "code loader".
Then, reading data of all bytecode files into a memory, obtaining an array with an element type of char type, and converting the array into an array declaration expression in the used native programming language (for example, the array declaration expression can be converted into a character string of [1,2,3,4] in C language).
Then, the tuple declaration expression and the unique identifier name of the bytecode (for example, the unique identifier name may be a relative path of the bytecode file) are processed to generate a code segment for inserting data into the hash table, where the unique identifier name of the bytecode is used as a key and the tuple created by the tuple declaration expression is used as a value. The code fragments are then inserted into "regions where code can be dynamically inserted" in the native code template.
And finally, calling a native code compiler, compiling the processed native code template, and compiling the dynamic link library or the static link library.
Therefore, as long as the code loader is loaded in the code runner and the running function is called, the program code logic can be normally run. When the program is distributed, only a code runner and a code loader need to be distributed, wherein the code loader comprises encrypted byte codes, and decryption logic is difficult to decompile. And compared with the source code, the bytecode is more difficult to read and parse, and the effect of protecting the source code is also achieved.
In an embodiment, fig. 3 is a schematic structural diagram of a compiling apparatus according to an embodiment of the present disclosure. As shown in fig. 3, the apparatus includes: a compiling module 310, a generating module 320, a decrypting module 330 and a call running module 340.
The compiling module 310 is configured to compile a pre-obtained original source code into a corresponding original bytecode; wherein the original source code is an interpreted language;
a generating module 320, configured to generate a corresponding dynamic link library or a corresponding static link library according to the encrypted bytecode corresponding to the original bytecode and a pre-obtained native code template;
the decryption module 330 is configured to, in response to a program running operation, read and decrypt the encrypted bytecode in the dynamic link library or the static link library to obtain a decrypted bytecode;
and a call execution module 340, configured to call a pre-created code runner to execute the decrypted bytecode.
It should be noted that the decryption module 330 and the call execution module 340 may be included in a dynamically linked library or a statically linked library as logical units. As can be understood, the decryption module 330 included in the dynamic link library or the static link library decrypts the encrypted bytecode to obtain a decrypted bytecode; the decryption bytecode is then executed by calling the code runner through the call execution module 340 included in the dynamic link library or the static link library.
Optionally, the compiling module 310 is specifically configured to: compiling the pre-acquired original source code through a pre-configured bytecode compiler or a pre-configured code runner to obtain a corresponding original bytecode; and the original source code is the source code corresponding to one or more original source code files.
Optionally, the generating module 320 includes:
the determining unit is used for determining an array declaration expression of a preset element type corresponding to the encrypted bytecode;
the generating unit is used for processing the array declaration expression and the unique identification name of the byte code corresponding to the encrypted byte code to generate a corresponding code segment;
and the compiling unit is used for inserting the code segments into a pre-acquired native code template and compiling to obtain a corresponding dynamic link library or a corresponding static link library.
Optionally, the decryption module 330 includes:
the first determining unit is used for determining a corresponding reading mode according to the position of the encrypted bytecode in the dynamic link library or the static link library;
the reading unit is used for reading the encrypted byte codes in the dynamic link library or the static link library according to the reading mode;
and the decryption unit is used for decrypting the encrypted byte code by adopting a preset decryption algorithm to obtain a decrypted byte code.
Optionally, the call execution module 340 includes:
the code runner is used for loading a running function of the dynamic link library or the static link library;
and the operation unit is used for operating the decryption byte codes through the operation function.
Optionally, the generating unit includes:
a determining subunit, configured to use a character string of a unique identification name of a bytecode corresponding to the encrypted bytecode as a key, and use an array created by the array declaration expression as a value;
and the generating subunit is used for combining the key and the value according to a preset data type to obtain a corresponding code segment.
Optionally, the native code template comprises at least the following function: an obtaining function of the encrypted byte code; an acquisition function to decrypt the bytecode.
The compiling device provided by the embodiment of the disclosure can execute the compiling method provided by any embodiment of the disclosure, and has corresponding functional modules and beneficial effects of the executing method.
In an embodiment, fig. 4 is a schematic structural diagram of an electronic device provided in an embodiment of the present disclosure. Electronic devices are intended to represent various forms of digital computers, such as laptops, desktops, workstations, personal digital assistants, servers, blade servers, mainframes, and other appropriate computers. The electronic device may also represent various forms of mobile devices, such as personal digital assistants, cellular phones, smart phones, wearable devices (e.g., helmets, glasses, watches, etc.), and other similar computing devices. The components shown herein, their connections and relationships, and their functions, are meant to be examples only, and are not intended to limit implementations of the disclosure described and/or claimed herein.
As shown in fig. 4, the electronic device 10 includes at least one processor 11, and a memory communicatively connected to the at least one processor 11, such as a Read Only Memory (ROM)12, a Random Access Memory (RAM)13, and the like, wherein the memory stores a computer program executable by the at least one processor, and the processor 11 can perform various suitable actions and processes according to the computer program stored in the Read Only Memory (ROM)12 or the computer program loaded from a storage unit 18 into the Random Access Memory (RAM) 13. In the RAM 13, various programs and data necessary for the operation of the electronic apparatus 10 may also be stored. The processor 11, the ROM 12, and the RAM 13 are connected to each other via a bus 14. An input/output (I/O) interface 15 is also connected to bus 14.
A number of components in the electronic device 10 are connected to the I/O interface 15, including: an input unit 16 such as a keyboard, a mouse, or the like; an output unit 17 such as various types of displays, speakers, and the like; a storage unit 18 such as a magnetic disk, optical disk, or the like; and a communication unit 19 such as a network card, modem, wireless communication transceiver, etc. The communication unit 19 allows the electronic device 10 to exchange information/data with other devices via a computer network such as the internet and/or various telecommunication networks.
The processor 11 may be a variety of general and/or special purpose processing components having processing and computing capabilities. Some examples of processor 11 include, but are not limited to, a Central Processing Unit (CPU), a Graphics Processing Unit (GPU), various specialized Artificial Intelligence (AI) computing chips, various processors running machine learning model algorithms, a Digital Signal Processor (DSP), and any suitable processor, controller, microcontroller, or the like. The processor 11 performs the various methods and processes described above, such as compiling methods.
In some embodiments, the compilation method may be implemented as a computer program that is tangibly embodied on a computer-readable storage medium, such as storage unit 18. In some embodiments, part or all of the computer program may be loaded and/or installed onto the electronic device 10 via the ROM 12 and/or the communication unit 19. When the computer program is loaded into RAM 13 and executed by processor 11, one or more steps of the compiling method described above may be performed. Alternatively, in other embodiments, the processor 11 may be configured by any other suitable means (e.g., by means of firmware) to perform a compilation method, including: compiling the pre-acquired original source code into a corresponding original byte code; wherein the original source code is an interpreted language; generating a corresponding dynamic link library or a static link library according to the encrypted bytecode corresponding to the original bytecode and a pre-acquired native code template; reading and decrypting the encrypted bytecode in the dynamic link library or the static link library in response to the running operation of a program to obtain a decrypted bytecode; and calling a pre-established code runner to run the decryption bytecode.
Various implementations of the systems and techniques described here above may be implemented in digital electronic circuitry, integrated circuitry, Field Programmable Gate Arrays (FPGAs), Application Specific Integrated Circuits (ASICs), Application Specific Standard Products (ASSPs), system on a chip (SOCs), load programmable logic devices (CPLDs), computer hardware, firmware, software, and/or combinations thereof. These various embodiments may include: implemented in one or more computer programs that are executable and/or interpretable on a programmable system including at least one programmable processor, which may be special or general purpose, receiving data and instructions from, and transmitting data and instructions to, a storage system, at least one input device, and at least one output device.
A computer program for implementing the methods of the present disclosure may be written in any combination of one or more programming languages. These computer programs may be provided to a processor of a general purpose computer, special purpose computer, or other programmable data processing apparatus, such that the computer programs, when executed by the processor, cause the functions/acts specified in the flowchart and/or block diagram block or blocks to be performed. A computer program can execute entirely on a machine, partly on a machine, as a stand-alone software package partly on a machine and partly on a remote machine or entirely on a remote machine or server.
In the context of this disclosure, a computer-readable storage medium may be a tangible medium that can contain, or store a computer program for use by or in connection with an instruction execution system, apparatus, or device. A computer readable storage medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any suitable combination of the foregoing. Alternatively, the computer readable storage medium may be a machine readable signal medium. More specific examples of a machine-readable storage medium would include an electrical connection based on one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
To provide for interaction with a user, the systems and techniques described here can be implemented on an electronic device having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to a user; and a keyboard and a pointing device (e.g., a mouse or a trackball) by which a user may provide input to the electronic device. Other kinds of devices may also be used to provide for interaction with a user; for example, feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user may be received in any form, including acoustic, speech, or tactile input.
The systems and techniques described here can be implemented in a computing system that includes a back-end component (e.g., as a data server), or that includes a middleware component (e.g., an application server), or that includes a front-end component (e.g., a user computer having a graphical user interface or a web browser through which a user can interact with an implementation of the systems and techniques described here), or any combination of such back-end, middleware, or front-end components. The components of the system can be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: local Area Networks (LANs), Wide Area Networks (WANs), blockchain networks, and the Internet.
The computing system may include clients and servers. A client and server are generally remote from each other and typically interact through a communication network. The relationship of client and server arises by virtue of computer programs running on the respective computers and having a client-server relationship to each other. The server can be a cloud server, also called a cloud computing server or a cloud host, and is a host product in a cloud computing service system, so that the defects of high management difficulty and weak service expansibility in the traditional physical host and VPS service are overcome.
According to one or more embodiments of the present disclosure, [ example 1 ] there is provided a compiling method including:
compiling the pre-acquired original source code into a corresponding original byte code; wherein the original source code is an interpreted language;
generating a corresponding dynamic link library or a static link library according to the encrypted bytecode corresponding to the original bytecode and a pre-acquired native code template;
reading and decrypting the encrypted bytecode in the dynamic link library or the static link library in response to the running operation of a program to obtain a decrypted bytecode;
and calling a pre-created code runner to run the decrypted bytecode.
According to one or more embodiments of the present disclosure, [ example 2 ] there is provided the method of example 1, said compiling pre-fetched original source code into corresponding original bytecode, comprising:
compiling the pre-acquired original source code through a pre-configured bytecode compiler or a pre-configured code runner to obtain a corresponding original bytecode; and the original source code is source code corresponding to one or more original source code files.
According to one or more embodiments of the present disclosure, [ example 3 ] there is provided the method of example 1, the generating of the corresponding dynamic link library or static link library according to the encrypted bytecode corresponding to the original bytecode and a pre-obtained native code template, comprising:
determining an array declaration expression of a preset element type corresponding to the encrypted bytecode;
processing the array declaration expression and the unique identification name of the byte code corresponding to the encrypted byte code to generate a corresponding code segment;
and inserting the code segments into a pre-acquired native code template, and compiling to obtain a corresponding dynamic link library or a corresponding static link library.
According to one or more embodiments of the present disclosure, [ example 4] there is provided the method of example 1, the reading and decrypting the encrypted bytecode in the dynamically linked library or the statically linked library to obtain a decrypted bytecode, including:
determining a corresponding reading mode according to the position of the encrypted bytecode in a dynamic link library or a static link library;
reading the encrypted byte codes in the dynamic link library or the static link library according to the reading mode;
and decrypting the encrypted byte code by adopting a preset decryption algorithm to obtain a decrypted byte code.
According to one or more embodiments of the present disclosure, [ example 5 ] there is provided the method of example 1 or example 2, the invoking a pre-created code runner to run the decrypted bytecode, comprising:
acquiring a running function of a code runner for loading a dynamic link library or a static link library;
and executing the decryption byte code through the execution function.
According to one or more embodiments of the present disclosure, [ example 6 ] there is provided the method of example 3, the processing the array declaration expression and the unique identification name of the bytecode corresponding to the original bytecode, generating a corresponding code fragment, comprising:
taking a character string of the unique identification name of the bytecode corresponding to the original bytecode as a key, and taking an array created by the array declaration expression as a value;
and combining the key and the value according to a preset data type to obtain a corresponding code segment.
According to one or more embodiments of the present disclosure, [ example 7 ] there is provided the method of any of examples 1-6, the native code template comprising at least the following function: encrypting an acquisition function of the bytecode; an acquisition function to decrypt the bytecode.
It should be understood that various forms of the flows shown above may be used, with steps reordered, added, or deleted. For example, the steps described in the present disclosure may be executed in parallel or sequentially or in different orders, and are not limited herein as long as the desired results of the technical solutions of the present disclosure can be achieved.
The above detailed description should not be construed as limiting the scope of the disclosure. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions may be made in accordance with design requirements and other factors. Any modification, equivalent replacement, and improvement made within the spirit and principle of the present disclosure should be included in the scope of protection of the present disclosure.

Claims (11)

1. A compilation method, comprising:
compiling the pre-acquired original source code into a corresponding original byte code; wherein the original source code is an interpreted language;
generating a corresponding dynamic link library or a static link library according to the encrypted bytecode corresponding to the original bytecode and a pre-acquired native code template;
reading and decrypting the encrypted bytecode in the dynamic link library or the static link library in response to the running operation of a program to obtain a decrypted bytecode;
and calling a pre-created code runner to run the decrypted bytecode.
2. The method of claim 1, wherein compiling the pre-fetched original source code into the corresponding original bytecode comprises:
compiling the pre-acquired original source code through a pre-configured byte code compiler to obtain a corresponding original byte code; and the original source code is the source code corresponding to one or more original source code files.
3. The method according to claim 1, wherein the generating a corresponding dynamic link library or static link library according to the encrypted bytecode corresponding to the original bytecode and a pre-obtained native code template includes:
determining an array declaration expression of a preset element type corresponding to the encrypted bytecode;
processing the array declaration expression and the unique identification name of the byte code corresponding to the encrypted byte code to generate a corresponding code segment;
and inserting the code segments into a pre-acquired native code template, and compiling to obtain a corresponding dynamic link library or a corresponding static link library.
4. The method of claim 1, wherein reading and decrypting the encrypted bytecode in the dynamically linked library or the statically linked library to obtain a decrypted bytecode comprises:
determining a corresponding reading mode according to the position of the encrypted byte code in a dynamic link library or a static link library;
reading the encrypted byte codes in the dynamic link library or the static link library according to the reading mode;
and decrypting the encrypted byte code by adopting a preset decryption algorithm to obtain a decrypted byte code.
5. The method of claim 1, wherein invoking the pre-created code runner to run the decrypted bytecode comprises:
acquiring a running function of a code runner for loading a dynamic link library or a static link library;
and running the decryption byte code through the running function.
6. The method of claim 3, wherein processing the array declaration expression and the unique identification name of the bytecode corresponding to the encrypted bytecode to generate a corresponding code fragment, comprises:
taking a character string of the unique identification name of the bytecode corresponding to the encrypted bytecode as a key, and taking an array created by an array declaration expression as a value;
and combining the key and the value according to a preset data type to obtain a corresponding code segment.
7. The method of any of claims 1-6, wherein the native code template comprises at least the following function: encrypting an acquisition function of the bytecode; an acquisition function to decrypt the bytecode.
8. A compiling apparatus characterized by comprising:
the compiling module is used for compiling the pre-acquired original source code into a corresponding original byte code; wherein the original source code is an interpreted language;
the generating module is used for generating a corresponding dynamic link library or a corresponding static link library according to the encrypted bytecode corresponding to the original bytecode and a pre-acquired native code template;
the decryption module is used for reading and decrypting the encrypted byte codes in the dynamic link library or the static link library in response to the running operation of a program to obtain decrypted byte codes;
and the calling operation module is used for calling a pre-established code operator to operate the decryption bytecode.
9. An electronic device, characterized in that the electronic device comprises:
at least one processor; and
a memory communicatively coupled to the at least one processor; wherein,
the memory stores a computer program executable by the at least one processor to enable the at least one processor to perform the compiling method of any of claims 1-7.
10. A computer-readable storage medium, having stored thereon computer instructions for causing a processor to execute a compiling method according to any one of claims 1-7.
11. A computer program product, characterized in that the computer program product comprises a computer program which, when being executed by a processor, implements a compiling method according to any one of claims 1-7.
CN202210506072.8A 2022-05-10 2022-05-10 Compiling method, device, equipment, medium and product Pending CN114925338A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210506072.8A CN114925338A (en) 2022-05-10 2022-05-10 Compiling method, device, equipment, medium and product

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210506072.8A CN114925338A (en) 2022-05-10 2022-05-10 Compiling method, device, equipment, medium and product

Publications (1)

Publication Number Publication Date
CN114925338A true CN114925338A (en) 2022-08-19

Family

ID=82807961

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210506072.8A Pending CN114925338A (en) 2022-05-10 2022-05-10 Compiling method, device, equipment, medium and product

Country Status (1)

Country Link
CN (1) CN114925338A (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115268937A (en) * 2022-09-27 2022-11-01 中国空气动力研究与发展中心计算空气动力研究所 Multi-phase flow field initialization method, device, equipment and medium
CN115686525A (en) * 2022-09-09 2023-02-03 上海和今信息科技有限公司 Code processing method and device

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115686525A (en) * 2022-09-09 2023-02-03 上海和今信息科技有限公司 Code processing method and device
CN115268937A (en) * 2022-09-27 2022-11-01 中国空气动力研究与发展中心计算空气动力研究所 Multi-phase flow field initialization method, device, equipment and medium
CN115268937B (en) * 2022-09-27 2023-02-17 中国空气动力研究与发展中心计算空气动力研究所 Multi-phase flow field initialization method, device, equipment and medium

Similar Documents

Publication Publication Date Title
CN107408135B (en) Database server and client for query processing of encrypted data
US10152430B2 (en) Cryptographic pointer address encoding
US11120018B2 (en) Spark query method and system supporting trusted computing
WO2021217980A1 (en) Java code packing method and system
CN107908392B (en) Data acquisition kit customization method and device, terminal and storage medium
CN114925338A (en) Compiling method, device, equipment, medium and product
US10482263B2 (en) Computing on encrypted data using deferred evaluation
CN107506256B (en) Method and device for monitoring crash data
CN105022936A (en) Class file encryption and decryption method and class file encryption and decryption device
CN107871066B (en) Code compiling method and device based on android system
CN113568680B (en) Dynamic link library protection method, device, equipment and medium for application program
US11036527B2 (en) Class splitting in object-oriented environments
CN107678755B (en) Installation package packaging method and device, electronic equipment and computer readable medium
CN113032741A (en) Class file encryption method, class file operation method, device, equipment and medium
CN112416395A (en) Hot repair updating method and device
CN112182518A (en) Software deployment method and device
CN114154123B (en) Encryption protection method applied to Python project
CN104657631A (en) Processing method and device of channel information of application
JP2023065323A (en) Computer-implemented method, system and computer program
CN113138797B (en) Intel SGX-oriented program automation transplanting system
CN113741949A (en) Method, device and equipment for generating application program installation package and storage medium
CN108427559B (en) Script file generation and calling method and device
CN111460464B (en) Data encryption and decryption method and device, electronic equipment and computer storage medium
CN113742008B (en) Interface calling method and device, electronic equipment and storage medium
CN113010174A (en) Service monitoring method and device

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination