A data processing method, device and electronic equipment

By using AST and JSVMP to provide multiple layers of protection for JavaScript code, the problem of low security caused by simple code obfuscation is solved, the difficulty of code analysis and security are improved, and the integrity of the website is protected.

CN122286731APending Publication Date: 2026-06-26AISINO CORPORATION
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
AISINO CORPORATION
Filing Date
2024-12-24
Publication Date
2026-06-26

AI Technical Summary

Technical Problem

Existing JavaScript code obfuscation methods are too simplistic, resulting in low code security and making it vulnerable to analysis and attacks by malicious actors.

Method used

The code to be processed is obfuscated and encrypted using an Abstract Syntax Tree (AST), and then further processed using the Scripting Virtual Machine (JSVMP) technology. Multiple protection measures are added, including console conditional statements, an unlimited debugger, and formatting detection code.

Benefits of technology

It significantly improves the security of JavaScript code, making it difficult for malicious actors to understand and attack, and protecting the security of front-end code and back-end servers.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122286731A_ABST
    Figure CN122286731A_ABST
Patent Text Reader

Abstract

This application discloses a data processing method, apparatus, and electronic device. The method includes: obfuscating and encrypting code to be processed using an Abstract Syntax Tree (AST) to obtain a first target code; and processing the first target code using JSVMP to obtain a second target code. The technical solution provided by the embodiments of this application ensures that the obtained second target code undergoes multiple processing steps, increasing the difficulty of analyzing the original code corresponding to the second target code. This makes it more difficult for malicious actors to correctly analyze the original code corresponding to the second target code, thereby improving the security of the original code corresponding to the second target code and the security of the website corresponding to the second target code.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of computer technology, and in particular to a data processing method, apparatus, and electronic device. Background Technology

[0002] JavaScript, as one of the core technologies for World Wide Web (WWW) development, works in conjunction with Hyper Text Markup Language (HTML) and Cascading Style Sheets (CSS) to enable web page development. HTML defines the content structure of a webpage, CSS handles styles and layout, and JavaScript controls the behavior and interactivity of the webpage.

[0003] In the early days of the web, JavaScript code was very simple and didn't require protection. However, with the development of the web and the improvement of browser performance and internet speed, some business logic was moved from the backend to the frontend to reduce the load on website servers. At this point, if the frontend JavaScript code is simple, it's easily analyzed by malicious actors, making it easier for them to simulate frontend requests to the backend and launch attacks. Therefore, protecting JavaScript code is now necessary.

[0004] Currently, JavaScript code protection methods include code obfuscation. Code obfuscation involves changing various elements of the code (such as variable, function, and class names) to meaningless names. For example, rewriting an element with a single letter or a simple, meaningless combination of letters makes it impossible for users reading the code (such as malicious actors) to guess its meaning and purpose, thus achieving protection for the JavaScript code.

[0005] However, the above code obfuscation is too simplistic, making the protection of JavaScript code too basic, resulting in low security for JavaScript code. Summary of the Invention

[0006] This application provides a data processing method to address the problem of insecure code caused by overly simplistic code obfuscation in existing technologies. The specific implementation scheme is as follows:

[0007] Firstly, this application provides a data processing method, the method comprising:

[0008] The code to be processed is obfuscated and encrypted using an Abstract Syntax Tree (AST) to obtain the first target code.

[0009] The first target code is processed using the scripting language virtual machine protection technology JSVMP to obtain the second target code.

[0010] Through the above application embodiments, the code to be processed is first obfuscated and encrypted using AST, and then the obfuscated and encrypted code (i.e., the first target code) is further processed using JSVMP. Thus, the code to be processed is processed multiple times, making the resulting second target code more complex than the code that has only undergone simple code obfuscation in the prior art. This makes it more difficult for criminals to understand the second target code, thereby significantly improving the security of the original code corresponding to the second target code.

[0011] In one possible implementation, before obfuscating and encrypting the code to be processed through an Abstract Syntax Tree (AST) to obtain the first target code, the following steps are also included:

[0012] Add a console condition to the first original code segment in the original code to obtain the code to be processed; wherein, the console condition is used to detect whether the browser console is open, and automatically close the website corresponding to the code to be processed when the browser console is opened.

[0013] Through the above-described embodiments, a console condition is added to the first original code segment. This condition allows for the determination of whether to open the browser console. If the browser console is opened, the website corresponding to the code to be processed (i.e., the website corresponding to the original code) is automatically closed. This prevents malicious actors from using the open browser console to attack the website, thus protecting it. Furthermore, by automatically closing the website corresponding to the code to be processed when the browser console is opened, the console condition also prevents malicious actors from continuing to parse the code to be processed, thereby preventing them from further parsing the original code corresponding to the code to be processed, further enhancing the security of the original code corresponding to the code to be processed.

[0014] In one possible implementation, before obfuscating and encrypting the code to be processed through an Abstract Syntax Tree (AST) to obtain the first target code, the following steps are also included:

[0015] Using the AST, a first timer is added to the first original code segment; wherein the first timer is associated with the console judgment condition.

[0016] Through the above application embodiments, by using AST, a first timer associated with the console judgment condition is added to the first original code segment, so that the console judgment condition can be executed automatically to automatically detect whether the browser console is open, that is, to realize the automatic detection of whether the browser console is opened (such as by the developer).

[0017] In one possible implementation, before obfuscating and encrypting the code to be processed through an Abstract Syntax Tree (AST) to obtain the first target code, the following steps are also included:

[0018] An infinite debugger is added to the second original code segment in the original code to obtain the code to be processed; wherein, the infinite debugger is used to prevent third parties from debugging the code to be processed.

[0019] Through the above application embodiments, an infinite debugger is added to the second original code segment in the original code, thereby preventing malicious actors from debugging the original code corresponding to the code to be processed, thus preventing malicious actors from easily obtaining the original code, thereby further improving the security of the original code and preventing the website corresponding to the original code from being attacked.

[0020] In one possible implementation, before processing the first target code using the Scripting Language Virtual Machine Protection (JSVMP) technology to obtain the second target code, the method further includes:

[0021] At the branch before the key logic code in the first target code, add format detection code; wherein, the format detection code is used to continuously run the specified function when the regular expression matching function is detected to include the specified character, and to automatically run the resource-consuming regular expression associated with the second timer through the second timer.

[0022] In the above-described embodiments, formatting detection code is added at the branch before the critical logic code in the first target code. This allows formatting detection to be performed before executing the critical logic code, and only after the formatting detection passes will the critical logic code be executed. This increases the difficulty for malicious actors to analyze the code to be processed, thereby increasing the difficulty for them to analyze the original code and further enhancing the security of the original code. Furthermore, through formatting detection, when a specified character is detected in the regular expression matching function, the specified function is continuously run, causing a memory overflow and preventing normal execution results. This prevents malicious actors from interpreting the original code, further improving the security of the original code. Additionally, through formatting detection, after the second timer is detected, the resource-consuming regular expression associated with the second timer is automatically executed, preventing malicious actors from interpreting the original code corresponding to the second target code, thus further improving the security of the original code.

[0023] In one possible implementation, processing the first target code using the Scripting Language Virtual Machine Protection (JSVMP) technology to obtain the second target code includes:

[0024] The first target code is escaped into bytecode to obtain the third target code;

[0025] Control flow obfuscation is performed on the third target code to obtain the fourth target code;

[0026] The fourth target code is encrypted to obtain the second target code.

[0027] The security of the second target code is further improved through the above application embodiments, thereby further improving the security of the original code.

[0028] In one possible implementation, the method further includes:

[0029] Add environment detection code to the code; wherein the code includes the code to be processed, the first target code, and the second target code, and the environment detection code is used to perform environment detection on the code to determine whether the environment of the code is a browser environment, and if it is not a browser environment, execute an error code branch or interrupt the execution of the code.

[0030] Through the above-described embodiments, environmental detection of the code is achieved, so that in a non-browser environment, the code can be entered into an incorrect branch or its execution can be interrupted. This prevents malicious actors from running the original code correctly in a non-browser environment, thereby further improving the security of the original code and the website to which the original code belongs.

[0031] Secondly, this application also provides a data processing apparatus, the apparatus comprising:

[0032] The obfuscation and encryption module is used to obfuscate and encrypt the code to be processed through the Abstract Syntax Tree (AST) to obtain the first target code.

[0033] The processing module is used to process the first target code using the scripting language virtual machine protection technology JSVMP to obtain the second target code.

[0034] In one possible implementation, the device further includes a control judgment module, which is used to add a console judgment condition to a first original code segment in the original code before obfuscating and encrypting the code to be processed through an abstract syntax tree (AST) to obtain the first target code, thereby obtaining the code to be processed; wherein the console judgment condition is used to detect whether a browser console is open, and automatically close the website corresponding to the code to be processed when the browser console is opened.

[0035] In one possible implementation, the control judgment module is specifically used to add a first timer to the first original code segment through the AST; wherein the first timer is associated with the console judgment condition.

[0036] In one possible implementation, the apparatus further includes a debugger module, which is used to add an infinite debugger to a second original code segment in the original code before obfuscating and encrypting the code to be processed through an abstract syntax tree (AST) to obtain the first target code, thereby obtaining the code to be processed; wherein the infinite debugger is used to prevent third parties from debugging the code to be processed.

[0037] In one possible implementation, the apparatus further includes a formatting detection module, which is configured to add formatting detection code at the branch before the critical logic code in the first target code before the second target code is obtained by processing the first target code using the scripting language virtual machine protection technology JSVMP; wherein the formatting detection code is configured to continuously run the specified function when the regular expression matching function is detected to include the specified character, and to automatically run the resource-consuming regular expression associated with the second timer via a second timer.

[0038] In one possible implementation, the processing module is specifically used to escape the first target code into bytecode to obtain the third target code; to perform control flow obfuscation on the third target code to obtain the fourth target code; and to encrypt the fourth target code to obtain the second target code.

[0039] In one possible implementation, the device further includes an environment detection module, which is used to add environment detection code to the code; wherein the code includes the code to be processed, the first target code, and the second target code, and the environment detection code is used to perform environment detection on the code to determine whether the environment of the code is a browser environment, and if it is not a browser environment, to execute an error code branch or interrupt the execution of the code.

[0040] Thirdly, this application provides an electronic device, comprising:

[0041] Memory, used to store computer programs;

[0042] When a processor executes a computer program stored in the memory, it implements the above-described data processing method steps.

[0043] Fourthly, this application provides a computer-readable storage medium storing a computer program, which, when executed by a processor, implements the above-described data processing method steps.

[0044] For the various aspects of the second to fourth aspects mentioned above, and the technical effects that each aspect may achieve, please refer to the above description of the technical effects that can be achieved for the first aspect or the various possible solutions in the first aspect, which will not be repeated here. Attached Figure Description

[0045] Figure 1 A flowchart illustrating data processing provided in an embodiment of this application;

[0046] Figure 2 A schematic diagram illustrating the data processing method provided in the embodiments of this application;

[0047] Figure 3 A schematic diagram of a data processing apparatus provided in an embodiment of this application;

[0048] Figure 4 This is a schematic diagram of an electronic device provided in an embodiment of this application. Detailed Implementation

[0049] To make the objectives, technical solutions, and advantages of this application clearer, the application will be further described in detail below with reference to the accompanying drawings. The specific operational methods in the method embodiments can also be applied to the device embodiments or system embodiments. It should be noted that in the description of this application, "multiple" is understood as "at least two". "And / or" describes the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A existing alone, A and B existing simultaneously, and B existing alone. A connected to B can represent: A and B directly connected, and A and B connected through C. Furthermore, in the description of this application, terms such as "first" and "second" are used only for distinguishing the purpose of description and should not be construed as indicating or implying relative importance or order.

[0050] The embodiments of this application will now be described in detail with reference to the accompanying drawings.

[0051] Currently, the pace of backend attack and defense is accelerating, and one key aspect is frontend attack and defense. Injecting simple JavaScript code into the frontend makes it easy for malicious actors to discover vulnerabilities and attack the backend server. Therefore, it's crucial to prioritize frontend code protection, making the frontend code more difficult to understand to prevent malicious actors from reading it, thereby protecting the security of the backend server.

[0052] Current code protection methods rely on code obfuscation. However, code obfuscation is too simplistic, making code protection too easy and resulting in low code security.

[0053] Therefore, this application proposes a data processing method. First, the code to be processed is obfuscated and encrypted using an Abstract Syntax Tree (AST). Then, the obfuscated and encrypted first target code is processed using JavaScript Virtual Machine Protection (JSVMP) to obtain a second target code. This process makes the second target code more difficult to analyze than the original code it corresponds to, thus making it harder for malicious actors to correctly analyze the original code corresponding to the second target code. This improves the security of the original code corresponding to the second target code and the security of the website corresponding to the second target code.

[0054] In the embodiments of this application, the above-mentioned code (such as the code to be processed, the first target code, and the second target code) can be JavaScript code or front-end JavaScript code, so as to improve the security of the front-end code, prevent malicious actors from easily cracking the front-end code and attacking the back-end, thereby further improving the security of the back-end.

[0055] Reference Figure 1 The diagram shown is a flowchart of a data processing method provided in an embodiment of this application. The method includes:

[0056] S101 uses AST to obfuscate and encrypt the code to be processed, obtaining the first target code.

[0057] Optionally, in order to further improve the security of the code to be processed, thereby enhancing the security of the original code corresponding to the code to be processed, before obfuscating and encrypting the code to be processed using AST, a console judgment condition can be added to the first original code segment in the original code to obtain the code to be processed.

[0058] The aforementioned source code can be the website's source code, which includes a first source code segment. The code to be processed includes the first source code segment. This first source code segment is the code after adding console conditional statements to the first source code segment.

[0059] The aforementioned console check condition is used to detect whether the browser console is open. If the browser console is open, the website corresponding to the code to be processed (i.e., the website corresponding to the original code) is automatically closed to prevent malicious actors from using the open browser console to attack the website, thus protecting it. Furthermore, closing the website corresponding to the code to be processed also prevents malicious actors from continuing to parse the code to be processed, thereby preventing them from further parsing the original code corresponding to the code to be processed, further enhancing the security of the original code.

[0060] In this embodiment of the application, the above-mentioned detection of whether the browser console is open can be performed by detecting whether the length and width values ​​of the current screen are the same as the length and width values ​​of the screen occupied by the open browser.

[0061] Specifically, the length and width values ​​of the current screen are obtained. Then, it is determined whether the obtained length value is the length of the screen occupied by the opened browser, and whether the obtained width value is the width of the screen occupied by the opened browser.

[0062] If the obtained length value is determined to be the length of the screen occupied by the opened browser, and the obtained width value is determined to be the width of the screen occupied by the opened browser, then it is determined that the browser console is not currently open.

[0063] If the obtained length value and the obtained width value are not simultaneously satisfied, then it is determined that the browser console is currently open.

[0064] By comparing the current screen length with the screen length occupied by the open browser, and the current screen width with the screen width occupied by the open browser, it can quickly and accurately detect whether the browser console is currently open or not.

[0065] The console judgment conditions mentioned above can be written using a custom AST script.

[0066] In this embodiment of the application, a first timer can also be added to the first original code segment through AST to automatically execute the above console judgment condition, thereby automatically detecting whether the browser console is open, that is, realizing automatic detection of whether the browser console is open (such as being opened by the developer).

[0067] Optionally, in order to further improve the security of the code to be processed, thereby enhancing the security of the original code corresponding to the code to be processed, an infinite debugger can be added to the second original code segment in the original code before obfuscating and encrypting the code to be processed using AST, so as to obtain the code to be processed.

[0068] The original code above includes a second original code segment, and the code to be processed includes the second code segment. This second code segment is the code after adding an infinite debugger to the second original code segment.

[0069] In the embodiments of this application, the second original code segment may be the same as or different from the first original code segment.

[0070] The aforementioned infinite debugger is used to prevent third parties from debugging the code to be processed, thereby preventing malicious actors from debugging the original code corresponding to the code to be processed. This prevents malicious actors from easily obtaining the original code, thereby further improving the security of the original code and the security of the website to which the original code belongs.

[0071] The above-mentioned method of adding an infinite debugger in the second original code segment can include the following three methods:

[0072] (1) Add the debugger keyword directly to the second original code segment.

[0073] (2) The debugger is executed by adding the eval function to the second original code segment.

[0074] For example, in the second original code segment, add an `eval` function, and in this `eval` function, add the string "debugger", so that the debugger is executed through the execution of the `eval` function.

[0075] Alternatively, in the second original code segment, add a function call that invokes the `eval` function, which contains the string "debugger", so that the debugger is executed by calling the function.

[0076] Alternatively, in the second original code segment, both the calling function and the eval function called by the calling function can be added. The eval function contains the string "debugger", so that the debugger is executed by executing the calling function.

[0077] (3) The debugger is executed by adding a second timer in the second original code segment.

[0078] For example, add a second timer to the second original code segment, which is associated with a function containing a debugger.

[0079] Alternatively, a function containing a debugger can be added to the second original code segment, and this function containing the debugger can be associated with a second timer, so that the function containing the debugger can be executed automatically through the second timer, thereby executing the debugger.

[0080] Alternatively, in the second original code segment, a second timer associated with a function containing a debugger could be added, along with a function containing a debugger. This second timer would then automatically execute the function containing the debugger, thereby executing the debugger.

[0081] Optionally, to further improve the security of the second code segment with an infinite debugger, thereby further enhancing the security of the original code corresponding to the code to be processed, an infinite debugger can be added by concatenating the debugger with strings.

[0082] For example, if a = "de", b = "b", c = "ug", and d = "ger", then using the `eval` function, or identifying a custom obfuscation function, or a `Function` function, concatenating a, b, c, and d to execute a debugger, this increases the debugging difficulty of the second code segment, and consequently, the debugging difficulty of the original code corresponding to the code being processed. Furthermore, this `Function` function can be replaced with a function constructor to execute an infinite number of debuggers, further increasing the debugging difficulty of the second code segment and making it more cumbersome, thus further protecting the original code.

[0083] However, it's important to note that when adding an infinite debugger, the original code must remain intact to avoid altering its business logic. Furthermore, the infinite debugger should be added in plaintext.

[0084] Furthermore, after obtaining the code to be processed, the code is obfuscated and encrypted using the AST to obtain the first target code.

[0085] Optionally, the first code segment containing the console condition in the code to be processed is obfuscated and encrypted using AST to further increase the complexity of the first code segment. This prevents malicious actors from directly analyzing the console condition in the first code segment and easily cracking it, thus preventing the code to be processed from being parsed. Furthermore, by increasing the complexity of the first code segment, the difficulty for malicious actors to analyze it is increased, thereby improving the security of the console condition in the first code segment, further enhancing the security of the code to be processed, and ultimately further improving the security of the original code.

[0086] Optionally, the second code segment containing the infinite debugger in the code to be processed is obfuscated and encrypted using AST to further increase the complexity of the second code segment. This prevents malicious actors from directly analyzing the infinite debugger in the second code segment and easily cracking it, thus preventing the code to be processed from being parsed. Furthermore, by increasing the complexity of the second code segment, the difficulty for malicious actors to analyze it is increased, thereby improving the security of the infinite debugger in the second code segment, further enhancing the security of the code to be processed, and ultimately further improving the security of the original code.

[0087] In the embodiments of this application, the first code segment and the second code segment can be obfuscated and encrypted using AST, or the first code segment can be obfuscated and encrypted using AST without obfuscating and encrypting the second code segment, or the second code segment can be obfuscated and encrypted using AST without obfuscating and encrypting the first code segment. The specific application scenario can be adjusted accordingly.

[0088] In addition, by using AST, besides obfuscating and encrypting the first and second code segments in the code to be processed, other code segments in the code to be processed can also be obfuscated and encrypted to further improve the security of the code to be processed, thereby further improving the security of the original code.

[0089] The aforementioned obfuscation and encryption of code segments in the code to be processed using AST can be considered code obfuscation. For example, rewriting the names of variables and / or functions and / or classes in the first and / or second code segments into single letters or simple, meaningless letter combinations increases the difficulty for malicious actors to understand the code to be processed, thereby increasing the difficulty for them to understand the original code, further enhancing the security of the original code, and further enhancing the security of the website to which the original code belongs. Another example is using AST to replace several lines of sequential syntax with switch syntax to increase the difficulty of reading the code, thereby further suggesting the security of the original code.

[0090] After obfuscating and encrypting the code to be processed to obtain the first target code, it is also necessary to determine whether the business logic in the first target code has changed. If it is determined that the business logic has not changed, then step S102 is executed to avoid the adverse effects of obfuscation and encryption on the business logic of the code to be processed, that is, to avoid the adverse effects of obfuscation and encryption on the business logic of the original code, such as causing the original code to no longer have the corresponding business functions.

[0091] S102, the first target code is processed by JSVMP to obtain the second target code.

[0092] Optionally, to further enhance the security of the code to be processed, and thus further enhance the security of the original code corresponding to the code to be processed, before processing the first target code using JSVMP, formatting detection code can be added to the branch before the key logic code in the first target code. This allows formatting detection to be performed before executing the key logic code, and only after the formatting detection passes will the key logic code be executed. This increases the difficulty for malicious actors to analyze the code to be processed, thereby increasing the difficulty for malicious actors to analyze the original code and further enhancing the security of the original code.

[0093] The aforementioned formatting detection code includes a regular expression matching function. By detecting whether the regular expression matching function contains a specified character, and continuously running the specified function when the specified character is detected, memory overflow occurs, resulting in no normal execution result. This prevents malicious actors from interpreting the code to be processed, further improving the security of the code to be processed.

[0094] The specified character can be a newline character or a space, but it is not limited to these.

[0095] The aforementioned formatting detection code may also include a second timer, which automatically runs a resource-consuming regular expression associated with the second timer to prevent malicious actors from interpreting the original code corresponding to the second target code, thereby further improving the security of the original code.

[0096] Optionally, the logic code can be obfuscated and encrypted using AST, or the code segment with added formatting detection code in the first target code can be obfuscated and encrypted using AST to further improve the security of the original code.

[0097] Furthermore, the first target code is processed using JSVMP to obtain the second target code.

[0098] Specifically, the first target code is first escaped into bytecode to obtain the third target code, thereby grouping a large number of functions into one function, disrupting the original code form, making the first target code controllable by bytecode, and transforming the function variable declarations into stack-based ones, and transforming the function return content, function calls, etc. into those managed by the escaped bytecode, thus further increasing the difficulty of analyzing the original code.

[0099] The escaped bytecode includes a custom virtual instruction set. This virtual instruction set is independent of the underlying hardware and operating system, making the code logic more complex. The instructions in this virtual instruction set also correspond to operations, thus creating a custom operation set. This allows the bytecode to be executed based on the custom virtual instruction set and its corresponding operation set, thereby enabling the execution of the original code. Furthermore, this method of executing bytecode using a custom virtual instruction set and its corresponding operation set further enhances the security of the original code.

[0100] Then, control flow obfuscation is performed on the third target code to obtain the fourth target code. This control flow obfuscation can be achieved by adding control flow logic unrelated to business logic to the third target code, thereby increasing the complexity of the fourth target code, which in turn increases the complexity of the original code, further enhancing the security of the original code.

[0101] Next, the fourth target code is encrypted to obtain the second target code. This encrypted bytecode (i.e., the second target code) can only be decrypted and executed in a virtual machine environment, preventing the second target code from being easily extracted and analyzed, thereby preventing the original code from being easily extracted and analyzed, and further improving the security of the original code.

[0102] The decryption of the second target code mentioned above can be achieved by decrypting the instruction set through a decryption function (such as an entry function), thereby obtaining a series of operation set instructions to run the bytecode normally, and thus run the original code normally.

[0103] In this embodiment, the order in which the formatting detection code, infinite debugger, console judgment condition, AST obfuscation encryption, and JSVMP processing are added is not limited, as long as the JSVMP processing is the last step in the above process.

[0104] For example, you can first add a console condition, then add an infinite debugger, then add formatting detection code, and then use AST to obfuscate and encrypt the console condition, infinite debugger, and formatting detection code respectively, and finally process them using JSVMP; you can also first add an infinite debugger, then add formatting detection code, then add a console condition, and then use AST to obfuscate and encrypt the console condition, infinite debugger, and formatting detection code respectively, and finally process them using JSVMP; you can also first add formatting detection code, then add a console condition, then add an infinite debugger, and then use AST to obfuscate and encrypt the console condition, infinite debugger, and formatting detection code respectively, and finally process them using JSVMP; you can also first add a console condition, and use AST to obfuscate and encrypt the console condition, then add an infinite debugger, and use AST to obfuscate and encrypt the infinite debugger, then add formatting detection code, and use AST to obfuscate and encrypt the formatting detection code, and finally process it using JSVMP.

[0105] In addition, environmental detection code can be added to all of the above processes.

[0106] That is, environment detection code is added to the first code segment; environment detection code is added to the second code segment; environment detection code is added to the first target code; environment detection code is added to the first target code where formatting detection code has been added; and environment detection code is added to the second target code. This allows environment detection to be performed during the console judgment process, the infinite debugger process, the AST obfuscation and encryption process, the formatting detection process, and the JSVMP processing process.

[0107] The aforementioned environment detection code is used to detect whether the code is running in a browser environment. If it is not in a browser environment, it will enter an incorrect code value or interrupt the program, thereby further protecting the original code and improving its security.

[0108] In summary, the data processing method proposed in this application first obfuscates and encrypts the code to be processed using an Abstract Syntax Tree (AST), and then processes the obfuscated and encrypted first target code using binary virtualization protection technology of instruction set (JSVMP), thereby improving the security of the code (such as the original code). Different logic is added during the AST obfuscation and encryption and JSVMP processing. For example, several sequential syntax statements are replaced with switch syntax using AST to increase readability. Subsequent additions of binary logic involving push, pop, and register operations further increase debugging difficulty and enhance the security of the original code.

[0109] Furthermore, by obfuscating and encrypting the code to be processed (such as the core front-end JavaScript code), the reverse engineering difficulty for malicious actors is increased, thus improving the security of front-end business operations. For example, simulating the core front-end JavaScript code normally takes one or two days, but due to the enhanced protection measures such as obfuscation, encryption, and JSVMP processing, the analysis of the core front-end JavaScript code becomes significantly more difficult, and the time required increases exponentially. This ensures normal communication between the front-end and back-end, as well as information and business security. It also prevents unwanted simulated requests from obtaining correct data, which is of great significance for maintaining data security, improving performance, and protecting privacy.

[0110] In addition, the data processing method provided by the embodiments of this application employs multiple logics to prevent normal acquisition of JavaScript code. Even if JavaScript code is acquired, it cannot be used normally because multiple logics (such as console judgment conditions, infinite debugger, AST obfuscation encryption, format detection, and JSVMP processing) are added to the JavaScript code, thereby further improving the security of the JavaScript code.

[0111] Furthermore, in terms of debugging, encryption and obfuscation are used, as well as the code is run by forming instruction sets (i.e., JSVMP processing), which greatly increases the difficulty of analyzing the original code and further enhances the security of the original code.

[0112] In addition, environmental detection principles were adopted for detection, so that the backend service can be controlled by training a model to score the environment later.

[0113] The technical solution of this application will be further explained below with reference to a specific application process.

[0114] like Figure 2 The diagram shows the data processing method. First, in the console debugging module, a console judgment condition is added to the first original code segment in the original code to obtain the code to be processed, including the first code segment. This allows the console judgment condition to detect whether the browser console is open and to automatically close the website corresponding to the original code when the browser console is opened.

[0115] In the infinite debugger blocking module, an infinite debugger is added to the second original code segment in the original code to obtain the code to be processed, which includes the second code segment. This allows the infinite debugger to prevent third parties from debugging the code to be processed, thereby preventing malicious actors from debugging the original code.

[0116] In the formatting detection module, formatting detection code is added to the third original code segment in the original code, resulting in code to be processed that includes the third code segment. This allows the formatting detection code to continuously run the specified function when the regular expression matching function detects that it contains a specified character, and to automatically run the resource-consuming regular expression associated with the second timer via a second timer. The third original code segment can be the code segment corresponding to the branch preceding the key logic code.

[0117] In the AST obfuscation and encryption module, the first code segment, the second code segment, and the third code segment in the code to be processed are obfuscated and encrypted using the AST to obtain the first target code.

[0118] In the JSVMP processing module, the first target code is processed using JSVMP to obtain the second target code.

[0119] By employing the above methods, including the console anti-debugging module, the infinite debugger blocking module, the format detection module, the AST obfuscation and encryption module, and the JSVMP processing module, the security of the original code is further enhanced.

[0120] Based on the same inventive concept, this application also provides a data processing device, such as... Figure 3 The diagram shown is a structural schematic of a data processing apparatus provided in this application. The apparatus includes:

[0121] The obfuscation and encryption module 301 is used to obfuscate and encrypt the code to be processed through the abstract syntax tree (AST) to obtain the first target code.

[0122] The processing module 302 is used to process the first target code using the scripting language virtual machine protection technology JSVMP to obtain the second target code.

[0123] In one possible implementation, the device further includes a control judgment module, which is used to add a console judgment condition to a first original code segment in the original code before obfuscating and encrypting the code to be processed through an abstract syntax tree (AST) to obtain the first target code, thereby obtaining the code to be processed; wherein the console judgment condition is used to detect whether a browser console is open, and automatically close the website corresponding to the code to be processed when the browser console is opened.

[0124] In one possible implementation, the control judgment module is specifically used to add a first timer to the first original code segment through the AST; wherein the first timer is associated with the console judgment condition.

[0125] In one possible implementation, the apparatus further includes a debugger module, which is used to add an infinite debugger to a second original code segment in the original code before obfuscating and encrypting the code to be processed through an abstract syntax tree (AST) to obtain the first target code, thereby obtaining the code to be processed; wherein the infinite debugger is used to prevent third parties from debugging the code to be processed.

[0126] In one possible implementation, the apparatus further includes a formatting detection module, which is configured to add formatting detection code at the branch before the critical logic code in the first target code before the second target code is obtained by processing the first target code using the scripting language virtual machine protection technology JSVMP; wherein the formatting detection code is configured to continuously run the specified function when the regular expression matching function is detected to include the specified character, and to automatically run the resource-consuming regular expression associated with the second timer via a second timer.

[0127] In one possible implementation, the processing module 302 is specifically used to escape the first target code into bytecode to obtain the third target code; to perform control flow obfuscation on the third target code to obtain the fourth target code; and to encrypt the fourth target code to obtain the second target code.

[0128] In one possible implementation, the device further includes an environment detection module, which is used to add environment detection code to the code; wherein the code includes the code to be processed, the first target code, and the second target code, and the environment detection code is used to perform environment detection on the code to determine whether the environment of the code is a browser environment, and if it is not a browser environment, to execute an error code branch or interrupt the execution of the code.

[0129] Based on the same inventive concept, this application also provides an electronic device that can realize the functions of the aforementioned data processing device. (Refer to...) Figure 4 The aforementioned electronic devices include:

[0130] At least one processor 401 and a memory 402 connected to at least one processor 401. In this embodiment, the specific connection medium between the processor 401 and the memory 402 is not limited. Figure 4 The example shown is the connection between processor 401 and memory 402 via bus 400. Bus 400 is... Figure 4 The connections between other components are indicated by thick lines and are for illustrative purposes only, not as limiting information. The 400 bus can be divided into address bus, data bus, control bus, etc., for ease of representation. Figure 4 The term is represented by a single thick line, but this does not imply that there is only one bus or one type of bus. Alternatively, processor 401 can also be called a controller; there is no restriction on the name.

[0131] In this embodiment, memory 402 stores instructions executable by at least one processor 401. By executing the instructions stored in memory 402, at least one processor 401 can perform the data processing method described above. Processor 401 can implement... Figure 3 The functions of each module in the device shown.

[0132] The processor 401 is the control center of the device. It can connect to various parts of the control device through various interfaces and lines. By running or executing instructions stored in memory 402 and calling data stored in memory 402, the processor can perform various functions and process data, thereby monitoring the device as a whole.

[0133] In one possible design, processor 401 may include one or more processing units. Processor 401 may integrate an application processor and a modem processor, wherein the application processor mainly handles the operating system, user interface, and applications, and the modem processor mainly handles wireless communication. It is understood that the modem processor may also not be integrated into processor 401. In some embodiments, processor 401 and memory 402 may be implemented on the same chip; in some embodiments, they may also be implemented separately on separate chips.

[0134] Processor 401 can be a general-purpose processor, such as a central processing unit (CPU), digital signal processor, application-specific integrated circuit, field-programmable gate array or other programmable logic device, discrete gate or transistor logic device, or discrete hardware component, capable of implementing or executing the methods, steps, and logic block diagrams disclosed in the embodiments of this application. The general-purpose processor can be a microprocessor or any conventional processor. The steps of the data processing methods disclosed in the embodiments of this application can be directly manifested as being executed by a hardware processor, or executed by a combination of hardware and software modules within the processor.

[0135] Memory 402, as a non-volatile computer-readable storage medium, can be used to store non-volatile software programs, non-volatile computer-executable programs, and modules. Memory 402 may include at least one type of storage medium, such as flash memory, hard disk, multimedia card, card-type memory, random access memory (RAM), static random access memory (SRAM), programmable read-only memory (PROM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), magnetic memory, magnetic disk, optical disk, etc. Memory 402 can be any other medium capable of carrying or storing desired program code in the form of instructions or data structures that can be accessed by a computer, but is not limited thereto. In the embodiments of this application, memory 402 can also be a circuit or any other device capable of implementing storage functions for storing program instructions and / or data.

[0136] By designing and programming the processor 401, the code corresponding to the data processing methods described in the foregoing embodiments can be embedded into the chip, enabling the chip to execute these methods during operation. Figure 1 The steps of the data processing method in the illustrated embodiment are as follows. How to design and program the processor 401 is a technique well-known to those skilled in the art and will not be described further here.

[0137] Based on the same inventive concept, embodiments of this application also provide a storage medium storing computer instructions that, when executed on a computer, cause the computer to perform the data processing method described above.

[0138] In some possible implementations, various aspects of the data processing methods provided in this application can also be implemented as a program product comprising program code that, when the program product is run on a device, causes the control device to perform the steps in the data processing methods according to the various exemplary embodiments of this application described above.

[0139] Those skilled in the art will understand that embodiments of this application can be provided as methods, systems, or computer program products. Therefore, this application can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this application can take the form of a computer program product embodied on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0140] This application is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of this application. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart... Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.

[0141] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.

[0142] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.

[0143] Obviously, those skilled in the art can make various modifications and variations to this application without departing from the spirit and scope of this application. Therefore, if such modifications and variations fall within the scope of the claims of this application and their equivalents, this application also intends to include such modifications and variations.

Claims

1. A method of processing data, characterized by, include: The code to be processed is obfuscated and encrypted using an Abstract Syntax Tree (AST) to obtain the first target code. The first target code is processed using the scripting language virtual machine protection technology JSVMP to obtain the second target code.

2. The method of claim 1, wherein, Before obfuscating and encrypting the code to be processed through an Abstract Syntax Tree (AST) to obtain the first target code, the following steps are also included: Add a console condition to the first original code segment in the original code to obtain the code to be processed; wherein, the console condition is used to detect whether the browser console is open, and automatically close the website corresponding to the code to be processed when the browser console is opened.

3. The method of claim 2, wherein, Before obfuscating and encrypting the code to be processed through an Abstract Syntax Tree (AST) to obtain the first target code, the following steps are also included: Using the AST, a first timer is added to the first original code segment; wherein the first timer is associated with the console judgment condition.

4. The method of claim 1, wherein, Before obfuscating and encrypting the code to be processed through an Abstract Syntax Tree (AST) to obtain the first target code, the following steps are also included: An infinite debugger is added to the second original code segment in the original code to obtain the code to be processed; wherein, the infinite debugger is used to prevent third parties from debugging the code to be processed.

5. The method of claim 1, wherein, Before processing the first target code using the scripting language virtual machine protection technology JSVMP to obtain the second target code, the method further includes: At the branch before the key logic code in the first target code, add format detection code; wherein, the format detection code is used to continuously run the specified function when the regular expression matching function is detected to include the specified character, and to automatically run the resource-consuming regular expression associated with the second timer through the second timer.

6. The method of claim 1, wherein, The process of processing the first target code using the scripting language virtual machine protection technology JSVMP to obtain the second target code includes: The first target code is escaped into bytecode to obtain the third target code; Control flow obfuscation is performed on the third target code to obtain the fourth target code; The fourth target code is encrypted to obtain the second target code.

7. The method according to any one of claims 1 to 6, wherein The method further includes: Add environment detection code to the code; wherein the code includes the code to be processed, the first target code, and the second target code, and the environment detection code is used to perform environment detection on the code to determine whether the environment of the code is a browser environment, and if it is not a browser environment, execute an error code branch or interrupt the execution of the code.

8. A data processing device, characterized by comprising: include: The obfuscation and encryption module is used to obfuscate and encrypt the code to be processed through the Abstract Syntax Tree (AST) to obtain the first target code. The processing module is used to process the first target code using the scripting language virtual machine protection technology JSVMP to obtain the second target code.

9. An electronic device, comprising: include: Memory, used to store computer programs; A processor, when executing a computer program stored in the memory, implements the method steps of any one of claims 1-7.

10. A computer-readable storage medium, characterized in that, The computer readable storage medium stores a computer program, and the computer program is executed by the processor to implement the method steps in any one of claims 1-7.