CN106681782B - Method and device for compiling dynamic link library SO file of android installation package - Google Patents

Method and device for compiling dynamic link library SO file of android installation package Download PDF

Info

Publication number
CN106681782B
CN106681782B CN201611131084.8A CN201611131084A CN106681782B CN 106681782 B CN106681782 B CN 106681782B CN 201611131084 A CN201611131084 A CN 201611131084A CN 106681782 B CN106681782 B CN 106681782B
Authority
CN
China
Prior art keywords
file
section
specified
specified section
symbol
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
CN201611131084.8A
Other languages
Chinese (zh)
Other versions
CN106681782A (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.)
Beijing Qihoo Technology Co Ltd
Original Assignee
Beijing Qihoo Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Qihoo Technology Co Ltd filed Critical Beijing Qihoo Technology Co Ltd
Priority to CN201611131084.8A priority Critical patent/CN106681782B/en
Publication of CN106681782A publication Critical patent/CN106681782A/en
Application granted granted Critical
Publication of CN106681782B publication Critical patent/CN106681782B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/41Compilation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/30Creation or generation of source code
    • G06F8/31Programming languages or programming paradigms
    • G06F8/315Object-oriented languages
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/445Program loading or initiating
    • G06F9/44521Dynamic linking or loading; Link editing at or after load time, e.g. Java class loading

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Computing Systems (AREA)
  • Stored Programmes (AREA)
  • Devices For Executing Special Programs (AREA)

Abstract

The invention discloses a method and a device for compiling a dynamic link library SO file of an android installation package. The method comprises the following steps: reading the SO file into a memory of SO file compiling equipment; positioning the starting address of a specified section for at least one specified section in the SO file; and acquiring the data information stored in the specified section according to the positioned initial address of the specified section. According to the technical scheme, the code segment needing to acquire the data information is quickly and accurately positioned through memory addressing, so that the needed data information is acquired and can be used for further development, reinforcement and the like, and the method is high in efficiency and good in practicability.

Description

Method and device for compiling dynamic link library SO file of android installation package
Technical Field
The invention relates to the technical field of computers, in particular to a method and a device for compiling a dynamic link library SO file of an android installation package.
Background
With the continuous development of the technology, android applications do not always rely on JAVA development environment alone in the development process, and some files written in other language environments, such as dynamic link library SO, DLL files, etc., are developed gradually by using the JAVA Native Interface (JAVA Native Interface) mechanism of JAVA. The files can be called by the android system through a JNI mechanism, and more functions are achieved. However, because of this, the reinforcement of these files is a process that developers continuously search for, and in the reinforcement process, the original SO file is often compiled to obtain some information therein, and how to accurately and quickly obtain the required information is an urgent problem to be solved.
Disclosure of Invention
In view of the above, the present invention has been made to provide a method and apparatus for compiling dynamically linked library SO files for android installation packages that overcomes or at least partially solves the above-mentioned problems.
According to one aspect of the invention, a method for compiling a dynamic link library SO file of an android installation package is provided, which comprises the following steps:
reading the SO file into a memory of SO file compiling equipment;
positioning the starting address of a specified section for at least one specified section in the SO file;
and acquiring the data information stored in the specified section according to the positioned initial address of the specified section.
Optionally, the positioning the start address of the specified section includes:
acquiring the initial address of the SO file;
calculating the file offset of the specified section in the SO file;
and taking the sum of the file offset of the specified section in the SO file and the start address of the SO file as the start address of the specified section.
Optionally, the calculating a file offset of the specified section in the SO file includes:
acquiring an initial virtual address of the SO file;
acquiring a starting virtual address of the specified section;
and making a difference between the initial virtual address of the specified section and the initial virtual address of the SO file, summing the obtained difference and the initial address of the SO file, and taking the obtained sum as the file offset of the specified section in the SO file.
Optionally, the obtaining the start virtual address of the SO file includes:
and reading the starting virtual address of the SO file from an SO file compiler of the SO file compiling device.
Optionally, the obtaining the starting virtual address of the specified section includes:
analyzing a dynamic segment of the SO file;
finding out Elf32_ Dyn items corresponding to the specified section from the dynamic section;
and reading the value of d _ ptr from an Elf32_ Dyn item corresponding to the specified section as the starting virtual address of the specified section.
Optionally, the designated section is a section of.dyntr and/or a section of.dynsym.
Optionally, the acquiring the data information stored in the specified section includes:
acquiring the symbol name of the import symbol and/or the export symbol stored in the dyntr section;
and/or the presence of a gas in the gas,
and acquiring the structural description information of the import symbol and/or the export symbol stored in the dynasym section.
Optionally, the method further comprises:
generating dynamic registration logic of the appointed import symbol and/or export symbol according to the symbol name and/or structure description information of the appointed import symbol and/or export symbol;
adding a shell to the SO file to obtain a reinforced SO file;
dynamic registration logic to write the specified import and/or export symbols in the shell.
Optionally, the adding a shell to the SO file includes:
and converting the SO file into a binary form, and adding the obtained binary SO file into the shell.
Optionally, the method further comprises:
and packaging the reinforced SO file into a corresponding android installation package, SO that after the android installation package is installed, when a corresponding application is started each time, the shell dynamically registers the relevant information of the specified import symbol and/or export symbol in the SO file into the shell according to the dynamic registration logic.
Optionally, the method further comprises, before all steps:
and unpacking the android installation package to obtain at least one SO file of the android installation package.
According to another aspect of the present invention, there is provided an apparatus for compiling a dynamic link library SO file of an android installation package, including:
the SO file reading unit is suitable for reading the SO file into the memory of the SO file compiling device;
the positioning unit is suitable for positioning the starting address of at least one specified section in the SO file;
and the data information acquisition unit is suitable for acquiring the data information stored in the specified section according to the positioned starting address of the specified section.
Optionally, the location unit is adapted to obtain a start address of the SO file; calculating the file offset of the specified section in the SO file; and taking the sum of the file offset of the specified section in the SO file and the start address of the SO file as the start address of the specified section.
Optionally, the location unit is adapted to obtain a starting virtual address of the SO file; acquiring a starting virtual address of the specified section; and making a difference between the initial virtual address of the specified section and the initial virtual address of the SO file, summing the obtained difference and the initial address of the SO file, and taking the obtained sum as the file offset of the specified section in the SO file.
Optionally, the positioning unit is adapted to read a starting virtual address of the SO file from an SO file compiler of the SO file compiling apparatus.
Optionally, the location unit is adapted to parse a dynamic segment of the SO file; finding out Elf32_ Dyn items corresponding to the specified section from the dynamic section; and reading the value of d _ ptr from an Elf32_ Dyn item corresponding to the specified section as the starting virtual address of the specified section.
Optionally, the designated section is a section of.dyntr and/or a section of.dynsym.
Optionally, the data information obtaining unit is adapted to obtain a symbol name of the import symbol and/or the export symbol stored in section dynastr; and/or obtaining structure description information of the import symbols and/or the export symbols stored in the dynasym section.
Optionally, the apparatus further comprises:
the reinforcing unit is suitable for generating dynamic registration logic of the specified import symbol and/or export symbol according to the symbol name and/or the structure description information of the specified import symbol and/or export symbol; adding a shell to the SO file to obtain a reinforced SO file; dynamic registration logic to write the specified import and/or export symbols in the shell.
Optionally, the ruggedization unit is adapted to convert the SO file into a binary form, and add the resulting SO file in binary form to the housing.
Optionally, the apparatus further comprises:
and the packaging unit is suitable for packaging the reinforced SO file into a corresponding android installation package, SO that after the android installation package is installed, the shell dynamically registers the relevant information of the specified import symbol and/or export symbol in the SO file into the shell according to the dynamic registration logic when the corresponding application is started each time.
Optionally, the apparatus further comprises:
and the unpacking unit is suitable for unpacking the android installation package to obtain at least one SO file of the android installation package.
In view of the above, according to the technical solution of the present invention, after the SO file is read to the memory of the SO file compiling device, the address of at least one specified section in the SO file is located, and the data information stored in the specified section is obtained from the address. According to the technical scheme, the code segment needing to acquire the data information is quickly and accurately positioned through memory addressing, so that the needed data information is acquired and can be used for further development, reinforcement and the like, and the method is high in efficiency and good in practicability.
The foregoing description is only an overview of the technical solutions of the present invention, and the embodiments of the present invention are described below in order to make the technical means of the present invention more clearly understood and to make the above and other objects, features, and advantages of the present invention more clearly understandable.
Drawings
Various other advantages and benefits will become apparent to those of ordinary skill in the art upon reading the following detailed description of the preferred embodiments. The drawings are only for purposes of illustrating the preferred embodiments and are not to be construed as limiting the invention. Also, like reference numerals are used to refer to like parts throughout the drawings. In the drawings:
FIG. 1 is a flow diagram illustrating a method for compiling a dynamically linked library SO file of an android installation package according to an embodiment of the invention;
fig. 2 is a schematic structural diagram of an apparatus for compiling a dynamically linked library SO file of an android installation package according to an embodiment of the present invention.
Detailed Description
Exemplary embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. While exemplary embodiments of the present disclosure are shown in the drawings, it should be understood that the present disclosure may be embodied in various forms and should not be limited to the embodiments set forth herein. Rather, these embodiments are provided so that this disclosure will be thorough and complete, and will fully convey the scope of the disclosure to those skilled in the art.
Fig. 1 is a flowchart illustrating a method for compiling a dynamic link library SO file of an android installation package according to an embodiment of the present invention, where as shown in fig. 1, the method includes:
step S110, reading the SO file into a memory of the SO file compiling device.
Step S120, for at least one designated section in the SO file, locating the initial address of the designated section.
The SO file is in ELF file format, and its structure can be divided into a number of code segments (sections), examples of some common sections in ELF are given below:
a text section for saving an instruction sequence of a program;
the data section is used for storing initialized global static variables and local static variables;
bss section for storing uninitialized global variables and local static variables
The rodata section is used for storing read-only data, such as a character string constant and a global const variable;
a debug section for storing debug information;
a dynamic section for storing dynamic link information;
hash section, symbolic hash table;
line section, line number table, i.e. the corresponding table of the line number of the source code and the compiled instruction;
note section for storing additional compiler information. Such as the company name of the program, release version number, etc.;
strtab section, string table, for storing various strings used in ELF files
Symtab section, legend;
shstrtab section, segment name table;
plt section, dynamic linked jump table
Section got, global entry of dynamic link;
init section, program initialization section;
section fini, program terminates the code fragment.
Step S130, according to the initial address of the located appointed section, the data information stored in the appointed section is obtained.
It can be seen that, in the method shown in fig. 1, after the SO file is read into the memory of the SO file compiling device, the address of at least one specified section in the SO file is located, and the data information stored in the specified section is obtained from the address. According to the technical scheme, the code segment needing to acquire the data information is quickly and accurately positioned through memory addressing, so that the needed data information is acquired and can be used for further development, reinforcement and the like, and the method is high in efficiency and good in practicability.
In one embodiment of the present invention, in the method shown in fig. 1, locating the start address of the specified section includes: acquiring an initial address of the SO file; calculating the file offset of the specified section in the SO file; and taking the sum of the file offset of the specified section in the SO file and the start address of the SO file as the start address of the specified section.
When the SO file is read into the memory of the SO file compiling device, the initial address of the SO file can be obtained. The file offset of the specified section in the SO file is usually equal to the starting virtual address of the section, SO in general, the sum of the starting virtual address of the specified section in the SO file and the starting address of the SO file can be directly used as the starting address of the specified section.
However, in many current SO files, the starting virtual address of the specified section cannot be consistent with the file offset of the specified section in the SO file, which is especially the case in system SO files requiring high version. To solve this problem, the present invention determines the commonality between virtual addresses and file offsets:
the difference between the starting virtual address of the specified section and the starting virtual address of the SO file is equal to the difference between the file offset of the specified section in the SO file and the starting address of the SO file.
Then, in accordance with the above conclusions, in one embodiment of the present invention, calculating the file offset of the specified section in the SO file comprises: acquiring an initial virtual address of the SO file; acquiring a starting virtual address of a specified section; and (3) making a difference between the initial virtual address of the specified section and the initial virtual address of the SO file, summing the obtained difference and the initial address of the SO file, and taking the sum as the file offset of the specified section in the SO file.
Wherein, obtaining the initial virtual address of the SO file comprises: and reading the starting virtual address of the SO file from an SO file compiler of the SO file compiling device.
In an embodiment of the present invention, in the method, obtaining a starting virtual address of the specified section includes: analyzing a dynamic segment of the SO file; finding out Elf32_ Dyn items corresponding to the specified section from the dynamic section; the value of d _ ptr is read from the Elf32_ Dyn entry corresponding to the specified section as the starting virtual address of the specified section.
An example of the structure of the dynamic segment is given below:
it can be seen that the dynamic segment is an array containing the above structure. Wherein d _ tag controls the interpretation meaning of d _ un, and the specific meaning can be interpreted as d _ val or d _ ptr; wherein d _ val means: the Elf32_ Word object represents an integer value, which may be interpreted in a variety of ways. d _ ptr means: this Elf32_ Addr object represents the virtual address of the program.
As previously described, there are multiple sections in the SO file, most of which have corresponding items Elf32_ Dyn in the dynamic segment. That is, the value of d _ ptr read from the Elf32_ Dyn entry corresponding to the specified section is the starting virtual address of the specified section.
In one embodiment of the present invention, the nodes are designated as nodes dyntr and/or nodes dynsym in the above method. Specifically, the acquiring the data information stored in the specified section includes: acquiring the symbol name of the import symbol and/or the export symbol stored in the dyntr section; and/or acquiring structure description information of the import symbol and/or the export symbol stored in the dynasym section.
According to the data information stored in the dyntr section and/or the dynsym section, the information of the import symbol and the export symbol in the SO file can be obtained, and the information can be modified and encrypted. Taking the SO file as an example, which is reinforced by adding a shell, since the SO file is not written by JAVA code, the android system needs to use a cross-platform mechanism of JAVA, that is, the SO file is used by a JNI (JAVA Native Interface ), that is, communication between the JAVA layer and the local layer (Native layer) is realized. Specifically, under the condition that the shell is not added to the SO file, the JAVA layer can directly call the JNI function in the SO file to use the SO file, but under the condition that the shell is added to the SO file, the JAVA layer cannot locate the function address of the JNI function in the SO file, SO that crash occurs.
Thus in one embodiment of the invention, the method further comprises: generating dynamic registration logic of the appointed import symbol and/or export symbol according to the symbol name and/or structure description information of the appointed import symbol and/or export symbol; adding a shell to the SO file to obtain a reinforced SO file; dynamic registration logic that writes specified import symbols and/or export symbols in the shell. In this embodiment, the shell is used as a medium to realize communication between the JAVA layer and the Native layer. And when the JNI function in the SO file needs to be called, the shell calls the corresponding JNI function according to the relevant information of the registered JNI function. That is to say, under the condition that the JAVA layer can not directly call the JNI function in the SO file, the shell has the function of calling the JNI function, SO that the JAVA layer only needs to interact with the shell, the corresponding JNI function can be further called through the shell, and the function of the application corresponding to the android installation package can be normally realized.
Therefore, in the above process, the dynamic registration logic of the JNI function can be written in the shell only by acquiring the relevant information of the JNI function in the SO file.
In an embodiment of the present invention, in the above method, adding a shell to the SO file includes: and converting the SO file into a binary form, and adding the obtained binary SO file into the shell.
In the process of reinforcing the SO file, other contents such as encryption of the function, addition of decryption logic and the like are also involved, and are not described herein too much since they are not the focus of the present invention. In this embodiment, the SO file is converted to binary form and added to the shell (e.g., written in section. data), forming a hardened SO file.
In an embodiment of the present invention, the method further includes: and packaging the reinforced SO file into a corresponding android installation package, SO that after the android installation package is installed, when a corresponding application is started each time, the shell dynamically registers the relevant information of the specified import symbol and/or export symbol in the SO file into the shell according to the dynamic registration logic.
In one embodiment of the present invention, the above method further comprises, before all the steps: and unpacking the android installation package to obtain at least one SO file of the android installation package.
In the above embodiment, because the SO file is reinforced, the SO file and other files of the android installation package, such as an android resource file, an android configuration file, and the like, need to be further packaged together into a complete android installation package. The SO file, the android resource file and the like can be respectively provided by developers, for example, different project groups provide different types of files in a development team, and finally the SO file is encrypted and all the files are packaged by the security group; or a special security service provider can unpack the non-reinforced android installation package provided by the developer, and repackage the reinforced SO file. The android system loaded consolidated SO file may be loaded through a Linker (dynamic library loader of android system).
Fig. 2 is a schematic structural diagram illustrating an apparatus for compiling a dynamic link library SO file of an android installation package according to an embodiment of the present invention, and as shown in fig. 2, an apparatus 200 for compiling a dynamic link library SO file of an android installation package includes:
the SO file reading unit 210 is adapted to read the SO file into a memory of the SO file compiling apparatus.
The locating unit 220 is adapted to locate a start address of a specified section for at least one specified section in the SO file.
The data information obtaining unit 230 is adapted to obtain the data information stored in the specified section according to the start address of the located specified section.
It can be seen that, in the apparatus shown in fig. 2, after the SO file is read into the memory of the SO file compiling device, the address of at least one specified section in the SO file is located, and the data information stored in the specified section is obtained from the address. According to the technical scheme, the code segment needing to acquire the data information is quickly and accurately positioned through memory addressing, so that the needed data information is acquired and can be used for further development, reinforcement and the like, and the method is high in efficiency and good in practicability.
In an embodiment of the present invention, in the above apparatus, the positioning unit 220 is adapted to obtain a start address of the SO file; calculating the file offset of the specified section in the SO file; and taking the sum of the file offset of the specified section in the SO file and the start address of the SO file as the start address of the specified section.
In an embodiment of the present invention, in the above apparatus, the positioning unit 220 is adapted to obtain a starting virtual address of the SO file; acquiring a starting virtual address of a specified section; and (3) making a difference between the initial virtual address of the specified section and the initial virtual address of the SO file, summing the obtained difference and the initial address of the SO file, and taking the sum as the file offset of the specified section in the SO file.
In an embodiment of the present invention, in the above apparatus, the positioning unit 220 is adapted to read a starting virtual address of the SO file from an SO file compiler of the SO file compiling apparatus.
In an embodiment of the present invention, in the above apparatus, the positioning unit 220 is adapted to parse a dynamic segment of the SO file; finding out Elf32_ Dyn items corresponding to the specified section from the dynamic section; the value of d _ ptr is read from the Elf32_ Dyn entry corresponding to the specified section as the starting virtual address of the specified section.
In one embodiment of the present invention, the nodes are designated as nodes dyntr and/or nodes dynsym in the above-described apparatus.
In an embodiment of the present invention, in the above apparatus, the data information obtaining unit 230 is adapted to obtain a symbol name of the import symbol and/or the export symbol stored in section dynastr; and/or obtaining structure description information of the import symbols and/or the export symbols stored in the dynasym section.
In an embodiment of the present invention, the apparatus further includes: a reinforcing unit (not shown) adapted to generate a dynamic registration logic associated with the designated import symbol and/or export symbol according to the symbol name and/or structure description information of the designated import symbol and/or export symbol; adding a shell to the SO file to obtain a reinforced SO file; dynamic registration logic that writes specified import symbols and/or export symbols in the shell.
In an embodiment of the invention, in the above apparatus, the reinforcement unit is adapted to convert the SO file into a binary form, and to add the resulting SO file in binary form to the shell.
In an embodiment of the present invention, in the above apparatus, the apparatus further includes: and a packing unit (not shown) adapted to pack the reinforced SO file into a corresponding android installation package, SO that after the android installation package is installed, the shell dynamically registers the relevant information of the import symbol and/or the export symbol specified in the SO file into the shell according to the dynamic registration logic each time the corresponding application is started.
In an embodiment of the present invention, the apparatus further includes: and the unpacking unit (not shown) is suitable for unpacking the android installation package to obtain at least one SO file of the android installation package.
It should be noted that the specific implementation of each of the above device embodiments is the same as the specific implementation of the corresponding method embodiment, and is not described herein again.
In summary, according to the technical solution of the present invention, after the SO file is read to the memory of the SO file compiling device, the address of at least one specified section in the SO file is located, and the data information stored in the specified section is obtained from the address. According to the technical scheme, the code segment needing to acquire the data information is quickly and accurately positioned through memory addressing, so that the needed data information is acquired and can be used for further development, reinforcement and the like, and the method is high in efficiency and good in practicability.
It should be noted that:
the algorithms and displays presented herein are not inherently related to any particular computer, virtual machine, or other apparatus. Various general purpose devices may be used with the teachings herein. The required structure for constructing such a device will be apparent from the description above. Moreover, the present invention is not directed to any particular programming language. It is appreciated that a variety of programming languages may be used to implement the teachings of the present invention as described herein, and any descriptions of specific languages are provided above to disclose the best mode of the invention.
In the description provided herein, numerous specific details are set forth. It is understood, however, that embodiments of the invention may be practiced without these specific details. In some instances, well-known methods, structures and techniques have not been shown in detail in order not to obscure an understanding of this description.
Similarly, it should be appreciated that in the foregoing description of exemplary embodiments of the invention, various features of the invention are sometimes grouped together in a single embodiment, figure, or description thereof for the purpose of streamlining the disclosure and aiding in the understanding of one or more of the various inventive aspects. However, the disclosed method should not be interpreted as reflecting an intention that: that the invention as claimed requires more features than are expressly recited in each claim. Rather, as the following claims reflect, inventive aspects lie in less than all features of a single foregoing disclosed embodiment. Thus, the claims following the detailed description are hereby expressly incorporated into this detailed description, with each claim standing on its own as a separate embodiment of this invention.
Those skilled in the art will appreciate that the modules in the device in an embodiment may be adaptively changed and disposed in one or more devices different from the embodiment. The modules or units or components of the embodiments may be combined into one module or unit or component, and furthermore they may be divided into a plurality of sub-modules or sub-units or sub-components. All of the features disclosed in this specification (including any accompanying claims, abstract and drawings), and all of the processes or elements of any method or apparatus so disclosed, may be combined in any combination, except combinations where at least some of such features and/or processes or elements are mutually exclusive. Each feature disclosed in this specification (including any accompanying claims, abstract and drawings) may be replaced by alternative features serving the same, equivalent or similar purpose, unless expressly stated otherwise.
Furthermore, those skilled in the art will appreciate that while some embodiments described herein include some features included in other embodiments, rather than other features, combinations of features of different embodiments are meant to be within the scope of the invention and form different embodiments. For example, in the following claims, any of the claimed embodiments may be used in any combination.
The various component embodiments of the invention may be implemented in hardware, or in software modules running on one or more processors, or in a combination thereof. Those skilled in the art will appreciate that a microprocessor or Digital Signal Processor (DSP) may be used in practice to implement some or all of the functions of some or all of the components of the apparatus for compiling dynamically linked library SO files for android installation packages in accordance with embodiments of the present invention. The present invention may also be embodied as apparatus or device programs (e.g., computer programs and computer program products) for performing a portion or all of the methods described herein. Such programs implementing the present invention may be stored on computer-readable media or may be in the form of one or more signals. Such a signal may be downloaded from an internet website or provided on a carrier signal or in any other form.
It should be noted that the above-mentioned embodiments illustrate rather than limit the invention, and that those skilled in the art will be able to design alternative embodiments without departing from the scope of the appended claims. In the claims, any reference signs placed between parentheses shall not be construed as limiting the claim. The word "comprising" does not exclude the presence of elements or steps not listed in a claim. The word "a" or "an" preceding an element does not exclude the presence of a plurality of such elements. The invention may be implemented by means of hardware comprising several distinct elements, and by means of a suitably programmed computer. In the unit claims enumerating several means, several of these means may be embodied by one and the same item of hardware. The usage of the words first, second and third, etcetera do not indicate any ordering. These words may be interpreted as names.
The embodiment of the invention discloses A1 and a method for compiling a dynamic link library SO file of an android installation package, wherein the method comprises the following steps:
reading the SO file into a memory of SO file compiling equipment;
positioning the starting address of a specified section for at least one specified section in the SO file;
and acquiring the data information stored in the specified section according to the positioned initial address of the specified section.
A2, the method of A1, wherein the locating the start address of the specified section comprises:
acquiring the initial address of the SO file;
calculating the file offset of the specified section in the SO file;
and taking the sum of the file offset of the specified section in the SO file and the start address of the SO file as the start address of the specified section.
A3, the method of A2, wherein the calculating the file offset of the specified section in the SO file comprises:
acquiring an initial virtual address of the SO file;
acquiring a starting virtual address of the specified section;
and making a difference between the initial virtual address of the specified section and the initial virtual address of the SO file, summing the obtained difference and the initial address of the SO file, and taking the obtained sum as the file offset of the specified section in the SO file.
A4, the method as in A3, wherein the obtaining the starting virtual address of the SO file comprises:
and reading the starting virtual address of the SO file from an SO file compiler of the SO file compiling device.
A5, the method of A3, wherein the obtaining the starting virtual address of the specified section comprises:
analyzing a dynamic segment of the SO file;
finding out Elf32_ Dyn items corresponding to the specified section from the dynamic section;
and reading the value of d _ ptr from an Elf32_ Dyn item corresponding to the specified section as the starting virtual address of the specified section.
A6 the method of A1, wherein,
the designated section is a section of.dynstr and/or a section of.dynsym.
A7, the method as in a6, wherein the acquiring the data information stored in the designated section includes:
acquiring the symbol name of the import symbol and/or the export symbol stored in the dyntr section;
and/or the presence of a gas in the gas,
and acquiring the structural description information of the import symbol and/or the export symbol stored in the dynasym section.
A8, the method of a7, wherein the method further comprises:
generating dynamic registration logic of the appointed import symbol and/or export symbol according to the symbol name and/or structure description information of the appointed import symbol and/or export symbol;
adding a shell to the SO file to obtain a reinforced SO file;
dynamic registration logic to write the specified import and/or export symbols in the shell.
A9, the method of A8, wherein the adding a shell to the SO file comprises:
and converting the SO file into a binary form, and adding the obtained binary SO file into the shell.
A10, the method of A8, wherein the method further comprises:
and packaging the reinforced SO file into a corresponding android installation package, SO that after the android installation package is installed, when a corresponding application is started each time, the shell dynamically registers the relevant information of the specified import symbol and/or export symbol in the SO file into the shell according to the dynamic registration logic.
A11, the method of any one of a1-a10, wherein the method further comprises, prior to all steps:
and unpacking the android installation package to obtain at least one SO file of the android installation package.
The embodiment of the invention also discloses B12 and a device for compiling the SO file of the dynamic link library of the android installation package, wherein the device comprises:
the SO file reading unit is suitable for reading the SO file into the memory of the SO file compiling device;
the positioning unit is suitable for positioning the starting address of at least one specified section in the SO file;
and the data information acquisition unit is suitable for acquiring the data information stored in the specified section according to the positioned starting address of the specified section.
B13, the device of B12, wherein,
the positioning unit is suitable for acquiring the initial address of the SO file; calculating the file offset of the specified section in the SO file; and taking the sum of the file offset of the specified section in the SO file and the start address of the SO file as the start address of the specified section.
B14, the device of B13, wherein,
the positioning unit is suitable for acquiring a starting virtual address of the SO file; acquiring a starting virtual address of the specified section; and making a difference between the initial virtual address of the specified section and the initial virtual address of the SO file, summing the obtained difference and the initial address of the SO file, and taking the obtained sum as the file offset of the specified section in the SO file.
B15, the device of B14, wherein,
the positioning unit is suitable for reading the starting virtual address of the SO file from an SO file compiler of the SO file compiling device.
B16, the device of B14, wherein,
the positioning unit is suitable for analyzing a dynamic segment of the SO file; finding out Elf32_ Dyn items corresponding to the specified section from the dynamic section; and reading the value of d _ ptr from an Elf32_ Dyn item corresponding to the specified section as the starting virtual address of the specified section.
B17, the device of B12, wherein,
the designated section is a section of.dynstr and/or a section of.dynsym.
B18, the device of B17, wherein,
the data information acquisition unit is suitable for acquiring the symbol names of the import symbols and/or the export symbols stored in the section dyntr; and/or obtaining structure description information of the import symbols and/or the export symbols stored in the dynasym section.
B19, the apparatus of B18, wherein the apparatus further comprises:
the reinforcing unit is suitable for generating dynamic registration logic of the specified import symbol and/or export symbol according to the symbol name and/or the structure description information of the specified import symbol and/or export symbol; adding a shell to the SO file to obtain a reinforced SO file; dynamic registration logic to write the specified import and/or export symbols in the shell.
B20, the device of B19, wherein,
the reinforcing unit is suitable for converting the SO file into a binary form and adding the obtained binary SO file into the shell.
B21, the apparatus of B19, wherein the apparatus further comprises:
and the packaging unit is suitable for packaging the reinforced SO file into a corresponding android installation package, SO that after the android installation package is installed, the shell dynamically registers the relevant information of the specified import symbol and/or export symbol in the SO file into the shell according to the dynamic registration logic when the corresponding application is started each time.
B22, the device according to any one of B12-B21, wherein the device further comprises:
and the unpacking unit is suitable for unpacking the android installation package to obtain at least one SO file of the android installation package.

Claims (18)

1. A method for compiling a dynamic link library (SO) file of an android installation package, wherein the method comprises the following steps:
reading the SO file into a memory of SO file compiling equipment;
positioning the starting address of a specified section for at least one specified section in the SO file;
acquiring data information stored in the appointed section according to the positioned initial address of the appointed section;
the positioning the starting address of the specified section comprises:
acquiring the initial address of the SO file;
calculating the file offset of the specified section in the SO file;
taking the sum of the file offset of the specified section in the SO file and the start address of the SO file as the start address of the specified section;
the calculating the file offset of the specified section in the SO file comprises:
acquiring an initial virtual address of the SO file;
acquiring a starting virtual address of the specified section;
and making a difference between the initial virtual address of the specified section and the initial virtual address of the SO file, summing the obtained difference and the initial address of the SO file, and taking the obtained sum as the file offset of the specified section in the SO file.
2. The method of claim 1, wherein the obtaining the starting virtual address of the SO file comprises:
and reading the starting virtual address of the SO file from an SO file compiler of the SO file compiling device.
3. The method of claim 1, wherein said obtaining a starting virtual address of the specified section comprises:
analyzing a dynamic segment of the SO file;
finding out Elf32_ Dyn items corresponding to the specified section from the dynamic section;
and reading the value of d _ ptr from an Elf32_ Dyn item corresponding to the specified section as the starting virtual address of the specified section.
4. The method of claim 1, wherein,
the designated section is a section of.dynstr and/or a section of.dynsym.
5. The method of claim 4, wherein said obtaining the data information stored in the specified section comprises:
acquiring the symbol name of the import symbol and/or the export symbol stored in the dyntr section;
and/or the presence of a gas in the gas,
and acquiring the structural description information of the import symbol and/or the export symbol stored in the dynasym section.
6. The method of claim 5, wherein the method further comprises:
generating dynamic registration logic of the appointed import symbol and/or export symbol according to the symbol name and/or structure description information of the appointed import symbol and/or export symbol;
adding a shell to the SO file to obtain a reinforced SO file;
dynamic registration logic to write the specified import and/or export symbols in the shell.
7. The method of claim 6, wherein the adding a shell to the SO file comprises:
and converting the SO file into a binary form, and adding the obtained binary SO file into the shell.
8. The method of claim 6, wherein the method further comprises:
and packaging the reinforced SO file into a corresponding android installation package, SO that after the android installation package is installed, when a corresponding application is started each time, the shell dynamically registers the relevant information of the specified import symbol and/or export symbol in the SO file into the shell according to the dynamic registration logic.
9. The method of any one of claims 1-8, wherein the method further comprises, prior to all steps:
and unpacking the android installation package to obtain at least one SO file of the android installation package.
10. An apparatus for compiling dynamically linked library (SO) files of an android installation package, wherein the apparatus comprises:
the SO file reading unit is suitable for reading the SO file into the memory of the SO file compiling device;
the positioning unit is suitable for positioning the starting address of at least one specified section in the SO file;
the data information acquisition unit is suitable for acquiring the data information stored in the specified section according to the positioned initial address of the specified section;
the positioning unit is suitable for acquiring the initial address of the SO file; calculating the file offset of the specified section in the SO file; taking the sum of the file offset of the specified section in the SO file and the start address of the SO file as the start address of the specified section;
the positioning unit is suitable for acquiring a starting virtual address of the SO file; acquiring a starting virtual address of the specified section; and making a difference between the initial virtual address of the specified section and the initial virtual address of the SO file, summing the obtained difference and the initial address of the SO file, and taking the obtained sum as the file offset of the specified section in the SO file.
11. The apparatus of claim 10, wherein,
the positioning unit is suitable for reading the starting virtual address of the SO file from an SO file compiler of the SO file compiling device.
12. The apparatus of claim 10, wherein,
the positioning unit is suitable for analyzing a dynamic segment of the SO file; finding out Elf32_ Dyn items corresponding to the specified section from the dynamic section; and reading the value of d _ ptr from an Elf32_ Dyn item corresponding to the specified section as the starting virtual address of the specified section.
13. The apparatus of claim 10, wherein,
the designated section is a section of.dynstr and/or a section of.dynsym.
14. The apparatus of claim 13, wherein,
the data information acquisition unit is suitable for acquiring the symbol names of the import symbols and/or the export symbols stored in the section dyntr; and/or obtaining structure description information of the import symbols and/or the export symbols stored in the dynasym section.
15. The apparatus of claim 14, wherein the apparatus further comprises:
the reinforcing unit is suitable for generating dynamic registration logic of the specified import symbol and/or export symbol according to the symbol name and/or the structure description information of the specified import symbol and/or export symbol; adding a shell to the SO file to obtain a reinforced SO file; dynamic registration logic to write the specified import and/or export symbols in the shell.
16. The apparatus of claim 15, wherein,
the reinforcing unit is suitable for converting the SO file into a binary form and adding the obtained binary SO file into the shell.
17. The apparatus of claim 15, wherein the apparatus further comprises:
and the packaging unit is suitable for packaging the reinforced SO file into a corresponding android installation package, SO that after the android installation package is installed, the shell dynamically registers the relevant information of the specified import symbol and/or export symbol in the SO file into the shell according to the dynamic registration logic when the corresponding application is started each time.
18. The apparatus of any one of claims 10-17, wherein the apparatus further comprises:
and the unpacking unit is suitable for unpacking the android installation package to obtain at least one SO file of the android installation package.
CN201611131084.8A 2016-12-09 2016-12-09 Method and device for compiling dynamic link library SO file of android installation package Active CN106681782B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201611131084.8A CN106681782B (en) 2016-12-09 2016-12-09 Method and device for compiling dynamic link library SO file of android installation package

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201611131084.8A CN106681782B (en) 2016-12-09 2016-12-09 Method and device for compiling dynamic link library SO file of android installation package

Publications (2)

Publication Number Publication Date
CN106681782A CN106681782A (en) 2017-05-17
CN106681782B true CN106681782B (en) 2019-12-24

Family

ID=58868619

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201611131084.8A Active CN106681782B (en) 2016-12-09 2016-12-09 Method and device for compiling dynamic link library SO file of android installation package

Country Status (1)

Country Link
CN (1) CN106681782B (en)

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109828758A (en) * 2018-12-05 2019-05-31 苏州蜗牛数字科技股份有限公司 A kind of analytic method of SO file
CN112905378B (en) * 2021-03-03 2024-03-08 广州虎牙科技有限公司 Crash information analysis method, device, electronic equipment and readable storage medium
CN113742002A (en) * 2021-09-10 2021-12-03 上海达梦数据库有限公司 Method, device, equipment and storage medium for acquiring dependency relationship of dynamic library

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH09288586A (en) * 1995-09-29 1997-11-04 Informix Software Inc Switching of dynamic library task
CN101908119A (en) * 2010-08-12 2010-12-08 浙江中控软件技术有限公司 Method and device for processing dynamic link library (DLL) file
CN102938036A (en) * 2011-11-29 2013-02-20 Ut斯达康通讯有限公司 Section double encryption and safe loading method of Windows dynamic link library
CN104298932A (en) * 2014-10-27 2015-01-21 中国建设银行股份有限公司 Method and device for calling SO file
CN106203006A (en) * 2016-08-31 2016-12-07 北京鼎源科技有限公司 Android application reinforcement means based on dex Yu so file Dynamic Execution

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH09288586A (en) * 1995-09-29 1997-11-04 Informix Software Inc Switching of dynamic library task
CN101908119A (en) * 2010-08-12 2010-12-08 浙江中控软件技术有限公司 Method and device for processing dynamic link library (DLL) file
CN102938036A (en) * 2011-11-29 2013-02-20 Ut斯达康通讯有限公司 Section double encryption and safe loading method of Windows dynamic link library
CN104298932A (en) * 2014-10-27 2015-01-21 中国建设银行股份有限公司 Method and device for calling SO file
CN106203006A (en) * 2016-08-31 2016-12-07 北京鼎源科技有限公司 Android application reinforcement means based on dex Yu so file Dynamic Execution

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
Android SO加壳;_夜风_;《https:// blog.csdn.net/ynnmnm/article/details/51883336》;20160711;第1-7页 *
Android逆向之旅一基于对so中的section加密技术实现so加固;roccheung;《https:// www.cnblogs.com/roccheung/p/5797267.html》;20151121;第1-31页 *

Also Published As

Publication number Publication date
CN106681782A (en) 2017-05-17

Similar Documents

Publication Publication Date Title
US9811360B2 (en) Dynamic determination of application server runtime classloading
CN107291480B (en) Function calling method and device
CN106355049B (en) Method and device for reinforcing SO file of dynamic link library of android installation package
US8607211B2 (en) Linking code for an enhanced application binary interface (ABI) with decode time instruction optimization
US8615745B2 (en) Compiling code for an enhanced application binary interface (ABI) with decode time instruction optimization
US9086943B2 (en) Integrated development environment-based repository searching in a networked computing environment
US8924944B2 (en) Implementation of distributed methods that support generic functions
CN110704063B (en) Method and device for compiling and executing intelligent contract
US7707631B2 (en) Device and method for processing a program code
JP2008516323A (en) Platform independent dynamic linking
CN108229112A (en) A kind of operation method and device for protecting application program, application program
CN106681782B (en) Method and device for compiling dynamic link library SO file of android installation package
CN105404794A (en) Protection method and device of Java application software
CN106598662B (en) Android-based application loading method and device
US20110113409A1 (en) Symbol capabilities support within elf
CN108460276B (en) Processing method and device for SO file of dynamic link library of android installation package
CN109409037B (en) Method, device and equipment for generating data confusion rule
CN111198690A (en) Modification method and device for installation package
US11144290B2 (en) Method and apparatus for enabling autonomous acceleration of dataflow AI applications
CN111090425A (en) Program packaging method and device and electronic equipment
CN117251234B (en) Function calling method and device based on patches
CN114579135B (en) Installation package generation method and device
CN117075960B (en) Program reconstruction method, application cross-platform migration method, device and computing equipment
CN109492353B (en) Application reinforcement method, device, electronic equipment and storage medium
CN117931145A (en) Application construction method, device, computing equipment and computer storage medium

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