[go: up one dir, main page]

CN114880632B - Method for obtaining obfuscated resources, intelligent terminal and computer-readable storage medium - Google Patents

Method for obtaining obfuscated resources, intelligent terminal and computer-readable storage medium Download PDF

Info

Publication number
CN114880632B
CN114880632B CN202210405339.4A CN202210405339A CN114880632B CN 114880632 B CN114880632 B CN 114880632B CN 202210405339 A CN202210405339 A CN 202210405339A CN 114880632 B CN114880632 B CN 114880632B
Authority
CN
China
Prior art keywords
resource
class
getidentifier
context
confusing
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202210405339.4A
Other languages
Chinese (zh)
Other versions
CN114880632A (en
Inventor
胡晓岽
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Hangzhou Tuya Information Technology Co Ltd
Original Assignee
Hangzhou Tuya Information Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Hangzhou Tuya Information Technology Co Ltd filed Critical Hangzhou Tuya Information Technology Co Ltd
Priority to CN202210405339.4A priority Critical patent/CN114880632B/en
Publication of CN114880632A publication Critical patent/CN114880632A/en
Application granted granted Critical
Publication of CN114880632B publication Critical patent/CN114880632B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F21/00Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
    • G06F21/10Protecting distributed programs or content, e.g. vending or licensing of copyrighted material ; Digital rights management [DRM]
    • G06F21/12Protecting executable software
    • G06F21/14Protecting executable software against software analysis or reverse engineering, e.g. by obfuscation
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/41Compilation

Landscapes

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

Abstract

本申请公开了一种获取混淆资源的方法、智能终端以及计算机可读存储介质,其中,该获取混淆资源的方法应用于资源安装包,资源安装包的上下文类中设置有自定义的子类上下文,子类上下文中设置有一资源管理类的自定义子类资源管理文件,该方法包括:在基于上下文类启动getIdentifier方法之前,将子类上下文传入上下文类的第一类对象和第二类对象中,以重写getIdentifier方法;基于重写的getIdentifier方法,获取混淆资源的标识信息;基于标识信息,获取混淆资源。通过上述方式,利用在子类上下文中设置子类资源管理文件,以将getIdentifier方法重写,能够在资源都被混淆的情况下,通过重写的getIdentifier方法来获取到混淆后对应的资源,从而优化获取混淆资源的流程以及减少资源管理成本。

The present application discloses a method for obtaining obfuscated resources, an intelligent terminal, and a computer-readable storage medium, wherein the method for obtaining obfuscated resources is applied to a resource installation package, a custom subclass context is set in the context class of the resource installation package, and a custom subclass resource management file of a resource management class is set in the subclass context, and the method includes: before starting the getIdentifier method based on the context class, passing the subclass context into the first class object and the second class object of the context class to rewrite the getIdentifier method; based on the rewritten getIdentifier method, obtaining the identification information of the obfuscated resource; based on the identification information, obtaining the obfuscated resource. In the above manner, by setting the subclass resource management file in the subclass context to rewrite the getIdentifier method, when all resources are obfuscated, the corresponding resources after obfuscation can be obtained through the rewritten getIdentifier method, thereby optimizing the process of obtaining obfuscated resources and reducing resource management costs.

Description

Method for obtaining confusion resource, intelligent terminal and computer readable storage medium
Technical Field
The application relates to the technical field of client development, in particular to a method for acquiring confusing resources, an intelligent terminal and a computer readable storage medium.
Background
In Android development, most Android applications confuse resource names for security and to reduce installation package size. But the scenario of needing to acquire the resource through its original name (e.g., the resource name is not known, but is issued through the network) is avoided in the application development. It is common practice to add the resources that need to be obtained by the original names to the white list in a unified way, and the resources in the white list will not be confused or the original names will be maintained.
The existing method for acquiring the resources through the white list has the defect that a part of the resources cannot be confused, and if the resources in the white list are too many, the meaning of protecting the resources through the confusion of the resources is weakened. And white lists require long-term manual maintenance, which is prone to mistakes and leaks, and causes some unknown problems.
Disclosure of Invention
In order to solve the above problems, the present application provides a method for obtaining a confusing resource, an intelligent terminal and a computer readable storage medium, which can optimize a flow for obtaining the confusing resource and reduce resource management cost.
The application provides a method for obtaining confusing resources, which is applied to a resource installation package, wherein a self-defined sub-class context is arranged in a context class of the resource installation package, and a self-defined sub-class resource management file of a resource management class is arranged in the sub-class context; the method comprises the steps of transferring the sub-class context into a first class object and a second class object of the context class before starting GETIDENTIFIER method based on the context class, rewriting GETIDENTIFIER method, obtaining identification information of the confusing resource based on a GETIDENTIFIER method of rewriting, and obtaining the confusing resource based on the identification information.
The method comprises the steps of calling a getResource method in a sub-class context to return a sub-class resource management file, reloading a GETIDENTIFIER method in the sub-class resource management file, and acquiring identification information based on a reloaded GETIDENTIFIER method.
The method comprises the steps of inputting an original variable name, a resource type and an application package name of the confused resource into a method GETIDENTIFIER to reload the method GETIDENTIFIER, using the original variable name, the resource type and the application package name to reflect and call an R.java file to carry out resource ID index based on the reloaded method GETIDENTIFIER, and obtaining the ID name based on the result of the resource ID index.
The method comprises the steps of calling an R.java class file in a reflection mode by utilizing an original variable name, a resource type and an application package name to index a resource ID, and indexing the resource ID corresponding to the original variable name based on the mapping relation table.
The method comprises the steps of creating an Application object and an Activity object before starting a GETIDENTIFIER method based on a context class, and calling the attachBaseContext method to transfer the sub-class context into the Application object and the Activity object to rewrite the GETIDENTIFIER method when the Application object and the Activity object are initialized.
The method comprises the steps of obtaining the confusing resource based on the identification information, and indexing a path of the confusing resource in a resource management class based on the identification information to obtain the confusing resource.
The indexing of the path of the confusing resource in the resource management class comprises indexing the path of the confusing resource in at least one of a character string class file, a layout class file or an image class file of the resource management class.
The method comprises the steps of obtaining a resource installation package, compiling original resources in the resource installation package to generate a mapping relation table of identification information and original variable names of the confused resources, storing the mapping relation table in an R.java class file, and confusing the original resources to form the confused resources.
The intelligent terminal comprises a processor and a memory connected with the processor, wherein program data are stored in the memory, and the processor calls the program data stored in the memory to execute the method for acquiring the confusing resources.
Another aspect of the present application is to provide a computer readable storage medium having program data stored therein, which when executed by a processor, is configured to implement a method of obtaining confusing resources as described above.
The method for acquiring the confusing resources is applied to a resource installation package, wherein a self-defined sub-class context is arranged in a context class of the resource installation package, a self-defined sub-class resource management file of a resource management class is arranged in the sub-class context, the method comprises the steps of transferring the sub-class context into a first class object and a second class object of the context class before starting GETIDENTIFIER based on the context class, rewriting GETIDENTIFIER, acquiring identification information of the confusing resources based on a rewritten GETIDENTIFIER method, and acquiring the confusing resources based on the identification information. By means of the method, the user-defined sub-class resource management file is set in the user-defined sub-class context to rewrite GETIDENTIFIER methods, and under the condition that all resources are guaranteed to be confused, the corresponding resources after confusion can be obtained through the rewritten GETIDENTIFIER method, so that the flow of obtaining the confused resources is optimized, and the resource management cost is reduced.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for the description of the embodiments will be briefly described below, and it is apparent that the drawings in the following description are only some embodiments of the present application, and other drawings may be obtained according to these drawings without inventive effort for a person skilled in the art. Wherein:
FIG. 1 is a schematic diagram illustrating one embodiment of a file configuration in accordance with the present application;
FIG. 2 is a flowchart of a first embodiment of a method for obtaining confusing resources according to the present application;
FIG. 3 is a flow chart of step 11 according to an embodiment of the present application;
FIG. 4 is a flow chart of an embodiment of establishing a mapping relationship between identification information of a confusing resource and an original variable name in the present application;
FIG. 5 is a flow chart of an embodiment of step 12 of the present application;
FIG. 6 is a flow chart of an embodiment of obtaining identification information according to the present application;
FIG. 7 is a flow chart illustrating an embodiment of performing resource ID indexing in accordance with the present application;
FIG. 8 is a flowchart illustrating a second embodiment of a method for obtaining confusing resources according to the present application;
fig. 9 is a schematic structural diagram of an intelligent terminal provided by the application;
fig. 10 is a schematic structural diagram of an embodiment of a computer readable storage medium according to the present application.
Detailed Description
The embodiments of the present disclosure will be described in detail below with reference to the attached drawings.
In the following description, for purposes of explanation and not limitation, specific details are set forth such as particular system architectures, flows, techniques, etc. in order to provide a thorough understanding of the present application.
The technical solutions in the embodiments of the present disclosure are clearly and completely described with reference to the drawings in the embodiments of the present disclosure. It is to be understood that the specific embodiments described herein are for purposes of illustration only and are not intended to be limiting. It should be further noted that, for convenience of description, only some, but not all of the structures related to the present disclosure are shown in the drawings. All other embodiments, which can be made by one of ordinary skill in the art without inventive effort, based on the embodiments in this disclosure are intended to be within the scope of this disclosure.
Reference in the present disclosure to "an embodiment" means that a particular feature, procedure, or characteristic described in connection with the embodiment may be included in at least one embodiment of the present disclosure. The appearances of such phrases in various places in the specification are not necessarily all referring to the same embodiment, nor are separate or alternative embodiments mutually exclusive of other embodiments. Those of skill in the art will explicitly and implicitly appreciate that the embodiments described herein may be combined with other embodiments.
The steps in the embodiments of the present disclosure are not necessarily processed according to the described step sequence, and may be rearranged selectively according to the requirement, or steps in the embodiments may be deleted, or steps in the embodiments may be added, where the description of the steps in the embodiments of the present disclosure is only an optional sequential combination, and does not represent all the sequential combinations of steps in the embodiments of the present disclosure, and the sequence of steps in the embodiments should not be considered as limiting the present disclosure.
The term "and/or" in the embodiments of the present disclosure is merely one association describing an associated object, and is a possible combination including any and all of one or more of the associated listed items, which means that three relationships may exist, for example, a and/or B, and that three cases, a alone, a and B together, and B alone, may be represented. In addition, the character "/" in the present disclosure generally indicates that the front and rear association objects are an or relationship. Further, "multiple" in the present disclosure means two or more than two. In addition, the term "at least one" in this disclosure means any one of a plurality or any combination of at least two of a plurality, for example, including at least one of A, B, C, may mean including any one or more elements selected from the group consisting of A, B and C. It should be further noted that the terms "comprises" and/or "comprising," when used in this disclosure, specify the presence of stated features, integers, steps, operations, elements, and/or components, but do not preclude the presence or addition of one or more other features, integers, steps, operations, elements, and/or components, and/or groups thereof.
The terms "first," "second," and the like in embodiments of the present disclosure are used for distinguishing between different objects and not for describing a particular sequential order. Furthermore, the terms "comprise" and "have," as well as any variations thereof, are intended to cover a non-exclusive inclusion. For example, a process, method, system, article, or apparatus that comprises a list of steps or elements is not limited to only those listed steps or elements but may include other steps or elements not listed or inherent to such process, method, article, or apparatus.
In addition, although the terms "first," "second," etc. may be used multiple times in the embodiments of the present disclosure to describe various operations (or various elements or various applications or various instructions or various thresholds) etc., these operations (or elements or applications or instructions or thresholds) should not be limited by these terms. These terms are only used to distinguish one operation (or element or application or instruction or threshold) from another operation (or element or application or instruction or threshold). For example, a first class of objects may be referred to as second class of objects, which may also be referred to as first class of objects, with only the scope encompassed by both of them being different, without departing from the scope of the disclosure, the first class of objects and the second class of objects may both be collections of various objects, with only both of them not being collections of the same objects, and with at least one object contained in a collection of various objects.
The intelligent terminal of the embodiments of the present disclosure may be implemented in various forms. The smart terminal may be a mobile terminal including a device such as a capture and recognition device (e.g., a video camera and a video recorder), a mobile phone, a smart phone, a notebook computer, a Personal Digital Assistant (PDA), a tablet Personal computer (PAD), etc., or a fixed terminal such as a digital broadcast transmitter, a digital TV, a desktop computer, a server, etc. In the following, it is assumed that the intelligent terminal is a fixed terminal. However, it will be understood by those skilled in the art that the configuration according to the embodiments of the present disclosure can be applied to a mobile type terminal in addition to being particularly used for a fixed type element.
In one embodiment, software design engineers currently use most Android applications to obfuscate resources and their original variable names for security and reduced installation package size. However, when a part of Resources need to acquire the storage path of the Resources through the original variable names of the Resources in the running process of the subsequent program, the Resources are not confused, the Resources are generally added into a white list uniformly, the Resources in the white list are not confused, the original variable names are kept, and when the storage path of the Resources needs to be acquired in the running process of the subsequent program, the intelligent terminal reflects the white list through the original variable names of the Resources and calls GETIDENTIFIER methods of Resources class, so that the storage path of the Resources is acquired.
However, there are some unavoidable drawbacks to the above approach by adding resources to a white list. For example, if there are more resources in the whitelist, then a significant portion of the resources are not confusing, and the effect of increasing security and reducing the size of the installation package is diminished. For another example, if a resource is needed to be acquired by a name in an item, the source of the resource is uncertain (for example, the name is not known but issued through a network), and then the resource cannot be added to a white list, only confusion can be abandoned, and the quantity of the white list is increased. And white lists require constant manual maintenance, which is prone to mistakes and leaks, causing some unknown problems.
Therefore, the application aims to provide a method for obtaining the confusing resources, which can still obtain the corresponding resources after confusing through the original variable names of the resources under the condition that all the resources are confusing, and does not need to set a white list, thereby playing the role of resource confusing to the greatest extent and reducing the manpower maintenance cost.
The method for obtaining the confusing resources in the embodiments of the present disclosure is applied to a resource installation package, where the resource installation package is a software development kit (SoftwareDevelopmentKit, abbreviated as SDK) of an intelligent terminal, which can provide general function components for application programs in the intelligent terminal, the application programs can integrate various function modules by referring to the SDK and calling interfaces of the SDK, and inside the resource installation package, there are multiple computer programs which can be run in a user mode to complete some or more specific tasks, the computer programs can be modified by a user, alternatively, the intelligent terminal can be used for program operation based on Liunx (GNU/Linux) system, mac (Macintosh) system, microsoft system, or the like, and the intelligent terminal can also be based onA platform(s),A platform(s),Platforms orPlatforms, etc. are used for program applications.
In one embodiment, as shown in fig. 1, fig. 1 is a schematic diagram of an embodiment of a file configuration in the present application, in which a custom sub-class Context (customContext) is set in a Context class (Context class) of a resource installation package, and a custom sub-class resource management file (CustomResources) of a resource management class (Resources class) is set in the sub-class Context. The Context class represents an application scenario, which describes information of an application environment, i.e. a Context, which represents a process of interaction with an operating system.
Wherein CustomResources is an extension class based on Kubernetes API, and the running state of the resource in the cluster can be controlled by dynamically registering the CustomResources class. And after installation CustomResources of the class, objects of the CustomResources class can be created and accessed through kubectl configuration as with built-in resources (e.g., pod resources). Alternatively, custom CustomResources classes typically have two ways, by way of CRD (CustomResourceDefinitions) and by way of using an aggregate API.
In one embodiment, in the application development process, if an object of the Resources class is to be used, the object needs to be acquired through an object of the Context class, and it cannot directly acquire the Resources object through the Resources class. Therefore, if the custom CustomResources class is set to the Context class, that is, the Resources object is saved in the Context object, and one resource object is saved in one Context object, the custom Resources object needs to be set to the custom customContext class in the constructor of the Resources class, and then the custom Resources object can be set to the Context object through the custom Context object, so that when the Context class is started to acquire Resources subsequently, the Context class acquires the custom Resources object.
Referring to fig. 2, fig. 2 is a flowchart illustrating a method for obtaining a confusing resource according to a first embodiment of the present application. The method is applied to the intelligent terminal in the above embodiment, so as to be executed by the intelligent terminal, and specifically, the method may include the following steps:
step 11. Before starting GETIDENTIFIER the method based on the context class, the sub-class context is passed into the first class object and the second class object of the context class to rewrite GETIDENTIFIER the method.
Specifically, before the intelligent terminal starts GETIDENTIFIER the method based on the context class to obtain the storage path of the confusing resource, the intelligent terminal needs to transfer the sub-class context into the first class object and the second class object of the context class to rewrite GETIDENTIFIER the method.
In one embodiment, the first class of objects of the Context class is an Application object of the Context class, and the second class of objects is an Activity object. The Application object and the Activity object are a sub-class Context of ContextWrapper class (wrapper class) in the Context class.
The Activity object class internally comprises a Theme (Theme) related interface which is specified by an android: theme attribute, namely the Activity object needs an android Theme.
Referring to fig. 3, fig. 3 is a flowchart illustrating an embodiment of step 11 in the present application. Specifically, step 11 may include the steps of:
step 111, creating an Application object and an Activity object before starting GETIDENTIFIER the method based on the context class.
In one embodiment, an Application object is first created in response to an Application of the intelligent terminal being started for the first time. And, the timing of creating the Application object is in the create handleBindApplication () method whose function is in the activitythread.
In an embodiment, when the intelligent terminal detects that an Activity object needs to be newly created, the intelligent terminal requests to start an Activity object through a STARTACTIVITY () method or a startActivityForResult () method, and can call back a handleLaunchActivity () method through the two methods, and further call up a performLaunchActivity () method, a callback onCreate () method and a onStart () method through the two methods, so that an Activity instance is created. Wherein the functions of performLaunchActivity () method, onCreate () method, and onStart () method are all located in the activitythread.
Step 112, when initializing based on the Application object and the Activity object, calling attachBaseContext the method to transfer the subclass context into the Application object and the Activity object to rewrite GETIDENTIFIER the method.
Specifically, the method for rewriting GETIDENTIFIER method is that when Application object and Activity object are created, and when Application object starts initialization program, the method is called attachBaseContext to transfer the self-defined sub-class context into Application object, and when Activity object starts initialization program, the method is called attachBaseContext to transfer the self-defined sub-class context into Activity object to rewrite GETIDENTIFIER method. Further, all the places in the application that call GETIDENTIFIER methods eventually call GETIDENTIFIER methods that are rewritten in custom CustomResources.
In an embodiment, before the method GETIDENTIFIER is rewritten, a mapping relationship between the identification information of the confusion resource and the original variable name needs to be established, so that the original variable name of the confusion resource is used for mapping to the identification information of the confusion resource through the rewritten GETIDENTIFIER method, and then the actual storage path of the confusion resource is indexed through the identification information of the confusion resource. Wherein, the identification information of the confusing resource can be the resource ID of the confusing resource. Wherein the identification information of the confusing resource and the actual storage path are not changed with the confusing of the resource.
Referring to fig. 4, fig. 4 is a flowchart illustrating an embodiment of establishing a mapping relationship between identification information of a confusing resource and an original variable name in the present application. Specifically, the method may include the steps of:
and a step a1, obtaining a resource installation package.
Specifically, the intelligent terminal can be connected with a third-party mechanism (such as a computer, a cloud server or a data processing platform) to transmit the resource installation package to the intelligent terminal through the third-party mechanism, and collect the resource installation package.
And a2, compiling the original resources in the resource installation package to generate a mapping relation table of the identification information of the confused resources and the original variable names.
Specifically, the intelligent terminal compiles the original resources in the resource installation package and simultaneously generates a mapping relation table corresponding to the identification information and the original variable names one by one. The mapping relation table may be further classified, for example, the identification information and the original variable name are the last level, the last level is the application package name to which the resource belongs, and the last level of the application package name may be the resource type of the resource. Therefore, when the mapping relation table is used for mapping index, the resource type of the resource is firstly used for indexing to the level of the resource type in the mapping relation table, then the application package name is used for mapping index so as to map to the level of the application package name of the resource, and in the application package name, the identification information of the resource is indexed through the original variable name of the resource.
Alternatively, the MAP table that confuses the identification information of the resource with the original variable name may be a MAP file. The MAP file is a mapping file generated after the CCS software is compiled and related to DSP (digital signal processing) to all programs, data and IO space. The MAP file is roughly divided into four parts, namely a file header, a memory configuration, a segment MAP and a global symbol. The MEMORY allocation is associated with a MEMORY command in the CMD file, a program defined in the CMD file and a data interval are defined, and when the MEMORY allocation is different from the CMD file, an actually used interval, that is, a space length actually used in the program, is added in the MAP file. The segment map portion is associated with the SECTION (section) instruction in the CMD file, and the start address and the actual length of the actual map of all segments in the program portion are described in detail. May be specific to the section specified in the program PROGMA (preprocessing instruction) and the OBJ (engineering project) file generated by each individual file. The global symbol may be each function used by the program, where the global variable defined in the program may find the corresponding starting address. The MAP file is enumerated in two ways, one arranged by corresponding address and the other arranged by global symbol letter.
And a step a3, storing the mapping relation table in an R.java class file.
The R.java file is automatically generated by the intelligent terminal during compiling and is used for defining indexes of all various types of resources in the Android program. And, the content in the R.java class file is read-only, and the developer does not modify the content. The mapping relation table is stored in the R.java class file, so that a user can conveniently restore and trace the confusion rules and the confusion resources.
And a step a4, confusing the original resources to form confusing resources.
Specifically, the original variable name and the resource ID given to the resource file at the time of compiling are the original resources of the resource file. After the original resource of the resource file is obtained, the original resource needs to be subjected to confusion processing through a preset confusion rule.
In one embodiment, the obfuscation process specifically refers to obfuscating the resource file and replacing the original variable name of the original resource with a simple alphabetic combination.
In one embodiment, the confusion rule is a method for generating a new resource variable name, and in this embodiment, the new resource variable name can be generated by randomly generating a letter combination of a predetermined length, randomly generating a letter combination of an indefinite length, or generating letter combinations of increasing lengths in a permutation manner. However, the resource variable names obtained by the confusion process are not limited to this, and the new resource variable names formed by the confusion rule can be (but not limited to) a numerical combination, a mixed combination of numbers and letters, or a common graphic combination according to the application scene. In this embodiment, the letters are not limited to the common english letters, and can be any one of the world text systems having letter characters according to the application scenario.
And replacing the original variable names with the new resource variable names generated according to the preset confusion rules to complete confusion. The new resource variable name is the confusing identity file of the resource file.
And 12, acquiring the identification information of the confusing resource based on the rewritten GETIDENTIFIER method.
Referring to fig. 5, fig. 5 is a flowchart illustrating an embodiment of step 12 in the present application. Specifically, step 12 may include the steps of:
step 121, call getResource method in the sub-class context to return sub-class resource management file.
Specifically, the intelligent terminal is used to return a URL (i.e., uniform resource locator) with a given resource name by calling the getResource method in the sub-class context, and therefore, the resource name of the given sub-class resource management file is required before calling the getResource method to return the uniform resource locator of the sub-class resource management file by the method.
The getResource method is a non-static method, which can only be accessed by objects of a class, and if an attempt is made to access the method using the class name, an error message is received. Also, the getResource method may be used in the java.
Step 122, reloading GETIDENTIFIER methods in the sub-class resource management file.
Specifically, the user inputs GETIDENTIFIER method instructions to the intelligent terminal to start the system to finally reload GETIDENTIFIER methods into the returned sub-class resource management file (i.e., custom CustomResources).
And 123, acquiring identification information based on a GETIDENTIFIER method of reloading.
Referring to fig. 6, fig. 6 is a flowchart illustrating an embodiment of obtaining identification information according to the present application. Specifically, step 123 may include the steps of:
And step b1, transmitting the original variable names, the resource types and the application package names of the confusing resources into the GETIDENTIFIER method so as to reload the GETIDENTIFIER method.
Specifically, in the method GETIDENTIFIER of the system, the user transmits the original variable name, the resource type and the application package name of the confusing resource into the method GETIDENTIFIER, the method GETIDENTIFIER of the system starts to start the identification information corresponding to the original variable name of the confusing resource, applies the GETIDENTIFIER method of the final system to the sub-class resource management file, and reloads the method GETIDENTIFIER in CustomResources based on the original variable name, the resource type and the application package name of the confusing resource.
And b2, reflecting and calling the R.java class file by using the original variable name, the resource type and the application package name based on the method GETIDENTIFIER of the reload so as to index the resource ID.
Referring to fig. 7, fig. 7 is a flowchart illustrating an embodiment of performing resource ID indexing in the present application. Specifically, step b2 may include the steps of:
And step c1, reflecting and calling a mapping relation table in the R.java file by using the original variable name, the resource type and the application package name.
Specifically, in the GETIDENTIFIER method in CustomResources, the intelligent terminal invokes the mapping relation table in the r.java file, reflects the application package name to which the confusing resource belongs by using the application package name, and reflects the resource type to which the confusing resource belongs in the corresponding application package name by using the resource type.
And c2, indexing the resource ID corresponding to the original variable name based on the mapping relation table.
Specifically, the intelligent terminal indexes the corresponding resource ID based on the original variable name of the confusing resource in the mapping relation table.
And b3, acquiring the ID name based on the result of the resource ID index.
Specifically, the result of the resource ID index obtained by the GETIDENTIFIER method includes returning a resource ID (i.e., the resource ID index was successful) and returning a "0" value (i.e., the resource ID index was failed).
And step 13, obtaining the confusing resource based on the identification information.
Specifically, after the intelligent terminal compiles the resource installation package, the resource ID and the actual path of the resource are not changed in the running process of the application. Therefore, the intelligent terminal indexes the path of the confusing Resource in the Resource management class (Resource class) based on the identification information (i.e. Resource ID) acquired by the GETIDENTIFIER method, so as to obtain the actual storage path of the confusing Resource, and acquires the confusing Resource according to the actual storage path.
In one embodiment, the intelligent terminal indexes the actual path of the confusing Resource in at least one of a string class file (Public STATIC CLASS STRING class), a layout class file (Public STATIC CLASS layout class), or an image class file (Public STATIC CLASS drawable class) of the Resource management class (Resource class).
Referring to fig. 8, fig. 8 is a flowchart illustrating a method for obtaining a confusing resource according to a second embodiment of the present application. The method is applied to the intelligent terminal in the above embodiment, so as to be executed by the intelligent terminal, and specifically, the method may include the following steps:
Step S1, APP calls context.
Specifically, the intelligent terminal control application program (i.e. APP) firstly calls the getResource () method in context class to return to Resource object, then the user inputs the original name of the confusing Resource to the intelligent terminal to start the program for calling GETDENTIFIER (STERING NAME) method in Resource object.
And step S2, the intelligent terminal responds to calling GETDENTIFIER (STERING NAME) the method, and the context class creates and initializes the Application class and the Activity class. When the Application class and the Activity class are initialized, the intelligent terminal transmits the self-defined Context class into the Application class and the Activity class so as to start attachBaseSontext (Context Context) methods for calling the Application class and the Activity class.
Step S3, the intelligent terminal responds to the call attachBaseSontext (Context Context) method, the custom CustomContext object in the custom Context class returns the custom CustomResources object packaged in the custom object to the system, and then the user inputs the original name of the confusing resource to the intelligent terminal to start the call GETDENTIFIER (STRING NAME) method in the CustomResources object.
And step S4, the intelligent terminal responds to the GETDENTIFIER (STRING NAME) method in the object of the call CustomResources, and the intelligent terminal reflects and calls at least one of Public STATIC CLASS STRING file, public STATIC CLASS drawable and Public STATIC CLASS layout in the R.java file in the Resource class so as to reflect the Resource ID corresponding to the original name of the confusing Resource in the at least one folder. And subsequently, the user indexes the actual storage path of the corresponding confusing Resource in the Resource class according to the Resource ID.
Compared with the prior art, the method for acquiring the confusing resources is applied to a resource installation package, wherein a self-defined sub-class context is arranged in a context class of the resource installation package, a self-defined sub-class resource management file of a resource management class is arranged in the sub-class context, the method comprises the steps of transmitting the sub-class context into a first class object and a second class object of the context class before starting GETIDENTIFIER based on the context class, overwriting GETIDENTIFIER, acquiring identification information of the confusing resources based on a rewritten GETIDENTIFIER method, and acquiring the confusing resources based on the identification information. By means of the method, the intelligent terminal utilizes the custom sub-class resource management file set in the custom sub-class context to rewrite GETIDENTIFIER methods, and under the condition that all resources are guaranteed to be confused, the corresponding resources after confusion can be obtained through the rewritten GETIDENTIFIER method, so that the flow of obtaining the confused resources is optimized, and the resource management cost is reduced.
Referring to fig. 9, fig. 9 is a schematic structural diagram of an intelligent terminal provided by the present application, where the intelligent terminal 100 includes a processor 101 and a memory 102 connected to the processor 101, where the memory 102 stores program data, and the processor 101 retrieves the program data stored in the memory 102 to execute the above method for obtaining confusing resources.
Optionally, in an embodiment, the processor 101 is applied to a resource installation package, wherein a context class of the resource installation package is provided with a custom sub-class context, the sub-class context is provided with a custom sub-class resource management file of a resource management class, and the processor 101 is configured to execute program data to implement a method of transferring the sub-class context into a first class object and a second class object of the context class to rewrite GETIDENTIFIER before starting GETIDENTIFIER method based on the context class, acquiring identification information of the confusing resource based on GETIDENTIFIER method of the rewrite, and acquiring the confusing resource based on the identification information.
According to the scheme, the intelligent terminal 100 utilizes the custom sub-class resource management file set in the custom sub-class context to rewrite GETIDENTIFIER methods, and can obtain the corresponding resources after confusion through the rewritten GETIDENTIFIER method under the condition that all the resources are guaranteed to be confused, so that the flow of obtaining the confused resources is optimized, and the resource management cost is reduced.
The processor 101 may also be referred to as a CPU (Central Processing Unit ). The processor 101 may be an electronic chip with signal processing capabilities. The Processor 101 may also be a general purpose Processor, a digital signal Processor (DIGITAL SIGNAL Processor, DSP), an Application SPECIFIC INTEGRATED Circuit (ASIC), an Application SPECIFIC INTEGRATED Circuit (ASIC), a Field-Programmable gate array (Field-Programmable GATE ARRAY, FPGA) or other Programmable logic device, discrete gate or transistor logic device, discrete hardware components. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like. In addition, the processor 101 may be commonly implemented by an integrated circuit chip.
The memory 102 may be a memory bank, a TF card, or the like, and may store all information in the intelligent terminal 100, including input raw data, a computer program, intermediate operation results, and final operation results, which are stored in the memory 102. It stores and retrieves information based on the location specified by the processor 101. With the memory 102, the intelligent terminal 100 has a memory function, so that normal operation can be ensured. The memory 102 of the intelligent terminal 100 may be classified into a main memory (memory) and an auxiliary memory (external memory) according to the purpose, and may be classified into an external memory and an internal memory. The external memory is usually a magnetic medium, an optical disk, or the like, and can store information for a long period of time. The memory refers to a storage component on the motherboard for storing data and programs currently being executed, but is only used for temporarily storing programs and data, and the data is lost when the power supply is turned off or the power is turned off.
By way of example, and not limitation, as shown in fig. 9, memory 102 may be loaded with application programs, program data, and an operating system that may include various applications being executed, such as a Web browser, middle tier application, relational database management system (RDBMS), and the like. As an example, the operating system may include various versions of Microsoft WindowsAppleAnd/or Linux operating systems, various commercial or classOperating systems (including but not limited to various GNU/Linux operating systems, google)OS, etc.) and/or a mobile operating system, such asPhone、OS、OS、OS operating systems, as well as other operating systems.
In the several embodiments provided in the present application, it should be understood that the disclosed method and apparatus may be implemented in other manners. For example, the above-described embodiment of the intelligent terminal 100 is merely exemplary, for example, the method of reloading GETIDENTIFIER the method according to the original variable name, the resource type and the application package name of the confusing resource, the reflection calling the r.java class file to index the resource ID, etc. is merely a collective way, and there may be another division way when actually implemented, for example, the string class file, the layout class file or the image class file of the resource management class may be combined or may be collected into another system, or some features may be omitted or not performed.
In addition, each functional unit (such as context class and resource management class) in the embodiments of the present application may be integrated in one processing unit, or each unit may exist alone physically, or two or more units may be integrated in one unit. The integrated units may be implemented in hardware or in software functional units.
Referring to fig. 10, fig. 10 is a schematic structural diagram of an embodiment of a computer readable storage medium provided in the present application, where the computer readable storage medium 110 stores program instructions 111 capable of implementing all the methods described above.
The units integrated with the functional units in the various embodiments of the present application may be stored in the computer-readable storage medium 110 if implemented in the form of software functional units and sold or used as separate products. Based on such understanding, the technical solution of the present application may be embodied essentially or in a part contributing to the prior art or all or part of the technical solution in the form of a software product, and the computer readable storage medium 110 includes several instructions in a program instruction 111 to enable a computer device (which may be a personal computer, a system server, or a network device, etc.), an electronic device (such as MP3, MP4, etc., also a mobile terminal such as a mobile phone, a tablet computer, a wearable device, etc., also a desktop computer, etc.), or a processor (to perform all or part of the steps of the methods of the embodiments of the present application.
Optionally, in an embodiment, the program instruction 111 is applied to the resource installation package, where a context class of the resource installation package is provided with a custom sub-class context, the sub-class context is provided with a custom sub-class resource management file of a resource management class, and the program instruction 111 when executed by the processor is configured to implement a method of transferring the sub-class context into a first class object and a second class object of the context class to rewrite GETIDENTIFIER before starting GETIDENTIFIER method based on the context class, obtain identification information of the confusing resource based on GETIDENTIFIER method rewritten, and obtain the confusing resource based on the identification information.
In the above solution, the computer readable storage medium 110 uses the custom sub-class resource management file set in the custom sub-class context to rewrite GETIDENTIFIER the method, and can obtain the corresponding resource after confusion by using the rewritten GETIDENTIFIER method under the condition that all the resources are guaranteed to be confused, so as to optimize the flow of obtaining the confused resource and reduce the resource management cost.
It will be appreciated by those skilled in the art that embodiments of the present application may be provided as a method, system, or computer program product. Accordingly, the present application may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present application may take the form of a computer program product embodied on one or more computer-readable storage media 110 (including but not limited to disk storage, CD-ROM, optical storage, etc.) having computer-usable program code embodied therein.
The present application is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems) and computer program products according to embodiments of the application. It will be understood that each flowchart and/or block of the flowchart and/or block diagrams, and combinations of flowcharts and/or block diagrams, can be implemented by computer readable storage medium 110. These computer-readable storage media 110 may 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 program instructions 111, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer-readable storage media 110 may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that program instructions 111 stored in the computer-readable storage media 110 produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer-readable storage media 110 may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the program instructions 111 which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
In one embodiment, these programmable data processing devices include a processor and memory thereon. The processor may also be referred to as a CPU (Central Processing Unit ). The processor may be an electronic chip with signal processing capabilities. The processor may also be a general purpose processor, a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field Programmable Gate Array (FPGA) or other programmable logic device, discrete gate or transistor logic, or discrete hardware components. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like.
The memory may be a memory bank, TF card, etc. that stores and retrieves information based on the location specified by the processor. The memories can be classified into main memories (memories) and auxiliary memories (memories) according to the purpose, and there are also classification methods of external memories and internal memories. The external memory is usually a magnetic medium, an optical disk, or the like, and can store information for a long period of time. The memory refers to a storage component on the motherboard for storing data and programs currently being executed, but is only used for temporarily storing programs and data, and the data is lost when the power supply is turned off or the power is turned off.
The foregoing description is only of embodiments of the present application, and is not intended to limit the scope of the application, and all equivalent structures or equivalent processes according to the present application and the accompanying drawings, or direct or indirect application in other related technical fields, are included in the scope of the present application.

Claims (9)

1. A method for obtaining confusing resources, the method being applied to a resource installation package, wherein a custom sub-class context is provided in a context class of the resource installation package, and a custom sub-class resource management file of a resource management class is provided in the sub-class context, the method comprising:
Before starting GETIDENTIFIER a method based on the context class, the subclass context is transferred into a first class object and a second class object of the context class to rewrite the GETIDENTIFIER method, wherein the first class object is an Application object, and the second class object is an Activity object;
acquiring identification information of the confusing resource based on the GETIDENTIFIER method of rewriting, wherein the identification information is the ID name of the confusing resource;
acquiring confusion resources based on the identification information;
The GETIDENTIFIER method based on overwriting obtains identification information of the confusing resource, including:
Transmitting the original variable name, the resource type and the application package name of the confusing resource into the GETIDENTIFIER method to reload the GETIDENTIFIER method;
Based on the GETIDENTIFIER method of the reload, the R.java class file is reflected and called by utilizing the original variable name, the resource type and the application package name so as to index the resource ID;
and acquiring the ID name based on the result of the resource ID index.
2. The method of claim 1, wherein the obtaining, based on the GETIDENTIFIER method of overwriting, identification information of a confusing resource comprises:
Calling a getResource method in the subclass context to return the subclass resource management file;
a GETIDENTIFIER method in the sub-class resource management file is reloaded;
and acquiring the identification information based on the GETIDENTIFIER method of the reload.
3. The method of claim 1, wherein the reflecting calls r.java class files using the original variable name, the resource type, and the application package name to index the resource ID, comprising:
Reflecting and calling a mapping relation table in the R.java file by using the original variable name, the resource type and the application package name;
and indexing the resource ID corresponding to the original variable name based on the mapping relation table.
4. The method of claim 1, wherein, before initiating GETIDENTIFIER the method based on the context class, the sub-class context is passed into a first class object and a second class object of the context class to rewrite the GETIDENTIFIER method, comprising:
Creating the Application object and the Activity object before starting GETIDENTIFIER a method based on the context class;
And when the Application object and the Activity object are initialized, calling attachBaseContext a method to transfer the subclass context into the Application object and the Activity object so as to rewrite the GETIDENTIFIER method.
5. The method of claim 1, wherein the obtaining the confusing resource based on the identification information comprises:
and indexing the path of the confusing resource in the resource management class based on the identification information to obtain the confusing resource.
6. The method of claim 5, wherein indexing the path of the confusing resource in the resource management class comprises:
and indexing the path of the confusing resource in at least one of a string class file, a layout class file or an image class file of the resource management class.
7. The method of claim 1, further comprising, prior to the method:
acquiring the resource installation package;
compiling the original resources in the resource installation package to generate a mapping relation table of the identification information and the original variable names of the confusing resources;
storing the mapping relation table in an R.java class file;
Obfuscating the original resource to form the obfuscated resource.
8. An intelligent terminal comprising a processor and a memory coupled to the processor, wherein program data is stored in the memory, and wherein the processor invokes the program data stored in the memory to perform the method of obtaining confusing resources of any of claims 1-7.
9. A computer readable storage medium having stored therein program instructions, the program instructions being executed to implement a method of obtaining confusing resources as claimed in any of claims 1-7.
CN202210405339.4A 2022-04-18 2022-04-18 Method for obtaining obfuscated resources, intelligent terminal and computer-readable storage medium Active CN114880632B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210405339.4A CN114880632B (en) 2022-04-18 2022-04-18 Method for obtaining obfuscated resources, intelligent terminal and computer-readable storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210405339.4A CN114880632B (en) 2022-04-18 2022-04-18 Method for obtaining obfuscated resources, intelligent terminal and computer-readable storage medium

Publications (2)

Publication Number Publication Date
CN114880632A CN114880632A (en) 2022-08-09
CN114880632B true CN114880632B (en) 2025-01-24

Family

ID=82669936

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210405339.4A Active CN114880632B (en) 2022-04-18 2022-04-18 Method for obtaining obfuscated resources, intelligent terminal and computer-readable storage medium

Country Status (1)

Country Link
CN (1) CN114880632B (en)

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109614771A (en) * 2018-10-31 2019-04-12 同盾控股有限公司 It is a kind of that method and apparatus are obscured based on Java code
CN111143789A (en) * 2019-12-05 2020-05-12 深圳市任子行科技开发有限公司 Method and device for confusing APK resource files

Family Cites Families (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6578068B1 (en) * 1999-08-31 2003-06-10 Accenture Llp Load balancer in environment services patterns
US20040006608A1 (en) * 2002-07-08 2004-01-08 Convergys Cmg Utah Flexible network element interface
US9596263B1 (en) * 2015-02-23 2017-03-14 Amazon Technolgies, Inc. Obfuscation and de-obfuscation of identifiers

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109614771A (en) * 2018-10-31 2019-04-12 同盾控股有限公司 It is a kind of that method and apparatus are obscured based on Java code
CN111143789A (en) * 2019-12-05 2020-05-12 深圳市任子行科技开发有限公司 Method and device for confusing APK resource files

Also Published As

Publication number Publication date
CN114880632A (en) 2022-08-09

Similar Documents

Publication Publication Date Title
US20240095043A1 (en) Execution of sub-application processes within application program
US11687645B2 (en) Security control method and computer system
CN110162296B (en) Method and device for generating application programming interface document and terminal equipment
CN109976761B (en) Software development kit generation method and device and terminal equipment
US6298353B1 (en) Checking serialization compatibility between versions of java classes
US10846101B2 (en) Method and system for starting up application
CN109614165B (en) Multi-version parallel operation method and device for COM (component object model) component
US11016785B2 (en) Method and system for mirror image package preparation and application operation
EP3267308B1 (en) Application loading method and device
CN114020621B (en) Debugging method, electronic device and storage medium
CN109032612B (en) Interface calling method and device of hybrid application and computer readable storage medium
US11500982B2 (en) Systems and methods for reliably injecting control flow integrity into binaries by tokenizing return addresses
CN111597553A (en) Process processing method, device, equipment and storage medium in virus searching and killing
CN112015497B (en) Skin changing method and device
CN116028122A (en) Device processing method and device based on processor
CN104615935B (en) A kind of hidden method towards Xen virtual platforms
CN110888972A (en) Sensitive content identification method and device based on Spark Streaming
US10572166B1 (en) Firmware download for a solid state storage card
CN114880632B (en) Method for obtaining obfuscated resources, intelligent terminal and computer-readable storage medium
CN111651248A (en) Scheduled task execution method, device, electronic device and storage medium
CN113139190A (en) Program file detection method and device, electronic equipment and storage medium
CN110888643A (en) Page processing method and device
CN112073218B (en) Network configuration file compatible method, electronic equipment and storage medium
US9086895B1 (en) Controlling hardware driver selection
CN110327626B (en) Virtual server creation method and device

Legal Events

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