A method, device, electronic device and storage medium for intelligent terminal code obfuscation
By inserting jump nodes into the code file and randomly inserting garbage code, the problem of insufficient code security in the existing technology is solved, and the difficulty and security of reverse code analysis are increased.
Patent Information
- Application Number
- CN202210621273.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-06-01
- Publication Date
- 2025-02-28
- Estimated Expiration
- 2042-06-01
AI Technical Summary
The prior art cannot effectively ensure the security of software development code and is easily reversely analyzed and tampered with.
By obtaining the code file to be obfuscated, performing call objects analysis, determining the number of times each call object is called, determining the target call object, and inserting jump nodes before these objects. When the code is running, inserting garbage code based on these jump nodes.
Ensure that the code file will change every time it runs, which increases the difficulty of reverse code analysis and effectively ensures the security of software development code.
Smart Images

Figure CN114924749B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of network security technology, and in particular to a smart terminal code obfuscation method, device, electronic device and storage medium. Background Art
[0002] At present, in the process of software development, the names of classes, variables, and functions in the code compilation are usually set to have a certain readability. At the same time, in order to protect the software development code, the code files compiled using the development code need to be obfuscated to increase the difficulty of decompiling and tampering with the installation files of the software application, thereby protecting the development code.
[0003] In the prior art, the names in the code are usually replaced with meaningless strings, or the names are encrypted using an encryption algorithm. However, both string replacement and encryption are easily reverse analyzed, and the security of the code cannot be guaranteed. Summary of the invention
[0004] The present application provides a smart terminal code obfuscation method, device, electronic device and storage medium to solve the defects of the prior art that the security of software development code cannot be guaranteed.
[0005] The first aspect of the present application provides a smart terminal code obfuscation method, comprising:
[0006] Get the code file to be obfuscated;
[0007] Performing call object analysis on the code file to determine the number of times each call object in the code file is called;
[0008] Determine multiple target calling objects according to the number of times each calling object is called;
[0009] Locating each of the target call objects in the code file, and inserting a jump node before each of the target call objects;
[0010] When the code file is run, junk code is inserted based on each of the jump nodes.
[0011] Optionally, determining a plurality of target calling objects according to the number of times each calling object is called includes:
[0012] Determining the obfuscation interval according to the number of times each of the calling objects is called;
[0013] The calling object whose called times belong to the confusion interval is determined as the target calling object.
[0014] Optionally, determining the obfuscation interval according to the number of times each of the calling objects is called includes:
[0015] Sort the number of times each calling object is called in ascending order, and determine the corresponding first quartile and third quartile;
[0016] Determine the interquartile range based on the difference between the first quartile and the third quartile;
[0017] The endpoint value of the confusion interval is determined according to the sum calculation result and the difference calculation result between the first quartile and the interquartile range.
[0018] Optionally, the inserting junk code based on each of the jump nodes includes:
[0019] Based on each of the jump nodes, junk codes are randomly called in a preset junk code library.
[0020] Optionally, also include:
[0021] Traversing the code file, and extracting all parameters in the code file;
[0022] Classify the parameters according to data types to obtain parameter sets corresponding to different data types;
[0023] According to the extraction order of each parameter, an index number is assigned to the parameters in each parameter set, and the index number is homomorphically encrypted.
[0024] Optionally, the classifying the parameters according to data types includes:
[0025] For any of the parameters, calling the target function corresponding to the parameter;
[0026] Comparing the target function with the functions in the standard library to obtain corresponding function comparison results;
[0027] The data type of the parameter is determined according to the function information represented by the function comparison result.
[0028] Optionally, the classifying the parameters according to data types includes:
[0029] Construct integer control group and character control group;
[0030] Based on the integer control group and the character control group, four arithmetic operations are performed on the parameters;
[0031] Determine the data type of the parameter according to the four calculation results of the parameter;
[0032] The data types include integer, character and Boolean.
[0033] The second aspect of the present application provides a smart terminal code obfuscation device, comprising:
[0034] The acquisition module is used to obtain the code file to be obfuscated;
[0035] A first determination module is used to perform call object analysis on the code file to determine the number of times each call object in the code file is called;
[0036] A second determination module is used to determine a plurality of target calling objects according to the number of times each calling object is called;
[0037] An insertion module, used for locating each of the target call objects in the code file and inserting a jump node before each of the target call objects;
[0038] The obfuscation module is used to insert junk code based on each of the jump nodes when running the code file.
[0039] Optionally, the second determining module is specifically configured to:
[0040] Determining the obfuscation interval according to the number of times each of the calling objects is called;
[0041] The calling object whose called times belong to the confusion interval is determined as the target calling object.
[0042] Optionally, the second determining module is specifically configured to:
[0043] Sort the number of times each calling object is called in ascending order, and determine the corresponding first quartile and third quartile;
[0044] Determine the interquartile range based on the difference between the first quartile and the third quartile;
[0045] The endpoint value of the confusion interval is determined according to the sum calculation result and the difference calculation result between the first quartile and the interquartile range.
[0046] Optionally, the obfuscation module is specifically used to:
[0047] Based on each of the jump nodes, junk codes are randomly called in a preset junk code library.
[0048] Optionally, the device further comprises:
[0049] A homomorphic encryption module is used to traverse the code file and extract all parameters in the code file; classify the parameters according to data type to obtain parameter sets corresponding to different data types; assign index numbers to the parameters in each parameter set according to the extraction order of each parameter, and homomorphically encrypt the index numbers.
[0050] Optionally, the homomorphic encryption module is specifically used for:
[0051] For any of the parameters, calling the target function corresponding to the parameter;
[0052] Comparing the target function with the functions in the standard library to obtain corresponding function comparison results;
[0053] The data type of the parameter is determined according to the function information represented by the function comparison result.
[0054] Optionally, the homomorphic encryption module is specifically used for:
[0055] Construct integer control group and character control group;
[0056] Based on the integer control group and the character control group, four arithmetic operations are performed on the parameters;
[0057] Determine the data type of the parameter according to the four calculation results of the parameter;
[0058] The data types include integer, character and Boolean.
[0059] A third aspect of the present application provides an electronic device, comprising: at least one processor and a memory;
[0060] The memory stores computer-executable instructions;
[0061] The at least one processor executes the computer-executable instructions stored in the memory, so that the at least one processor performs the method described in the first aspect and various possible designs of the first aspect.
[0062] A fourth aspect of the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores computer-executable instructions. When a processor executes the computer-executable instructions, the method described in the first aspect and various possible designs of the first aspect are implemented.
[0063] The technical solution of this application has the following advantages:
[0064] The present application provides a method, device, electronic device and storage medium for code obfuscation of smart terminals, the method comprising: obtaining a code file to be obfuscated; performing call object analysis on the code file to determine the number of times each call object in the code file is called; determining multiple target call objects according to the number of times each call object is called; locating each target call object in the code file and inserting a jump node before each target call object; when running the code file, inserting junk code based on each jump node. The method provided by the above scheme ensures that the code file will change each time it is run by randomly inserting junk code based on the jump node set before the target call object, which increases the difficulty of code reverse analysis and ensures the security of software development code. BRIEF DESCRIPTION OF THE DRAWINGS
[0065] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present application, and a person skilled in the art can also obtain other drawings based on these drawings.
[0066] Figure 1 This is a schematic diagram of the structure of the intelligent terminal code obfuscation system based on the embodiment of the present application;
[0067] Figure 2 A flowchart of a smart terminal code obfuscation method provided in an embodiment of the present application;
[0068] Figure 3 A flowchart of another smart terminal code obfuscation method provided in an embodiment of the present application;
[0069] Figure 4 A schematic diagram of the structure of a smart terminal code obfuscation device provided in an embodiment of the present application;
[0070] Figure 5 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application.
[0071] The above drawings have shown clear embodiments of the present application, which will be described in more detail below. These drawings and text descriptions are not intended to limit the scope of the present disclosure in any way, but to illustrate the concepts of the present application to those skilled in the art by referring to specific embodiments. DETAILED DESCRIPTION
[0072] In order to make the purpose, technical solution and advantages of the embodiments of the present application clearer, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0073] In addition, the terms "first", "second", etc. are used for descriptive purposes only and should not be understood as indicating or implying relative importance or implicitly indicating the number of technical features indicated. In the description of the following embodiments, the meaning of "multiple" is more than two, unless otherwise clearly and specifically defined.
[0074] As introduced in the background technology, the terminals of power Internet devices are characterized by large number and variety, and most of them are embedded systems. The computing power, communication capability, storage capacity, etc. of the devices are limited, and complex security technologies cannot usually be directly applied. Firmware is software specially customized for embedded devices and is the core of smart terminal devices. Unlike traditional software, firmware usually interacts with the outside world through a set of peripheral devices, but firmware has important features similar to traditional software. Its important parts are usually built in unsafe low-level languages. The fragile features carried by these languages have buried various security risks for firmware.
[0075] Regarding the anti-tampering method of the firmware of the smart terminal equipment of the power grid, it is found that code obfuscation is a firmware protection mechanism used to hide the original algorithm, data structure or logic of the code, or to strengthen the protection of the code from the unauthorized reverse engineering process. In general, code obfuscation can hide the implementation details of the program from the adversary, that is, convert the program into a semantically equivalent (same computing effect) program. However, the current code obfuscation technology has not yet been able to meet all the obfuscation effectiveness standards to resist reverse engineering attacks.
[0076] In the prior art, the names in the code are usually replaced with meaningless strings, or the names are encrypted using an encryption algorithm. However, both string replacement and encryption are easily reverse analyzed, and the security of the code cannot be guaranteed.
[0077] In response to the above problems, the smart terminal code obfuscation method, device, electronic device and storage medium provided in the embodiments of the present application obtain the code file to be obfuscated; perform call object analysis on the code file to determine the number of times each call object in the code file is called; determine multiple target call objects based on the number of times each call object is called; locate each target call object in the code file, and insert a jump node before each target call object; when running the code file, insert junk code based on each jump node. The method provided by the above scheme ensures that the code file will change each time it is run, increases the difficulty of code reverse analysis, and ensures the security of software development code.
[0078] The following specific embodiments may be combined with each other, and the same or similar concepts or processes may not be described in detail in some embodiments. The embodiments of the present invention will be described below in conjunction with the accompanying drawings.
[0079] First, the structure of the intelligent terminal code obfuscation system on which this application is based is described:
[0080] The smart terminal code obfuscation method, device, electronic device and storage medium provided in the embodiments of the present application are suitable for obfuscating the development code to improve the security of the development code. Figure 1 The figure is a schematic diagram of the structure of the smart terminal code obfuscation system based on the embodiment of the present application, which mainly includes a data acquisition device and a smart terminal code obfuscation device. Specifically, the data acquisition device can be used to collect the code file to be obfuscated, and the code file can be sent to the smart terminal code obfuscation device, and the smart terminal code obfuscation device can perform corresponding code obfuscation processing on the code file.
[0081] The embodiment of the present application provides a smart terminal code obfuscation method for obfuscating the development code running on the smart terminal. The execution subject of the embodiment of the present application is an electronic device, such as a server, a desktop computer, a laptop computer, a tablet computer, and other electronic devices that can be used for running code and code obfuscation.
[0082] like Figure 2 As shown, it is a flow chart of a smart terminal code obfuscation method provided by an embodiment of the present application, and the method includes:
[0083] Step 201, obtaining the code file to be obfuscated.
[0084] The code file may be a firmware code file of a smart terminal or an APP code file, etc.
[0085] Step 202: perform call object analysis on the code file to determine the number of times each call object in the code file is called.
[0086] The calling object may be a class or a function, etc.
[0087] Specifically, the calling object information set M of the code file can be obtained by performing call object analysis on the code file and counting the name of each call object in the code file and the corresponding number of times it is called. i ,c i ), where m i Indicates the name of the calling object, c i Indicates m i The number of times it is called, that is, the number of times it is called. In the process of analyzing the code file line by line, if the object m is currently called j , check whether M exists (m j , c j ), if it exists, then c j ++, otherwise add a new element (m j , c j ) to M, then c j =1, and record the total number of calling objects C=C 0 +c j (C 0 The initial value is 0).
[0088] Step 203: Determine multiple target calling objects according to the number of times each calling object is called.
[0089] Specifically, the popularity of each calling object may be determined according to the number of times each calling object is called, and then multiple target calling objects may be screened from all calling objects according to the popularity of each calling object.
[0090] Step 204: locate each target call object in the code file, and insert a jump node before each target call object.
[0091] It should be noted that the jump node is used to execute the control flow obfuscator to perform corresponding control flow obfuscation on the code file during its execution.
[0092] Step 205: When the code file is executed, junk code is inserted based on each jump node.
[0093] It should be noted that junk code does not affect the normal operation of the code file, but it can make it difficult for reverse analysts to know the truly useful instructions from the running program.
[0094] On the basis of the above embodiments, since the effectiveness of code obfuscation processing mainly depends on the insertion position of the jump node, in order to improve the effectiveness of code obfuscation processing, as an implementable method, in one embodiment, multiple target calling objects are determined according to the number of times each calling object is called, including:
[0095] Step 2031, determining the obfuscation interval according to the number of times each calling object is called;
[0096] Step 2032: determine the calling object whose called times belong to the obfuscation interval as the target calling object.
[0097] It should be noted that the obfuscation interval determined in the embodiment of the present application will cover all calling objects that should be subjected to code obfuscation processing.
[0098] Specifically, in one embodiment, the number of times each calling object is called can be sorted in ascending order, and the corresponding first quartile and third quartile can be determined; the interquartile range can be determined based on the difference calculation result between the first quartile and the third quartile; the endpoint value of the confusion interval can be determined based on the sum calculation result and the difference calculation result between the first quartile and the interquartile range.
[0099] Specifically, the interquartile range IQR=|Q3-Q1|, where Q1 is the first quartile and Q3 is the third quartile.
[0100] Furthermore, the endpoint value of the confusion interval can be calculated according to the following formula:
[0101] C_max=Q1-1.5IQR
[0102] C_min=Q1+1.5IQR
[0103] Among them, C_max represents the maximum abnormal value of the number of times called, C_min represents the minimum abnormal value of the number of times called, and the confusion interval is [C min , C max ].
[0104] Furthermore, if the number of times a certain calling object is called falls within the confusion interval [C min , C max ], then the calling object is determined as the target calling object.
[0105] Based on the above embodiment, since junk codes are directly added to the code file, the device may require more memory to store the code file.
[0106] In order to solve the above problem, as an implementable method, in one embodiment, junk code is inserted based on each jump node, including:
[0107] Step 2051: randomly call junk codes in a preset junk code library based on each jump node.
[0108] Specifically, in order to avoid increasing the memory consumption of the code file, a junk code library can be preset. During the running of the code file, a junk code call instruction can be sent to the junk code library based on the jump node to randomly call junk code in the junk code library and insert the junk code into the running program.
[0109] Based on the above embodiments, Figure 3 As shown, it is a flowchart of another smart terminal code obfuscation method provided in an embodiment of the present application. As an implementable manner, in one embodiment, the method further includes:
[0110] Step 301, traverse the code file and extract all parameters in the code file;
[0111] Step 302, classify the parameters according to the data type to obtain parameter sets corresponding to different data types;
[0112] Step 303, assign index numbers to the parameters in each parameter set according to the extraction order of each parameter, and homomorphically encrypt the index numbers.
[0113] Among them, data types include integer, character, and Boolean.
[0114] Specifically, the code file can be read line by line, and then the read content can be detected based on the regular expression \s*const-string\s+(v|p)(\d), \s+″(.*)″ to determine the string data in the code file, and determine the value of the string data as a parameter. Finally, the obtained parameters are extracted into the total parameter set, and the location information of each parameter, such as the line number, is recorded.
[0115] Furthermore, according to the data type of each parameter in the total parameter set, the total parameter set is divided into multiple parameter sets, one parameter set corresponding to one data type. Then, according to the extraction order of each parameter, which is also the order of each parameter in the code file represented by its position information, an index number is assigned to the parameters in each parameter set. Finally, the homomorphic encryption technology is used to encrypt the index numbers of all parameters.
[0116] In order to facilitate those skilled in the art to better understand the technical solution provided in the embodiment of the present application, the embodiment of the present application provides the following exemplary homomorphic encryption process:
[0117] Step 1: Use the Miller-Rabin prime number detection algorithm to select prime numbers for the index number (integer) of the parameter, select p and q as large prime numbers from these selected prime numbers, and calculate m=pq (p, q are kept confidential).
[0118] Step 2: Select a safety parameter n of appropriate size according to needs.
[0119] Step 3: Assume that the plaintext space T = Z m (Z m are all integers less than m), the ciphertext space T′=(Z p ×Z q )n, randomly select two prime numbers r p , r q Make them satisfy r p ∈Z p , r q ∈Z q .
[0120] Step 4: The generated encryption key is K = (p, q, r p , r q ).
[0121] Step 5: Encryption operation. Suppose a plaintext x∈Z m , randomly divide x into n parts: x 1 , x 2 ,......,x n And satisfy x i ∈Z m ,i=(1,2,...,n),x=∑ i=1 n x i mod m,E k (x)=([x 1 r p mod p,x 1 rq mod q],[x 2 r p 2 mod p,x 2 r q 2 mod q],……,[x n r p n mod p,x n r q n mod q]).
[0122] Step 6: Ciphertext calculation, using Fourier transform (for any integer n>=0, k>=0, d>0, w dndk =w n k (w is a complex number). It is known that X(n) = ∑ k=0 N - 1 x 0 (k)e πnk / N n=0,1,2……N-1,let W=e π / N , p=nk, when N=2 r When n and k can be represented by binary numbers, the formula can be rewritten as
[0123] because The formula is rewritten as X(n r-1 n r-2 ……n 0 )=x r (n 0 n 1 ……n r-1 ), and because each x in the Lth array 1 (k) = x 1 (n r-1 n r-2 ……n 0 k r-1 k r-2 ……k 0 ) depends only on two data in the previous array, the positions of these two data differ by 2 r-1 =N / 2, that is, k=i=j+n / 2, so the two new data calculated using the previous set of data can still be stored in the original position.
[0124] Step 7: Decryption calculation. ([x 1 r p mod p,x 1 rq mod q],[x 2 r p 2 mod p,x 2 r q 2 modq],……,[x n r p n mod p,x n r q n mod q]), where r p -n and r q -n r p mod p,r qmod q the inverse element of the corresponding power, ∑ i=1 n [x i mod p,x i mod q]=[∑ i=1 n x i mod p,∑ i=1 n x i mod q] = [x mod p, x mod q], and then use the Sunzi theorem to get D k (x) = (xqq -1 +xpp -1 )mod m. Among them, qq -1 =1 mod p, that is -1 =1mod q.
[0125] It should be noted that the data is encrypted using homomorphic encryption technology, and then the ciphertext data is submitted to the server to ensure that the parameters in the code file are not stolen by malicious service providers. The server does not need to decrypt the data, and can use the above method to convert the original calculation of the plaintext data into the calculation of the ciphertext, and obtain the calculation result of the ciphertext. Alternatively, when the user needs to update the ciphertext information stored on the server, the encrypted parameters can be submitted, and the server directly calculates the ciphertext using the above method, and updates the original ciphertext data with the new calculation result. Finally, when the result is returned to the user in ciphertext form, the plaintext result can be obtained by decryption by the client, and the homomorphism of the encryption scheme ensures the correctness of the result. In the above process, the data is always in ciphertext form on the server, so it can not only ensure the smooth operation of the code file, but also protect the security of the code file.
[0126] Based on the above embodiments, since the main idea of homomorphic data obfuscation is to convert all variables in the program into arrays, the type of the array must be kept consistent during the conversion process. As an implementable method, in one embodiment, the parameters are classified according to the data type, including:
[0127] Step 3021, for any parameter, calling the target function corresponding to the parameter;
[0128] Step 3022, comparing the target function with the functions in the standard library to obtain corresponding function comparison results;
[0129] Step 3023: Determine the data type of the parameter according to the function information represented by the function comparison result.
[0130] It should be noted that the existing function detection technology in the current standard library can accurately obtain the functions used by the program slice. Based on the known function prototype, the data type of the parameter found at this time can be directly inferred. Using this method to determine the data type is essentially to determine the parameter type through the function definition. This method is simple and will not cause ambiguity. It is the most accurate way to obtain data type information.
[0131] Among them, the function call data transmission process is as follows:
[0132]
[0133] esp is the stack pointer register (extended stack pointer), which stores a pointer that always points to the top of the top stack frame of the system stack.
[0134] Ebp is the base pointer register (extended base pointer), which stores a pointer that always points to the bottom of the top stack frame of the system stack.
[0135] Specifically, first, the push instruction pushes the original base address ebp of the stack into the stack, the mov instruction transfers the value of esp to ebp and enters the function body, and the sub instruction allocates an address and space for esp. The push instruction puts the parameters into the allocated address and space. The call instruction calls the required parameters and pushes the parameters into the stack. The add instruction returns the space occupied by esp to the system, and the stack is used up. When executing the call instruction, rewards detects who called the call instruction, compares it with the functions in the standard library, determines the parameter type corresponding to the target function, and then determines the parameter type corresponding to the parameter.
[0136] Specifically, in one embodiment, when the target function of the parameter is not in the standard library, an integer control group and a character control group may be constructed; based on the integer control group and the character control group, four arithmetic operations are performed on the parameters; and based on the four arithmetic operations results of the parameters, the data type of the parameters is determined.
[0137] Among them, the integer control group A = {a 0 , a 1 , ..., a 8} stores integer numbers from 1 to 9, character control group B = {b 0 , b 1 ,......,b 25} stores string characters from a to z, O represents a set of four arithmetic operations, O = {o1, o2, o3, o4}, corresponding to addition, subtraction, multiplication and division respectively. It is known that data parameters with the same data type can be operated, and parameters with different data types will return a null value.
[0138] Specifically, an element is randomly selected from A and O, and the following equation is used to determine whether the data type of the parameter z is an integer.
[0139] s=(z O a)V null
[0140] s is not null
[0141] S i =z
[0142] If the value of s is not empty, add z to the corresponding parameter set S of the integer type i middle.
[0143] s=(z O b)V null
[0144] s is not null
[0145] S j =z
[0146] If the value of s is not empty, add z to the parameter set S corresponding to the character type j middle.
[0147] Furthermore, if the value of s is empty twice, the following equation is used to determine whether the data type of parameter z is Boolean.
[0148] s=(zV0)
[0149] s==1∨s==0
[0150] S k =z
[0151] If the value of s is not empty and s=1, z is a Boolean type, and z is added to the Boolean array S k middle.
[0152] If the value of s is not empty and s=0, z is a Boolean type, and z is added to the Boolean array S k middle.
[0153] The smart terminal code obfuscation method provided in the embodiment of the present application obtains the code file to be obfuscated; performs call object analysis on the code file to determine the number of times each call object in the code file is called; determines multiple target call objects based on the number of times each call object is called; locates each target call object in the code file, and inserts a jump node before each target call object; when the code file is run, inserts junk code based on each jump node. The method provided by the above scheme ensures that the code file will change each time it is run, increases the difficulty of code reverse analysis, and ensures the security of the software development code. In addition, the index number of each parameter in the code file in the parameter set is homomorphically encrypted, which further improves the security of the software development code.
[0154] An embodiment of the present application provides a smart terminal code obfuscation device, which is used to execute the smart terminal code obfuscation method provided in the above embodiment.
[0155] like Figure 4 , which is a schematic diagram of the structure of the smart terminal code obfuscation device provided in the embodiment of the present application. The smart terminal code obfuscation device 40 comprises: an acquisition module 401, a first determination module 402, a second determination module 403, an insertion module 404 and an obfuscation module 405.
[0156] Among them, the acquisition module is used to obtain the code file to be obfuscated; the first determination module is used to analyze the call objects of the code file and determine the number of times each call object in the code file is called; the second determination module is used to determine multiple target call objects based on the number of times each call object is called; the insertion module is used to locate each target call object in the code file and insert a jump node before each target call object; the obfuscation module is used to insert junk code based on each jump node when running the code file.
[0157] Specifically, in one embodiment, the second determining module is specifically configured to:
[0158] Determine the confusion interval according to the number of times each calling object is called;
[0159] The calling object whose calling times belong to the confusion interval is determined as the target calling object.
[0160] Specifically, in one embodiment, the second determining module is specifically configured to:
[0161] Sort the number of times each calling object is called in ascending order, and determine the corresponding first quartile and third quartile;
[0162] The interquartile range was determined based on the difference between the first and third quartiles;
[0163] The endpoint values of the confusion interval are determined based on the sum and difference calculation results between the first quartile and the interquartile range.
[0164] Specifically, in one embodiment, the obfuscation module is specifically used to:
[0165] Based on each jump node, junk code is randomly called in the preset junk code library.
[0166] Specifically, in one embodiment, the device further includes:
[0167] The homomorphic encryption module is used to traverse the code file and extract all parameters in the code file; classify the parameters according to the data type to obtain parameter sets corresponding to different data types; assign index numbers to the parameters in each parameter set according to the extraction order of each parameter, and homomorphically encrypt the index numbers.
[0168] Specifically, in one embodiment, the homomorphic encryption module is specifically used to:
[0169] For any parameter, call the objective function corresponding to the parameter;
[0170] Compare the target function with the functions in the standard library to obtain the corresponding function comparison results;
[0171] The data type of the parameter is determined according to the function information represented by the function comparison result.
[0172] Specifically, in one embodiment, the homomorphic encryption module is specifically used to:
[0173] Construct integer control group and character control group;
[0174] Based on the integer control group and the character control group, perform four arithmetic operations on the parameters;
[0175] Determine the data type of the parameter based on the four arithmetic results of the parameter;
[0176] Among them, data types include integer, character, and Boolean.
[0177] Regarding the smart terminal code obfuscation device in this embodiment, the specific manner in which each module performs operations has been described in detail in the embodiment of the method, and will not be elaborated here.
[0178] The smart terminal code obfuscation device provided in the embodiment of the present application is used to execute the smart terminal code obfuscation method provided in the above embodiment. Its implementation method and principle are the same and will not be repeated here.
[0179] An embodiment of the present application provides an electronic device for executing the smart terminal code obfuscation method provided in the above embodiment.
[0180] like Figure 5 FIG. 5 is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application. The electronic device 50 includes: at least one processor 51 and a memory 52.
[0181] The memory stores computer-executable instructions; at least one processor executes the computer-executable instructions stored in the memory, so that the at least one processor executes the smart terminal code obfuscation method provided in the above embodiment.
[0182] An electronic device provided in an embodiment of the present application is used to execute the smart terminal code obfuscation method provided in the above embodiment. Its implementation method and principle are the same and will not be repeated here.
[0183] An embodiment of the present application provides a computer-readable storage medium, in which computer-executable instructions are stored. When a processor executes the computer-executable instructions, the smart terminal code obfuscation method provided in any of the above embodiments is implemented.
[0184] The storage medium containing computer executable instructions in the embodiment of the present application can be used to store computer executable instructions of the smart terminal code obfuscation method provided in the aforementioned embodiment. Its implementation method and principle are the same and will not be repeated here.
[0185] In the several embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0186] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0187] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of hardware plus software functional units.
[0188] The above-mentioned integrated unit implemented in the form of a software functional unit can be stored in a computer-readable storage medium. The above-mentioned software functional unit is stored in a storage medium, including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) or a processor to perform some steps of the methods of each embodiment of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (Read-Only Memory, ROM), random access memory (Random Access Memory, RAM), disk or optical disk and other media that can store program codes.
[0189] Those skilled in the art can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional modules is used as an example for illustration. In actual applications, the above-mentioned functions can be assigned to different functional modules as needed, that is, the internal structure of the device is divided into different functional modules to complete all or part of the functions described above. The specific working process of the device described above can refer to the corresponding process in the aforementioned method embodiment, and will not be repeated here.
[0190] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit it. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or replace some or all of the technical features therein with equivalents. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present application.
Claims
1. A smart terminal code obfuscation method, characterized in that: include: Get the code file to be obfuscated; Performing call object analysis on the code file to determine the number of times each call object in the code file is called; Determine multiple target calling objects according to the number of times each calling object is called; Locating each of the target call objects in the code file, and inserting a jump node before each of the target call objects; When the code file is run, junk code is inserted based on each of the jump nodes; Determining a plurality of target calling objects according to the number of times each calling object is called includes: Determining the obfuscation interval according to the number of times each of the calling objects is called; Determine the calling object whose calling times fall within the obfuscation interval as the target calling object; The determining of the obfuscation interval according to the number of times each of the calling objects is called includes: Sort the number of times each calling object is called in ascending order, and determine the corresponding first quartile and third quartile; Determine the interquartile range based on the difference between the first quartile and the third quartile; Determine the endpoint value of the confusion interval according to the sum calculation result and the difference calculation result between the first quartile and the interquartile range; The inserting of junk code based on each of the jump nodes comprises: Based on each of the jump nodes, junk codes are randomly called in a preset junk code library.
2. The method according to claim 1, characterized in that Also includes: Traversing the code file, and extracting all parameters in the code file; Classify the parameters according to data types to obtain parameter sets corresponding to different data types; According to the extraction order of each parameter, an index number is assigned to the parameters in each parameter set, and the index number is homomorphically encrypted.
3. The method according to claim 2, characterized in that The classifying the parameters according to data types includes: For any of the parameters, calling the target function corresponding to the parameter; Comparing the target function with the functions in the standard library to obtain corresponding function comparison results; The data type of the parameter is determined according to the function information represented by the function comparison result.
4. The method according to claim 2, characterized in that: The classifying the parameters according to data types includes: Construct integer control group and character control group; Based on the integer control group and the character control group, four arithmetic operations are performed on the parameters; Determine the data type of the parameter according to the four calculation results of the parameter; The data types include integer, character and Boolean.
5. A smart terminal code obfuscation device, characterized in that: include: The acquisition module is used to obtain the code file to be obfuscated; A first determination module is used to perform call object analysis on the code file to determine the number of times each call object in the code file is called; A second determination module is used to determine a plurality of target calling objects according to the number of times each calling object is called; An insertion module, used for locating each of the target call objects in the code file and inserting a jump node before each of the target call objects; An obfuscation module, used for inserting junk code based on each of the jump nodes when running the code file; The second determining module is specifically used to: Determining the obfuscation interval according to the number of times each of the calling objects is called; Determine the calling object whose calling times fall within the obfuscation interval as the target calling object; The second determining module is specifically used to: Sort the number of times each calling object is called in ascending order, and determine the corresponding first quartile and third quartile; Determine the interquartile range based on the difference between the first quartile and the third quartile; Determine the endpoint value of the confusion interval according to the sum calculation result and the difference calculation result between the first quartile and the interquartile range; The obfuscation module is specifically used for: Based on each of the jump nodes, junk codes are randomly called in a preset junk code library.
6. An electronic device, characterized in that: include: at least one processor and memory; The memory stores computer-executable instructions; The at least one processor executes the computer-executable instructions stored in the memory, so that the at least one processor performs the method according to any one of claims 1 to 4.
7. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer-executable instructions, and when a processor executes the computer-executable instructions, the method according to any one of claims 1 to 4 is implemented.