CN113535278A - Dynamic library calling method and device, electronic equipment and storage medium - Google Patents

Dynamic library calling method and device, electronic equipment and storage medium Download PDF

Info

Publication number
CN113535278A
CN113535278A CN202110660726.8A CN202110660726A CN113535278A CN 113535278 A CN113535278 A CN 113535278A CN 202110660726 A CN202110660726 A CN 202110660726A CN 113535278 A CN113535278 A CN 113535278A
Authority
CN
China
Prior art keywords
dynamic library
folder
target
file
obfuscated
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.)
Pending
Application number
CN202110660726.8A
Other languages
Chinese (zh)
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.)
Shenzhen Launch Technology Co Ltd
Original Assignee
Shenzhen Yuanzheng Future Automobile 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 Shenzhen Yuanzheng Future Automobile Technology Co ltd filed Critical Shenzhen Yuanzheng Future Automobile Technology Co ltd
Priority to CN202110660726.8A priority Critical patent/CN113535278A/en
Publication of CN113535278A publication Critical patent/CN113535278A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • 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/448Execution paradigms, e.g. implementations of programming paradigms
    • G06F9/4482Procedural

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Stored Programmes (AREA)

Abstract

The application is applicable to the technical field of computers, and provides a dynamic library calling method, a dynamic library calling device, electronic equipment and a storage medium, wherein the dynamic library calling method comprises the following steps: creating a first folder; creating a first preset number of obfuscated files in the first folder, wherein the size of the obfuscated files is consistent with the size of the encrypted target dynamic library; decrypting the encrypted target dynamic library into the first folder, wherein the name format of the decrypted target dynamic library is consistent with the obfuscated file; and calling the target dynamic library to execute a target function. The embodiment of the application can safely realize the calling of the dynamic library and prevent the dynamic library from being illegally used.

Description

Dynamic library calling method and device, electronic equipment and storage medium
Technical Field
The application belongs to the technical field of computers, and particularly relates to a dynamic library calling method, a dynamic library calling device, electronic equipment and a storage medium.
Background
With the development of software technology, various application programs have more and more software functions, and great convenience is brought to people. In an application program, a Dynamic Library (also called Dynamic Link Library, abbreviated as DLL) is often called to efficiently and conveniently implement corresponding functions.
Currently, when an application calls a dynamic library, the dynamic library usually needs to be loaded into a local operating system to be called and run. However, the dynamic library called to run in the local operating system without encryption may be illegally acquired and used by other pirate programs, thereby causing a certain loss to the original application program developer.
Disclosure of Invention
In view of this, embodiments of the present application provide a dynamic library calling method, an apparatus, an electronic device, and a storage medium, so as to solve the problem in the prior art that a dynamic library of an application program is easily obtained illegally.
A first aspect of an embodiment of the present application provides a dynamic library calling method, including:
creating a first folder;
creating a first preset number of obfuscated files in the first folder, wherein the size of the obfuscated files is consistent with the size of the encrypted target dynamic library;
decrypting the encrypted target dynamic library into the first folder, wherein the name format of the decrypted target dynamic library is consistent with the obfuscated file;
and calling the target dynamic library to execute a target function.
Optionally, the creating a first preset number of obfuscated files in the first folder includes:
creating a second preset number of second folders in the first folder, wherein the name formats of the second folders are consistent;
creating a confusion file in at least one second folder to obtain a first preset number of confusion files;
correspondingly, the decrypting the encrypted target dynamic library into the first folder includes:
randomly selecting one second folder from the second preset number of second folders as a target folder under the directory of the first folder;
and decrypting the encrypted target dynamic library into the target folder.
Optionally, after the creating the first folder, the method further includes:
mounting a memory file system of an operating system to the first folder;
correspondingly, after the calling the target dynamic library and executing the target function, the method further includes:
and unloading the memory file system.
Optionally, the first folder is a hidden folder, and/or the obfuscated file is a hidden file.
Optionally, the names of the first folder and/or the obfuscated files are randomly generated.
Optionally, the decrypted target dynamic library is a hidden file, and the name of the hidden file is randomly generated.
Optionally, after the invoking the target dynamic library and executing the target function, the method further includes:
and deleting the first folder.
A second aspect of the embodiments of the present application provides a dynamic library invoking device, including:
a first creating unit configured to create a first folder;
a second creating unit, configured to create a first preset number of obfuscated files in the first folder, where a size of the obfuscated files is consistent with a size of the encrypted target dynamic library;
the decryption unit is used for decrypting the encrypted target dynamic library into the first folder, and the name format of the decrypted target dynamic library is consistent with the obfuscated file;
and the calling unit is used for calling the target dynamic library and executing the target function.
Optionally, the second creating unit is specifically configured to create a second preset number of second folders in the first folder, where a name format of each of the second folders is consistent; creating a confusion file in at least one second folder to obtain a first preset number of confusion files;
correspondingly, the decryption unit is specifically configured to randomly select one second folder from the second preset number of second folders as a target folder in the directory of the first folder; and decrypting the encrypted target dynamic library into the target folder.
Optionally, the dynamic library invoking device further includes:
the mounting unit is used for mounting a memory file system of an operating system to the first folder;
and the unloading unit is used for unloading the memory file system.
Optionally, the first folder is a hidden folder, and/or the obfuscated file is a hidden file.
Optionally, the names of the first folder and/or the obfuscated files are randomly generated.
Optionally, the decrypted target dynamic library is a hidden file, and the name of the hidden file is randomly generated.
Optionally, the dynamic library invoking device further includes:
and the deleting unit is used for deleting the first folder after the calling unit calls the target dynamic library and executes a target function.
A third aspect of embodiments of the present application provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, and when the computer program is executed by the processor, the electronic device is enabled to implement the steps of the dynamic library invocation method.
A fourth aspect of embodiments of the present application provides a computer-readable storage medium storing a computer program which, when executed by a processor, causes an electronic device to implement the steps of the dynamic library invocation method as described.
A fifth aspect of embodiments of the present application provides a computer program product, which, when run on an electronic device, causes the electronic device to execute the dynamic library invocation method of any one of the above first aspects.
Compared with the prior art, the embodiment of the application has the advantages that: according to the dynamic library calling method, the target dynamic library is obtained and called to achieve the target function by creating the first folder, creating the first preset number of obfuscated files in the first folder, and decrypting the encrypted dynamic library into the first folder. Because the first folder contains a first preset number of obfuscated files and an encrypted target dynamic library, the size of the obfuscated files is consistent with that of the dynamic library, and the format of the file name of the target dynamic library are both in a first preset format, namely, the size and the name format of the obfuscated files are consistent with those of the dynamic library, other pirate programs cannot acquire the accurate dynamic library due to the difficulty in distinguishing the obfuscated files from the dynamic library, so that the calling of the dynamic library can be safely realized, and the illegal use of the dynamic library is avoided.
Drawings
In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings used in the embodiments or the description of the prior art will be briefly described below.
Fig. 1 is an interaction flow diagram of a first dynamic library invocation method provided in an embodiment of the present application;
fig. 2 is an interaction flow diagram of a second dynamic library invocation method provided in the embodiment of the present application;
fig. 3 is a schematic diagram of a dynamic library calling apparatus according to an embodiment of the present application;
fig. 4 is a schematic diagram of an electronic device provided in an embodiment of the present application.
Detailed Description
In the following description, for purposes of explanation and not limitation, specific details are set forth, such as particular system structures, techniques, etc. in order to provide a thorough understanding of the embodiments of the present application. It will be apparent, however, to one skilled in the art that the present application may be practiced in other embodiments that depart from these specific details. In other instances, detailed descriptions of well-known systems, devices, circuits, and methods are omitted so as not to obscure the description of the present application with unnecessary detail.
In order to explain the technical solution described in the present application, the following description will be given by way of specific examples.
It will be understood that the terms "comprises" and/or "comprising," when used in this specification and the appended claims, 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, components, and/or groups thereof.
It is also to be understood that the terminology used in the description of the present application herein is for the purpose of describing particular embodiments only and is not intended to be limiting of the application. As used in the specification of the present application and the appended claims, the singular forms "a," "an," and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise.
It should be further understood that the term "and/or" as used in this specification and the appended claims refers to and includes any and all possible combinations of one or more of the associated listed items.
As used in this specification and the appended claims, the term "if" may be interpreted contextually as "when", "upon" or "in response to a determination" or "in response to a detection". Similarly, the phrase "if it is determined" or "if a [ described condition or event ] is detected" may be interpreted contextually to mean "upon determining" or "in response to determining" or "upon detecting [ described condition or event ]" or "in response to detecting [ described condition or event ]".
In addition, in the description of the present application, the terms "first", "second", and the like are used only for distinguishing the description, and are not intended to indicate or imply relative importance.
Currently, when an application calls a dynamic library, the dynamic library usually needs to be loaded into a local operating system to be called and run. However, dynamic libraries called to run in the native operating system without encryption may be illegally acquired by other pirate programs. These pirate programs can bypass the identity authentication set by the original application program developer (referred to as the original developer), and covertly invoke the dynamic library of the original application program by taking the change of the operation interface as a mask, so that the original developer is difficult to discover and follow up the responsibility of the pirate, thereby bringing a certain loss to the original developer. Therefore, the dynamic library of the application program in the prior art is easy to be illegally acquired, which is a problem to be solved urgently.
In order to solve the foregoing technical problem, an embodiment of the present application provides a dynamic library calling method, an apparatus, an electronic device, and a storage medium, including: creating a first folder, creating a first preset number of obfuscated files in the first folder, decrypting the encrypted dynamic library into the first folder to obtain a target dynamic library, and calling the target dynamic library to realize a target function. Because the first folder contains a first preset number of obfuscated files and an encrypted target dynamic library, the size of the obfuscated files is consistent with that of the dynamic library, and the format of the file name of the target dynamic library are both in a first preset format, namely, the size and the name format of the obfuscated files are consistent with those of the dynamic library, other pirate programs cannot acquire the dynamic library due to difficulty in distinguishing the obfuscated files from the dynamic library, so that the calling of the dynamic library can be safely realized, and the dynamic library is prevented from being illegally used.
The first embodiment is as follows:
fig. 1 is a flowchart illustrating a first dynamic library calling method according to an embodiment of the present application, where an execution subject of the dynamic library calling method is an electronic device, such as a computer, a mobile terminal, and the like. The dynamic library invocation method shown in FIG. 1 is detailed as follows:
in S101, a first folder is created.
In the embodiment of the application, after the target application program is started, the corresponding sections of running codes in the application program are run in sequence or according to the operation instruction of the user, so that the corresponding functions are realized. If the current running code is detected to contain a dynamic library calling instruction (namely, a function code for calling the dynamic library), a first folder is created according to the dynamic library calling instruction, and the first folder is used for storing a target dynamic library after subsequent decryption. In particular, the dynamic library call instruction may include name or pointer information for the dynamic library currently desired to be called.
Optionally, before the step S101, the method includes:
and starting a target application program, wherein an application program folder corresponding to the target application program contains a prestored encrypted dynamic library.
In the embodiment of the application, the electronic device starts the target application program after acquiring the start instruction of the target application program. Specifically, an application folder corresponding to the target application is stored in an external memory (e.g., a hard disk) of the electronic device, and the application folder is a folder containing various files related to the operation of the target application. Specifically, the target application folder at least includes an executable file corresponding to the target application and a pre-stored encrypted dynamic library. The encrypted dynamic library is obtained by compiling and encrypting a relevant program function written by a developer of a target application program, and the encrypted dynamic library is packaged and issued together with an executable file of the application program, so that the application program folder which can be downloaded and used by a user is obtained.
After the electronic device obtains the application program starting instruction, the executable file in the application program folder can be opened, so that the target application program is started.
In S102, a first preset number of obfuscated files are created in the first folder, wherein the size of the obfuscated files is consistent with the size of the encrypted target dynamic library.
In the embodiment of the application, the target dynamic library is a dynamic library required to be called by the current target application program. Specifically, according to the identification information (for example, a dynamic library name) included in the currently detected dynamic library calling instruction, the dynamic library corresponding to the identification information may be determined from the application folder as the encrypted target dynamic library. After the first folder is created, according to the size of the encrypted target dynamic library, a first preset number of obfuscated files which are consistent with the size of the encrypted target dynamic library are created under the first folder. The first preset number is a positive integer greater than or equal to 1, and the larger the first preset number is, that is, the more the obfuscated files in the first folder are, the better the protection effect on the dynamic library decrypted into the first folder is, and the higher the security is.
In S103, the encrypted target dynamic library is decrypted into the first folder, and the name format of the decrypted target dynamic library is consistent with the obfuscated file.
And after the first folder is created, decrypting the encrypted target dynamic library into the first folder to obtain the decrypted target dynamic library. The name format of the decrypted target dynamic library is consistent with the name format of the obfuscated file created in step S102. That is, although the names of the target dynamic library and the obfuscated file are different, the names are consistent in format (specifically, the names may include the length, prefix, and suffix of the file name are consistent), so that it is difficult for a pirate program to distinguish the target dynamic library from the obfuscated file, and it is difficult to accurately obtain the target dynamic library, thereby preventing the target dynamic library from being illegally used.
In an embodiment, the name format of the obfuscated file is a first predetermined format, and correspondingly, the name format of the decrypted target dynamic library is also the first predetermined format. Specifically, the first preset format may specify a length, a prefix, a suffix, and the like of a file name.
Illustratively, the first preset format may specify: the length of the file name is 4, the prefix is aa, the suffix is bb, and the middle is 3 numeric characters, then the name of the obfuscated file 1 may be: aa123bb, the name of obfuscated file 2 may be: aa112bb, the name of the target dynamic library may be: aa245 bb.
In S104, the target dynamic library is called to execute a target function.
After the decrypted target dynamic library is obtained, the target dynamic library can be called, so that the target function is realized. Specifically, the target dynamic library may be opened via a dlopen function (a computer function for opening a specified dynamic library), and a handle corresponding to the target dynamic library may be returned. Next, a pointer to the target function to be executed currently in the target dynamic library is obtained through a dlsym function (a computer function for returning an address corresponding to the function according to the dynamic link library operation handle and the function name). And then, executing the target function according to the pointer of the target function to realize the target function, and closing the target dynamic library through a dlclose function (a function for closing the currently opened dynamic library) after the target function is executed, so as to complete the current dynamic library call.
For example, if the current electronic device is a vehicle diagnostic device and the current target dynamic library to be called is a fault code analysis dynamic library, the target function correspondingly realized by calling the target dynamic library is a fault code analysis function.
In the embodiment of the application, after the application program is started, a first folder is created according to a dynamic library calling instruction in the application program, then a first preset number of obfuscated files are created in the first folder, and the encrypted dynamic library is decrypted to the first folder, so that a target dynamic library is obtained and called to achieve a target function. The first folder comprises a first preset number of obfuscated files and an encrypted target dynamic library, the size of the obfuscated files is consistent with that of the dynamic library, and the file name format of the target dynamic library are both in a first preset format, namely, the size and the name format of the obfuscated files are consistent with those of the dynamic library, so that other pirate programs cannot distinguish the obfuscated files from the dynamic library and cannot acquire the dynamic library, the dynamic library can be safely called, and the dynamic library is prevented from being illegally used. Meanwhile, the action of decrypting the encrypted target dynamic library is specifically executed in the application program, and decryption is not required to be carried out by depending on an instruction of an operating system, so that compared with the existing dynamic library calling method for decrypting in the operating system, the method and the device for decrypting the target dynamic library have the advantages that the operating system is not required to be modified, the method and the device are simple and convenient, and the compatibility is stronger.
Example two:
fig. 2 is a schematic flow chart illustrating a second dynamic library calling method provided in the embodiment of the present application, where the method in this embodiment is further improved on the basis of the dynamic library calling method in the first embodiment, and details are not repeated for the same points as in the first embodiment. The dynamic library invocation method shown in FIG. 2 is detailed as follows:
in S201, a first folder is created.
In S202, a first preset number of obfuscated files is created in the first folder, wherein the size of the obfuscated files is consistent with the size of the encrypted target dynamic library.
In S203, the encrypted target dynamic library is decrypted into the first folder, and the name format of the decrypted target dynamic library is consistent with the obfuscated file.
In S204, the target dynamic library is called to execute a target function.
In S205, the first folder is deleted.
In the embodiment of the application, after the target dynamic library is called and the target function is executed, the completion of the dynamic library calling task is described. At this time, the first folder containing the target dynamic library is deleted, so that the decrypted target dynamic library called by the target application program is prevented from being stolen by other pirated programs, thereby further avoiding illegal use of the dynamic library and improving the security of dynamic library calling.
Optionally, the step S102 or the step S202 includes:
creating a second preset number of second folders in the first folder, wherein the name formats of the second folders are consistent;
creating a confusion file in at least one second folder to obtain a first preset number of confusion files;
correspondingly, step S103 or step S203 described above includes:
randomly selecting one second folder from the second preset number of second folders as a target folder in the first folder directory;
and decrypting the encrypted target dynamic library into the target folder.
In the embodiment of the application, after the first folder is created, a second folder with a second preset number is further created in the first folder. The second preset number is at least two, the specific number of the second preset number can be determined according to the current residual computing resource of the electronic device, and under the condition that the computing resource allows, the larger the value of the second preset number is, the more difficult the target dynamic library obtained by subsequent decryption is to be stolen, and the higher the security is. And in the second preset number of second folders, the name format of each second folder is kept consistent. In one embodiment, the name of the second folder may be formatted in a second predetermined format different from the first predetermined format, and the second predetermined format may also collectively specify the length, prefix, and suffix of the name.
After a second preset number of second preset folders are created, confusion files are randomly created in the second folders to obtain a first preset number of confusion files. In at least one of the second folders with the second preset number, at least one obfuscated file needs to be created in at least one second folder, and the other second folders may randomly create 0, 1, or more than 1 obfuscated file. Further, at least one obfuscated file is created in each second folder, thereby improving the security of dynamic library invocation.
After creating the second predetermined number of obfuscated files and the first predetermined number of obfuscated files, a second folder may be randomly selected from the created second predetermined number of folders as a target folder under the directory of the first folder.
And then, decrypting the encrypted target dynamic library into the target folder to obtain the decrypted target dynamic library positioned in the directory of the target folder.
In the embodiment of the application, after the first folder is created, a second folder with a second preset number is also created, and an obfuscated file is further created under the directory of the second folder; and then, selecting one of the second preset number of second folders as a target folder, wherein the target folder is used for storing the decrypted target dynamic library, so that the second folders except the target folder can be made into confusion folders, and the judgment of a pirate program can be interfered by the confusion folders and the confusion files, so that the pirate program can hardly accurately acquire the target dynamic library, the illegal use of the dynamic library is avoided, and the calling safety of the dynamic library is improved.
Optionally, the obfuscated file and the decrypted target dynamic library are stored in a memory unit of an operating system running the target application program.
In the embodiment of the present application, a first preset number of obfuscated files and a decrypted target dynamic library created in a first folder are specifically stored in a memory unit of an operating system of a current electronic device.
In one embodiment, the first folder may be created in a memory unit of an operating system, such that the obfuscated files and the target dynamic library (which may also include a second folder) under the first folder and the first folder directory are both stored in the memory unit. In another embodiment, a first folder is created in an external storage of the electronic device, and then a memory file system of the operating system can be mounted to the first folder, so that the obfuscated files and the target dynamic library in the first folder directory are both stored in the memory unit
The operating system may be, for example, a Linux operating system or a Windows operating system. Among them, the Linux operating system is a set of Unix-like operating systems which are free to use and freely spread (Unix is an operating system appearing in the early 70 th 20 th century), and is an operating system based on multiple users, multiple tasks, support multiple threads and multiple processors. The Windows operating system (Microsoft Windows) is a suite of operating systems developed by Microsoft corporation of america.
In the embodiment of the application, because the obfuscated file and the decrypted target dynamic library are specifically stored in the memory unit of the operating system, if a power failure occurs in the running process of the target application program, the obfuscated file and the target dynamic library stored in the memory unit can be automatically cleared, the power failure automatic clearing of the target dynamic library can avoid the target dynamic library from being stolen by other pirated programs, and the automatic clearing of the obfuscated file can automatically release the memory space to avoid long-term occupation of too many useless files on the memory space, so that the security and the efficiency of dynamic library calling can be improved by the method of the embodiment of the application.
Optionally, after the creating the first folder, the method further includes:
mounting a memory file system of an operating system to the first folder;
correspondingly, after the calling the target dynamic library and executing the target function, the method further includes:
and unloading the memory file system.
In the embodiment of the present application, after the first folder is created, the memory file system of the operating system is mounted to the first folder, so that the folders and files subsequently created in the first folder are cached in the operating memory of the Linux operating system, that is, the obfuscated files and the target dynamic library (which may also include the second folder) are all stored in the memory unit. Illustratively, the operating system may be a Linux system.
After the target dynamic library is called and the target function is executed, the memory file system can be unloaded from the first folder, and after the unloading, the obfuscated file and the target dynamic library stored in the running memory are automatically deleted. Further, after the memory file system is unloaded, the first folder may be deleted.
In the embodiment of the application, after the first folder is created, the memory file system of the operating system can be mounted to the first folder, so that the obfuscated file and the target dynamic library which are subsequently created in the first folder are specifically stored in the memory unit of the operating system, and the target dynamic library and the obfuscated file can be automatically cleared when the electronic device has a power failure, so that the security of calling the dynamic library is improved. In addition, after the target dynamic library is called, the memory file system can be unloaded from the first folder, so that automatic deletion after the dynamic library calling is finished can be realized, and the safety of the dynamic library calling is further improved.
Optionally, the first folder is a hidden folder, and/or the obfuscated file is a hidden file.
In this embodiment, the first folder may be a folder set as a hidden folder, where the hidden folder is a folder that actually exists in the electronic device but is not displayed in the display interface. Alternatively, the obfuscated file may be set as a hidden file that is a file that actually exists in the electronic device but is not displayed in the display interface. In one embodiment, the first folder is a hidden folder, each subfolder (e.g., the second folder described above) under the first folder directory is a hidden folder, and each file (which may include an obfuscated file and a target dynamic library) is a hidden file.
In the application, the first folder is set as the hidden folder and/or the confusing file is set as the hidden file, so that a pirate is difficult to find and crack the target dynamic library, the dynamic library is prevented from being illegally used, and the calling safety of the dynamic library is improved.
Optionally, the names of the first folder and/or the obfuscated files are randomly generated.
In the embodiment of the application, the name of the first folder and/or the name of the obfuscated file are/is randomly generated, that is, the name of the first folder and/or the obfuscated file generated during each dynamic library call is not fixed, so that a pirate is difficult to determine the storage location of the dynamic library each time, the dynamic library is difficult to illegally use, and the security of the dynamic library call is further improved. In one embodiment, before creating the first folder, a folder name may be randomly generated, and then the folder name is used as the name of the first folder; and then, generating an obfuscated file and a target dynamic library in the first folder in sequence, wherein the name of the obfuscated file is a randomly generated name in a first preset format.
Optionally, the decrypted target dynamic library is a hidden file, and the name of the hidden file is randomly generated.
In this embodiment of the present application, before decrypting the target dynamic library, a name (for example, a name in a first preset format) whose name format is consistent with that of the obfuscated file is randomly generated, and then, the randomly generated name is used as the target name, and the hidden file format is used as the target format, so as to decrypt the target dynamic library, thereby obtaining a decrypted target dynamic library whose file format is the hidden file and name is randomly generated.
In the embodiment of the application, the decrypted target dynamic library is a hidden file and the name of the target dynamic library is not fixed randomly, so that a pirate is difficult to find and crack the target dynamic library, the dynamic library is prevented from being illegally used, and the calling safety of the dynamic library is improved.
Optionally, the name of the first folder, the name of the obfuscated file, and/or the name of the target dynamic library may be generated by a random function of the operating system itself. For example, the name of the folder may be defined as a 5-bit random number, and the name of the obfuscated file, the target dynamic library may be a name with a fixed prefix and suffix and consisting of 3-bit random numbers in the middle. The 5-bit random number can be implemented by:
folder=time(NULL)%65538;
if(folder<10000)folder+=10000;
the 3-bit random number may be implemented by:
file=time(NULL)%537;
if(file<100)file+=100;
where folder is a folder name variable, file is a file name variable, time (null) is a function of obtaining a system timestamp,% is a remainder symbol, if is a conditional symbol, a + ═ b denotes a ═ a + b, for example, if (folder <10000) folder + ═ 10000 denotes: when the folder name variable folder is less than 10000, the updated value of folder is equal to the current value of folder plus 10000.
Further, the randomly generated name may also be generated by a dedicated hardware random number generator or a cryptographic chip. The efficiency of generating the random name by the hardware random number generator and the encryption chip is higher, so that the efficiency of the dynamic library calling method can be further improved.
Optionally, the encrypted dynamic library in the embodiment of the present application is a dynamic library obtained by encrypting through an encryption tool carried by the operating system, and in step S103 or step S203, the encrypted dynamic library may be specifically decrypted into the first folder through the encryption tool carried by the operating system. Illustratively, the encryption tool may be an Open Secure Sockets Layer (Open Secure Sockets Layer) tool provided in the Linux operating system. The encryption and decryption of the dynamic library are realized conveniently through the encryption tool carried by the operating system, but the security is low.
Optionally, the encrypted dynamic library in the embodiment of the present application is a dynamic library obtained by encrypting through an encryption server, and correspondingly, in step S103 or step S203, the electronic device may specifically communicate with the encryption server to obtain a corresponding decryption method, so as to implement decryption of the encrypted dynamic library. The encryption server is used for encrypting and decrypting the dynamic library, and compared with a method for encrypting and decrypting through an encryption tool carried by an operating system, the security of dynamic library calling is further improved. However, since the electronic device and the encryption server need to perform network communication, the encryption and decryption efficiency and stability are low.
Optionally, the encrypting the target dynamic library is a dynamic library obtained by encrypting through an encryption chip, and correspondingly, decrypting the encrypted target dynamic library into the first folder includes:
and decrypting the encrypted dynamic library into the first folder through the encryption chip.
In the embodiment of the application, the encryption and decryption of the dynamic library are specifically realized through an encryption chip. The encryption chip is a chip which is arranged in the electronic equipment and stores an encryption algorithm with higher security. Through this set up in the encryption chip that is used for encryption and decryption specially of electronic equipment realizes the encryption and the decryption of dynamic storehouse, its efficiency of encryption and decryption is higher and the security is higher, consequently, can guarantee the efficiency and the stability that dynamic storehouse was called when further improving the security that dynamic storehouse was called.
The following describes the detailed steps of the dynamic library calling method according to the embodiment of the present application, taking an operating system of an electronic device as a Linux operating system as an example:
(1) and acquiring a starting instruction, and opening an executable file in the application program file package to realize the starting of the target application program. Wherein, the application program file package contains the pre-stored encrypted target dynamic library.
(2) When the target application program runs and detects that a dynamic library calling instruction exists, a random name (called a first random name for distinguishing purposes) is generated.
(3) In an external memory of the electronic device, a hidden folder named the first random name is created as a first folder.
(4) And mounting a memory file system of the Linux operating system into the first folder.
(5) And generating a random folder name sequence, wherein the random folder name sequence comprises a second preset number of folder names which are generated randomly.
(6) And creating a second preset number of second folders in the first folder according to the random folder name sequence.
(7) And generating hidden files with a first preset number, randomly named names and a first preset format as obfuscated files, and randomly storing the generated obfuscated files into a second folder.
(8) A random name (simply referred to as a second random name) is generated with a name in a first preset format.
(9) And randomly selecting one from the second folders as a target folder, decrypting the encrypted target dynamic library into the target folder, and using the second random name as the file name of the decrypted target dynamic library.
(10) And calling a dlopen function to open the target dynamic library.
(11) And calling a dlsym function to acquire a pointer of the target function in the target dynamic library.
(12) The objective function is executed.
(13) And finishing the execution of the target function.
(14) And calling dlclose function to close the target dynamic library.
(15) And (4) unloading the mounted memory file system in the step (4).
(16) And (4) deleting the first folder created in the step (3).
In the embodiment of the application, a first preset number of obfuscated files are created in a first folder, and an encrypted dynamic library is decrypted into the first folder to obtain a target dynamic library and is called, so that a target function is realized. Because the first folder contains a first preset number of obfuscated files and a decrypted target dynamic library, and the size and the name format of the obfuscated files are consistent with those of the target dynamic library, other pirate programs cannot acquire the dynamic library because the obfuscated files and the dynamic library are difficult to distinguish, so that the dynamic library can be safely called, and the dynamic library is prevented from being illegally used.
It should be understood that, the sequence numbers of the steps in the foregoing embodiments do not imply an execution sequence, and the execution sequence of each process should be determined by its function and inherent logic, and should not constitute any limitation to the implementation process of the embodiments of the present application.
Example three:
fig. 3 is a schematic structural diagram of a dynamic library invocation device provided in an embodiment of the present application, and for convenience of description, only parts related to the embodiment of the present application are shown:
the dynamic library calling device comprises: a first creation unit 31, a second creation unit 32, a decryption unit 33, a calling unit 34. Wherein:
a first creating unit 31 for creating a first folder.
A second creating unit 32, configured to create a first preset number of obfuscated files in the first folder, where a size of the obfuscated files is consistent with a size of the encrypted target dynamic library.
A decryption unit 33, configured to decrypt the encrypted target dynamic library into the first folder, where a name format of the decrypted target dynamic library is consistent with the obfuscated file.
And the calling unit 34 is used for calling the target dynamic library and executing the target function.
Optionally, the second creating unit 32 is specifically configured to create a second preset number of second folders in the first folder, where a name format of each of the second folders is consistent; creating a confusion file in at least one second folder to obtain a first preset number of confusion files;
correspondingly, the decryption unit 33 is specifically configured to randomly select one second folder from the second preset number of second folders as a target folder in the directory of the first folder; and decrypting the encrypted target dynamic library into the target folder.
Optionally, the dynamic library invoking device further includes:
the mounting unit is used for mounting a memory file system of an operating system to the first folder;
and the unloading unit is used for unloading the memory file system.
Optionally, the first folder is a hidden folder, and/or the obfuscated file is a hidden file.
Optionally, the names of the first folder and/or the obfuscated files are randomly generated.
Optionally, the encrypted target dynamic library is a dynamic library obtained by encrypting through an encryption chip, and correspondingly, the decryption unit 33 is specifically configured to decrypt the encrypted target dynamic library into the first folder through the encryption chip.
Optionally, the dynamic library invoking device further includes:
and the deleting unit is used for deleting the first folder after the calling unit calls the target dynamic library and executes a target function.
It should be noted that, for the information interaction, execution process, and other contents between the above-mentioned devices/units, the specific functions and technical effects thereof are based on the same concept as those of the embodiment of the method of the present application, and specific reference may be made to the part of the embodiment of the method, which is not described herein again.
It will be apparent to those skilled in the art that, for convenience and brevity of description, only the above-mentioned division of the functional units and modules is illustrated, and in practical applications, the above-mentioned function distribution may be performed by different functional units and modules according to needs, that is, the internal structure of the apparatus is divided into different functional units or modules to perform all or part of the above-mentioned functions. Each functional unit and module in the embodiments may be integrated in one processing unit, or each unit may exist alone physically, or two or more units are integrated in one unit, and the integrated unit may be implemented in a form of hardware, or in a form of software functional unit. In addition, specific names of the functional units and modules are only for convenience of distinguishing from each other, and are not used for limiting the protection scope of the present application. The specific working processes of the units and modules in the system may refer to the corresponding processes in the foregoing method embodiments, and are not described herein again.
Example four:
fig. 4 is a schematic diagram of an electronic device according to an embodiment of the present application. As shown in fig. 4, the electronic apparatus 4 of this embodiment includes: a processor 40, a memory 41, and a computer program 42, such as a dynamic library call program, stored in the memory 41 and operable on the processor 40. The processor 40, when executing the computer program 42, implements the steps in the various dynamic library invocation method embodiments described above, such as the steps S101-S104 shown in fig. 1. Alternatively, the processor 40, when executing the computer program 42, implements the functions of the modules/units in the device embodiments, such as the functions of the first creating unit 31 to the calling unit 34 shown in fig. 3.
Illustratively, the computer program 42 may be partitioned into one or more modules/units that are stored in the memory 41 and executed by the processor 40 to accomplish the present application. The one or more modules/units may be a series of computer program instruction segments capable of performing specific functions, which are used to describe the execution of the computer program 42 in the electronic device 4.
The electronic device 4 may be a desktop computer, a notebook, a palm computer, a cloud server, or other computing devices. The electronic device may include, but is not limited to, a processor 40, a memory 41. Those skilled in the art will appreciate that fig. 4 is merely an example of an electronic device 4 and does not constitute a limitation of the electronic device 4 and may include more or fewer components than shown, or some components may be combined, or different components, e.g., the electronic device may also include input-output devices, network access devices, buses, etc.
The Processor 40 may be a Central Processing Unit (CPU), other 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, discrete hardware components, etc. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like.
The memory 41 may be an internal storage unit of the electronic device 4, such as a hard disk or a memory of the electronic device 4. The memory 41 may also be an external storage device of the electronic device 4, such as a plug-in hard disk, a Smart Media Card (SMC), a Secure Digital (SD) Card, a Flash memory Card (Flash Card), and the like, which are provided on the electronic device 4. Further, the memory 41 may also include both an internal storage unit and an external storage device of the electronic device 4. The memory 41 is used for storing the computer program and other programs and data required by the electronic device. The memory 41 may also be used to temporarily store data that has been output or is to be output.
It will be apparent to those skilled in the art that, for convenience and brevity of description, only the above-mentioned division of the functional units and modules is illustrated, and in practical applications, the above-mentioned function distribution may be performed by different functional units and modules according to needs, that is, the internal structure of the apparatus is divided into different functional units or modules to perform all or part of the above-mentioned functions. Each functional unit and module in the embodiments may be integrated in one processing unit, or each unit may exist alone physically, or two or more units are integrated in one unit, and the integrated unit may be implemented in a form of hardware, or in a form of software functional unit. In addition, specific names of the functional units and modules are only for convenience of distinguishing from each other, and are not used for limiting the protection scope of the present application. The specific working processes of the units and modules in the system may refer to the corresponding processes in the foregoing method embodiments, and are not described herein again.
In the above embodiments, the descriptions of the respective embodiments have respective emphasis, and reference may be made to the related descriptions of other embodiments for parts that are not described or illustrated in a certain embodiment.
Those of ordinary skill in the art will appreciate that the various illustrative elements and algorithm steps described in connection with the embodiments disclosed herein may be implemented as electronic hardware or combinations of computer software and electronic hardware. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the implementation. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present application.
In the embodiments provided in the present application, it should be understood that the disclosed apparatus/electronic device and method may be implemented in other ways. For example, the above-described apparatus/electronic device embodiments are merely illustrative, and for example, the division of the modules or units is only one logical division, and there may be other divisions when actually implemented, for example, a plurality of units or components may be combined or integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection through some interfaces, devices or units, and may be in an electrical, mechanical or other form.
The units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.
In addition, functional units in the embodiments of the present application may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit. The integrated unit can be realized in a form of hardware, and can also be realized in a form of a software functional unit.
The integrated modules/units, if implemented in the form of software functional units and sold or used as separate products, may be stored in a computer readable storage medium. Based on such understanding, all or part of the flow in the method of the embodiments described above can be realized by a computer program, which can be stored in a computer-readable storage medium and can realize the steps of the embodiments of the methods described above when the computer program is executed by a processor. Wherein the computer program comprises computer program code, which may be in the form of source code, object code, an executable file or some intermediate form, etc. The computer-readable medium may include: any entity or device capable of carrying the computer program code, recording medium, usb disk, removable hard disk, magnetic disk, optical disk, computer Memory, Read-Only Memory (ROM), Random Access Memory (RAM), electrical carrier wave signals, telecommunications signals, software distribution medium, and the like. It should be noted that the computer readable medium may contain content that is subject to appropriate increase or decrease as required by legislation and patent practice in jurisdictions, for example, in some jurisdictions, computer readable media does not include electrical carrier signals and telecommunications signals as is required by legislation and patent practice.
The above-mentioned embodiments are only used for illustrating the technical solutions of the present application, and not for limiting the same; although the present application has been described in detail with reference to the foregoing embodiments, it should be understood by those of ordinary skill in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some technical features may be equivalently replaced; such modifications and substitutions do not substantially depart from the spirit and scope of the embodiments of the present application and are intended to be included within the scope of the present application.

Claims (10)

1. A dynamic library calling method applied to a target application program comprises the following steps:
creating a first folder;
creating a first preset number of obfuscated files in the first folder, wherein the size of the obfuscated files is consistent with the size of the encrypted target dynamic library;
decrypting the encrypted target dynamic library into the first folder, wherein the name format of the decrypted target dynamic library is consistent with the obfuscated file;
and calling the target dynamic library to execute a target function.
2. The dynamic library call method of claim 1, wherein creating a first preset number of obfuscated files in the first folder comprises:
creating a second preset number of second folders in the first folder, wherein the name formats of the second folders are consistent;
creating a confusion file in at least one second folder to obtain a first preset number of confusion files;
correspondingly, the decrypting the encrypted target dynamic library into the first folder includes:
randomly selecting one second folder from the second preset number of second folders as a target folder under the directory of the first folder;
and decrypting the encrypted target dynamic library into the target folder.
3. The dynamic library invocation method according to claim 1, further comprising, after said creating a first folder:
mounting a memory file system of an operating system to the first folder;
correspondingly, after the calling the target dynamic library and executing the target function, the method further includes:
and unloading the memory file system.
4. The dynamic library invocation method according to claim 1, wherein said first folder is a hidden folder and/or said obfuscated file is a hidden file.
5. The dynamic library invocation method according to claim 1, wherein the name of the first folder and/or the obfuscated file is randomly generated.
6. The dynamic library invocation method according to claim 1, wherein the decrypted target dynamic library is a hidden file and the name is randomly generated.
7. The dynamic library invocation method according to any of claims 1 to 6, further comprising, after said invoking said target dynamic library to perform a target function:
and deleting the first folder.
8. A dynamic library invocation apparatus, comprising:
a first creating unit configured to create a first folder;
a second creating unit, configured to create a first preset number of obfuscated files in the first folder, where a size of the obfuscated files is consistent with a size of the encrypted target dynamic library;
the decryption unit is used for decrypting the encrypted target dynamic library into the first folder, and the name format of the decrypted target dynamic library is consistent with the obfuscated file;
and the calling unit is used for calling the target dynamic library and executing the target function.
9. An electronic device comprising a memory, a processor and a computer program stored in the memory and executable on the processor, characterized in that the computer program, when executed by the processor, causes the electronic device to carry out the steps of the method according to any one of claims 1 to 7.
10. A computer-readable storage medium, in which a computer program is stored which, when being executed by a processor, causes an electronic device to carry out the steps of the method according to any one of claims 1 to 7.
CN202110660726.8A 2021-06-15 2021-06-15 Dynamic library calling method and device, electronic equipment and storage medium Pending CN113535278A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110660726.8A CN113535278A (en) 2021-06-15 2021-06-15 Dynamic library calling method and device, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110660726.8A CN113535278A (en) 2021-06-15 2021-06-15 Dynamic library calling method and device, electronic equipment and storage medium

Publications (1)

Publication Number Publication Date
CN113535278A true CN113535278A (en) 2021-10-22

Family

ID=78124957

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110660726.8A Pending CN113535278A (en) 2021-06-15 2021-06-15 Dynamic library calling method and device, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN113535278A (en)

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105683990A (en) * 2013-10-10 2016-06-15 Inka安特沃客有限公司 Method and apparatus for protecting dynamic libraries
CN106909855A (en) * 2017-03-24 2017-06-30 腾讯科技(深圳)有限公司 File hiding method and device
CN111581647A (en) * 2019-02-15 2020-08-25 武汉海康存储技术有限公司 File encryption and decryption method and device

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105683990A (en) * 2013-10-10 2016-06-15 Inka安特沃客有限公司 Method and apparatus for protecting dynamic libraries
CN106909855A (en) * 2017-03-24 2017-06-30 腾讯科技(深圳)有限公司 File hiding method and device
CN111581647A (en) * 2019-02-15 2020-08-25 武汉海康存储技术有限公司 File encryption and decryption method and device

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
杨峥等;: "一种基于诱饵文件的勒索软件及时检测方法", 武汉大学学报(理学版), vol. 66, no. 05, 24 October 2020 (2020-10-24), pages 473 - 482 *

Similar Documents

Publication Publication Date Title
US10586026B2 (en) Simple obfuscation of text data in binary files
US8892876B1 (en) Secured application package files for mobile computing devices
US20190332766A1 (en) Early runtime detection and prevention of ransomware
CN109062582B (en) Encryption method and device for application installation package
US20080216071A1 (en) Software Protection
US20070271446A1 (en) Application Execution Device and Application Execution Device Application Execution Method
US8417969B2 (en) Storage volume protection supporting legacy systems
CN109784007B (en) Byte code encryption method, byte code decryption method and terminal
US20160275019A1 (en) Method and apparatus for protecting dynamic libraries
WO2015119978A1 (en) Content item encryption on mobile devices
CN112231702A (en) Application protection method, device, equipment and medium
US9292708B2 (en) Protection of interpreted source code in virtual appliances
CN111737718A (en) Encryption and decryption method and device for jar packet, terminal equipment and storage medium
US20110145596A1 (en) Secure Data Handling In A Computer System
CN112148709A (en) Data migration method, system and storage medium
CN113220314B (en) APP resource loading and APK generation method, device, equipment and medium
CN113535278A (en) Dynamic library calling method and device, electronic equipment and storage medium
CN110298146B (en) Application processing and running method and device
JP6698775B2 (en) Security providing apparatus and method for protecting code of shared object, and security executing apparatus and method
US9965621B2 (en) Program protection device
CN111562916B (en) Method and device for sharing algorithm
CN112231757B (en) Privacy protection method, device and equipment for embedded application
JP7348701B2 (en) Methods and systems for loading executable images into memory
CN109937407B (en) Extended memory for SMM transfer monitor
CN114297688A (en) Data protection method and device and electronic equipment

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
TA01 Transfer of patent application right

Effective date of registration: 20221011

Address after: 518000 Guangdong province Shenzhen Longgang District Bantian Street five and Avenue North 4012 Yuan Zheng Industrial Park.

Applicant after: LAUNCH TECH Co.,Ltd.

Address before: 518000 522, headquarters office building of Yuanzheng technology plant, No. 4012, North Wuhe Avenue, Bantian street, Longgang District, Shenzhen, Guangdong Province

Applicant before: Shenzhen Yuanzheng Future Automobile Technology Co.,Ltd.

TA01 Transfer of patent application right