WO2018205494A1 - 代码混淆方法、装置及计算机可读存储介质 - Google Patents

代码混淆方法、装置及计算机可读存储介质 Download PDF

Info

Publication number
WO2018205494A1
WO2018205494A1 PCT/CN2017/105006 CN2017105006W WO2018205494A1 WO 2018205494 A1 WO2018205494 A1 WO 2018205494A1 CN 2017105006 W CN2017105006 W CN 2017105006W WO 2018205494 A1 WO2018205494 A1 WO 2018205494A1
Authority
WO
WIPO (PCT)
Prior art keywords
preset type
code
hash value
code information
information
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.)
Ceased
Application number
PCT/CN2017/105006
Other languages
English (en)
French (fr)
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.)
Ping An Technology Shenzhen Co Ltd
Original Assignee
Ping An Technology Shenzhen 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 Ping An Technology Shenzhen Co Ltd filed Critical Ping An Technology Shenzhen Co Ltd
Publication of WO2018205494A1 publication Critical patent/WO2018205494A1/zh
Anticipated expiration legal-status Critical
Ceased legal-status Critical Current

Links

Images

Classifications

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

Definitions

  • the present invention relates to the field of software development, and in particular, to a code obfuscation method, apparatus, and computer readable storage medium.
  • the object of the present invention is to provide a technical solution for preventing source code leakage during software development, aiming at avoiding hacking and reversing in the software development process and protecting the security of the software source code.
  • the present invention provides a code obfuscation method comprising the following steps:
  • the preset type code information in the compiled code is replaced with the corresponding preset type hash value according to the saved mapping relationship data.
  • each preset type code information there are multiple types of information of the code information; the steps of converting each preset type code information into a preset type hash value include:
  • step of saving the mapping relationship data between the preset type code information and the preset type hash value includes:
  • the code compilation obfuscated file includes a mapping relationship data table, the image
  • the shot relationship data table includes at least two columns, one column stores each preset type code information, and the other column stores a preset type hash value corresponding to each preset type code information;
  • the preset type code information and the preset type hash value corresponding to each other are in the same row of the mapping relation data table, and the non-corresponding preset type code information and the preset type hash value are in different rows of the mapping relation data table.
  • step B the method further includes the following steps:
  • the replaced preset type hash value is restored to the corresponding preset type code information, and after the code information is restored, The mapping relationship between the saved preset type code information and the preset type hash value is deleted, and the obfuscation process is not performed in the process of compiling the code of the software to be developed subsequently.
  • the present invention also provides a code obfuscation device comprising: a memory, a processor, and a code obfuscating program stored on the memory and operable on the processor, the code obfuscating program being executed when executed by the processor.
  • the preset type code information in the compiled code is replaced with the corresponding preset type hash value according to the saved mapping relationship data.
  • the processor execution code obfuscation program implements the steps of converting each preset type code information into a preset type hash value, including:
  • the step of the processor executing the code obfuscation program to implement the mapping relationship data of the preset type code information and the preset type hash value comprises:
  • the code compilation obfuscation file includes a mapping relationship data table, and the mapping relationship data table includes at least two a column, one column stores each preset type code information, and another column stores a preset type hash value corresponding to each preset type code information;
  • the preset type code information and the preset type hash value corresponding to each other are in the same row of the mapping relationship data table, and the non-corresponding preset type code information and the preset type hash value are in the mapping relationship. Different rows of the data table.
  • the processor is further configured to execute a code obfuscation program to implement the following steps:
  • the closing instruction of the code confusing by the user is received during the process of compiling the software to be developed, the replaced preset type hash value is restored to the corresponding preset type code information, and the code is After the information restoration is completed, the saved mapping data of the preset type code information and the preset type hash value is deleted, and the confusion processing is not performed in the process of compiling the software to be developed later.
  • the present invention also provides a computer readable storage medium storing a code obfuscation program, which is implemented by a processor to implement the code obfuscation method in any of the above embodiments.
  • the beneficial effects of the present invention are: by converting the preset type code information of the software to be developed into a preset type hash value corresponding thereto and saving the mapping relationship data between the preset type code information and the preset type hash value,
  • the preset type code information contained in the compiled code is replaced with a preset type hash value corresponding to the preset type hash value according to the saved mapping relationship data, and the preset type hash value is an unreadable code and It is irreversible and unique, so it greatly avoids the attack and reverse risks in the software development process.
  • step S2 is a schematic diagram of a refinement process of step S2 shown in FIG. 1;
  • FIG. 3 is a schematic diagram of an operating environment of an embodiment of a code obfuscation system according to the present invention.
  • FIG. 4 is a schematic structural diagram of a system according to an embodiment of the present invention.
  • FIG. 5 is a schematic structural view of the memory module shown in FIG. 4.
  • FIG. 1 is a schematic flowchart of an embodiment of the present invention. In this embodiment, the following steps are included:
  • the acquired preset type code information includes a class name, a variable name, and a function name in the code.
  • the shot relationship data replaces the preset type code information in the compiled code with a preset type hash value corresponding thereto.
  • step S12 includes the following steps:
  • S12-1 Determine a hash value type of a hash value corresponding to each preset type code information. Specifically, the hash value type corresponding to each preset type code information is determined according to the mapping relationship between the information type of the code information and the hash value type of the hash value.
  • the hash value type includes the MD5 value, and the MD5 value is unreadable code and is irreversible and unique.
  • S12-2 Convert each preset type code information into a hash value type of a corresponding hash value.
  • the hash value of the hash value is a preset type hash value.
  • S12-4 Mapping each preset type code information to a corresponding preset type hash value one by one and storing the code in the code compiling confusion file.
  • mapping relationship data table is established in the code compiling confusion file, where the mapping relationship data table includes at least two columns, one column is used for storing each preset type code information, and another column is used for storing corresponding preset type code information.
  • the preset type hash value, the preset type code information and the preset type hash value corresponding to each other are in the same row of the mapping relation data table, and the preset preset type code information and the preset type hash value are in the mapping. Different rows of relational data tables.
  • the class name, the variable name, and the mapping relationship between the function name and the corresponding MD5 value in the code are determined. And convert the class name, variable name, and function name in the code to the corresponding MD5 value type.
  • the preset type code information to be saved is The mapping data of the preset type hash value is deleted, and the code obfuscation process is not performed in compiling the code of the software to be developed.
  • the replaced preset type hash value is restored to the corresponding preset type code information, and After the code information is restored, the saved mapping data of the preset type code information and the preset type hash value is deleted, and the confusion processing is not performed in the process of compiling the software to be developed later.
  • the shutdown instruction includes an instruction issued by the user to delete the mapping relationship data between the saved preset type code information and the preset type hash value.
  • the software project developer uses the technical solution of the present invention to count the key class names, variable names and function names in the project when developing the software, and converts them into corresponding MD5 values, and then creates a new file.
  • Macro definition the class name, variable name and function name are associated with their corresponding MD5 values one by one.
  • the code When compiling, the class name, variable name and function name in the code are automatically replaced with their MD5 values through macro definition, so that even if a hacker cracks the developed software, the result is unreadable, unique and irreversible. The hash value can therefore be greatly avoided by being attacked and reversed.
  • the programmer does not need to consider the confusion of the code at all.
  • it is necessary to confuse it is only necessary to import the statistically confusing file. If there is no need to confuse, the file can be deleted, no at all. Affect existing development models and methods.
  • the embodiment obtains and counts the preset type code information of the software to be developed, converts the preset type code information into a preset type hash value, and saves the preset type code information and the preset. Mapping data between type hash values, in the process of compiling the software to be developed, replacing the preset type code information in the compiled code with the corresponding preset type hash value according to the saved mapping relationship, To enhance the security of the software development process, reduce the risk of the source code being reversed by the attack.
  • FIG. 3 it is a schematic diagram of the operating environment of the preferred embodiment of the code obfuscation system 10 of the present invention.
  • the code obfuscation system 10 is installed and operated in the code obfuscating device 1.
  • the code obfuscation device 1 can be a computing device such as a desktop computer, a notebook, a palmtop computer, and a server.
  • the code obfuscating device 1 may include, but is not limited to, the memory 11 and the processor 12.
  • Figure 3 shows only the code obfuscation device 1 having the component 11 and the component 12, but it should be understood that not all illustrated components may be implemented, and more or fewer components may be implemented instead.
  • the memory 11 may be an internal storage unit of the code obfuscating device 1, such as a hard disk or memory of the code obfuscating device 1, in some embodiments.
  • the memory 11 may also be an external storage device of the code obfuscating device 1 in other embodiments, such as a plug-in hard disk equipped with the code obfuscating device 1, a smart memory card (SMC), and a secure digital (Secure Digital, SD) card, flash card, etc. Further, the memory 11 may also include both an internal storage unit of the code obfuscating device 1 and an external storage device.
  • the memory 11 is used to store application software and various types of data installed in the code obfuscating device 1, such as program code of the code obfuscation system 10.
  • the memory 11 can also be used to temporarily store data that has been output or is about to be output.
  • the processor 12 in some embodiments, may be a Central Processing Unit (CPU), microprocessor or other data processing chip for running program code or processing data stored in the memory 11, such as executing a code obfuscation system. 10 and so on.
  • CPU Central Processing Unit
  • microprocessor or other data processing chip for running program code or processing data stored in the memory 11, such as executing a code obfuscation system. 10 and so on.
  • the code obfuscating device 1 can also include a display (not shown).
  • the display can be an LED display, a liquid crystal display, a touch liquid crystal display, and an OLED (Organic Light-Emitting Diode). ) Toucher, etc.
  • the display is used to display information processed in the code obfuscating device 1 and a user interface for displaying visualizations, such as an APP installation interface and the like.
  • the component 11 and the component 12 of the code obfuscating device 1 communicate with each other through a system bus.
  • the memory 11 and the processor 12 are different components respectively. In other embodiments of the present invention, the memory 11 and the processor 12 are integrated to form a controller, and no device is used here. Narration.
  • the code obfuscating device 1 may not include a display, and after the user sends the written code to the code obfuscating device 1, the code obfuscating system running in the code obfuscating device 1 confuses the received code. I will not repeat them here.
  • FIG. 4 is a functional block diagram of a preferred embodiment of the code obfuscation system 10 of the present invention.
  • the code obfuscation system 10 can be partitioned into one or more modules, one or more modules being stored in the memory 11 and being processed by one or more processors (the processor 12 in this embodiment). Executed to complete the present invention.
  • the code obfuscation system 10 can be divided into an acquisition module 101, a storage module 102, a detection module 103, and a processing module 104.
  • module refers to a series of computer program instruction segments capable of performing a specific function, and is more suitable than the program for describing the execution process of the code obfuscation system 10 in the code obfuscating device 1.
  • the code obfuscation system 10 includes:
  • the obtaining module 101 is configured to acquire and count preset type code information of the software to be developed.
  • the storage module 102 is configured to convert each preset type code information acquired by the obtaining module 101 into a preset type hash value, and save mapping relationship data between the preset type code information and the preset type hash value.
  • the detecting module 103 is configured to detect, in real time or periodically, whether the compiled code contains the saved preset type code information during the process of compiling the software to be developed.
  • the processing module 104 is configured to: when the detection module 103 detects that the compiled code includes preset type code information, replace the preset type code information in the compiled code with the corresponding preset according to the saved mapping relationship data. Set the type hash value.
  • the storage module 102 includes an analysis unit 110 and a storage unit 111.
  • the analyzing unit 110 is configured to determine a hash value type corresponding to each preset type code information according to a mapping relationship between the information type of the code information and a hash value type of the hash value, and convert each preset type code information into a corresponding one.
  • the hash value of the hash value type is configured to determine a hash value type corresponding to each preset type code information according to a mapping relationship between the information type of the code information and a hash value type of the hash value, and convert each preset type code information into a corresponding one.
  • the storage unit 111 is configured to create a new code compiling confusion file, map each preset type code information to a corresponding preset type hash value, and store the code in the code compilation obfuscated file.
  • the system further includes a control module (the control module is not shown in FIG. 4).
  • the control module deletes the mapping relationship between the saved preset type code information and the preset type hash value, and if it receives the closing instruction of the code confusing by the user before compiling the code of the software to be developed, No code obfuscation is performed during the code development process of the software.
  • the replaced preset type hash value is restored to the corresponding preset type code information, and After the code information is restored, the saved mapping data of the preset type code information and the preset type hash value is deleted, and the obfuscation process is not performed in the process of compiling the software to be developed later.
  • the embodiment obtains and counts the preset type code information of the software to be developed, converts the preset type code information into a preset type hash value, and saves the preset type code information and the preset. Mapping data between type hash values, in compiling the code process of the software to be developed According to the saved mapping relationship, the preset type code information in the compiled code is replaced with the corresponding preset type hash value to enhance the security in the software development process, and reduce the risk of the source code being reversed by the attack.

Landscapes

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

Abstract

一种代码混淆方法,包括,获取并统计待开发软件的预设类型代码信息(S1),将各个预设类型代码信息转换成预设类型哈希值,并保存预设类型代码信息与预设类型哈希值的映射关系数据(S2),在编译待开发软件的代码过程中,实时或者定时侦测编译的代码中是否含有保存的预设类型代码信息,若侦测到编译的代码中含有预设类型代码信息(S3),则根据保存的映射关系数据将编译的代码中的预设类型代码信息替换为与其相对应的预设类型哈希值(S4)。所述方法能够避免软件开发过程中被攻击与逆向,保护软件源码的安全。

Description

代码混淆方法、装置及计算机可读存储介质
本申请申明享有2017年5月10日递交的申请号为201710327381.8、名称为“代码混淆方法、装置及计算机可读存储介质”的中国专利申请的优先权,该中国专利申请的整体内容以参考的方式结合在本申请中。
技术领域
本发明涉及软件开发领域,尤其涉及一种代码混淆方法、装置及计算机可读存储介质。
背景技术
目前,APP开发过程中,为了方便开发与维护,通常将代码编译中的类、变量与函数的命名都设置为具有一定的可读性,并为了安全起见,程序员在编写软件的时候,需要考虑代码的混淆,这样通常需要花费程序员很多精力和时间,即便是如此,目前的APP开发过程中也存在容易造成程序源码泄露的问题,从而导致APP被黑客攻击与逆向。
发明内容
本发明的目的在于提供一种防止软件开发过程中源码泄露的技术方案,旨在避免软件开发过程中被黑客攻击与逆向,保护软件源码的安全。
为实现上述目的,本发明提供一种代码混淆方法,包括如下步骤:
A、获取并统计待开发软件的预设类型代码信息;
B、将各个预设类型代码信息转换成预设类型哈希值,并保存预设类型代码信息与预设类型哈希值的映射关系数据;
C、在编译待开发软件的代码过程中,实时或者定时侦测编译的代码中是否含有保存的预设类型代码信息;
D、若侦测到编译的代码中含有预设类型代码信息,则根据保存的映射关系数据将编译的代码中的预设类型代码信息替换为与其相对应的预设类型哈希值。
进一步地,哈希值的哈希值类型有多个,代码信息的信息类型有多个;将各个预设类型代码信息转换成预设类型哈希值的步骤包括:
根据代码信息的信息类型与哈希值的哈希值类型的映射关系,确定各个预设类型代码信息对应的哈希值类型;
将各个预设类型代码信息转换成对应的哈希值类型的哈希值。
进一步地,保存预设类型代码信息与预设类型哈希值的映射关系数据的步骤包括:
新建一个代码编译混淆文件;
将各个预设类型代码信息与对应的预设类型哈希值一一关联映射、并存储在代码编译混淆文件中;代码编译混淆文件中包含映射关系数据表,该映 射关系数据表中至少包含两列,一列存储有各个预设类型代码信息,另一列存储有与各个预设类型代码信息对应的预设类型哈希值;
相互对应的预设类型代码信息和预设类型哈希值处于该映射关系数据表的同一行,不对应的预设类型代码信息和预设类型哈希值处于该映射关系数据表的不同行。
进一步地,在步骤B之后,该方法还包括如下步骤:
在编译待开发软件的代码之前,若收到用户发出的代码混淆的关闭指令,则将保存的预设类型代码信息与预设类型哈希值的映射关系数据删除,并在编译待开发软件的代码过程中不进行代码混淆处理;
若在编译待开发软件的代码过程中,收到用户发出的代码混淆的关闭指令,则将已替换的预设类型哈希值还原成对应的预设类型代码信息,并在代码信息还原完成后将保存的预设类型代码信息与预设类型哈希值的映射关系数据删除,并在后续编译待开发软件的代码过程中不进行混淆处理。
为实现上述目的,本发明还提供了一种代码混淆装置,该装置包括:存储器、处理器及存储在存储器上并可在处理器上运行的代码混淆程序,代码混淆程序被处理器执行时执行以下步骤:
A、获取并统计待开发软件的预设类型代码信息;
B、将各个预设类型代码信息转换成预设类型哈希值,并保存预设类型代码信息与预设类型哈希值的映射关系数据;
C、在编译待开发软件的代码过程中,实时或者定时侦测编译的代码中是否含有保存的预设类型代码信息;
D、若侦测到编译的代码中含有预设类型代码信息,则根据保存的映射关系数据将编译的代码中的预设类型代码信息替换为与其相对应的预设类型哈希值。
优选地,哈希值的哈希值类型有多个,代码信息的信息类型有多个;处理器执行代码混淆程序实现将各个预设类型代码信息转换成预设类型哈希值的步骤包括:
根据代码信息的信息类型与哈希值的哈希值类型的映射关系,确定各个预设类型代码信息对应的哈希值类型;
将各个预设类型代码信息转换成对应的哈希值类型的哈希值。
优选地,处理器执行代码混淆程序实现保存预设类型代码信息与预设类型哈希值的映射关系数据的步骤包括:
新建一个代码编译混淆文件;
将各个预设类型代码信息与对应的预设类型哈希值一一关联映射、并存储在代码编译混淆文件中;代码编译混淆文件中包含映射关系数据表,该映射关系数据表中至少包含两列,一列存储有各个预设类型代码信息,另一列存储有与各个预设类型代码信息对应的预设类型哈希值;
相互对应的预设类型代码信息和预设类型哈希值处于该映射关系数据表的同一行,不对应的预设类型代码信息和预设类型哈希值处于该映射关系 数据表的不同行。
优选地,处理器执行代码混淆程序实现步骤B之后,还用于执行代码混淆程序以实现以下步骤:
在编译待开发软件的代码之前,若收到用户发出的代码混淆的关闭指令,则将保存的预设类型代码信息与预设类型哈希值的映射关系数据删除,并在编译待开发软件的代码过程中不进行代码混淆处理;
及/或,若在编译待开发软件的代码过程中,收到用户发出的代码混淆的关闭指令,则将已替换的预设类型哈希值还原成对应的预设类型代码信息,并在代码信息还原完成后将保存的预设类型代码信息与预设类型哈希值的映射关系数据删除,并在后续编译待开发软件的代码过程中不进行混淆处理。
为了实现上述目的,本发明还提出了一种计算机可读存储介质,该计算机可读存储介质存储有代码混淆程序,代码混淆程序被处理器执行时实现上述任一实施例中的代码混淆方法。
本发明的有益效果是:通过将待开发软件的预设类型代码信息转换为与其对应的预设类型哈希值并保存预设类型代码信息与预设类型哈希值之间的映射关系数据,在软件开发过程中,根据保存的映射关系数据将编译的代码中含有的预设类型代码信息替换为与其相对应的预设类型哈希值,而预设类型哈希值为不可读的代码且具有不可逆性和唯一性,因此,极大地避免了软件开发过程中存在的被攻击与逆向的分险。
附图说明
图1为本发明一实施例的流程示意图;
图2为图1所示步骤S2的细化流程示意图;
图3为本发明的代码混淆系统一实施例的运行环境示意图;
图4为本发明一实施例的系统结构示意图;
图5为图4所示存储模块的结构示意图。
具体实施方式
以下结合附图对本发明的原理和特征进行描述,所举实施例只用于解释本发明,并非用于限定本发明的范围。
如图1所示,图1为本发明一实施例的流程示意图,在该实施例中,包括以下步骤:
S11,获取并统计待开发软件的预设类型代码信息。具体地,获取的预设类型代码信息包括代码中的类名、变量名以及函数名。
S12,将各个预设类型代码信息转换成预设类型哈希值,并保存预设类型代码信息与预设类型哈希值的映射关系数据。
S13,在编译待开发软件的代码过程中,实时或者定时侦测编译的代码中是否含有保存的预设类型代码信息。
S14,若侦测到编译的代码中含有预设类型代码信息,则根据保存的映 射关系数据将编译的代码中的预设类型代码信息替换为与其相对应的预设类型哈希值。
具体如图2所示,步骤S12包括如下步骤:
S12-1:确定各个预设类型代码信息对应的哈希值的哈希值类型。具体为,根据代码信息的信息类型与哈希值的哈希值类型的映射关系,确定各个预设类型代码信息对应的哈希值类型。
其中,哈希值类型包括MD5值,且MD5值为不可读的代码并具有不可逆性和唯一性。
S12-2:将各个预设类型代码信息转换成对应的哈希值的哈希值类型。其中,哈希值的哈希值类型为预设类型哈希值。
S12-3:新建一个代码编译混淆文件。
S12-4:将各个预设类型代码信息与对应的预设类型哈希值一一关联映射并存储在代码编译混淆文件中。
例如,在代码编译混淆文件中建立映射关系数据表,该映射关系数据表中至少包含两列,一列用于存储各个预设类型代码信息,另一列用于存储与各个预设类型代码信息对应的预设类型哈希值,相互对应的预设类型代码信息和预设类型哈希值处于该映射关系数据表的同一行,不对应的预设类型代码信息和预设类型哈希值处于该映射关系数据表的不同行。
在本实施例中,具体为根据代码中的类名、变量名以及函数名与各自对应的MD5值之间的映射关系,确定代码中的类名、变量名以及函数名对应的MD5值的类型,并将代码中的类名、变量名以及函数名转换成对应的MD5值的类型。
可以理解地,为了提高安全性,提高混淆代码的破译难度,哈希值的哈希值类型有多个,代码信息的信息类型也有多个。
在一优选的实施例中,在上述图1的实施例的基础上,在编译待开发软件的代码之前,若收到用户发出的代码混淆的关闭指令,则将保存的预设类型代码信息与预设类型哈希值的映射关系数据删除,并在编译待开发软件的代码过程中不进行代码混淆处理。
进一步可以理解地,若在编译待开发软件的代码过程中,收到用户发出的代码混淆的关闭指令,则将已替换的预设类型哈希值还原成对应的预设类型代码信息,并在代码信息还原完成后将保存的预设类型代码信息与预设类型哈希值的映射关系数据删除,并在后续编译待开发软件的代码过程中不进行混淆处理。
其中,关闭指令包括用户发出的删除保存的预设类型代码信息与预设类型哈希值的映射关系数据的指令。
由上述实施例可知,软件项目开发人员利用本发明的技术方案在开发软件时将项目中关键的类名、变量名与函数名统计出来,转成相对应的MD5值,再新建一个文件,通过宏定义,将类名、变量名与函数名与它们所对应的MD5值一一对应起来,项目上线的时候,将该文件导入到项目中,代码 编译的时候会通过宏定义而自动将代码中的类名、变量名与函数名替换成各自的MD5值,这样即使有黑客去破解开发的软件,得到的也是不可读的、唯一的以及不可逆向的哈希值,因此可以极大的避免被攻击与逆向。并且在实施本发明的技术方案时,程序员完全不需要去考虑代码的混淆,当需要混淆的时候,只需要导入统计好的混淆文件即可,如果不需要混淆,删除文件即可,完全不影响现有的开发模式与方法。
与现有技术相比,本实施例通过获取并统计待开发软件的预设类型代码信息,并将预设类型代码信息转换为预设类型哈希值,并保存预设类型代码信息与预设类型哈希值之间的映射关系数据,在编译待开发软件的代码过程中,根据保存的映射关系将编译的代码中的预设类型代码信息替换为与其相对应的预设类型哈希值,来增强软件开发过程中的安全性,减少源码被攻击逆向的分险。
如图3所示,是本发明的代码混淆系统10较佳实施例的运行环境示意图。
在本实施例中,代码混淆系统10安装并运行于代码混淆装置1中。代码混淆装置1可以是桌上型计算机、笔记本、掌上电脑及服务器等计算设备。代码混淆装置1可包括,但不仅限于,存储器11及处理器12。图3仅示出了具有组件11和组件12的代码混淆装置1,但是应理解的是,并不要求实施所有示出的组件,可以替代的实施更多或者更少的组件。
存储器11在一些实施例中可以是代码混淆装置1的内部存储单元,例如代码混淆装置1的硬盘或内存。存储器11在另一些实施例中也可以是代码混淆装置1的外部存储设备,例如代码混淆装置1上配备的插接式硬盘,智能存储卡(Smart Media Card,SMC),安全数字(Secure Digital,SD)卡,闪存卡(Flash Card)等。进一步地,存储器11还可以既包括代码混淆装置1的内部存储单元也包括外部存储设备。存储器11用于存储安装于代码混淆装置1的应用软件及各类数据,例如代码混淆系统10的程序代码等。存储器11还可以用于暂时地存储已经输出或者将要输出的数据。
处理器12在一些实施例中可以是一中央处理器(Central Processing Unit,CPU),微处理器或其他数据处理芯片,用于运行存储器11中存储的程序代码或处理数据,例如执行代码混淆系统10等。
可以理解地,代码混淆装置1还可以包括显示器(图中未示出)在一些实施例中显示器可以是LED显示器、液晶显示器、触控式液晶显示器以及OLED(Organic Light-Emitting Diode,有机发光二极管)触摸器等。显示器用于显示在代码混淆装置1中处理的信息以及用于显示可视化的用户界面,例如APP安装界面等。代码混淆装置1的部件11和部件12之间通过系统总线相互通信。
需要说明的是,在本实施例中,存储器11与处理器12分别是不同的部件,在本发明的其他实施例中,存储器11与处理器12集成在一起形成一个控制器,在此不做赘述。
在本发明的其他实施例中,代码混淆装置1可以不包括显示器,用户将编写的代码发送给代码混淆装置1后,由代码混淆装置1中运行的代码混淆系统对接收的代码进行混淆处理,在此不做赘述。
请参阅图4,是本发明代码混淆系统10较佳实施例的功能模块示意图。在本实施例中,代码混淆系统10可以被分割成一个或多个模块,一个或者多个模块被存储于存储器11中,并由一个或多个处理器(本实施例为处理器12)所执行,以完成本发明。例如,在图4中,代码混淆系统10可以被分割成获取模块101、存储模块102、侦测模块103及处理模块104。本发明所称的模块是指能够完成特定功能的一系列计算机程序指令段,比程序更适合于描述代码混淆系统10在代码混淆装置1中的执行过程,
进一步地,如图4所示,代码混淆系统10包括:
获取模块101,用于获取并统计待开发软件的预设类型代码信息。
存储模块102,用于将获取模块101获取的各个预设类型代码信息转换成预设类型哈希值,并保存预设类型代码信息与预设类型哈希值的映射关系数据。
侦测模块103,用于在编译待开发软件的代码过程中,实时或者定时侦测编译的代码中是否含有保存的预设类型代码信息。
处理模块104,用于在侦测模块103侦测到编译的代码中含有预设类型代码信息时,根据保存的映射关系数据将编译的代码中的预设类型代码信息替换为与其相对应的预设类型哈希值。
进一步地,由图5可知,存储模块102包括分析单元110和存储单元111。
分析单元110用于根据代码信息的信息类型与哈希值的哈希值类型的映射关系,确定各个预设类型代码信息对应的哈希值类型、并将各个预设类型代码信息转换成对应的哈希值类型的哈希值。
存储单元111用于新建一个代码编译混淆文件,将各个预设类型代码信息与对应的预设类型哈希值一一关联映射、并存储在代码编译混淆文件中。
进一步地,在图4所示实施例的基础上,该系统还包括控制模块(控制模块图4未示出)。控制模块,在编译待开发软件的代码之前,若收到用户发出的代码混淆的关闭指令,则将保存的预设类型代码信息与预设类型哈希值的映射关系数据删除,并在编译待开发软件的代码过程中不进行代码混淆处理。
若在编译所述待开发软件的代码过程中,收到用户发出的代码混淆的关闭指令,则将已替换的所述预设类型哈希值还原成对应的所述预设类型代码信息,并在代码信息还原完成后将保存的预设类型代码信息与预设类型哈希值的映射关系数据删除,并在后续编译待开发软件的代码过程中不进行混淆处理。
与现有技术相比,本实施例通过获取并统计待开发软件的预设类型代码信息,并将预设类型代码信息转换为预设类型哈希值,并保存预设类型代码信息与预设类型哈希值之间的映射关系数据,在编译待开发软件的代码过程 中,根据保存的映射关系将编译的代码中的预设类型代码信息替换为与其相对应的预设类型哈希值,来增强软件开发过程中的安全性,减少源码被攻击逆向的分险。
以上所述仅为本发明的较佳实施例,并不用以限制本发明,凡在本发明的精神和原则之内,所作的任何修改、等同替换、改进等,均应包含在本发明的保护范围之内。

Claims (20)

  1. 一种代码混淆方法,其特征在于,所述方法包括如下步骤:
    A、获取并统计待开发软件的预设类型代码信息;
    B、将各个所述预设类型代码信息转换成预设类型哈希值,并保存所述预设类型代码信息与所述预设类型哈希值的映射关系数据;
    C、在编译所述待开发软件的代码过程中,实时或者定时侦测编译的代码中是否含有保存的所述预设类型代码信息;
    D、若侦测到编译的代码中含有所述预设类型代码信息,则根据保存的所述映射关系数据将编译的代码中的所述预设类型代码信息替换为与其相对应的所述预设类型哈希值。
  2. 根据权利要求1所述的代码混淆方法,其特征在于,所述哈希值的哈希值类型有多个,所述代码信息的信息类型有多个;所述将各个所述预设类型代码信息转换成预设类型哈希值的步骤包括:
    根据代码信息的信息类型与哈希值的哈希值类型的映射关系,确定各个所述预设类型代码信息对应的哈希值类型;
    将各个所述预设类型代码信息转换成对应的哈希值类型的哈希值。
  3. 根据权利要求1所述的代码混淆方法,其特征在于,所述保存所述预设类型代码信息与所述预设类型哈希值的映射关系数据的步骤包括:
    新建一个代码编译混淆文件;
    将各个所述预设类型代码信息与对应的所述预设类型哈希值一一关联映射、并存储在所述代码编译混淆文件中;所述代码编译混淆文件中包含映射关系数据表,该映射关系数据表中至少包含两列,一列存储有各个预设类型代码信息,另一列存储有与各个预设类型代码信息对应的预设类型哈希值;相互对应的预设类型代码信息和预设类型哈希值处于该映射关系数据表的同一行,不对应的预设类型代码信息和预设类型哈希值处于该映射关系数据表的不同行。
  4. 根据权利要求2所述的代码混淆方法,其特征在于,所述保存所述预设类型代码信息与所述预设类型哈希值的映射关系数据的步骤包括:
    新建一个代码编译混淆文件;
    将各个所述预设类型代码信息与对应的所述预设类型哈希值一一关联映射、并存储在所述代码编译混淆文件中;所述代码编译混淆文件中包含映射关系数据表,该映射关系数据表中至少包含两列,一列存储有各个预设类型代码信息,另一列存储有与各个预设类型代码信息对应的预设类型哈希值;
    相互对应的预设类型代码信息和预设类型哈希值处于该映射关系数据表的同一行,不对应的预设类型代码信息和预设类型哈希值处于该映射关系数据表的不同行。
  5. 根据权利要求1所述的代码混淆方法,其特征在于,在所述步骤B之后,该方法还包括如下步骤:
    在编译所述待开发软件的代码之前,若收到用户发出的代码混淆的关闭指令,则将保存的所述预设类型代码信息与所述预设类型哈希值的映射关系数据删除,并在编译所述待开发软件的代码过程中不进行代码混淆处理;
    及/或,若在编译所述待开发软件的代码过程中,收到用户发出的代码混淆的关闭指令,则将已替换的所述预设类型哈希值还原成对应的所述预设类型代码信息,并在代码信息还原完成后将保存的所述预设类型代码信息与所述预设类型哈希值的映射关系数据删除,并在后续编译所述待开发软件的代码过程中不进行混淆处理。
  6. 一种代码混淆装置,其特征在于,所述装置包括:存储器、处理器及存储在所述存储器上并可在所述处理器上运行的代码混淆程序,所述代码混淆程序被所述处理器执行时执行以下步骤:
    A、获取并统计待开发软件的预设类型代码信息;
    B、将各个所述预设类型代码信息转换成预设类型哈希值,并保存所述预设类型代码信息与所述预设类型哈希值的映射关系数据;
    C、在编译所述待开发软件的代码过程中,实时或者定时侦测编译的代码中是否含有保存的所述预设类型代码信息;
    D、若侦测到编译的代码中含有所述预设类型代码信息,则根据保存的所述映射关系数据将编译的代码中的所述预设类型代码信息替换为与其相对应的所述预设类型哈希值。
  7. 根据权利要求6所述的代码混淆装置,其特征在于,所述哈希值的哈希值类型有多个,所述代码信息的信息类型有多个;所述处理器执行所述代码混淆程序实现将各个所述预设类型代码信息转换成预设类型哈希值的步骤包括:
    根据代码信息的信息类型与哈希值的哈希值类型的映射关系,确定各个所述预设类型代码信息对应的哈希值类型;
    将各个所述预设类型代码信息转换成对应的哈希值类型的哈希值。
  8. 根据权利要求6所述的代码混淆装置,其特征在于,所述处理器执行所述代码混淆程序实现所述保存所述预设类型代码信息与所述预设类型哈希值的映射关系数据的步骤包括:
    新建一个代码编译混淆文件;
    将各个所述预设类型代码信息与对应的所述预设类型哈希值一一关联映射、并存储在所述代码编译混淆文件中;所述代码编译混淆文件中包含映射关系数据表,该映射关系数据表中至少包含两列,一列存储有各个预设类型代码信息,另一列存储有与各个预设类型代码信息对应的预设类型哈希值;
    相互对应的预设类型代码信息和预设类型哈希值处于该映射关系数据表的同一行,不对应的预设类型代码信息和预设类型哈希值处于该映射关系数据表的不同行。
  9. 根据权利要求6所述的代码混淆装置,其特征在于,所述处理器执行所述代码混淆程序实现所述保存所述预设类型代码信息与所述预设类型哈 希值的映射关系数据的步骤包括:
    新建一个代码编译混淆文件;
    将各个所述预设类型代码信息与对应的所述预设类型哈希值一一关联映射、并存储在所述代码编译混淆文件中;所述代码编译混淆文件中包含映射关系数据表,该映射关系数据表中至少包含两列,一列存储有各个预设类型代码信息,另一列存储有与各个预设类型代码信息对应的预设类型哈希值;
    相互对应的预设类型代码信息和预设类型哈希值处于该映射关系数据表的同一行,不对应的预设类型代码信息和预设类型哈希值处于该映射关系数据表的不同行。
  10. 根据权利要求6所述的代码混淆装置,其特征在于,所述处理器执行所述代码混淆程序实现步骤B之后,还用于执行所述代码混淆程序以实现以下步骤:
    在编译所述待开发软件的代码之前,若收到用户发出的代码混淆的关闭指令,则将保存的所述预设类型代码信息与所述预设类型哈希值的映射关系数据删除,并在编译所述待开发软件的代码过程中不进行代码混淆处理;
    及/或,若在编译所述待开发软件的代码过程中,收到用户发出的代码混淆的关闭指令,则将已替换的所述预设类型哈希值还原成对应的所述预设类型代码信息,并在代码信息还原完成后将保存的所述预设类型代码信息与所述预设类型哈希值的映射关系数据删除,并在后续编译所述待开发软件的代码过程中不进行混淆处理。
  11. 一种计算机可读存储介质,其特征在于,所述计算机可读存储介质存储有代码混淆程序,所述代码混淆程序被处理器执行时,可实现如下步骤:
    A、获取并统计待开发软件的预设类型代码信息;
    B、将各个所述预设类型代码信息转换成预设类型哈希值,并保存所述预设类型代码信息与所述预设类型哈希值的映射关系数据;
    C、在编译所述待开发软件的代码过程中,实时或者定时侦测编译的代码中是否含有保存的所述预设类型代码信息;
    D、若侦测到编译的代码中含有所述预设类型代码信息,则根据保存的所述映射关系数据将编译的代码中的所述预设类型代码信息替换为与其相对应的所述预设类型哈希值。
  12. 根据权利要求11所述的计算机可读存储介质,其特征在于,所述哈希值的哈希值类型有多个,所述代码信息的信息类型有多个;所述将各个所述预设类型代码信息转换成预设类型哈希值的步骤包括:
    根据代码信息的信息类型与哈希值的哈希值类型的映射关系,确定各个所述预设类型代码信息对应的哈希值类型;
    将各个所述预设类型代码信息转换成对应的哈希值类型的哈希值。
  13. 根据权利要求11所述的计算机可读存储介质,其特征在于,所述保存所述预设类型代码信息与所述预设类型哈希值的映射关系数据的步骤包括:
    新建一个代码编译混淆文件;
    将各个所述预设类型代码信息与对应的所述预设类型哈希值一一关联映射、并存储在所述代码编译混淆文件中;所述代码编译混淆文件中包含映射关系数据表,该映射关系数据表中至少包含两列,一列存储有各个预设类型代码信息,另一列存储有与各个预设类型代码信息对应的预设类型哈希值;相互对应的预设类型代码信息和预设类型哈希值处于该映射关系数据表的同一行,不对应的预设类型代码信息和预设类型哈希值处于该映射关系数据表的不同行。
  14. 根据权利要求12所述的计算机可读存储介质,其特征在于,所述保存所述预设类型代码信息与所述预设类型哈希值的映射关系数据的步骤包括:
    新建一个代码编译混淆文件;
    将各个所述预设类型代码信息与对应的所述预设类型哈希值一一关联映射、并存储在所述代码编译混淆文件中;所述代码编译混淆文件中包含映射关系数据表,该映射关系数据表中至少包含两列,一列存储有各个预设类型代码信息,另一列存储有与各个预设类型代码信息对应的预设类型哈希值;
    相互对应的预设类型代码信息和预设类型哈希值处于该映射关系数据表的同一行,不对应的预设类型代码信息和预设类型哈希值处于该映射关系数据表的不同行。
  15. 根据权利要求11所述的计算机可读存储介质,其特征在于,在所述步骤B之后,所述代码混淆程序被处理器执行时,还可实现如下步骤:
    在编译所述待开发软件的代码之前,若收到用户发出的代码混淆的关闭指令,则将保存的所述预设类型代码信息与所述预设类型哈希值的映射关系数据删除,并在编译所述待开发软件的代码过程中不进行代码混淆处理;
    及/或,若在编译所述待开发软件的代码过程中,收到用户发出的代码混淆的关闭指令,则将已替换的所述预设类型哈希值还原成对应的所述预设类型代码信息,并在代码信息还原完成后将保存的所述预设类型代码信息与所述预设类型哈希值的映射关系数据删除,并在后续编译所述待开发软件的代码过程中不进行混淆处理。
  16. 一种代码混淆系统,其特征在于,所述代码混淆系统存储于存储器中,并可被至少一处理器执行,以实现如下步骤:
    A、获取并统计待开发软件的预设类型代码信息;
    B、将各个所述预设类型代码信息转换成预设类型哈希值,并保存所述预设类型代码信息与所述预设类型哈希值的映射关系数据;
    C、在编译所述待开发软件的代码过程中,实时或者定时侦测编译的代码中是否含有保存的所述预设类型代码信息;
    D、若侦测到编译的代码中含有所述预设类型代码信息,则根据保存的所述映射关系数据将编译的代码中的所述预设类型代码信息替换为与其相对应的所述预设类型哈希值。
  17. 根据权利要求16所述的代码混淆系统,其特征在于,所述哈希值的哈希值类型有多个,所述代码信息的信息类型有多个;所述将各个所述预设类型代码信息转换成预设类型哈希值的步骤包括:
    根据代码信息的信息类型与哈希值的哈希值类型的映射关系,确定各个所述预设类型代码信息对应的哈希值类型;
    将各个所述预设类型代码信息转换成对应的哈希值类型的哈希值。
  18. 根据权利要求16所述的代码混淆系统,其特征在于,所述保存所述预设类型代码信息与所述预设类型哈希值的映射关系数据的步骤包括:
    新建一个代码编译混淆文件;
    将各个所述预设类型代码信息与对应的所述预设类型哈希值一一关联映射、并存储在所述代码编译混淆文件中;所述代码编译混淆文件中包含映射关系数据表,该映射关系数据表中至少包含两列,一列存储有各个预设类型代码信息,另一列存储有与各个预设类型代码信息对应的预设类型哈希值;相互对应的预设类型代码信息和预设类型哈希值处于该映射关系数据表的同一行,不对应的预设类型代码信息和预设类型哈希值处于该映射关系数据表的不同行。
  19. 根据权利要求17所述的代码混淆系统,其特征在于,所述保存所述预设类型代码信息与所述预设类型哈希值的映射关系数据的步骤包括:
    新建一个代码编译混淆文件;
    将各个所述预设类型代码信息与对应的所述预设类型哈希值一一关联映射、并存储在所述代码编译混淆文件中;所述代码编译混淆文件中包含映射关系数据表,该映射关系数据表中至少包含两列,一列存储有各个预设类型代码信息,另一列存储有与各个预设类型代码信息对应的预设类型哈希值;
    相互对应的预设类型代码信息和预设类型哈希值处于该映射关系数据表的同一行,不对应的预设类型代码信息和预设类型哈希值处于该映射关系数据表的不同行。
  20. 根据权利要求16所述的代码混淆系统,其特征在于,在所述步骤B之后,所述代码混淆系统被处理器执行时,还可实现如下步骤:
    在编译所述待开发软件的代码之前,若收到用户发出的代码混淆的关闭指令,则将保存的所述预设类型代码信息与所述预设类型哈希值的映射关系数据删除,并在编译所述待开发软件的代码过程中不进行代码混淆处理;
    及/或,若在编译所述待开发软件的代码过程中,收到用户发出的代码混淆的关闭指令,则将已替换的所述预设类型哈希值还原成对应的所述预设类型代码信息,并在代码信息还原完成后将保存的所述预设类型代码信息与所述预设类型哈希值的映射关系数据删除,并在后续编译所述待开发软件的代码过程中不进行混淆处理。
PCT/CN2017/105006 2017-05-10 2017-09-30 代码混淆方法、装置及计算机可读存储介质 Ceased WO2018205494A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201710327381.8 2017-05-10
CN201710327381.8A CN107766702A (zh) 2017-05-10 2017-05-10 代码混淆方法、装置及计算机可读存储介质

Publications (1)

Publication Number Publication Date
WO2018205494A1 true WO2018205494A1 (zh) 2018-11-15

Family

ID=61265760

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2017/105006 Ceased WO2018205494A1 (zh) 2017-05-10 2017-09-30 代码混淆方法、装置及计算机可读存储介质

Country Status (2)

Country Link
CN (1) CN107766702A (zh)
WO (1) WO2018205494A1 (zh)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113805888A (zh) * 2021-01-27 2021-12-17 北京沃东天骏信息技术有限公司 一种代码文件编译方法和装置

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101807239A (zh) * 2010-03-29 2010-08-18 山东高效能服务器和存储研究院 一种防止源代码反编译的方法
CN105103127A (zh) * 2013-02-28 2015-11-25 微软技术许可有限责任公司 基于编译器的混淆
CN106203085A (zh) * 2016-07-08 2016-12-07 东软集团股份有限公司 一种编译方法及装置
CN106203007A (zh) * 2015-05-08 2016-12-07 腾讯科技(深圳)有限公司 一种代码处理方法、装置及计算设备
CN106326693A (zh) * 2016-08-18 2017-01-11 广州优视网络科技有限公司 应用程序的代码混淆方法及装置

Family Cites Families (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104504313A (zh) * 2014-12-31 2015-04-08 北京畅游天下网络技术有限公司 一种对代码进行保密处理的方法及装置
US9582666B1 (en) * 2015-05-07 2017-02-28 Shape Security, Inc. Computer system for improved security of server computers interacting with client computers
CN105975816B (zh) * 2015-12-25 2019-06-07 武汉安天信息技术有限责任公司 移动终端下基于虚拟技术的代码保护方法及系统

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101807239A (zh) * 2010-03-29 2010-08-18 山东高效能服务器和存储研究院 一种防止源代码反编译的方法
CN105103127A (zh) * 2013-02-28 2015-11-25 微软技术许可有限责任公司 基于编译器的混淆
CN106203007A (zh) * 2015-05-08 2016-12-07 腾讯科技(深圳)有限公司 一种代码处理方法、装置及计算设备
CN106203085A (zh) * 2016-07-08 2016-12-07 东软集团股份有限公司 一种编译方法及装置
CN106326693A (zh) * 2016-08-18 2017-01-11 广州优视网络科技有限公司 应用程序的代码混淆方法及装置

Also Published As

Publication number Publication date
CN107766702A (zh) 2018-03-06

Similar Documents

Publication Publication Date Title
US11507671B1 (en) Detection and healing of vulnerabilities in computer code
Ligh et al. The art of memory forensics: detecting malware and threats in windows, linux, and Mac memory
JP7053486B2 (ja) メタデータ処理のための技法
Lu et al. How to Make ASLR Win the Clone Wars: Runtime Re-Randomization.
US7861305B2 (en) Method and system for hardware based program flow monitor for embedded software
CN109583200B (zh) 一种基于动态污点传播的程序异常分析方法
US9229746B2 (en) Identifying load-hit-store conflicts
CN103324481B (zh) 通过汇编实现代码混淆的编译方法和系统
US20170017789A1 (en) High Performance Software Vulnerabilities Detection System and Methods
CN111868694A (zh) 在时间旅行跟踪调试中保护敏感信息
CN107480476B (zh) 一种基于ELF感染的Android本地层指令编译虚拟化加壳方法
Coppens et al. Feedback-driven binary code diversification
Livshits Dynamic taint tracking in managed runtimes
CN110088736B (zh) 自调试方法和系统
CN107526970B (zh) 基于动态二进制平台检测运行时程序漏洞的方法
CN105683985A (zh) 虚拟机内省
CN103116715A (zh) Windows平台可执行文件API延迟导入保护方法
CN104252596A (zh) 一种脚本病毒的监控方法及装置
CN104317723B (zh) 一种驱动程序运行信息的跟踪方法及系统
US9411363B2 (en) Synchronization in a computing device
CN108446186B (zh) 从加壳Android应用程序中恢复Dex源文件的方法
CN107368713B (zh) 保护软件的方法和安全组件
WO2018205494A1 (zh) 代码混淆方法、装置及计算机可读存储介质
Wang et al. Offdtan: A new approach of offline dynamic taint analysis for binaries
Pagani Advances in memory forensics

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 17909631

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 17909631

Country of ref document: EP

Kind code of ref document: A1