WO2015101042A1 - 检测智能终端中恶意代码的方法及装置 - Google Patents

检测智能终端中恶意代码的方法及装置 Download PDF

Info

Publication number
WO2015101042A1
WO2015101042A1 PCT/CN2014/083908 CN2014083908W WO2015101042A1 WO 2015101042 A1 WO2015101042 A1 WO 2015101042A1 CN 2014083908 W CN2014083908 W CN 2014083908W WO 2015101042 A1 WO2015101042 A1 WO 2015101042A1
Authority
WO
WIPO (PCT)
Prior art keywords
function
virtual machine
information structure
malicious code
sequence
Prior art date
Application number
PCT/CN2014/083908
Other languages
English (en)
French (fr)
Inventor
杨康
陈卓
唐海
Original Assignee
北京奇虎科技有限公司
奇智软件(北京)有限公司
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 北京奇虎科技有限公司, 奇智软件(北京)有限公司 filed Critical 北京奇虎科技有限公司
Publication of WO2015101042A1 publication Critical patent/WO2015101042A1/zh

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F21/00Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
    • G06F21/50Monitoring users, programs or devices to maintain the integrity of platforms, e.g. of processors, firmware or operating systems
    • G06F21/55Detecting local intrusion or implementing counter-measures
    • G06F21/56Computer malware detection or handling, e.g. anti-virus arrangements
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F21/00Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
    • G06F21/50Monitoring users, programs or devices to maintain the integrity of platforms, e.g. of processors, firmware or operating systems
    • G06F21/55Detecting local intrusion or implementing counter-measures
    • G06F21/56Computer malware detection or handling, e.g. anti-virus arrangements
    • G06F21/562Static detection

Definitions

  • the present invention relates to the field of intelligent terminal security technologies, and in particular, to a method and apparatus for detecting malicious code in an intelligent terminal. Background technique
  • the present invention has been made in order to provide a method and apparatus for detecting malicious code in an intelligent terminal that overcomes the above problems or at least partially solves the above problems.
  • a method for detecting malicious code in an intelligent terminal includes: obtaining a virtual machine execution file of an application from an application layer of the smart terminal operating system; decompiling the virtual machine execution file Obtaining a decompiled function information structure; parsing the decompiled function information structure, extracting a function call sequence in the decompiled function information structure; using the pre-set malicious code feature library, calling the sequence of the function A match is made, and if the match is successful, it is determined that the virtual machine execution file of the application contains malicious code.
  • an apparatus for detecting malicious code in an intelligent terminal comprising: a file obtaining unit, configured to acquire a virtual machine execution file of an application from an application layer of a smart terminal operating system; And decompiling the virtual machine execution file to obtain a decompiled function information structure; an extracting unit, configured to parse the decompiled function information structure, and extracting a function in the decompiled function information structure a calling sequence; the detecting unit is configured to match the function calling sequence by using a preset malicious code feature library, and if the matching is successful, determining that the virtual machine execution file of the application includes malicious code.
  • the embodiment of the present invention obtains a function call sequence by analyzing and decompiling the dex file format, and matching the malicious code feature library by using the function call sequence as a basic feature to determine whether the dex file contains malicious code.
  • the function of the function can be analyzed. Therefore, the code of a series of function call sequences can be used as a target feature to match the malicious code feature library to determine whether the dex file contains malicious code.
  • the dex file of the application can be analyzed to determine whether the application contains malicious code, thereby tampering with the falsified application or the malware, and protecting the security of the smart terminal.
  • FIG. 1 shows a flow diagram of a method of detecting malicious code in a smart terminal, in accordance with one embodiment of the present invention
  • FIG. 2 is a block diagram showing the structure of an apparatus for detecting malicious code in a smart terminal according to an embodiment of the present invention
  • Fig. 3 shows a block diagram of an intelligent electronic device for carrying out the method according to the invention
  • Fig. 4 shows a schematic diagram of a storage unit for holding or carrying program code implementing the method according to the invention.
  • the app layer can be understood as the upper layer, which is responsible for interacting with the user, such as application maintenance, and identifying different kinds of click content when the page is clicked to display different context menus.
  • the framework layer acts as the middle layer. The main responsibility of this layer is to get the user request obtained by the app layer, such as launching the application, clicking the link, clicking to save the image, etc., forwarding to the lower layer; , or through the message, or through the intermediate proxy class, to the upper layer, to show the user.
  • Dalvik is a Java virtual machine for the Android platform. Dalvik is optimized to allow multiple instances of virtual machines to run simultaneously in limited memory, and each Dalvik application executes as a separate Linux process. A separate process prevents all programs from being closed when the virtual machine crashes.
  • the Dalvik virtual machine can support the running of Java applications that have been converted to dex (Dalvik Executable) format.
  • the dex format is a compression format designed for Dalvik, suitable for systems with limited memory and processor speed.
  • the dex file is a virtual machine executable file that can be directly run in the Dalvik VM (Dalvik VM).
  • Dalvik VM Dalvik VM
  • ADT Android Development Tools
  • the j a va source code can be converted to a dex file after complicated compilation.
  • the dex file is the result of optimization for the embedded system.
  • the Dalvik virtual machine's script is not a standard Java virtual machine script, but instead uses its own unique set of instructions.
  • the dex file shares a lot of class names and constant strings, making it smaller in size and more efficient.
  • the inventor of the present invention found in the research process that after parsing the dex file, the function of the function in the dex file can be known, thereby determining whether the dex file contains malicious code (including the dex file itself is malware, or The dex file has been tampered with, etc.).
  • FIG. 1 there is shown a flow diagram of a method of detecting malicious code in a smart terminal, in accordance with one embodiment of the present invention.
  • the method for detecting malicious code in a smart terminal includes the following steps.
  • S101 Obtain a virtual machine execution file of the application from an application layer of the smart terminal operating system, for example, obtain a dex file of the application;
  • the Android operating system includes an application layer (app layer) and a system framework layer (framework layer), and the present invention focuses on the research and improvement of the app layer.
  • apps layer application layer
  • framework layer framework layer
  • the present invention focuses on the research and improvement of the app layer.
  • the Dalvik VM monitors all programs (APK files) and frameworks and creates a dependency tree for them.
  • the Da 1 V i k VM optimizes the code for each program through this dependency tree and stores it in the Dalvik cache (dalvik-cache). This way, all programs will use optimized code at runtime.
  • a program or framework library
  • the Dalvik VM will re-optimize the code and store it again in the cache.
  • the cache/dalvik-cache is the dex file generated by the program stored on the system
  • the data/dalvik-cacheJ ⁇ J is the dex file generated by the data/app. That is, the present invention focuses on the analysis and processing of the dex file generated by the data/app, but it should be understood that the theory and operation of the present invention are equally applicable to the dex file generated by the program on the system.
  • the way to get the dex file can be obtained by parsing the APK (Android Package, Android installation package).
  • the APK file is actually a zip file, but the suffix name is modified to apk. After UnZip decompression, you can get the Dex file.
  • the first way is to parse the dex file according to the dex file format to obtain the function information structure of each class; according to the field in the function information structure, determine the position and size of the function of the dex file, and obtain the decompiled function.
  • Information structure wherein, by parsing the function information structure, a bytecode array field indicating the function position of the dex file and a list length field indicating the function size of the dex file are obtained, thereby determining the position and size of the function of the dex file.
  • the dex file is parsed, and the function information body of each class is found.
  • the function information structure contains the fields as shown in Table 1.
  • ins-S ize ushor t The number of words of the input parameter of the method in this code. outs -S ize ushor t This piece of code calls the method to provide space for the function's output function.
  • Tries-size ushor t The number of try_items for this object, if non-zero, it will appear as an array of tries behind the insns of this object.
  • debug-info-off uint Offset from file to debug info, if not The value of this information is 0. If it is not 0, it should represent a position of the data segment. The data must follow the format specified by debug-info-it em.
  • Padding ushor t with two padding bytes to satisfy the alignment of 4 bytes
  • Tries try. i tern [ This array is used to identify where the delegate may throw an exception and tr ies-S iz and how to handle it. Array elements must be sorted in ascending order by address, and no duplicate addresses can appear. This element is only in
  • Handlers encoded-c These bytes represent a list of exception types and their address lists for their atch-hand handlers. Each try_ item has an offset of ler.list byte width, only if the series _ si ze is not 0, (optional this element exists.
  • the insns-size and insns fields in each function information structure represent the Function size and location. Then, you can decompile the information structure of the function according to the two fields of insns_size and insns.
  • the decompiled information structure is composed of Dalvik VM bytecodes, which will be described in detail later.
  • the second way is to decompile the dex file into virtual machine bytecode using the dex file decompiler.
  • the Dalvik virtual machine runs Dalvik bytecode, which exists as a dex (Dalvik Executable) executable.
  • the Dalkvik virtual machine executes the code by interpreting the dex file.
  • dex file decompilation tools include: baksmali, Dedexer 1.26, dexdump, dexinspecto 03-12-12r, IDA Pro, androguard, dex2 jar, 010 Editor, etc.
  • the function information structure includes function execution code.
  • the virtual machine instruction sequence and the virtual machine mnemonic sequence are formed, as in the following example, the Dalvik VM instruction sequence and the Dalvik VM mnemonic.
  • the sequence constitutes a function information structure.
  • a function information structure obtained by decompiling a dex file according to an embodiment of the present invention is as follows:
  • the dex file is decompiled into the Dalvik VM instruction sequence and the Dalvik VM mnemonic ⁇
  • the first two digits of each line in the machine code field are the instruction sequence (the circled part on the left side of the above example), and the corresponding part of the instruction sequence is the mnemonic (on On the right side of the example, the part is circled, not all selected).
  • the mnemonic is mainly for user communication and code writing.
  • the dex file is decompiled to get the instruction sequence of the function: "125438 71 Oc 6e Oc 6e Oa 38 54 54 6e Oc 6e 54 6e Oc 6e Oc 38 72 Oa 39 12 38 54 6e 54 71 Oe 01 28 54 13 6e".
  • the mnemonic sequence is: "const/4 iget_ object if-eqz invoke—static move—result—object invoke—virtual move—result—object invoke—virtual move—result if-eqz iget-object iget-ob ject invoke —virtual move-re su 1 t-ob invoke invoke—virtual iget-ob invoke invoke—virtual move-re sul t-ob invoke invoke—virtual move-result-object if-eqz invoke-interf ace move-result if-nez Const/4 if-eqz iget-object invoke-virtual iget-object invoke-static return-void move goto iget-object const/16 invoke-virtual " .
  • a function call sequence can be extracted from the above mnemonic sequence.
  • a function call sequence is code that has semantic functions, such as code that has the functions of string decryption, creation of an instance, and the like described later.
  • call sequence of the function basically describes the behavior of the function.
  • the function sequence can be basically analyzed to determine the function of this function.
  • S104 Match the function call sequence by using a preset malicious code feature library, and if the matching is successful, determine that the application dex file contains malicious code.
  • Malicious Code refers to a program or code that spreads through a storage medium or network, destroys the integrity of the operating system without unauthorized authentication, and steals undisclosed secret information in the system.
  • a mobile phone malicious code is a malicious code that points to a handheld device such as a mobile phone or a PDA.
  • Mobile phone malicious code can be simply divided into duplicate malicious code and non-replicated malicious code.
  • the copy-type malicious code mainly includes virus (Virus) and worm (Worm).
  • the non-replicating malicious code mainly includes Trojan Horse, Rogue Software, Malicious Mobile Code and Rootki. t program, etc.
  • Mobile phone malicious code protection technology protects against malicious code.
  • the feature value scanning method requires pre-learning to establish a malicious code feature library, and the feature value stored in the malicious code feature library may be a continuous fixed string or a discontinuity in which several other uncertain characters are inserted in the middle.
  • the string determines the signature string; when scanning, it is based on malicious code.
  • i means code protection.
  • This type of defense; the program is mainly for polymorphism and variant viruses.
  • a so-called virtual machine is a complete computer system that runs in a completely isolated environment by software emulation with full hardware system functionality.
  • This program also known as software simulation, is a software analyzer that uses software methods to simulate and analyze program runs.
  • the first feature is the feature value scanning technology.
  • the virtual machine module is started to allow the encrypted code to decode itself. After decoding, the traditional code can be used.
  • the feature value scanning method is used for killing.
  • Another example is the heuristic scanning method. Heuristic scanning solutions focus on the constant variation of malicious code and in order to enhance the study of unknown malicious code.
  • Heuristic comes from artificial intelligence, which refers to "the ability to self-discover” or “the knowledge and skills to use certain methods or methods to determine things.”
  • Heuristic scanning of malicious code means that the scanning software can use the rules extracted from experience to discover the virus by analyzing the structure of the program and its behavior. Because malicious code is intended to achieve infection and destruction, the usual behavior has certain characteristics, such as non-conventional read and write files, termination itself, unconventional cut-in zero ring, and so on. Therefore, it is possible to judge whether a program is malicious code according to a specific behavior of scanning or a combination of multiple behaviors.
  • similar sample clustering can be performed on the target program. For example, the K-means clustering algorithm is used to cluster the similar samples determined by the analysis.
  • the core consists of two parts.
  • the first is a well-organized malicious code feature library, and the second is an efficient scanning algorithm (also known as a matching algorithm).
  • the matching algorithm is generally divided into a single mode matching algorithm and a multi-pattern matching algorithm.
  • Single pattern matching algorithms include BF (Brute-Force) algorithm, KMP (Knuth-Morr i s-Pra t t) algorithm, BM (Boerer-Moore) algorithm and QS (Quick Search) algorithm.
  • Multi-pattern matching algorithms include classical multi-pattern matching DFSA algorithm and multi-pattern matching algorithm based on ordered binary tree.
  • the matching algorithm can also be divided into a fuzzy matching algorithm and a similar matching algorithm.
  • BF algorithm it is a simple and intuitive single-pattern matching algorithm, which belongs to the fuzzy matching algorithm.
  • the basic idea is: First, compare the first character si in the main string with the first character t1 in the pattern t. If they are equal, continue to compare the subsequent characters one by one; otherwise, the second character in s s 2 is compared with tl, and so on, until each character in t is equal to a sequence of consecutive characters in s (matching success), returning the position of the first character in the sequence of characters in the main string; or in s A sequence of characters equal to t is not found (match failed) and 0 is returned.
  • KMP algorithm it is an improved pattern matching algorithm.
  • the biggest improvement for the BF algorithm is: Using the information of "partial matching" implied in the pattern, in the event of a mismatch, for the next comparison, the i pointer in the main string (pointing to the mismatched character) does not require backtracking, and the j pointer in the pattern (pointing to the next comparison position) is "sliding" backwards as far as possible. This sliding K is evaluated by the next function.
  • the KMP algorithm can be described as: H does not increase by 1 for pointers i and j respectively; if si is not equal to tj, then i does not change, j retreats to the position of next (j) and then compares, so looping until it finds in the main string The substring with the same pattern string or the same string after searching for the complete main string does not find the same string as the pattern string, and the algorithm ends.
  • the function call sequence is matched by using a preset malicious code feature library. If the matching is successful, it is determined that the application dex file contains malicious code.
  • the function call sequence is used as a killing target, and the function call sequence is checked and killed by using a preset malicious code feature library, for example, function similarity matching or function feature fuzzy matching.
  • a function with a certain function composed of a plurality of function call sequences is used as a target feature, and the target feature is checked and killed by using a preset malicious code feature library, for example, function similarity matching or function feature is performed. Fuzzy matching.
  • Detection for example, can use the sample feature killing (characteristic value scan) described above, based on virtual machine killing or heuristic killing, and similar sample clustering can also be performed.
  • the matching algorithm there is no limitation on the matching algorithm.
  • the fuzzy matching algorithm or the similar matching algorithm described above may be used.
  • the embodiment of the present invention obtains a function call sequence by analyzing and decompiling the dex file format, and matching the malicious code feature library by using the function call sequence as a basic feature to determine whether the dex file contains malicious code.
  • the function call sequence can be used to analyze the function of the function. Therefore, the code of a series of function call sequences can be used as a target feature to match the malicious code feature library to determine whether the dex file contains malicious code.
  • the dex file of the application can be analyzed to determine whether the application contains malicious code, thereby tampering with the falsified application or the malware, and protecting the security of the intelligent terminal.
  • an embodiment of the present invention further provides an apparatus for detecting malicious code in an intelligent terminal.
  • the device can be implemented by software, hardware or a combination of software and hardware.
  • the device may be a terminal device or a functional entity inside the device.
  • the device may refer to a functional module inside the mobile phone.
  • the device operates under the Andro i d operating system.
  • the apparatus includes a file acquisition unit 201, a decompilation unit 202, an extraction unit 203, and a detection unit 204.
  • the file obtaining unit 201 is configured to obtain, from an application layer of the smart terminal operating system, a virtual machine execution file of the application, for example, acquiring a dex file;
  • the decompilation unit 202 is configured to decompile the dex file to obtain a decompiled function information structure;
  • the extracting unit 203 is configured to parse the decompiled function information structure, and extract a function calling sequence in the decompiled function information structure;
  • the detecting unit 204 is configured to match the function call sequence by using a preset malicious code feature library, and if the matching is successful, determine that the application dex file contains the malicious code.
  • the apparatus further comprises a parsing unit 205:
  • the parsing unit 205 is configured to obtain a virtual machine mnemonic sequence by parsing the decompiled function information structure
  • the extracting unit 203 extracts a function call sequence from the virtual machine mnemonic sequence.
  • the function call sequence is multiple; in this case, the device further includes:
  • the function function determining unit 206 is configured to determine the function of the function by analyzing the instructions of the plurality of function call sequences executed in sequence.
  • the instructions that the plurality of function call sequences determined by the function function determining unit 206 execute in order include: decrypting a string, creating a message signature instance, obtaining a string sub-needle, hashing encryption.
  • the detecting unit 204 is specifically configured to perform function similarity matching on the function calling sequence by using a preset malicious code feature library, and/or perform function feature fuzzy matching on the function calling sequence;
  • the detecting unit 204 is specifically configured to perform function similarity matching on the target feature by using a preset malicious code feature library, and/or perform function feature fuzzy matching on the target feature, where the target feature refers to the function function determining unit.
  • 206 determines a plurality of function call sequences to form a function having a certain function.
  • the detecting unit 204 performs sample feature killing on the dex file, based on virtual machine killing, heuristic killing, and/or similar sample clustering.
  • the decompilation unit 202 is specifically configured to parse the dex file according to the dex file format to obtain a function information structure of each class; and determine the position and size of the function of the dex file according to the field in the function information structure, Decompiled function information structure; further, the decompilation unit 202 is further configured to: parse the function information structure, obtain a bytecode array field indicating a function position of the dex file, and a list length field indicating a function size of the dex file; The section code array field and the list length field determine the position and size of the function of the dex file;
  • the decompilation unit 202 is specifically configured to decompile the dex file into a virtual machine bytecode by using a dex file decompilation tool.
  • the obtaining unit 201 is specifically configured to: find an installation package of the application from an application layer of the operating system of the smart terminal; parse the installation package, and obtain a dex file of the application.
  • modules in the devices of the embodiments can be adaptively changed and placed in one or more devices different from the embodiment.
  • the modules or units or components of the embodiments may be combined into one module or unit or component, and further they may be divided into a plurality of sub-modules or sub-units or sub-components.
  • any combination of the features disclosed in the specification, including the accompanying claims, the abstract and the drawings, and any methods so disclosed may be employed in any combination. Or combine all the processes or units of the device.
  • Each feature disclosed in the specification (including the accompanying claims, the abstract and the drawings) may be replaced by alternative features that provide the same, equivalent or similar purpose, unless otherwise stated.
  • the various component embodiments of the present invention may be implemented in hardware, or in a software module running on one or more processors, or in a combination thereof.
  • a microprocessor or digital signal processor may be used in practice to implement some or all of some or all of the means for detecting malicious code in a smart terminal in accordance with an embodiment of the present invention.
  • the invention can also be implemented as a device or device program (e.g., a computer program and a computer program product) for performing some or all of the methods described herein.
  • Such a program implementing the present invention may be stored on a computer readable medium or may have the form of one or more signals. Such signals may be downloaded from an Internet website, provided on a carrier signal, or provided in any other form.
  • FIG. 3 illustrates an intelligent electronic device that can implement a method of detecting malicious code in a smart terminal in accordance with the present invention.
  • the intelligent electronic device conventionally includes a processor 310 and a computer program product or computer readable medium in the form of a memory 320.
  • Memory 320 can be an electronic memory such as flash memory, EEPROM (Electrically Erasable Programmable Read Only Memory), EPROM, hard disk, or ROM.
  • the memory 320 has a memory space 330 for program code 331 for performing any of the method steps described above.
  • storage space 330 for program code may include various program code 331 for implementing various steps in the above methods, respectively.
  • the program code can be read from or written to one or more computer program products.
  • Computer program products include program code carriers such as hard disks, compact disks (CDs), memory cards or floppy disks.
  • program code carriers such as hard disks, compact disks (CDs), memory cards or floppy disks.
  • Such a computer program product is generally as described with reference to Figure 4 Portable or fixed storage unit.
  • the storage unit may have a storage section or a storage space or the like arranged similarly to the storage 320 in the intelligent electronic device of FIG.
  • the program code may, for example, be in a proper order, ie, code that can be read by a process H, such as 310, which, when executed by the intelligent electronic device, causes the intelligent electronic device to perform the method described above.
  • a process H such as 310

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Security & Cryptography (AREA)
  • Software Systems (AREA)
  • Computer Hardware Design (AREA)
  • General Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Virology (AREA)
  • Health & Medical Sciences (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • General Health & Medical Sciences (AREA)
  • Storage Device Security (AREA)
  • Telephone Function (AREA)

Abstract

本发明公开了一种检测智能终端中恶意代码的方法及装置。其中的方法包括:从智能终端操作系统的应用程序层,获取应用程序的虚拟机执行文件;对虚拟机执行文件进行反编译,得到反编译的函数信息结构;解析反编译的函数信息结构,提取出反编译的函数信息结构中的函数调用序列;利用预先设置的恶意代码特征库,对函数调用序列进行匹配,如果匹配成功,则确定应用程序的虚拟机执行文件包含恶意代码。应用本发明方案,通过应用程序的虚拟机执行文件,可分析确定该应用程序是否包含恶意代码,由此可以对被篡改的应用程序或者对恶意软件进行查杀,保护智能终端的安全。

Description

检测智能终端中恶意代码的方法及装置 技术领域
本发明涉及智能终端安全技术领域,具体涉及一种检测智能终端中恶意代 码的方法及装置。 背景技术
随着科技发展, 智能终端具有越来越多的功能。 例如, 人们的手机从传统 的 GSM、 TDMA数字手机转向了拥有能够处理多媒体资源、 提供网页浏览、 电话 会议、 电子商务等多种信息服务的智能手机。 然而, 品种日益繁多的手机恶意 代码攻击以及形势日益严峻的个人数据安全问题也随之而来,越来越多的手机 病毒让智能手机用户饱受其苦。 发明内容
鉴于上述问题,提出了本发明以便提供一种克服上述问题或者至少部分地 解决上述问题的检测智能终端中恶意代码的方法及装置。
依据本发明的一个方面,提供一种检测智能终端中恶意代码的方法,包括: 从智能终端操作系统的应用程序层, 获取应用程序的虚拟机执行文件; 对所述 虚拟机执行文件进行反编译,得到反编译的函数信息结构; 解析所述反编译的 函数信息结构,提取出所述反编译的函数信息结构中的函数调用序列; 利用预 先设置的恶意代码特征库, 对所述函数调用序列进行匹配, 如果匹配成功, 则 确定所述应用程序的虚拟机执行文件包含恶意代码。
依据本发明的另一个方面,提供一种检测智能终端中恶意代码的装置, 包 括: 文件获取单元, 用于从智能终端操作系统的应用程序层, 获取应用程序的 虚拟机执行文件; 反编译单元, 用于对所述虚拟机执行文件进行反编译, 得到 反编译的函数信息结构; 提取单元, 用于解析所述反编译的函数信息结构, 提 取出所述反编译的函数信息结构中的函数调用序列; 检测单元, 用于利用预先 设置的恶意代码特征库, 对所述函数调用序列进行匹配, 如果匹配成功, 则确 定所述应用程序的虚拟机执行文件包含恶意代码。
可见, 本发明实施例通过对 dex文件的格式分析和反编译, 得到函数调用 序列, 通过将函数调用序列作为基础特征, 进行与恶意代码特征库进行匹配, 从而确定 dex文件是否包含恶意代码。 此外, 通过函数调用序列, 可以分析确 定函数的功能, 因此, 可以将一系列函数调用序列的代码作为一个目标特征, 进行与恶意代码特征库进行匹配, 从而确定 dex文件是否包含恶意代码。 应用本发明方案, 通过应用程序的 dex文件, 可分析确定该应用程序是否 包含恶意代码, 由此可以对被篡改的应用程序或者对恶意软件进行查杀,保护 智能终端的安全。
上述说明仅是本发明技术方案的概述,为了能够更清楚了解本发明的技术 手段,而可依照说明书的内容予以实施,并且为了让本发明的上述和其它目的、 特征和优点能够更明显易懂, 以下特举本发明的具体实施方式。 附图说明
通过阅读下文优选实施方式的详细描述,各种其他的优点和益处对于本领 域普通技术人员将变得清楚明了。 附图仅用于示出优选实施方式的目的, 而并 不认为是对本发明的限制。 而且在整个附图中, 用相同的参考符号表示相同的 部件。 在附图中:
图 1示出了根据本发明一个实施例的检测智能终端中恶意代码的方法的流 程图;
图 2示出了根据本发明一个实施例的检测智能终端中恶意代码的装置的结 构示意图; 以及
图 3示出了用于执行根据本发明的方法的智能电子设备的框图; 以及 图 4示出了用于保持或者携带实现根据本发明的方法的程序代码的存储单 元示意图。
具体实施方式
下面将参照附图更详细地描述本公开的示例性实施例。虽然附图中显示了 本公开的示例性实施例, 然而应当理解, 可以以各种形式实现本公开而不应被 这里阐述的实施例所限制。相反,提供这些实施例是为了能够更透彻地理解本 公开, 并且能够将本公开的范围完整的传达给本领域的技术人员。
以安卓(Android )操作系统为例, 包括应用程序层( app层)和系统框架 层(framework层) , 至于从功能划分上有可能包括的的其他层本发明则不作 讨论。 其中, 通常 app层可以理解为上层, 负责与用户交互的界面, 例如应用 程序维护、以及点击页面时识别不同种类的点击内容从而显示不同的上下文菜 单等。 通常 f ramework层作为中间层, 这一层的主要职责是, 将 app层获得的用 户请求, 如启动用用程序、 点击链接、 点击保存图片之类, 转发往下层去; 将 下层处理好的内容, 或者通过消息, 或者通过中间代理类, 来分发至上层, 对 用户展现出来。 Dalvik是用于 Android平台的 Java虚拟机。 Dalvik 经过优化,允许在有限 的内存中同时运行多个虚拟机的实例, 并且每一个 Dalvik 应用作为一个独立 的 Linux 进程执行。独立的进程可以防止在虚拟机崩溃的时候所有程序都被关 闭。 Dalvik虚拟机可以支持已转换为 dex ( Dalvik Executable )格式的 Java 应用程序的运行, dex格式是专为 Dalvik设计的一种压缩格式,适合内存和处 理器速度有限的系统。
可见,在 Android系统中, dex文件是可以直接在 Dalvik虚拟机( Dalvik VM) 中力口载运行的虚拟机执行文件。 通过 ADT (Android Development Tools ) , 经 过复杂的编译, 可以把 j a va源代码转换为 dex文件。 dex文件是针对嵌入式系统 优化的结果, Dalvik虚拟机的指令码并不是标准的 Java虚拟机指令码, 而是使 用了自己独有的一套指令集。 dex文件中共用了很多类名称、 常量字符串, 使 它的体积比较小, 运行效率也比较高。
本发明的发明人在研究过程中发现, 经过对 dex文件的解析, 可以获知 dex 文件中函数的功能, 由此, 可以据此判断 dex文件是否包含恶意代码(包括 dex 文件本身就是恶意软件, 或者 dex文件被篡改等情况) 。
参见图 1, 示出了根据本发明一个实施例的检测智能终端中恶意代码的方 法的流程图。
该检测智能终端中恶意代码的方法包括以下步骤。
S101: 从智能终端操作系统的应用程序层, 获取应用程序的虚拟机执行文 件, 例如获取应用程序的 dex文件;
如前所述, Android操作系统包括应用程序层 ( app层) 和系统框架层 (framework层), 本发明重点在于对 app层的研究和改进。 但是, 本领域技术 人员理解, 当 Android启动时, Dalvik VM监视所有的程序 ( APK文件)和框架, 并且为它们创建一个依存关系树。 Da 1 V i k VM通过这个依存关系树来为每个程序 优化代码并存储在 Dalvik緩存(dalvik-cache)中。 这样, 所有程序在运行时 都会使用优化过的代码。 当一个程序 (或者框架库)发生变更, Dalvik VM将 会重新优化代码并且再次将其存在緩存中。 在 cache/dalvik- cache是存放 system上的程序生成的 dex文件,而 data/dalvik- cacheJ^J是存放 data/app生成 的 dex文件。也就是, 本发明重点在于对 data/app生成的 dex文件进行的分析和 处理, 但是应该理解, 对于 system上的程序生成的 dex文件, 本发明的理论和 操作同样适用。
关于获取 dex文件的方式,可以通过解析 APK ( Android Package, Android 安装包)获得。 APK文件其实是 zip格式的一个压缩包, 但后缀名被修改为 apk, 通过 UnZip解压后, 就可以得到 Dex文件。 S102 : 对 dex文件进行反编译, 得到反编译的函数信息结构; 对 dex文件进行反编译(或称为: 反汇编)有多种方式。
第一种方式是, 根据 dex文件格式对 dex文件进行解析, 得到每个类的函 数信息结构体; 根据函数信息结构体中的字段, 确定 dex文件的函数的位置及 大小, 得到反编译的函数信息结构。 其中, 通过解析函数信息结构体, 得到指 示 dex文件的函数位置的字节码数组字段以及指示 dex文件的函数大小的列表 长度字段, 从而确定 dex文件的函数的位置及大小。
例如, 根据 dex文件格式, 解析 dex文件, 查找到每个类得函数信息体。 比 如函数信息结构体包含如表 1中的字段。
表 1
regis ters-S ize ushor t 该段代码所用到的寄存器数目
ins-S ize ushor t 该段代码中方法的输入参数的字数(words ) outs -S ize ushor t 该段代码调用方法需要为函数的输出函数提 供的空间
tries-size ushor t 该对象的 try_item的个数, 如果非 0, 它会作 为一个 tries数组出现在本对象 insns的后面. debug-info-off uint 从文件开始到 debug info的偏移量,如果没有 信息该值为 0,如果非 0,应该代表数据段的一 个位置,数据必须遵循 debug-info-it em规定 的格式
insns -S ize uint Instructions 列表的长度, 以两字节为单位 insns 字节码数组, 字节码数组的格式在文件
"Bytecode for the Dalvik VM"中详述, 尽管 它被定义为 ushor t型的数组,但是有一些内部 结构是 4字节对齐方式, 如果这个文件恰好是 经过字节交换操作的文件, 字节的交换只在 ushor t类型内部进行
padding ushor t 用两个填充字节来满足 tries 4个字节的对齐
(optional 方式, 该元素只有当 tries— size非 0并且为奇 ) = o 数时才存在
tries try. i tern [ 该数组用来标识代表中哪里可能抛出异常并 tr ies-S iz 且如何处理。数组元素必须按照地址的升序排 e] 列, 不能有重复地址出现。 这个元素只有在
(optional tries-size^^;OH†^" ^
)
handlers encoded-c 这些字节代表一系列异常的类型以及他们的 atch-hand 处理方法的地址列表,每个 try_ item都有一个 ler.list 字节宽度的偏移,只有当 t r i e s _ s i ze不为 0时, (optional 该元素才存在。
)
其中, 每个函数信息结构体中的 insns -size和 insns字段, 分别代表了该 函数大小及位置。 那么, 就可以根据 insns_size和 insns这两个字段, 反编译 出函数的信息结构。 反编译的信息结构是由 Dalvik VM字节码构成的, 后续会 详细介绍。
第二种方式是, 利用 dex文件反编译工具,将 dex文件反编译为虚拟机字节 码。
如前介绍的, Dalvik虚拟机运行的是 Dalvik字节码,其以一个 dex( Dalvik Executable )可执行文件形式存在, Da lvik虚拟机通过解释 dex文件来执行代 码。 目前有一些工具, 可将 DEX文件反汇编成 Dalvik汇编代码。 这类 dex文件反 编译工具包括: baksmali、 Dedexer 1.26, dexdump, dexinspecto 03-12-12r, IDA Pro, androguard, dex2 jar , 010 Editor等。
可见, 通过对 dex文件的反编译, 可以得到反编译的所有函数信息结构。 其中, 函数信息结构包含函数执行代码, 本发明实施例中, 是由虚拟机指令序 列和虚拟机助记符序列构成的, 如下面的例子, 由 Dalvik VM的指令序列和 Dalvik VM的助记符序列构成函数信息结构。
例如, 根据本发明一个实施例对 dex文件进行反编译得到的函数信息结构 ^口下:
Figure imgf000008_0001
可见, dex文件被反编译成 Dalvik VM的指令序列和 Dalvik VM的助记符序 歹 |J。
S103: 解析反编译的函数信息结构,提取出反编译的函数信息结构中的函 数调用序列;
如上例子,在反编译得到的函数信息结构中,机器码字段中的每一行的前 2个数字是指令序列 (上例子左侧被圈部分) , 而指令序列对应的部分为助记 符(上例子右侧, 部分被圈, 未全部选择)。 助记符主要是为了方便用户交流 和代码编写。
如上例子, dex文件经过反编译就可以得到函数的指令序列为: "125438 71 Oc 6e Oc 6e Oa 38 54 54 6e Oc 6e 54 6e Oc 6e Oc 38 72 Oa 39 12 38 54 6e 54 71 Oe 01 28 54 13 6e" 。 助记符序列为: "const/4 iget— object if-eqz invoke—static move—result—object invoke—virtual move—result—object invoke—virtual move—result if-eqz iget-ob ject iget-ob ject invoke—virtual move-re su 1 t-ob ject invoke—virtual iget-ob ject invoke—virtual move-re sul t-ob ject invoke—virtual move-result-object if-eqz invoke-interf ace move-result if-nez const/4 if-eqz iget-ob ject invoke-virtual iget-ob ject invoke-static return-void move goto iget-ob ject const/16 invoke-virtual " 。
接下来,从上述助记符序列中可提取得到函数调用序列。 函数调用序列是 指具有语义功能的代码, 例如后面描述的具有字符串解密、创建实例等功能的 代码。
■ const -string■ vQ; ■ "WN5"■ / ■ stri ng^QQZb
|i nvoke-st ti c■ { vO , - Lcom/nizhengDS; . Decrypt St r i ng: L ja a Ί ang/Stri ng; ■ ' nethod@0031 I
it-ooject - nvoke-stati c - { Q} , java/securlty/MessageDl z; . get instance]: /sec rity/MessageDi sz; - // - rnethod(¾iQ6; - nove-re5 1t -object ·ν0
- nvoke-yl rtual ■ {vG}, - Ljava/Ί ang stri ng; . get B tes: [ - // - rnethod^QQ4e |
- rnove-rgsult -object - vl
■ i nvoke-vi rtual ■《 vO,■ vl},■ Ljava/sec rity/Messageoi gest; . update :v■ / ■ niethod&006¾
■ i nvoke-vi「tua,■ {vO'j, ja a/secur ty/Hess geDi gest; . di gest: [B■ // ' nethod@0061
Figure imgf000010_0001
- array-Ί ength - νϋ , 2
'00? 4
■ i nvoke-vi rtual ■ { v¾ , ■ Lj a/Ί ang/Str"i ngBuf f er; . toSt「"i ng : L ja a/Ί ang/Str"i ng; ■ //■ method@00¾6
■rnove-res lt -o ect - νϋ
- ret urn-object · vO
■ aget-byte■ vO,■ v2, - l
and-int/1itl6■ vQ, -、'〇, Μπτ 7/ -^QQff
invoke-stati ■ jvO'j, - ang/integer; . toHexstri ng: Ljava/Ί ang/5tri ng; ■ / - nnethod^QQ4g ~|
■ rnove-res lt -object - vO
■ i nvoke-vi rtual ■ {vO'j,■ Lj a/Ί ang/Str"i ng; . Ί ength :∑■//■ method@004f
It■ v4
■const/4■ v5, .2■// #2
if-Ίτ -v4, v5, QQ^a- -+Q009
■ i nvoke—vl rtual ■ - vO}, - Ljava/1 ang/stri ngsuffer; . append : L jav anang/strlngsuffer; - // - method^0055 ■add-int/ litS -vO, vi, -^int -1 // ^01
■ move - vl , ■ vO
■goto-001c7/ --00Ld
■ new-i nstance - v4 , 'Ljava/I ang/St「"i ngWi Ί der ; ■ // - typei¾0031
- const-stri n ■ , "Q"■ //■ stri nqi¾QQQc
■ i nvoke-5tati c■ {vS , - Lcon/mzhengDS; . Decrypt stri ng: Ljava/Ί ng/stri ng; - //■ nethod^OO l
- rnove-result -object - v5
■ i nvoke- H rect■《v4,■ v5 , ■ Ljava/Ί ang/5tri ngsui Ί der; . <i nit > : v■ // - rnethod^00&7
■ i nvokg-vi rtual ■ jv4 r ■ vQ},■ L jav a/1 ang/stri ngB i Ί der; . append: Ljava/Ί ang/st r~i ngwi Ί dgr ; ■ //■ nigthod&QQ^B
■ rnove-res lt -object - vO
■|i nvoke-vi rtual ■ vO , ■ L jav a 1 ang/stri ngBui Ί der ; . toStri ng : L ang/stri ng; ■ // ' nethodi¾0059 ~ | 上面例子框选的部分即为相关函数调用。
将这些调用抽取出,按调用顺序排序即可组成函数调用序列, 函数的调用 序列基本描述了本函数的行为。
如上例子:
1: "Lcom/mzhengDS; . DecryptStr ing: L java/lang/Str ing"
通过代码分析, 可得知函数解密了一个字符串。
2:
" invoke-static {vO} , L java/ security/MessageDigest; . get Instance: L jav a/ secur i ty/Mes sageDiges t"
通过代码分析, 可得知程序创建了一个消息签名实例, 可以猜测到可能是 准备使用 md5 sha等类似 hash算法给 1过程界面后的字符串加密。 3: "invoke-virtual {v6} , Ljava/lang/Str ing; . getBytes: [B,, 获取字符串的指针, 可以猜测字符串可能是过程 1解密后的字符串, 而获 取指针可能是为了使用过程 2的实例给字符串加密。
4 : " invoke-virtual {νθ, vl} , Ljava/ security/MessageDigest; . update: V" ;
" invoke-virtual {νθ} ,
Ljava/ security/MessageDigest; . digest: [B,,
这 2个函数调用证实了上述判断, 根据函数名可以得知, 这是对数据做了 ha s h力口密。
从上面这个例子可以看出,通过函数的调用序列就可以基本分析确定出这 个函数的功能。
S104: 利用预先设置的恶意代码特征库, 对函数调用序列进行匹配, 如果 匹配成功, 则确定应用程序的 dex文件包含恶意代码。
恶意代码(Malicious Code)是指通过存储介质或网络进行传播, 在未经 授权认证的情况下破坏操作系统完整性、窃取系统中未公开秘密信息的程序或 代码。 以手机为例, 手机恶意代码是指针对手机、 PDA等手持设备的恶意代码。 手机恶意代码可以简单地划分为复制型恶意代码和非复制型恶意代码。其中复 制型恶意代码主要包括病毒(Virus ) 、 蠕虫 (Worm) , 非复制型恶意代码主 要包括特洛伊木马后门程序(Trojan Horse)、 流氓软件 (Rogue Software )、 恶意移动代码 (Malicious Mobile Code ) 以及 Rootki t程序等。
手机恶意代码防护技术针对恶意代码进行防护。 手机恶意代码防护方式 包括多种。 例如, 特征值扫描方式, 它需要预先学习建立恶意代码特征库, 恶 意代码特征库中保存的特征值可以是一段连续的固定字符串,也可以是几段中 间插有其他不确定字符的不连续的字符串确定其中的特征串; 在扫描时,基于 感染了恶意代码。 如, 基于虚拟机技术的, i意代码防护。 此类防;方案主要 针对多态和变形病毒。所谓的虚拟机是指通过软件模拟具有完整硬件系统功能 的、运行在一个完全隔离环境中的完整计算机系统。该方案也称为软件模拟法, 是一种软件分析器, 用软件方法来模拟和分析程序的运行。 它实质是在内存中 模拟出一个小的封闭程序执行环境, 所有待查杀文件都在其中被虚拟执行。釆 用虚拟机技术进行杀毒时, 首先使用的还是特征值扫描技术, 当发现目标具有 加密恶意代码的特征时,才会启动虚拟机模块让加密代码自行解码,解码之后, 就可以釆用传统的特征值扫描方式进行查杀。 再如, 启发式扫描方式。 启发式 扫描方案主要针对恶意代码的不断变种以及为了加强对未知恶意代码的研究。 所谓 "启发式" 源自人工智能, 是指 "自我发现的能力" 或 "运用某种方式或 方法去判定事物的知识和技能"。 恶意代码的启发式扫描是指扫描软件能够利 用从经验中提取的规则,通过分析程序的结构和它的行为来发现病毒。 因为恶 意代码要达到感染和破坏的目的,通常的行为都会有一定的特征, 例如非常规 读写文件、 终结自身、 非常规切入零环等。 因此可以根据扫描特定的行为或多 种行为的组合来判断一个程序是否为恶意代码。 此外,还可以对目标程序进行 相似样本聚类, 例如釆用 K均值聚类算法对分析确定的相似样本进行聚类。
不论哪种防护方式,其核心都包含两部分, 第一是组织合理的恶意代码特 征库, 第二是高效的扫描算法(也称为匹配算法)。 匹配算法一般分为单模式 匹配算法和多模式匹配算法两种。单模式匹配算法包括 BF (Brute-Force)算法、 KMP ( Knuth-Morr i s-Pra t t )算法、 BM ( Boyer-Moore )算法和 QS ( Quick Search ) 算法等。 多模式匹配算法包括经典多模式匹配 DFSA 算法和基于有序二叉树的 多模式匹配算法。 另外, 还可将匹配算法分为模糊匹配算法、 相似匹配算法。 以 BF算法为例, 它是一种简单直观的单模式匹配算法, 属于模糊匹配算法。 其 基本思想为: 首先将主串中的第一个字符 s i与模式 t中的第一个字符 t l进行比 较, 若相等, 则继续逐个比较后继字符; 否则, 就将 s中的第二个字符 s 2与 t l 进行比较,依次类推, 直到 t中每一个字符依次和 s中的一个连续字符序列相等 (匹配成功) , 返回该字符序列中第一个字符在主串中的位置; 或者在 s中找 不到和 t相等的字符序列 (匹配失败) , 返回 0。 再以 KMP算法为例, 它是一种 改进的模式匹配的算法, 它对于 BF算法其最大的改进就是: 利用模式中隐含的 "部分匹配" 的信息, 使的在出现失配情况下, 进行下一次比较时主串中的 i 指针(指向失配字符) 不需要回溯, 而将模式中的 j指针(指向下一次比较的 位置)向后 "滑动"一个尽可能远的距离继续进行。 此滑动 K由 next函数求的。
KMP算法可描述为: H没以指针 i和 j分别增 1 ; 若 s i不等于 t j, 则 i不变, j退到 next ( j )位置再比较, 如此循环往复, 直至在主串中找到与模式串相等的子 串或者搜索完整个主串后也没发现与模式串相等的字串, 算法结束。
本步骤中, 利用预先设置的恶意代码特征库, 对函数调用序列进行匹配, 如果匹配成功, 则确定应用程序的 dex文件包含恶意代码。 具体地, 又包括两 种情况。 第一种情况是, 将函数调用序列作为查杀目标, 利用预先设置的恶意 代码特征库, 对函数调用序列进行查杀, 例如, 进行函数相似度匹配或进行函 数特征模糊匹配。 第二种情况是, 将多个函数调用序列构成的具有一定功能的 函数作为目标特征, 利用预先设置的恶意代码特征库, 对目标特征进行查杀, 例如, 进行函数相似度匹配或进行函数特征模糊匹配。
需要说明的是,本发明不限定釆用何种恶意代码防护方案对恶意代码进行 检测, 例如, 可以釆用上面介绍的样本特征查杀(特征值扫描)、 基于虚拟机 查杀或者启发式查杀, 另外还可以进行相似样本聚类。 而且, 对于匹配算法也 不作限制, 例如, 可以釆用上面介绍的模糊匹配算法或者相似匹配算法等。
可见, 本发明实施例通过对 dex文件的格式分析和反编译, 得到函数调用 序列, 通过将函数调用序列作为基础特征, 进行与恶意代码特征库进行匹配, 从而确定 dex文件是否包含恶意代码。 此外, 通过函数调用序列, 可以分析确 定函数的功能, 因此, 可以将一系列函数调用序列的代码作为一个目标特征, 进行与恶意代码特征库进行匹配, 从而确定 dex文件是否包含恶意代码。
应用本发明方案, 通过应用程序的 dex文件, 可分析确定该应用程序是否 包含恶意代码, 由此可以对被篡改的应用程序或者对恶意软件进行查杀,保护 智能终端的安全。
与上述方法相对应,本发明实施例还提供一种检测智能终端中恶意代码的 装置。 该装置可以通过软件、 硬件或软硬件结合实现。 具体地, 该装置可以是 指一个终端设备, 也可以是指设备内部的功能实体。 例如, 该装置可以是指手 机内部的功能模块。 优选地, 该装置运行在 Andro i d操作系统下。
参见图 2, 该装置包括文件获取单元 201、 反编译单元 202、 提取单元 203 以及检测单元 204。
其中:
文件获取单元 201, 用于从智能终端操作系统的应用程序层, 获取应用程 序的虚拟机执行文件, 例如获取 dex文件;
反编译单元 202,用于对 dex文件进行反编译,得到反编译的函数信息结构; 提取单元 203, 用于解析反编译的函数信息结构, 提取出反编译的函数信 息结构中的函数调用序列;
检测单元 204, 用于利用预先设置的恶意代码特征库, 对函数调用序列进 行匹配, 如果匹配成功, 则确定应用程序的 dex文件包含恶意代码。
优选地, 该装置还包括解析单元 205 :
解析单元 205, 用于通过解析反编译的函数信息结构, 得到虚拟机助记符 序列;
此情况下,提取单元 203是从虚拟机助记符序列中提取得到函数调用序列。 优选地, 函数调用序列为多个; 此情况下, 该装置还包括:
函数功能确定单元 206, 用于通过分析按照顺序执行的多个函数调用序列 的指令, 确定函数的功能。
例如, 函数功能确定单元 206确定的多个函数调用序列按照顺序执行的指 令包括: 解密字符串、 创建消息签名实例、 获取字符串子针、 哈希加密。 其中, 检测单元 204具体用于, 利用预先设置的恶意代码特征库, 对函数 调用序列进行函数相似度匹配, 和 /或,对函数调用序列进行函数特征模糊匹 配;
或者, 检测单元 204具体用于, 利用预先设置的恶意代码特征库, 对目标 特征进行函数相似度匹配,和 /或,对目标特征进行函数特征模糊匹配,其中, 目标特征是指函数功能确定单元 206确定的多个函数调用序列构成的具有一定 功能的函数。
此外, 检测单元 204对 dex文件进行样本特征查杀、基于虚拟机查杀、 启发 式查杀, 和 /或, 相似样本聚类。
其中, 反编译单元 202具体用于, 根据 dex文件格式对 dex文件进行解析, 得到每个类的函数信息结构体; 根据函数信息结构体中的字段, 确定 dex文件 的函数的位置及大小, 得到反编译的函数信息结构; 进一步, 反编译单元 202 还用于, 解析函数信息结构体, 得到指示 dex文件的函数位置的字节码数组字 段以及指示 dex文件的函数大小的列表长度字段; 根据字节码数组字段以及列 表长度字段, 确定 dex文件的函数的位置及大小;
或者, 反编译单元 202具体用于, 利用 dex文件反编译工具, 将 dex文件反 编译为虚拟机字节码。
其中, 获取单元 201具体用于, 从智能终端操作系统的应用程序层, 查找 到应用程序的安装包; 解析安装包, 得到应用程序的 dex文件。
关于该装置的具体实现细节可参加方法实施例, 在此不赘述。
在此提供的算法和显示不与任何特定计算机、虚拟系统或者其它设备固有 相关。 各种通用系统也可以与基于在此的示教一起使用。 根据上面的描述, 构 造这类系统所要求的结构是显而易见的。此外, 本发明也不针对任何特定编程 语言。 应当明白, 可以利用各种编程语言实现在此描述的本发明的内容, 并且 上面对特定语言所做的描述是为了披露本发明的最佳实施方式。
在此处所提供的说明书中, 说明了大量具体细节。 然而, 能够理解, 本发 明的实施例可以在没有这些具体细节的情况下实践。在一些实例中, 并未详细 示出公知的方法、 结构和技术, 以便不模糊对本说明书的理解。
类似地,应当理解, 为了精简本公开并帮助理解各个发明方面中的一个或 多个,在上面对本发明的示例性实施例的描述中, 本发明的各个特征有时被一 起分组到单个实施例、 图、 或者对其的描述中。 然而, 并不应将该公开的方法 解释成反映如下意图:即所要求保护的本发明要求比在每个权利要求中所明确 记载的特征更多的特征。 更确切地说, 如下面的权利要求书所反映的那样, 发 明方面在于少于前面公开的单个实施例的所有特征。 因此, 遵循具体实施方式 的权利要求书由此明确地并入该具体实施方式,其中每个权利要求本身都作为 本发明的单独实施例。
本领域那些技术人员可以理解,可以对实施例中的设备中的模块进行自适 应性地改变并且把它们设置在与该实施例不同的一个或多个设备中。可以把实 施例中的模块或单元或组件组合成一个模块或单元或组件,以及此外可以把它 们分成多个子模块或子单元或子组件。 除了这样的特征和 /或过程或者单元中 的至少一些是相互排斥之外, 可以釆用任何组合对本说明书(包括伴随的权利 要求、摘要和附图)中公开的所有特征以及如此公开的任何方法或者设备的所 有过程或单元进行组合。除非另外明确陈述,本说明书(包括伴随的权利要求、 摘要和附图)中公开的每个特征可以由提供相同、等同或相似目的的替代特征 来代替。
此外, 本领域的技术人员能够理解,尽管在此所述的一些实施例包括其它 实施例中所包括的某些特征而不是其它特征,但是不同实施例的特征的组合意 味着处于本发明的范围之内并且形成不同的实施例。例如,在下面的权利要求 书中, 所要求保护的实施例的任意之一都可以以任意的组合方式来使用。
本发明的各个部件实施例可以以硬件实现,或者以在一个或者多个处理器 上运行的软件模块实现,或者以它们的组合实现。本领域的技术人员应当理解, 可以在实践中使用微处理器或者数字信号处理器 (DSP )来实现根据本发明实 施例的检测智能终端中恶意代码的装置中的一些或者全部部件的一些或者全 部功能。本发明还可以实现为用于执行这里所描述的方法的一部分或者全部的 设备或者装置程序(例如, 计算机程序和计算机程序产品)。 这样的实现本发 明的程序可以存储在计算机可读介质上,或者可以具有一个或者多个信号的形 式。 这样的信号可以从因特网网站上下载得到, 或者在载体信号上提供, 或者 以任何其他形式提供。
例如, 图 3示出了可以实现根据本发明的检测智能终端中恶意代码的方 法的智能电子设备。 该智能电子设备传统上包括处理器 310和以存储器 320 形式的计算机程序产品或者计算机可读介质。 存储器 320可以是诸如闪存、 EEPROM (电可擦除可编程只读存储器)、 EPROM、 硬盘或者 ROM之类的 电子存储器。存储器 320具有用于执行上述方法中的任何方法步骤的程序代 码 331的存储空间 330。 例如, 用于程序代码的存储空间 330可以包括分别用 于实现上面的方法中的各种步骤的各个程序代码 331。这些程序代码可以从 一个或者多个计算机程序产品中读出或者写入到这一个或者多个计算机程 序产品中。 这些计算机程序产品包括诸如硬盘, 紧致盘 (CD ) 、 存储卡或 者软盘之类的程序代码载体。这样的计算机程序产品通常为如参考图 4所述 的便携式或者固定存储单元。该存储单元可以具有与图 4的智能电子设备中 的存储器 320类似布置的存储段或者存储空间等。程序代码可以例如以适当 序^ 1,Γ即可以由例如诸如 310之类的处理 H读取的代码, 这些代码一当由智 能电子设备运行时, 导致该智能电子设备执行上面所描述的方法中的各个 步骤。
应该注意的是上述实施例对本发明进行说明而不是对本发明进行限制,并 且本领域技术人员在不脱离所附权利要求的范围的情况下可设计出替换实施 例。在权利要求中, 不应将位于括号之间的任何参考符号构造成对权利要求的 限制。 单词 "包含" 不排除存在未列在权利要求中的元件或步骤。 位于元件之 前的单词 "一" 或 "一个" 不排除存在多个这样的元件。 本发明可以借助于包 括有若干不同元件的硬件以及借助于适当编程的计算机来实现。在列举了若干 装置的单元权利要求中,这些装置中的若干个可以是通过同一个硬件项来具体 体现。 单词第一、 第二、 以及第三等的使用不表示任何顺序。 可将这些单词解 释为名称。

Claims

权 利 要 求
1、 一种检测智能终端中恶意代码的方法, 其特征在于, 包括:
从智能终端操作系统的应用程序层, 获取应用程序的虚拟机执行文件; 对所述虚拟机执行文件进行反编译, 得到反编译的函数信息结构; 解析所述反编译的函数信息结构,提取出所述反编译的函数信息结构中的 函数调用序列;
利用预先设置的恶意代码特征库,对所述函数调用序列进行匹配,如果匹 配成功, 则确定所述应用程序的虚拟机执行文件包含恶意代码。
2、 如权利要求 1所述的方法, 其特征在于, 还包括:
通过解析所述反编译的函数信息结构, 得到虚拟机助记符序列; 从所述虚拟机助记符序列中提取得到所述函数调用序列。
3、 如权利要求 1所述的方法, 其特征在于, 所述函数调用序列为多个; 所 述方法还包括:
通过分析按照顺序执行的多个函数调用序列的指令, 确定所述函数的功 能。
4、 如权利要求 3所述的方法, 其特征在于, 所述多个函数调用序列按照顺 序执行的指令包括: 解密字符串、 创建消息签名实例、 获取字符串子针、 哈希 加密。
5、 如权利要求 1所述的方法, 其特征在于, 所述利用预先设置的恶意代码 特征库, 对所述函数调用序列进行匹配包括:
利用预先设置的恶意代码特征库,对所述函数调用序列进行函数相似度匹 配, 和 /或, 对所述函数调用序列进行函数特征模糊匹配。
6、 如权利要求 3所述的方法, 其特征在于, 将所述多个函数调用序列构成 的具有一定功能的函数作为目标特征;
所述利用预先设置的恶意代码特征库, 对所述函数调用序列进行匹配包 括:
利用预先设置的恶意代码特征库, 对所述目标特征进行函数相似度匹配, 和 /或, 对所述目标特征进行函数特征模糊匹配。
7、 如权利要求 1所述的方法, 其特征在于, 对所述虚拟机执行文件进行样 本特征查杀、 基于虚拟机查杀、 启发式查杀, 和 /或, 相似样本聚类。
8、 如权利要求 1所述的方法, 其特征在于, 所述对所述虚拟机执行文件进 行反编译, 得到反编译的函数信息结构包括:
根据虚拟机执行文件格式对虚拟机执行文件进行解析,得到每个类的函数 信息结构体; 根据所述函数信息结构体中的字段,确定所述虚拟机执行文件的函数的位 置及大小, 得到所述反编译的函数信息结构。
9、 如权利要求 8所述的方法, 其特征在于, 所述根据函数信息结构体中的 字段, 确定所述虚拟机执行文件的函数的位置及大小包括:
解析所述函数信息结构体,得到指示虚拟机执行文件的函数位置的字节码 数组字段以及指示虚拟机执行文件的函数大小的列表长度字段;
根据所述字节码数组字段以及所述列表长度字段,确定所述虚拟机执行文 件的函数的位置及大小。
10、 如权利要求 1所述的方法, 其特征在于, 所述对所述虚拟机执行文件 进行反编译, 得到反编译的函数信息结构包括:
利用虚拟机执行文件反编译工具,将所述虚拟机执行文件反编译为虚拟机 字节码。
11、 如权利要求 1所述的方法, 其特征在于, 所述从智能终端操作系统的 应用程序层, 获取应用程序的虚拟机执行文件包括:
从智能终端操作系统的应用程序层, 查找到所述应用程序的安装包; 解析所述安装包, 得到所述应用程序的虚拟机执行文件。
12、 如权利要求 1-11任一项所述的方法, 其特征在于, 所述操作系统是指 安卓系统。
1 3、 一种检测智能终端中恶意代码的装置, 其特征在于, 包括:
文件获取单元, 用于从智能终端操作系统的应用程序层,获取应用程序的 虚拟机执行文件;
反编译单元, 用于对所述虚拟机执行文件进行反编译,得到反编译的函数 信息结构;
提取单元,用于解析所述反编译的函数信息结构,提取出所述反编译的函 数信息结构中的函数调用序列;
检测单元,用于利用预先设置的恶意代码特征库,对所述函数调用序列进 行匹配,如果匹配成功,则确定所述应用程序的虚拟机执行文件包含恶意代码。
14、 如权利 要求 1 3所述的装置, 其特征在于, 还包括:
解析单元,用于通过解析所述反编译的函数信息结构,得到虚拟机助记符 序列;
所述提取单元是从所述虚拟机助记符序列中提取得到所述函数调用序列 的。
15、 如权利要求 1 3所述的装置, 其特征在于, 所述函数调用序列为多个; 所述装置还包括: 函数功能确定单元,用于通过分析按照顺序执行的多个函数调用序列的指 令, 确定所述函数的功能。
16、 如权利要求 15所述的装置, 其特征在于, 所述函数功能确定单元确定 的多个函数调用序列按照顺序执行的指令包括: 解密字符串、创建消息签名实 例、 获取字符串子针、 哈希加密。
17、 如权利要求 1 3所述的装置, 其特征在于, 所述检测单元具体用于, 利 用预先设置的恶意代码特征库,对所述函数调用序列进行函数相似度匹配, 和 /或, 对所述函数调用序列进行函数特征模糊匹配。
18、 如权利要求 15所述的装置, 其特征在于, 所述检测单元具体用于, 利 用预先设置的恶意代码特征库, 对目标特征进行函数相似度匹配, 和 /或, 对 所述目标特征进行函数特征模糊匹配, 其中, 所述目标特征是指所述多个函数 调用序列构成的具有一定功能的函数。
19、 如权利要求 1 3所述的装置, 其特征在于, 所述检测单元对所述虚拟机 执行文件进行样本特征查杀、 基于虚拟机查杀、 启发式查杀, 和 /或, 相似样 本聚类。
20、 如权利要求 1 3所述的装置, 其特征在于, 所述反编译单元具体用于, 根据虚拟机执行文件格式对虚拟机执行文件进行解析,得到每个类的函数信息 结构体; 根据所述函数信息结构体中的字段,确定所述虚拟机执行文件的函数 的位置及大小, 得到所述反编译的函数信息结构。
21、 如权利要求 20所述的装置, 其特征在于, 所述反编译单元, 解析所述 函数信息结构体,得到指示虚拟机执行文件的函数位置的字节码数组字段以及 指示虚拟机执行文件的函数大小的列表长度字段;根据所述字节码数组字段以 及所述列表长度字段, 确定所述虚拟机执行文件的函数的位置及大小。
22、如权利要求 1 3所述的装置,其特征在于,所述对反编译单元具体用于, 利用虚拟机执行文件反编译工具,将所述虚拟机执行文件反编译为虚拟机字节 码。
23、 如权利要求 1 3所述的装置, 其特征在于, 所述获取单元具体用于, 从 智能终端操作系统的应用程序层, 查找到所述应用程序的安装包; 解析所述安 装包, 得到所述应用程序的虚拟机执行文件。
24、 如权利要求 1 3-23任一项所述的装置, 其特征在于, 所述操作系统是 指安卓系统。
25、 一种计算机程序, 包括计算机可读代码, 当智能电子设备运行所述计 算机可读代码运行时,导致权利要求 1-12中的任一项权利要求所述的方法被执 行。 、 一种计算机可读介质, 其中存储了如权利要求 25所述的计算机程序,
PCT/CN2014/083908 2013-12-30 2014-08-07 检测智能终端中恶意代码的方法及装置 WO2015101042A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201310746029.XA CN103761475B (zh) 2013-12-30 2013-12-30 检测智能终端中恶意代码的方法及装置
CN201310746029.X 2013-12-30

Publications (1)

Publication Number Publication Date
WO2015101042A1 true WO2015101042A1 (zh) 2015-07-09

Family

ID=50528711

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2014/083908 WO2015101042A1 (zh) 2013-12-30 2014-08-07 检测智能终端中恶意代码的方法及装置

Country Status (2)

Country Link
CN (1) CN103761475B (zh)
WO (1) WO2015101042A1 (zh)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
EP3433788A4 (en) * 2016-03-25 2019-09-11 Nokia Technologies Oy HYBRID APPROACH TO THE DETECTION OF MALICIOUS SOFTWARE

Families Citing this family (29)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103902910B (zh) * 2013-12-30 2016-07-13 北京奇虎科技有限公司 检测智能终端中恶意代码的方法及装置
CN103761475B (zh) * 2013-12-30 2017-04-26 北京奇虎科技有限公司 检测智能终端中恶意代码的方法及装置
WO2015101096A1 (zh) * 2013-12-30 2015-07-09 北京奇虎科技有限公司 检测智能终端中恶意代码的方法及装置
CN104268473B (zh) * 2014-09-23 2017-05-24 龙芯中科技术有限公司 应用程序检测方法和装置
CN105653949B (zh) * 2014-11-17 2019-06-21 华为技术有限公司 一种恶意程序检测方法及装置
CN104657661B (zh) * 2015-01-26 2018-05-22 武汉安天信息技术有限责任公司 移动终端中恶意代码的检测方法和装置
CN105550581B (zh) * 2015-12-10 2018-09-25 北京奇虎科技有限公司 一种恶意代码检测方法及装置
CN106909839B (zh) * 2015-12-22 2020-04-17 北京奇虎科技有限公司 一种提取样本代码特征的方法及装置
CN106909844A (zh) * 2015-12-22 2017-06-30 北京奇虎科技有限公司 一种应用程序样本的分类方法及装置
CN106909841A (zh) * 2015-12-22 2017-06-30 北京奇虎科技有限公司 一种判断病毒代码的方法及装置
CN106940771A (zh) * 2016-01-04 2017-07-11 阿里巴巴集团控股有限公司 基于文件的漏洞检测方法和装置
CN106682505B (zh) 2016-05-04 2020-06-12 腾讯科技(深圳)有限公司 一种病毒检测方法、终端、服务器及系统
CN106130959B (zh) * 2016-06-12 2019-07-23 微梦创科网络科技(中国)有限公司 恶意应用识别方法及装置
CN105978911B (zh) * 2016-07-15 2019-05-21 江苏博智软件科技有限公司 基于虚拟执行技术的恶意代码检测方法及装置
CN106529294B (zh) * 2016-11-15 2019-03-01 广东华仝九方科技有限公司 一种用于手机病毒判定与过滤的方法
CN106650426A (zh) * 2016-12-09 2017-05-10 哈尔滨安天科技股份有限公司 一种动态提取可执行文件内存映像的方法及系统
CN108401253B (zh) * 2017-02-06 2022-12-27 腾讯科技(深圳)有限公司 一种应用信息识别方法、装置以及系统
CN107169355B (zh) * 2017-04-28 2020-05-08 北京理工大学 一种蠕虫同源性分析方法和装置
CN113761482A (zh) * 2017-06-06 2021-12-07 杭州网易智企科技有限公司 一种程序代码保护方法和装置
CN108710492B (zh) * 2018-04-20 2021-09-07 四川普思科创信息技术有限公司 一种识别app程序中第三方库的方法
CN109120593A (zh) * 2018-07-12 2019-01-01 南方电网科学研究院有限责任公司 一种移动应用安全防护系统
CN109492353B (zh) * 2018-10-11 2024-04-16 北京奇虎科技有限公司 应用加固方法、装置、电子设备和存储介质
CN110147671B (zh) * 2019-05-29 2022-04-29 奇安信科技集团股份有限公司 一种程序内字符串提取方法及装置
CN112580043B (zh) * 2019-09-30 2023-08-01 奇安信安全技术(珠海)有限公司 基于虚拟机的杀毒方法及装置、存储介质、计算机设备
CN111046385B (zh) * 2019-11-22 2022-04-22 北京达佳互联信息技术有限公司 软件类型检测方法、装置、电子设备及存储介质
CN111046388B (zh) * 2019-12-16 2022-09-13 北京智游网安科技有限公司 识别应用中第三方sdk的方法、智能终端及储存介质
CN111459822B (zh) * 2020-04-01 2023-10-03 抖音视界有限公司 系统组件数据的提取方法、装置、设备及可读介质
CN112364349A (zh) * 2020-11-30 2021-02-12 江苏极鼎网络科技有限公司 一种手机app智能检测设备
CN112817603B (zh) * 2021-01-26 2023-06-30 京东科技控股股份有限公司 应用程序处理方法、装置、电子设备、系统和存储介质

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103268445A (zh) * 2012-12-27 2013-08-28 武汉安天信息技术有限责任公司 一种基于OpCode的android恶意代码检测方法及系统
CN103473509A (zh) * 2013-09-30 2013-12-25 清华大学 Android平台恶意软件自动检测方法
CN103473507A (zh) * 2013-09-25 2013-12-25 西安交通大学 一种基于方法调用图的Android恶意软件检测方法
CN103761475A (zh) * 2013-12-30 2014-04-30 北京奇虎科技有限公司 检测智能终端中恶意代码的方法及装置
CN103761476A (zh) * 2013-12-30 2014-04-30 北京奇虎科技有限公司 特征提取的方法及装置
CN103902910A (zh) * 2013-12-30 2014-07-02 北京奇虎科技有限公司 检测智能终端中恶意代码的方法及装置

Family Cites Families (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102819697B (zh) * 2011-12-26 2015-07-22 哈尔滨安天科技股份有限公司 一种基于线程反编译的多平台恶意代码检测方法和系统
CN103365699B (zh) * 2012-12-21 2016-08-03 北京安天电子设备有限公司 基于apk的系统api和运行时字符串的提取方法及系统
CN103440459B (zh) * 2013-09-25 2016-04-06 西安交通大学 一种基于函数调用的Android恶意代码检测方法

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103268445A (zh) * 2012-12-27 2013-08-28 武汉安天信息技术有限责任公司 一种基于OpCode的android恶意代码检测方法及系统
CN103473507A (zh) * 2013-09-25 2013-12-25 西安交通大学 一种基于方法调用图的Android恶意软件检测方法
CN103473509A (zh) * 2013-09-30 2013-12-25 清华大学 Android平台恶意软件自动检测方法
CN103761475A (zh) * 2013-12-30 2014-04-30 北京奇虎科技有限公司 检测智能终端中恶意代码的方法及装置
CN103761476A (zh) * 2013-12-30 2014-04-30 北京奇虎科技有限公司 特征提取的方法及装置
CN103902910A (zh) * 2013-12-30 2014-07-02 北京奇虎科技有限公司 检测智能终端中恶意代码的方法及装置

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
EP3433788A4 (en) * 2016-03-25 2019-09-11 Nokia Technologies Oy HYBRID APPROACH TO THE DETECTION OF MALICIOUS SOFTWARE

Also Published As

Publication number Publication date
CN103761475B (zh) 2017-04-26
CN103761475A (zh) 2014-04-30

Similar Documents

Publication Publication Date Title
WO2015101042A1 (zh) 检测智能终端中恶意代码的方法及装置
US10114946B2 (en) Method and device for detecting malicious code in an intelligent terminal
WO2015101043A1 (zh) 检测智能终端中恶意代码的方法及装置
Chen et al. Detecting android malware using clone detection
Cozzi et al. The tangled genealogy of IoT malware
WO2015101097A1 (zh) 特征提取的方法及装置
Gawlik et al. Towards automated integrity protection of C++ virtual function tables in binary programs
US7636856B2 (en) Proactive computer malware protection through dynamic translation
Christodorescu et al. Malware normalization
Zhang et al. Android application forensics: A survey of obfuscation, obfuscation detection and deobfuscation techniques and their impact on investigations
WO2013139215A1 (zh) 病毒apk的识别方法及装置
WO2013139216A1 (zh) 一种apk病毒特征码的提取方法及装置
CN102867144B (zh) 一种用于检测和清除计算机病毒的方法和装置
Yang et al. APKLancet: tumor payload diagnosis and purification for android applications
Adkins et al. Heuristic malware detection via basic block comparison
Dhaya et al. Detecting software vulnerabilities in android using static analysis
Jain et al. Integrated Malware analysis using machine learning
Yin et al. Function recognition in stripped binary of embedded devices
Oh Fight against 1-day exploits: Diffing binaries vs anti-diffing binaries
Akram et al. DroidMD: an efficient and scalable android malware detection approach at source code level
Masid et al. Application of the SAMA methodology to Ryuk malware
Alam et al. Droidnative: Semantic-based detection of android native code malware
Lakhotia et al. Mining malware secrets
Wang et al. NativeSpeaker: Identifying crypto misuses in Android native code libraries
Byrne et al. Ace: Just-in-time serverless software component discovery through approximate concrete execution

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: 14876817

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: 14876817

Country of ref document: EP

Kind code of ref document: A1