A processing method, apparatus and electronic device

By breaking down the source code of low-code platform applications into constituent objects and performing personalized obfuscation, the problem of easily cracked source code in existing technologies is solved, achieving higher-security obfuscation and encryption.

CN114547560BActive Publication Date: 2025-12-19LENOVO (BEIJING) LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202210181487.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-02-25
Publication Date
2025-12-19
Estimated Expiration
2042-02-25

AI Technical Summary

Technical Problem

Existing low-code platform applications use insecure source code obfuscation and encryption methods, which are easily cracked by reverse engineering.

Method used

The application source code is divided into component objects. An object identifier is generated for each component object, and the corresponding program code obfuscation information is determined based on the object identifier. Obfuscation processing is then performed on each component object, thereby achieving finer obfuscation granularity and diversification of obfuscation information.

Benefits of technology

It enhances the security of application source code obfuscation and encryption, increases the difficulty of cracking, and ensures the effectiveness of source code protection.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114547560B_ABST
    Figure CN114547560B_ABST
Patent Text Reader

Abstract

The application discloses a processing method, device and electronic equipment. In response to a protection instruction of source code of a target application, the application determines constituent objects of the source code, obtains a constituent object set of the source code, and generates corresponding object identifiers for each constituent object in the constituent object set. According to the object identifiers corresponding to each constituent object, the application determines matching program code obfuscation information for each constituent object based on a pre-established rule related to the object identifiers of the constituent objects. Then, the application performs obfuscation processing on the program code of each constituent object by using the matching program code obfuscation information of each constituent object. Finally, the application determines obfuscated code corresponding to the source code based on the obfuscation processing results corresponding to each constituent object.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application belongs to the technical field of data security, and particularly relates to a processing method and device and electronic equipment. BACKGROUND

[0002] For a low-code platform application, the source code of the application needs to be obfuscated and encrypted to protect the source code and ensure the security of the application source code.

[0003] Traditional technologies generally obfuscate application source code by randomly generating a program code and inserting it into any location of the application source code, or use operator replacement or function parameter removal to obfuscate the application source code, and then implement obfuscation and encryption of the application source code.

[0004] However, the above obfuscation and encryption method is not secure and can be easily cracked by reverse operation. SUMMARY

[0005] To this end, the present application discloses the following technical solutions:

[0006] A processing method comprises:

[0007] In response to a protection instruction for the source code of a target application, determining constituent objects of the source code to obtain a constituent object set of the source code;

[0008] Generating a corresponding object identifier for each constituent object in the constituent object set;

[0009] Based on a pre-prepared obfuscation information determination rule related to the object identifier of the constituent object, determining matching program code obfuscation information for each constituent object according to the object identifier corresponding to each constituent object;

[0010] Using the matching program code obfuscation information of each constituent object, respectively obfuscating the program code of each constituent object to obtain an obfuscation processing result corresponding to each constituent object;

[0011] Based on the obfuscation processing result corresponding to each constituent object, determining the obfuscated code corresponding to the source code.

[0012] Optionally, the determination of the constituent objects of the source code to obtain the constituent object set of the source code comprises:

[0013] Performing lexical analysis on the source code to obtain a lexical analysis result; the lexical analysis result comprises each lexical element obtained by performing lexical analysis on the source code of the target application;

[0014] performing syntax analysis on the source code based on the lexical analysis result to obtain a syntax structure of the source code;

[0015] extracting each component object of the source code based on the syntax structure of the source code, each extracted component object including a program code block formed by at least one keyword lexical element in the keyword lexical elements that satisfies a correlation condition.

[0016] Optionally, each component object corresponds to a component-level program code block of the target application.

[0017] The component objects of the source code are organized by an abstract syntax tree, a node in the abstract syntax tree corresponds to one component object of the source code, and a tree structure of the abstract syntax tree corresponds to the syntax structure among the component objects.

[0018] Optionally, the object identifier corresponding to each component object in the component object set is generated respectively, including:

[0019] For each component object, a first sub-identifier corresponding to the component object is generated, and a second sub-identifier is selected for the component object based on a preset selection strategy.

[0020] The object identifier of the component object is generated to include the first sub-identifier and the second sub-identifier corresponding to the component object. Different component objects correspond to different first sub-identifiers, and correspond to the same or different second sub-identifiers. Different second sub-identifiers correspond to different program code obfuscation information.

[0021] If different component objects correspond to the same second sub-identifier, the same program code obfuscation information is used to realize code obfuscation of different component objects. If different component objects correspond to different second sub-identifiers, different program code obfuscation information is used to realize code obfuscation of different component objects.

[0022] Optionally, the first sub-identifier corresponding to the component object includes a random number generated for the component object. The second sub-identifier corresponding to the component object includes a syntax decorator selected from a pre-defined syntax decorator set based on the preset selection strategy.

[0023] Optionally, based on the object identifier corresponding to each component object, the matching program code obfuscation information of each component object is determined based on a pre-prepared obfuscation information determination rule related to the object identifier of the component object, including:

[0024] determine, according to a second sub-identifier in each object identifier corresponding to each of the constituent objects and a pre-established correspondence between different second sub-identifiers and different program code obfuscation information, matched program code obfuscation information for each of the constituent objects;

[0025] The obfuscation information determination rule includes the correspondence between the different second sub-identifiers and the different program code obfuscation information.

[0026] Optionally, the obfuscation processing of the program code of each of the constituent objects by using the matched program code obfuscation information of each of the constituent objects includes:

[0027] The matched program code obfuscation information of each of the constituent objects is injected into the program code of each of the constituent objects.

[0028] Optionally, the same constituent objects of different applications correspond to the same second sub-identifier, and the program code obfuscation information injected into the same constituent objects of different applications has the same code structure and different variables.

[0029] For the same constituent objects of different applications, the program code obfuscation information corresponding to the second sub-identifier of the same constituent objects is adjusted in variable information by using the first sub-identifier corresponding to the same constituent objects in the application to which the same constituent objects belong, so that the program code obfuscation information injected into the same constituent objects of different applications has the same code structure and different variables.

[0030] A processing apparatus includes:

[0031] A first determination module is configured to determine constituent objects of source code of a target application in response to a protection instruction of the source code, and obtain a constituent object set of the source code.

[0032] A generation module is configured to generate corresponding object identifiers for each of the constituent objects in the constituent object set.

[0033] A second determination module is configured to determine, according to each object identifier corresponding to each of the constituent objects, matched program code obfuscation information for each of the constituent objects based on a pre-established obfuscation information determination rule related to the object identifier of the constituent object.

[0034] An obfuscation processing module is configured to perform obfuscation processing on the program code of each of the constituent objects by using the matched program code obfuscation information of each of the constituent objects, and obtain an obfuscation processing result corresponding to each of the constituent objects.

[0035] A third determination module is configured to determine obfuscated code corresponding to the source code based on the obfuscation processing result corresponding to each of the constituent objects.

[0036] An electronic device comprises:

[0037] a memory for storing at least a set of instruction sets;

[0038] a processor for invoking and executing the instruction sets in the memory, and realizing the processing method as claimed in any one of the above by executing the instruction sets.

[0039] From the above solutions, the processing method, device and electronic device disclosed by the present application, in response to the protection instruction of the application source code, divide the application source code into each constituent object, and perform obfuscation processing (such as obfuscation information injection) on each constituent object respectively, so as to refine the obfuscation granularity of the application source code, and finally determine the obfuscated code corresponding to the application source code based on the obfuscation processing result corresponding to each constituent object respectively, realize the obfuscation processing of the application source code, and determine the matching obfuscation information for the obfuscation processing for each constituent object of the application source code according to the object identifier, so as to realize the diversification of the obfuscation information, and finally improve the security of the obfuscation encryption of the application source code through the refinement of the obfuscation granularity of the application source code and the diversification of the obfuscation information. BRIEF DESCRIPTION OF DRAWINGS

[0040] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the drawings needed to be used in the embodiments or prior art description will be briefly introduced. Obviously, the drawings in the following description are only embodiments of the present application, and those skilled in the art can obtain other drawings according to the provided drawings without creative labor.

[0041] Figure 1 is a flowchart of the processing method provided by the present application;

[0042] Figure 2 is a flowchart of determining the constituent objects of the source code provided by the present application;

[0043] Figure 3 is a flowchart of generating the corresponding object identifier for each constituent object provided by the present application;

[0044] Figure 4 is an example of obfuscating the source code of the low-code platform application provided by the present application;

[0045] Figure 5 is a constituent structure diagram of the processing device provided by the present application;

[0046] Figure 6 is a constituent structure diagram of the electronic device provided by the present application. DETAILED DESCRIPTION

[0047] With reference to the drawings of the embodiments of the present application, the technical solutions in the embodiments of the present application will be clearly and completely described, obviously, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments of the present application. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative labor are within the scope of protection of the present application.

[0048] The present application discloses a processing method, device and electronic equipment, which is used to improve the security of application source code obfuscation encryption, and is suitable for obfuscation encryption processing scenarios of any application source code with security protection requirements. The embodiments of the present application will mainly take the processing of the source code of a low-code platform application as an example for illustration. The low-code platform is a development platform that does not require coding (0 code) or can quickly generate an application program through a small amount of coding, allowing end users to develop their own application programs using easy-to-understand visual tools.

[0049] The method of the present application can be used for devices in a variety of general or special computing device environments or configurations, such as personal computers, server computers, handheld or portable devices, tablet devices, multi-processor devices, and the like.

[0050] Referring to Figure 1 The processing method flowchart shown, the processing method disclosed by the embodiments of the present application comprises the following processing steps:

[0051] Step 101, in response to the protection instruction of the source code of the target application, determine the constituent objects of the source code, and obtain the constituent object set of the source code.

[0052] The target application can be any type of application whose source code needs to be protected, such as a system-level application / user-level application whose source code needs to be protected, or a low-code platform application / other type of application different from a low-code platform application whose source code needs to be protected, etc., which is not limited.

[0053] The application developer and other related personnel can trigger the protection instruction of the source code of the target application by operating the corresponding function control after the development of the target application is completed.

[0054] But not limited to this, in other embodiments, the protection instruction of the source code of the target application can also be automatically triggered by the application development platform (such as a low-code platform) based on the set trigger condition at any preset link before the application is released.

[0055] Among them, the trigger condition can be but not limited to any one of the following:

[0056] 11) detecting an application development start event;

[0057] 12) detecting that the development of the application is completed;

[0058] 13) detecting a release instruction of the application.

[0059] For example, the above protection instruction is triggered automatically by the application development platform based on the detection of the application development start event when the application starts to be developed, so that the corresponding steps of the method of the application are executed synchronously in the process of the developer developing the application, the corresponding objects of the source code are determined continuously with the progress of the development process, the object set is formed, and the corresponding object identifier of each determined object is determined synchronously, so as to facilitate the subsequent obfuscation processing of each object. For another example, when the application developer completes the application development in a drag-and-drop manner based on the visual tool of the low-code platform and operates the application save control, the platform detects this operation representing the completion of the application development, saves the application, and automatically triggers the protection instruction of the application source code, or triggers the protection instruction of the application source code before the application is released based on the detection of the release instruction of the application, so as to protect the source code of the application and ensure its security.

[0060] In response to the protection instruction of the source code of the target application, the application first determines the constituent objects of the source code to obtain the object set of the source code. The constituent objects of the source code can be components or other objects of a finer granularity than components, such as a single statement (assignment statement, control statement) with complete semantics in the component.

[0061] In the embodiment of the application, preferably, each constituent object in the object set is a component of the source code, that is, the program code block included in each constituent object is a program code block at the component level in the source code of the target application, so that the source code of the target application is processed by obfuscation based on the obfuscation granularity of the component level.

[0062] Optionally, as shown in the following table, the process of determining the constituent objects of the source code can be implemented as follows: Figure 2

[0063] Step 201, performing lexical analysis on the source code of the target application to obtain a lexical analysis result.

[0064] The lexical analysis result includes each lexical element obtained by performing lexical analysis on the source code of the target application, and the lexical element can be but is not limited to a word, a word, an operator or an operator in the source code, etc.

[0065] Step 202, performing syntax analysis on the source code of the target application based on the above lexical analysis result to obtain the syntax structure of the source code of the target application.

[0066] ​Step 203, based on the syntax structure of the source code of the target application, extracting each component object of the source code; each extracted component object includes a program code block composed of at least one keyword lexical element satisfying the association condition among the above-mentioned various lexical elements.

[0067] Among them, the association condition can be but not limited to set as any one of the following:

[0068] 21) There is a syntax association between different lexical elements that can realize the function of a complete component;

[0069] 22) There is a syntax association between different lexical elements that can realize the function of a complete semantic code statement (such as a single or multiple logical coupling but not enough to constitute a component statement).

[0070] Optionally, each component object of the source code can be organized through an Abstract Syntax Tree (AST), and the nodes in the Abstract Syntax Tree correspond one-to-one to the component objects of the source code, for example, each node in the Abstract Syntax Tree represents a component in the source code of the target application, and the component can be but not limited to an input box, a single selection box, a check box, a button, a menu, a table, etc. Moreover, the tree structure of the Abstract Syntax Tree corresponds to the syntax structure between each component object of the source code, and reflects the logical association between each component object.

[0071] Step 102, generating a corresponding object identifier for each component object in the component object set.

[0072] Preferably, in the embodiments of the present application, the object identifier of the component object includes two parts: a first sub-identifier and a second sub-identifier.

[0073] Referring to Figure 3 The process of generating a corresponding object identifier for each component object in the component object set can be further implemented as:

[0074] Step 301, for each component object, generating a corresponding first sub-identifier for the component object, and selecting a second sub-identifier for the component object based on a preset selection strategy.

[0075] Among them, the first sub-identifier can be used to uniquely identify the corresponding component object, that is, different component objects correspond to different first sub-identifiers, and optionally, for each component object of the source code of the target application, such as each component, a random shuffle algorithm can be used to generate a random number corresponding to it, and the generated random number is used as its first sub-identifier.

[0076] The second sub-identifier is used to determine the program code obfuscation information (referred to as "obfuscation information" for short) required in the corresponding constituent object. The obfuscation information used in the obfuscation process can be, but is not limited to, useless code (i.e., useless program code) that can be used to obfuscate the source code, or a combination of useless code and predefined special symbols, without limitation.

[0077] Different second sub-identifiers correspond to different program code obfuscation information, that is, in the embodiments of the present application, the correspondence between different second sub-identifiers and different program code obfuscation information is predefined to support the determination of matching obfuscation information (such as useless code) for different constituent objects for obfuscation processing according to the second sub-identifier of the different constituent objects of the source code. Preferably, the code structures of different program code obfuscation information are different.

[0078] In implementation, a syntax decorator set can be predefined, and a series of different syntax decorators included in the syntax decorator set are used as different second sub-identifiers. The syntax decorator can be, but is not limited to, symbols such as *, #, / , @, or symbol combinations formed by assembling these symbols in a corresponding manner.

[0079] In actual application, the same or different second sub-identifiers can be selected / configured for different constituent objects of the target application source code according to requirements or selection strategies, such as selecting / configuring the same or different syntax decorators from the syntax decorator set for different constituent objects.

[0080] If the different constituent objects correspond to the same second sub-identifier, the same program code obfuscation information is used for code obfuscation of different constituent objects; if the different constituent objects correspond to different second sub-identifiers, different program code obfuscation information is used for code obfuscation of different constituent objects.

[0081] An example of the above selection strategy is provided as follows:

[0082] According to the component category, the corresponding second sub-identifier is selected for different components of the target application source code. Specifically, different second sub-identifiers are selected for different categories of components, and the same second sub-identifier is selected for different components of the same category.

[0083] For example, the first structure of useless code is selected for input components such as input boxes, input tables, etc. of the low-code platform application, the second structure of useless code is selected for selection components such as single selection boxes, check boxes, etc., the third structure of useless code is selected for control components such as start buttons, end buttons, pause buttons, etc., so that the diversification of the confusion information adopted by different component objects of the target application source code is ensured, and the workload and processing complexity caused by formulating different second sub-identifiers / different confusion information for all component objects are avoided.

[0084] Step 302, generating an object identifier including the first sub-identifier and the second sub-identifier corresponding to the component object for the component object.

[0085] On the basis of obtaining the first sub-identifier and the second sub-identifier of each component object of the target application source code, the first sub-identifier and the second sub-identifier of each component object are assembled to obtain the object identifier (tokenType) of each component object including the first sub-identifier and the second sub-identifier. It is easy to understand that the object identifier can be used to uniquely identify the corresponding component object.

[0086] The assembly processing of the first sub-identifier and the second sub-identifier of the component object can be, but is not limited to, appending the second sub-identifier to the tail of the first sub-identifier, or appending the first sub-identifier to the tail of the second sub-identifier, or inserting the first sub-identifier into a predetermined position of different components (such as multiple symbols) of the second sub-identifier, or inserting the second sub-identifier into a predetermined position of different components (such as multiple digits of a random number) of the first sub-identifier, etc.

[0087] For the embodiment of organizing each component object of the source code by using the abstract syntax tree, the object identifier of each component object can be further associated with the node of the abstract syntax tree where the component object is located, that is, each node of the abstract syntax tree includes the corresponding component object (such as a code block composed of keyword elements of a certain component) and the object identifier of the component object.

[0088] It should be noted that in actual application, the object identifier is not limited to the above-mentioned component structure including two parts. For example, in other embodiments, the object identifier only includes one component, and the corresponding component object of the source code is uniquely identified based on the one component, and the matching program code confusion information is determined for the component object.

[0089] Step 103, determining the matching program code confusion information for each component object based on the object identifier corresponding to each component object and the pre-formulated confusion information determination rule related to the object identifier of the component object.

[0090] The obfuscation information determination rule includes the correspondence relationship between the different second sub-identifiers and the different program code obfuscation information.

[0091] After obtaining the object identifier corresponding to each component object of the target application source code, the second sub-identifier included in the object identifier of each component object can be used to select the matching obfuscation information for obfuscation processing from the correspondence relationship.

[0092] For example, the tokenType of each node in the abstract syntax tree is read and parsed using a pre-generated compilation grammar parser, the decorator in the tokenType is extracted, and the matching obfuscation information (such as useless code) is queried from the correspondence relationship information between the decorator and the obfuscation information based on the decorator, which is used as the obfuscation information to be used by the component corresponding to the node in the obfuscation processing.

[0093] The following is an example:

[0094] Suppose that the component objects of a certain low-code platform application include input boxes, radio boxes, check boxes, buttons, menus, tables, and other components, and in the scenario of obfuscating and encrypting the source code of the low-code platform application, each of the above components corresponds to a node in the abstract syntax tree, and each node includes the component content (such as a code block composed of the keyword elements of the component) and the component identifier tokenType of the corresponding component. The component identifier tokenType includes a random number and a decorator.

[0095] For the input box component, the tokenType1 of the input box component can be read and parsed from the abstract syntax tree by the compilation grammar parser, and the decorator1 can be extracted therefrom, and the matching obfuscation information for obfuscation processing of the input box component is determined to be the useless program code1 corresponding to the decorator1 according to the pre-prepared correspondence relationship between different decorators and different useless program codes. Similarly, for the radio box component, the matching obfuscation information of the radio box component is determined to be the useless program code2 corresponding to the decorator2 in the tokenType2 of the radio box component according to the correspondence relationship, and so on, until the obfuscation information required for obfuscation processing of all the components is obtained.

[0096] Step 104, using the program code obfuscation information matched by each component object, respectively obfuscating the program code of each component object to obtain the obfuscation processing result corresponding to each component object.

[0097] Afterwards, each component object of the target application source code, such as each component, is obfuscated according to the program code obfuscation information matched by the component object, which can be but not limited to injecting the program code obfuscation information matched by the component object into the program code of the component object, such as injecting a piece of useless program code corresponding to the input box component code block into the component object to achieve the obfuscation of the component object.

[0098] In an embodiment, each component object of the source code is obfuscated by using different obfuscation information; in other embodiments, on the basis of some component objects of the source code being obfuscated by using different obfuscation information, some component objects (such as components of the same category) are allowed to be obfuscated by using the same obfuscation information. The former embodiment has higher protection strength but relatively large workload, and requires more obfuscation information to be formulated; the latter embodiment saves the workload but has slightly lower protection strength than the former embodiment. In implementation, the required embodiment can be selected according to the requirements.

[0099] In step 105, the obfuscated code corresponding to the source code of the target application is determined based on the obfuscation results of each component object.

[0100] After obtaining the obfuscation results of each component object, the obfuscated code corresponding to the source code of the target application is determined based on the obfuscation results of each component object.

[0101] Specifically, for example, after injecting useless program code into the code block of each component object (such as a component) corresponding to a node according to the abstract syntax tree, and obtaining the obfuscated code of each component object, the obfuscated code of each component object is assembled and restored to the source code format (such as a line of code, rather than a tree form) according to the syntax structure of each component object, and the obfuscated code corresponding to the source code of the target application is obtained. The obfuscated code is the result of scrambling and obfuscating the program code of the source code by using the obfuscation information corresponding to each component object.

[0102] Referring to Figure 4 , an example of obfuscating the source code of a low-code platform application based on the processing logic of the method of the present application is shown.

[0103] Subsequently, the obfuscated and encrypted target application source code can be obtained by further compressing and encrypting the obfuscated code corresponding to the target application source code, so as to achieve the security protection purpose of the target application source code.

[0104] From the above scheme, the method of the embodiment, in response to the protection instruction of the application source code, divides the application source code into each constituent object, respectively processes the obfuscation (such as obfuscation information injection) for each constituent object, thereby refining the obfuscation granularity of the application source code, and finally determines the obfuscated code corresponding to the application source code based on the obfuscation processing result of each constituent object, implements the obfuscation processing of the application source code, and determines the matching obfuscation information for the obfuscation processing for each constituent object of the application source code according to the object identifier, thereby realizing the diversification of the obfuscation information, and finally improving the security of the obfuscation encryption of the application source code through the refinement of the obfuscation granularity of the application source code and the diversification of the obfuscation information.

[0105] Different applications can contain the same constituent objects, such as checkboxes, control buttons, and other components. When obfuscating the source code of different applications, the same components of different applications correspond to different first sub-identifiers, such as different random numbers, so that the object identifier formed based on the first sub-identifier can be used to uniquely identify the constituent objects of the application, and the same constituent objects of different applications can correspond to the same or different second sub-identifiers, respectively. Accordingly, the same or different obfuscation information can be used to obfuscate the same constituent objects of different applications. This is not limited.

[0106] Preferably, in an embodiment, the same constituent objects of different applications correspond to the same second sub-identifier, and the program code obfuscation information injected into the same constituent objects of different applications has the same code structure and different variables.

[0107] Specifically, in this embodiment, for the same constituent objects of different applications, the same second sub-identifier (such as the same syntax decorator) contained in the object identifier corresponding to the same constituent object in different applications is used to determine the same program code obfuscation information for the obfuscation processing of the same constituent object of different applications. On this basis, the first sub-identifier corresponding to the same constituent object in the application is used to adjust the variable information of the program code obfuscation information corresponding to the second sub-identifier of the same constituent object, so that the program code obfuscation information injected into the same constituent objects of different applications has the same code structure and different variables.

[0108] For example, for the same component object, a checkbox, of the application 1 and the application 2 under the low-code platform, a same piece of useless program code is determined, in the process of obfuscating the source code of the application 1, one or more variables in the useless program code are assigned or modified in value by using the random number 1 in the object identifier corresponding to the checkbox in the application 1, and in the process of obfuscating the source code of the application 2, one or more variables in the useless program code are assigned or modified in value by using the random number 2 in the object identifier corresponding to the checkbox in the application 2.

[0109] The embodiment adjusts the variable information in the obfuscation information by using the first sub-identifier corresponding to the component object in the application, so that the same component object in different applications is injected with the obfuscation information with the same code structure but different variables, the protection strength of the source code of different applications is further improved, the cracking difficulty is improved, and cracking of the same component object in another application is not caused by cracking of a component object in one application. In addition, no excessive workload is introduced.

[0110] It should be noted that in actual application, the embodiment is not limited to the implementation of adjusting the variable information in the obfuscation information by using the first sub-identifier, for example, adjusting the variable by temporarily generating a random number, as long as the code structure of the program code obfuscation information injected into the same component object in different applications is the same and the variables are different through variable adjustment, which belongs to the protection scope of the embodiment.

[0111] Corresponding to the above method, the embodiment of the application further discloses a processing device, and the component structure of the processing device is as shown in Figure 5 The processing device specifically includes:

[0112] The first determination module 501 is configured to determine the component objects of the source code of the target application in response to the protection instruction of the source code of the target application, and obtain a component object set of the source code.

[0113] The generation module 502 is configured to generate a corresponding object identifier for each component object in the component object set.

[0114] The second determination module 503 is configured to determine the matching program code obfuscation information for each component object based on the pre-prepared obfuscation information determination rule related to the object identifier of the component object according to the object identifier corresponding to each component object.

[0115] The obfuscation processing module 504 is configured to obfuscate the program code of each component object by using the matching program code obfuscation information of each component object, and obtain the obfuscation processing result corresponding to each component object.

[0116] The third determining module 505 is configured to determine the obfuscated code corresponding to the source code based on the obfuscation results corresponding to the respective component objects.

[0117] In an embodiment, the first determining module 501 is specifically configured to:

[0118] performing lexical analysis on the source code to obtain a lexical analysis result, wherein the lexical analysis result comprises respective lexical elements obtained by performing lexical analysis on the source code of the target application;

[0119] performing syntax analysis on the source code based on the lexical analysis result to obtain a syntax structure of the source code;

[0120] extracting respective component objects of the source code based on the syntax structure of the source code, wherein each component object extracted comprises a program code block composed of at least one keyword lexical element satisfying an association condition among the respective lexical elements.

[0121] In an embodiment, the respective component objects correspond to the program code blocks at the component level of the target application.

[0122] The respective component objects of the source code are organized by an abstract syntax tree, wherein the nodes in the abstract syntax tree correspond to the respective component objects of the source code one by one, and the tree structure of the abstract syntax tree corresponds to the syntax structure among the respective component objects of the source code.

[0123] In an embodiment, the generating module 502 is specifically configured to:

[0124] generating, for each component object, a first sub-identifier corresponding to the component object, and selecting a second sub-identifier for the component object based on a preset selection strategy;

[0125] generating, for each component object, an object identifier comprising the first sub-identifier and the second sub-identifier corresponding to the component object, wherein different component objects correspond to different first sub-identifiers, and correspond to the same or different second sub-identifiers, and different second sub-identifiers correspond to different program code obfuscation information;

[0126] When different component objects correspond to the same second sub-identifier, the different component objects respectively use the same program code obfuscation information to implement code obfuscation on the different component objects; when different component objects correspond to different second sub-identifiers, the different component objects respectively use different program code obfuscation information to implement code obfuscation on the different component objects.

[0127] In an embodiment, the first sub-identifier corresponding to the component object includes a random number generated for the component object; and the second sub-identifier corresponding to the component object includes a syntax decorator selected from a pre-defined syntax decorator set based on the preset selection strategy.

[0128] In an embodiment, the second determining module 503 is specifically configured to:

[0129] determine the matching program code obfuscation information for each component object according to the second sub-identifier in the object identifier corresponding to each component object and a pre-prepared correspondence between different second sub-identifiers and different program code obfuscation information.

[0130] The obfuscation information determination rule includes the correspondence between the different second sub-identifiers and the different program code obfuscation information.

[0131] In an embodiment, the obfuscation processing module 504 is specifically configured to:

[0132] inject the program code obfuscation information respectively matched by the component objects into the program code of the component objects.

[0133] In an embodiment, the same component objects of different applications correspond to the same second sub-identifier, and the program code obfuscation information respectively injected into the same component objects of different applications have the same code structure and different variables.

[0134] For the same component objects of different applications, the program code obfuscation information corresponding to the second sub-identifier of the same component objects is adjusted in variable information by using the first sub-identifier corresponding to the same component objects in the application, so that the program code obfuscation information respectively injected into the same component objects of different applications have the same code structure and different variables.

[0135] For the processing device disclosed in the embodiments of the present application, the description is relatively simple because it corresponds to the processing method disclosed in the above method embodiments. Please refer to the description of the above method embodiments for relevant similar parts, which will not be described in detail here.

[0136] The embodiments of the present application also disclose an electronic device, which can be, but is not limited to, a device in a plurality of general-purpose or special-purpose computing device environments or configurations, such as a personal computer, a server computer, a handheld device or a portable device, a tablet device, a multi-processor device, and the like.

[0137] The component structure of the electronic device is shown in Figure 6 The electronic device at least includes:

[0138] The memory 10 is configured to store a computer instruction set.

[0139] The computer instruction set can be implemented in the form of a computer program.

[0140] The processor 20 is configured to implement the processing method disclosed in any of the above method embodiments by executing the computer instruction set.

[0141] The processor 20 can be a central processing unit (CPU), an application-specific integrated circuit (ASIC), a digital signal processor (DSP), a field programmable gate array (FPGA) or other programmable logic devices, etc.

[0142] In addition, the electronic device can further include a communication interface, a communication bus, and the like. The memory, the processor, and the communication interface complete communication with each other through the communication bus.

[0143] The communication interface is configured to enable communication between the electronic device and other devices. The communication bus can be a peripheral component interconnect (PCI) bus, an extended industry standard architecture (EISA) bus, or the like, and can be divided into an address bus, a data bus, a control bus, and the like.

[0144] It should be noted that each of the embodiments in the present specification is described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the embodiments can be mutually referred to.

[0145] For the convenience of description, the above system or device is described in various modules or units in terms of functions. Of course, the functions of each unit can be implemented in the same or multiple software and / or hardware in the implementation of the present application.

[0146] From the above description of the embodiments, those skilled in the art can clearly understand that the present application can be implemented by means of software and the necessary general hardware platform. Based on such understanding, the technical solutions of the present application can be embodied in the form of a software product, which can be stored in a storage medium, such as a ROM / RAM, a magnetic disk, an optical disk, etc., and includes a number of instructions to make a computer device (which can be a personal computer, a server, or a network device, etc.) execute the methods described in each embodiment or some parts of the embodiments of the present application.

[0147] Finally, it needs to be pointed out that, in this document, relational terms such as first, second, third, and fourth and the like can only be used to distinguish one entity or action from another entity or action, without necessarily requiring or implying any actual relationship or order between or among such entities or actions. Moreover, the terms "comprises", "comprising", or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but can include other elements not expressly listed or inherent to such process, method, article, or apparatus. An element proceeded by "comprises... a" does not, without more constraints, exclude the existence of additional identical elements in the process, method, article, or apparatus that comprises the element.

[0148] The above description is only the preferred embodiment of the present application, and it should be pointed out that, for those skilled in the art, some improvements and refinements can be made without departing from the principles of the present application, and these improvements and refinements should also be considered as the protection scope of the present application.

Claims

1. A processing method, comprising: In response to a protection instruction for the source code of a target application, the constituent objects of the source code are determined, and a set of constituent objects of the source code is obtained; Generate a corresponding object identifier for each component object in the set of component objects; the object identifier includes: a first sub-identifier and a second sub-identifier; Based on the object identifier corresponding to each component object, and based on the pre-defined obfuscation information determination rules related to the object identifier of the component object, matching program code obfuscation information is determined for each component object. Using the program code obfuscation information matched by each component object, the program code of each component object is obfuscated to obtain the obfuscation result corresponding to each component object; wherein, the same component objects of different applications correspond to the same second sub-identifier, and the code structure of the program code obfuscation information injected into the same component objects of different applications is the same but the variables are different. Based on the obfuscation results corresponding to each component object, the obfuscated code corresponding to the source code is determined.

2. The method according to claim 1, wherein determining the constituent objects of the source code to obtain the set of constituent objects of the source code comprises: Lexical analysis was performed on the source code to obtain the lexical analysis results; The lexical analysis results include the various lexical elements obtained from the lexical analysis of the source code of the target application; Based on the lexical analysis results, the source code is subjected to syntactic analysis to obtain the syntactic structure of the source code; Based on the syntactic structure of the source code, extract the constituent objects of the source code; each extracted constituent object includes a program code block composed of at least one keyword element that satisfies the association condition among the various lexical elements.

3. The method according to claim 2, wherein each component object corresponds to a program code block, which is a component-level program code block of the target application; in, The source code is organized into various component objects by an abstract syntax tree. The nodes in the abstract syntax tree correspond one-to-one with the component objects of the source code, and the tree structure of the abstract syntax tree corresponds to the syntax structure between the component objects of the source code.

4. The method according to claim 1, wherein generating a corresponding object identifier for each component object in the component object set comprises: For each component object, a corresponding first sub-identifier is generated for the component object, and a second sub-identifier is selected for the component object based on a preset selection strategy; Generate an object identifier for the constituent objects, including a first sub-identifier and a second sub-identifier corresponding to the constituent objects; wherein, different constituent objects correspond to different first sub-identifiers and correspond to the same or different second sub-identifiers, and different second sub-identifiers correspond to different program code obfuscation information; If different constituent objects correspond to the same second sub-identifier, then the same program code obfuscation information is used to obfuscate the code of the different constituent objects; if different constituent objects correspond to different second sub-identifiers, then different program code obfuscation information is used to obfuscate the code of the different constituent objects.

5. The method according to claim 4, wherein, The first sub-identifier corresponding to the constituent object includes the random number generated for the constituent object; The second sub-identifier corresponding to the constituent object includes: a syntax decorator selected from a predefined set of syntax decorators based on the preset selection strategy.

6. The method according to claim 4, wherein determining matching program code obfuscation information for each component object based on its corresponding object identifier and a pre-defined obfuscation information determination rule related to the object identifier of the component object comprises: Based on the second sub-identifier in the object identifier corresponding to each component object, and the pre-defined correspondence between different second sub-identifiers and different program code obfuscation information, matching program code obfuscation information is determined for each component object. The obfuscation information determination rules include the correspondence between different second sub-identifiers and different program code obfuscation information.

7. The method according to claim 4, wherein obfuscating the program code of each component object using the program code obfuscation information matched by each component object respectively includes: The obfuscation information of the program code matched by each component object is injected into the program code of each component object respectively.

8. The method according to claim 7, wherein, For the same component objects in different applications, by using the first sub-identifier corresponding to the same component object in its respective application, the variable information of the program code obfuscation information corresponding to the second sub-identifier of the same component object is adjusted, so that the code structure of the program code obfuscation information injected into the same component objects in different applications is the same but the variables are different.

9. A processing apparatus, comprising: The first determining module is used to determine the constituent objects of the source code in response to a protection instruction for the source code of the target application, and obtain the set of constituent objects of the source code; The generation module is used to generate corresponding object identifiers for each component object in the component object set; The object identifier includes: a first sub-identifier and a second sub-identifier; The second determining module is used to determine matching program code obfuscation information for each component object based on the object identifier corresponding to each component object and on a pre-defined obfuscation information determination rule related to the object identifier of the component object. The obfuscation module is used to obfuscate the program code of each component object by using the program code obfuscation information matched by each component object, and to obtain the obfuscation result corresponding to each component object; wherein, the same component objects of different applications correspond to the same second sub-identifier, and the code structure of the program code obfuscation information injected into the same component objects of different applications is the same but the variables are different. The third determining module is used to determine the obfuscated code corresponding to the source code based on the obfuscation processing results corresponding to each component object.

10. An electronic device, comprising: Memory, used to store at least one set of instructions; A processor for calling and executing the instruction set in the memory, thereby implementing the processing method as described in any one of claims 1-8.

Citation Information

Patent Citations

  • Code obfuscation method and system for application

    CN104992083A

  • Code obfuscation method and device, code running method and device, medium and equipment

    CN112597454A