Analysis function imparting method, analysis function imparting device, and analysis function imparting program
The analysis function imparting device and program overcome code obfuscation and conditional path challenges by analyzing script engines' virtual machines and applying exception handling, ensuring complete behavior detection of malicious scripts.
Patent Information
- Application Number
- JP2023553917
- Authority / Receiving Office
- JP · JP
- Patent Type
- Patents
- Current Assignee / Owner
- Filing Date
- 2021-10-18
- Publication Date
- 2024-10-16
- Estimated Expiration
- 2041-10-18
AI Technical Summary
Existing methods for analyzing malicious scripts, such as static and dynamic analysis, are hindered by code obfuscation and conditional execution paths that cannot be traced comprehensively, leading to incomplete behavior detection and potential analysis interference.
An analysis function imparting device and program that analyze a script engine's virtual machine, insert hooks, and apply exception handling to continue execution beyond exceptions, using virtual program counters and architecture information to trace all execution paths.
Enables comprehensive tracing of all execution paths in malicious scripts, suppressing execution stoppages due to exceptions, allowing for thorough behavior analysis and detection.
Smart Images

Figure 0007568129000001 
Figure 0007568129000002 
Figure 0007568129000003
Abstract
Description
[Technical field]
[0001] The present invention relates to an analytical function imparting method, an analytical function imparting device, and an analytical function imparting program. [Background technology]
[0002] As various forms of attacks such as spam using malware (malspam) and fileless malware emerge, the threat of attacks using scripts that exhibit malicious behavior (malicious scripts) is becoming more apparent.
[0003] A malicious script is a script that has malicious behavior and is a program that realizes attacks by exploiting the functions provided by a script engine. In general, attacks are carried out using the script engine that is installed by default in the Operating System (OS) or the script engine of a specific application such as a web browser or document file viewer.
[0004] Many of these script engines can also perform system actions such as file operations, network communications, and process launches, although they may require user permission. Therefore, attacks using malicious scripts pose a threat to users in the same way as attacks using malware in executable files.
[0005] In order to take measures against these malicious script attacks, it is necessary to accurately understand the behavior of the scripts. Therefore, there is a demand for technology that can clarify the behavior of scripts by analyzing them.
[0006] One problem that arises when analyzing malicious scripts is code obfuscation. Many malicious scripts are subject to a process called obfuscation, which hinders analysis. Obfuscation intentionally increases the complexity of the code, making it difficult to analyze based on superficial information about the code. In other words, it hampers an analysis method called static analysis, which analyzes the script without executing it, but using information obtained from the code.
[0007] In particular, when a part of the code to be executed is dynamically obtained from outside, that code cannot be statically analyzed because it can only be obtained by executing the code. Therefore, static analysis is impossible in principle.
[0008] On the other hand, a method called dynamic analysis, which executes a script and monitors its behavior to learn its behavior, is not affected by the obfuscation described above. For this reason, methods based on dynamic analysis are mainly used to analyze malicious scripts.
[0009] In general dynamic analysis, a malicious script is executed in an analysis environment and its behavior is monitored, and only the behavior of a single execution path executed in the malicious script is obtained. Therefore, there is a problem that the behavior of paths that were not executed in the analysis environment cannot be obtained.
[0010] In other words, for a malicious script that has a path that is executed only under specific conditions, there is a problem that not all behaviors can be analyzed even by dynamic analysis.
[0011] There may be cases where a path is only executed under certain conditions, for example, when the further execution path is determined by commands from a command server, or when analysis interference prevents malicious behavior from occurring in the analysis environment.
[0012] In the former case, if there is no command from the command server, the execution path is not determined and the path with malicious behavior is not executed. When a malicious script is detected and analyzed, it is often the case that the attacker has already retreated and the command server no longer exists, so in such cases, the malicious behavior cannot be observed.
[0013] The latter is an anti-analysis technique in which a malicious script obtains information about the environment in which it is being executed, and does not exhibit malicious behavior unless certain conditions are met. For example, if a frequently seen characteristic is found in the analysis environment, the script will determine that it is being analyzed and will halt execution.
[0014] Figure 26 is a diagram showing a code fragment that shows an example of anti-analysis. This code fragment has an anti-analysis function that obtains the number of cores of the CPU (Central Processing Unit) of the environment in which it is being executed, and if it is not between 2 and 8, it determines that the environment is likely to be an analysis environment and terminates execution. Otherwise, it determines that the environment is not an analysis environment and displays malicious behavior.
[0015] In order to capture the behavior of a path that is executed only under such specific conditions, multi-pass execution, which executes multiple execution paths, is required.
[0016] In multipath execution, when execution reaches a conditional branch, the execution state branches and each branched execution state follows its own execution path, thereby executing both of the two execution paths that occur at the conditional branch.
[0017] Regarding the realization of multi-pass execution, for example, Non-Patent Document 1 describes a method for realizing symbolic execution, which is a type of multi-pass execution, for JavaScript (registered trademark). With this method, executable paths can be exhaustively traced in conditional branches of JavaScript scripts, and behavior can be observed.
[0018] In addition, Non-Patent Document 2 describes a method for implementing forced path execution, which is a type of multi-path execution, for JavaScript. This method makes it possible to comprehensively trace all paths in conditional branches of JavaScript scripts and observe their behavior.
[0019] Non-Patent Document 3 describes a method for implementing symbolic execution of scripts executed on a script engine through the script engine by manually modifying the script engine in advance and then executing the script engine on a binary symbolic execution platform. According to this method, if there is a script engine that can be manually modified, it is possible to implement symbolic execution generically for any script language, and to comprehensively trace executable paths and observe behavior.
[0020] Non-Patent Document 4 describes a method for analyzing a virtual machine (VM) that malware often uses to obfuscate its own programs. This method makes it possible to obtain information about the architecture by analyzing the VM. Since it is the VM that controls the execution of scripts in a script engine, the concept of this method can be partially diverted.
[0021] In Non-Patent Document 5, a script engine is analyzed, and based on the obtained architecture information, a code that realizes a multi-pass execution function is added, thereby enabling multi-pass execution of scripts. This method makes it possible to realize multi-pass execution for a variety of script languages and engines. [Prior art documents] [Non-patent literature]
[0022] [Non-Patent Document 1] Prateek Saxena, et al, “A Symbolic Execution Framework for JavaScript”, 2010 IEEE Symposium on Security and Privacy. [Non-Patent Document 2] Kyungtae Kim, et al, “J-Force: Forced Execution on JavaScript”. [Non-Patent Document 3] Stefan Bucur, et al, “Prototyping Symbolic Execution Engines for Interpreted Languages”. [Non-Patent Document 4] Monirul Sharif, et al, “Automatic Reverse Engineering of Malware Emulators”, 2009 30th IEEE Symposium on Security and Privacy. [Non-Patent Document 5] Toshinori Usui, Kazuki Furukawa, Hayato Otsuki, Tomonori Ikuyo, Yuhei Kawakoya, Makoto Iwamura, Jun Miyoshi, Kanta Matsuura, “Automatic Addition of Multi-path Execution Function to Script Execution Environments”, Computer Security Symposium 2019 (CSS2019), pp.961-968, 2019. Summary of the Invention [Problem to be solved by the invention]
[0023] Here, an attacker may intentionally cause an exception to stop the analysis execution and disrupt the analysis. In addition, in multi-path execution using forced path execution, forcing the execution path may cause an exception that would not occur in normal execution to occur, causing the execution to stop. Since the analysis execution stops when an exception occurs, there is a demand for a technology that can continue the analysis execution even when an exception occurs.
[0024] To achieve this, when an exception occurs, it is necessary to forcibly skip the part that caused the exception and continue execution. In this case, the extent to which the part should be skipped (for example, should the currently executing instruction be skipped, should the basic block be skipped, or should the function be skipped) depends on the exception that occurred.
[0025] Therefore, as one technique for preventing execution from being stopped due to an exception, a technique for skipping the instruction that caused the exception and continuing execution is required.
[0026] The present invention has been made in consideration of the above, and aims to provide an analysis function-imparting method, an analysis function-imparting device, and an analysis function-imparting program that can provide a script engine with an execution function that suppresses execution stoppage due to an exception by skipping an instruction that causes an exception. [Means for solving the problem]
[0027] In order to solve the above-mentioned problems and achieve the object, the analysis function providing method of the present invention is an analysis function providing method executed by an analysis function providing device, and is characterized in that it includes a first analysis step of analyzing a virtual machine of a script engine and obtaining a hook point, which is a point where analysis code is inserted by applying a hook, and a virtual program counter, which is a variable indicating the next virtual machine instruction to be executed, a second analysis step of analyzing an instruction set architecture, which is a system of virtual machine instructions, and detecting an offset value of the virtual program counter, and an providing step of providing an analysis function by applying a hook to a hook point of the script engine, including a process of setting the next virtual program counter value to a value obtained by adding the virtual program counter offset value to the previous virtual program counter value, when an exception occurs, based on the virtual program counter and the virtual program counter offset value, which are architectural information obtained by the analysis in the first analysis step and the second analysis step. Effect of the Invention
[0028] According to the present invention, it is possible to provide a script engine with an execution function that prevents execution from being stopped due to an exception. [Brief description of the drawings]
[0029] [Figure 1] FIG. 1 is a diagram illustrating an example of an exception handler. [Diagram 2] FIG. 2 is a diagram illustrating an example of a hypervisor call using a hook of a script API. [Diagram 3] FIG. 3 is a diagram illustrating an example of a configuration of an analysis function imparting device according to an embodiment. [Figure 4] FIG. 4 is a diagram showing an example of a test script used for detecting a virtual program counter (VPC). [Diagram 5] FIG. 5 is a diagram illustrating an example of an execution trace. [Figure 6] FIG. 6 is a diagram illustrating an example of a VM execution trace. [Figure 7] FIG. 7 is a diagram illustrating the process of the VM instruction boundary detection unit. [Figure 8] FIG. 8 is a diagram illustrating the process of the virtual program counter detection unit. [Figure 9] FIG. 9 is a diagram illustrating the process of the dispatcher detection unit. [Figure 10] FIG. 10 is a diagram illustrating an example of the VPC determination process. [Figure 11] FIG. 11 is a diagram illustrating an example of the VPC determination process. [Figure 12] FIG. 12 is a diagram illustrating an example of the VPC determination process. [Figure 13] FIG. 13 is a diagram illustrating an example of a VPC update process. [Figure 14] FIG. 14 is a flowchart illustrating a processing procedure of the analysis function providing process according to the embodiment. [Figure 15] FIG. 15 is a flowchart of the execution trace acquisition process shown in FIG. [Figure 16]FIG. 16 is a flowchart showing the procedure of the hook / tap point detection process shown in FIG. [Figure 17] FIG. 17 is a flowchart illustrating the procedure of the VM instruction boundary detection process shown in FIG. [Figure 18] FIG. 18 is a flowchart illustrating the procedure of the virtual program counter detection process shown in FIG. [Figure 19] FIG. 19 is a diagram illustrating the process of the dispatcher detection unit. [Figure 20] FIG. 20 is a flowchart of the VM execution trace acquisition process shown in FIG. [Figure 21] FIG. 21 is a flowchart showing the procedure of the hook insertion process shown in FIG. [Figure 22] FIG. 22 is a flowchart showing the procedure of the VPC determination process. [Figure 23] FIG. 23 is a flowchart showing the procedure of the VPC update process. [Figure 24] FIG. 24 is a flowchart illustrating the procedure of the exception handler insertion process shown in FIG. [Diagram 25] FIG. 25 is a diagram illustrating an example of a computer that realizes the analysis function providing device by executing a program. [Figure 26] FIG. 26 is a diagram showing a code fragment that is an example of anti-analysis. DETAILED DESCRIPTION OF THE PREFERRED EMBODIMENTS
[0030] Hereinafter, an embodiment of an analysis function providing method, an analysis function providing device, and an analysis function providing program according to the present application will be described in detail with reference to the drawings. The present invention is not limited to the embodiment described below.
[0031] [Embodiment Mode] The analysis function adding device according to the embodiment is an analysis function adding device that can be applied to a script engine.
[0032] The analysis function providing device according to this embodiment executes a test script while monitoring the binary of a script engine, and obtains a branch trace and a memory access trace as an execution trace.
[0033] The analysis function providing device then analyzes the virtual machine based on this execution trace, and obtains architecture information such as hook points, tap points, a virtual program counter (VPC) which is a variable indicating the next VM instruction to be executed, VM instruction boundaries, and a dispatcher. Note that all of these are components of the script engine, and are information related to the architecture, and are stored in an architecture information DB 132 (described later).
[0034] Furthermore, the analysis function adding device executes the test script to obtain a VM execution trace, and detects the offset value of the VPC using the VM execution trace, thereby obtaining the offset value of the VPC as architecture information.
[0035] Then, the analysis function adding device inserts a hook into the hook point of the script engine using a hook handler based on the acquired architecture information. Furthermore, the analysis function adding device inserts an exception handler into the script to be analyzed, and adds an exception handling function. The exception handler has a function of forcibly transferring processing to the VM area when an exception occurs and captures the occurrence of the exception. The hook handler is added with a function of skipping the basic block in which the exception occurred by setting the value of the next VPC to a value obtained by adding a VPC offset value to the value of the previous VPC. As a result, the analysis function adding device transfers processing to the VM area when an exception occurs, and suppresses the stop of execution due to the exception by skipping the basic block in which the exception occurred as instructed by the hook handler.
[0036] Fig. 1 is a diagram for explaining an example of an exception handler. Fig. 2 is a diagram showing an example of a hypervisor call using a script API hook. As shown in Fig. 1, the analysis function providing device statically adds the contents of the boxes E1 to E3 to the entry point of the script to be analyzed before execution ((1) and (2) in Fig. 1).
[0037] Specifically, as shown in FIG. 1, the analysis function adding device adds "try" and "catch" codes to the entry point of the script to be analyzed (boxes E1 and E2), and adds "hooked_script_API(e)" code that hooks the script API when an exception occurs, as in the third line of box E3. As a result, when an exception occurs, the script API is hooked and used as a hypervisor call to skip the exception ((3) in FIG. 1). That is, as shown in FIG. 2, the analysis function adding device realizes the equivalent of a hypervisor call by hooking the script API ((1) in FIG. 2), and when an exception occurs, it transfers processing to the VM area and skips the basic block instructed by the hook handler where the exception occurred.
[0038] In this way, the analysis function-adding device captures the exception and inserts an exception handler into the script to be analyzed, forcing execution to proceed beyond the point where the exception occurred, thereby preventing unintended stops in execution and continuing the analysis.
[0039] [Configuration of the analysis function adding device] Next, the configuration of the analysis function-imparting device 10 according to the embodiment will be specifically described with reference to Fig. 3. Fig. 3 is a diagram illustrating an example of the configuration of the analysis function-imparting device according to the embodiment.
[0040] 3, the analysis function-imparting device 10 includes an input unit 11, a control unit 12, a storage unit 13, and an output unit 14. The analysis function-imparting device 10 receives inputs of a test script, a script engine binary, and a script to be analyzed.
[0041] The input unit 11 is composed of input devices such as a keyboard and a mouse, and accepts input of information from the outside and inputs it to the control unit 12. The input unit 11 also has a communication interface for transmitting and receiving various information to and from other devices connected via a wired connection or a network, etc., and accepts input of information transmitted from other devices. The input unit 11 accepts input of a test script and a script engine binary, and outputs it to the control unit 12. The test script is a script that is input when dynamically analyzing a script engine to obtain an execution trace and a VM execution trace. The test script will be described in detail later. The script engine binary is an executable file that constitutes a script engine. The script engine binary may be composed of multiple executable files. The analysis target script is a script to be analyzed.
[0042] The control unit 12 has an internal memory for storing programs that define various processing procedures and required data, and executes various processes using these. For example, the control unit 12 is an electronic circuit such as a CPU (Central Processing Unit) or an MPU (Micro Processing Unit). The control unit 12 has a virtual machine analysis unit 121 (first analysis unit), an instruction set architecture analysis unit 122 (second analysis unit), and a function provision unit 123 (provision unit).
[0043] The virtual machine analysis unit 121 analyzes the VM of the script engine. The virtual machine analysis unit 121 acquires a plurality of execution traces by changing the conditions at the time of execution, analyzes the plurality of execution traces using differential execution analysis, and acquires hook points, tap points, and VPCs. The virtual machine analysis unit 121 also analyzes the script engine binary to acquire VM instruction boundaries and dispatchers. The virtual machine analysis unit 121 includes an execution trace acquisition unit 1211, a hook / tap point detection unit 1212, a VM instruction boundary detection unit 1213, a virtual program counter detection unit 1214, and a dispatcher detection unit 1215.
[0044] The execution trace acquisition unit 1211 receives a test script and a script engine binary as input. The execution trace acquisition unit 1211 acquires an execution trace by executing the test script while monitoring the execution of the script engine binary.
[0045] The execution trace is composed of a branch trace and a memory access trace. The branch trace records the type of branch instruction at the time of execution, the branch source address, and the branch destination address. The memory access trace records the type of memory operation and the memory address of the operation target. It is known that the branch trace and the memory access trace can be acquired by an instruction hook. The execution trace acquired by the execution trace acquisition unit 1211 is stored in the execution trace DB 131.
[0046] The hook / tap point detection unit 1212 analyzes the virtual machine based on the execution trace acquired by the execution trace acquisition unit 1211, and detects hook points and tap points. Here, a hook point is a point where a hook is applied and analysis code is inserted. In the embodiment, the unit is a function (called an internal function) that the internal implementation of the script engine has, and a hook is applied to the beginning of this internal function. Also, a tap point is a memory monitoring point that is logged by analysis code, and is one of the arguments of the internal function.
[0047] The hook / tap point detection unit 1212 extracts and analyzes the execution trace stored in the execution trace DB 131 to find candidates for hook points. The hook / tap point detection unit 1212 searches the execution trace for calls to system APIs related to the analysis target, and detects hook point candidates by backtracing from there. The hook / tap point detection unit 1212 detects hook points by applying a backtrace from a system API corresponding to the language element (e.g., a script API) of the analysis target.
[0048] The hook / tap point detection unit 1212 detects hook point candidates by extracting the differences between multiple execution traces obtained under different conditions and finding parts that satisfy specific conditions. The hook / tap point detection unit 1212 detects hook points based on the differences found between execution traces obtained under multiple different conditions. In this case, the hook / tap point detection unit 1212 detects hook points using an algorithm (e.g., the Smith-Waterman algorithm) that detects the occurrence of a highly homologous sequence a specific number of times.
[0049] The hook / tap point detection unit 1212 hooks the obtained hook point candidates and detects tap points by searching the memory of the arguments of the hooked function. The hook / tap point detection unit 1212 detects tap points, which are memory monitoring points that are logged by the analysis code, based on monitoring at the hook points. In addition, the hook / tap point detection unit 1212 determines the hook point candidates that have tap points as hook points. Please refer to International Publication No. 2020 / 075335 for details of the processing of the hook / tap point detection unit 1212.
[0050] The VM instruction boundary detection unit 1213 clusters the execution trace to detect the boundaries of each VM instruction. The VM instruction boundary detection unit 1213 clusters the execution trace to detect clusters with a threshold or more of execution count as VM instructions. In the clustering, consecutive code regions executed multiple times are detected. For example, executed instructions that are close to each other in the code may be grouped together, or a common subsequence of executed code blocks may be found, or other methods may be used. The analysis function providing device 10 detects the start and end points of consecutive instruction sequences that constitute the detected VM instruction as boundaries. The VM instruction boundaries detected here are used in VPC detection and dispatcher detection.
[0051] The virtual program counter detection unit 1214 extracts and analyzes execution traces for test scripts stored in the execution trace DB 131 to detect VPCs. The virtual program counter detection unit 1214 detects VPCs by analyzing multiple execution traces using differential execution analysis focusing on the number of memory reads and the boundaries of each VM instruction detected by the VM instruction boundary detection unit 1213. The virtual program counter detection unit 1214 utilizes the fact that a read into a memory that holds a VPC always occurs after the execution of each VM instruction, and detects the VPC by discovering the destination of this read.
[0052] For this reason, the virtual program counter detection unit 1214 uses differential execution analysis focusing on the number of memory reads to detect VPCs. The virtual program counter detection unit 1214 compares execution traces of multiple test scripts acquired using the test scripts, and finds memories whose memory read counts change in proportion to both the increase and decrease of the number of repetitions and the number of repeated statements. The virtual program counter detection unit 1214 then refers to the boundaries of each VM instruction detected by the VM instruction boundary detection unit 1213, and narrows down the memory values that are read to those that always point to the start points of the VM instructions. The virtual program counter detection unit 1214 detects this memory as a VPC.
[0053] The dispatcher detection unit 1215 extracts each VM instruction portion from the script engine binary based on the boundaries of the VM instructions detected by the VM instruction boundary detection unit 1213, and detects the portion with high similarity between each VM instruction as a dispatcher. As a premise, the dispatcher is realized by referring to a pointer cache and jumping to the pointer of the next VM instruction handler. The dispatchers are distributed and arranged at the rear of each VM instruction handler, and the identity of their codes is generally high. By searching for the code with high identity at the rear of such VM instruction handlers, the analysis function adding device detects the dispatcher by a predetermined method. The detection of the portion with high similarity may use, for example, a sequence alignment algorithm, or other methods.
[0054] The instruction set architecture analysis unit 122 analyzes an instruction set architecture, which is a system of instructions for a VM, and includes a VM execution trace acquisition unit 1221 and a VPC offset detection unit 1222.
[0055] Like the execution trace acquisition unit 1211, the VM execution trace acquisition unit 1221 receives a test script and a script engine binary as input. The VM execution trace acquisition unit 1221 acquires a VM execution trace by monitoring a VPC and a pointer of a VM instruction handler dispatched by a dispatcher. The VM execution trace acquisition unit 1221 acquires a VM execution trace, which is an execution trace executed on a VM, by executing a test script while monitoring the execution of the script engine binary. The VM execution trace acquisition unit 1221 acquires a VM execution trace by executing a large number of test scripts in detecting a branch VM instruction. The VM execution trace acquisition unit 1221 associates a pointer to a VM instruction with the VM instruction, and virtually assigns a VM opcode as an identifier to each of them.
[0056] The VM execution trace is a record of the pointer of the executed VM instruction handler and the VPC. Specifically, the VM execution trace is composed of the VPC and the VM opcode for each executed VM instruction. The VPC can be recorded by monitoring the memory of the VPC detected by the virtual program counter detection unit 1214. The VM opcode is an identifier virtually assigned to each of the pointer to the VM instruction and the VM instruction that are linked to each other. The VM execution trace acquired by the VM execution trace acquisition unit 1221 is stored in the VM execution trace DB 133.
[0057] The VPC offset detection unit 1222 extracts the VM execution trace acquired by the VM execution trace acquisition unit and stored in the VM execution trace DB 133, and analyzes the log of the VM execution trace. The VPC offset detection unit 1222 acquires a pair of the opcode of the VM instruction and the offset value of the VPC before and after the execution of the VM instruction from the VM execution trace. The offset o is calculated by multiplying the value of the VPC before the execution of the VM instruction by p prev , the value after execution is p next Then, o=p next -p prev It is calculated as follows.
[0058] The function adding unit 123 inserts a hook into the script engine based on the acquired architecture information, and inserts an exception handler into the script to be analyzed, thereby adding an exception handling function. The function adding unit 123 has a hook inserting unit 1231 and an exception handler inserting unit 1232.
[0059] The hook insertion unit 1231 inserts a hook into the script engine. The hook insertion unit 1231 hooks the script engine based on architecture information obtained by the analysis by the virtual machine analysis unit 121 and the instruction set architecture analysis unit 122. The hook insertion unit 1231 receives hook points and tap points, and inserts hooks into the script engine using a hook handler based on the hook points and tap points to provide an analysis function. The hook handler includes a process of setting the value of the next VPC in the VM area to a value obtained by adding a VPC offset value to the value of the previous VPC.
[0060] Specifically, the hook insertion unit 1231 adds, to the hook handler, a VPC determination process for determining the value of the next VPC, and a VPC change process for changing the value of the next VPC to the VPC-determined value of the VPC.
[0061] The exception handler insertion unit 1232 inserts an exception handler into the script to be analyzed, and provides an exception handling function. The exception handler has a function of forcibly transferring processing to a VM area when an exception occurs and is caught. The exception handler insertion unit 1232 analyzes the script to be analyzed, and inserts the exception handler by adding exception handler code (for example, see FIG. 1) to each entry point so that exceptions in the code after the entry point can be caught.
[0062] The storage unit 13 is realized by a semiconductor memory element such as a RAM (Random Access Memory) or a flash memory, or a storage device such as a hard disk or an optical disk, and stores a processing program that operates the analysis function providing device 10, data used during execution of the processing program, etc. The storage unit 13 has an execution trace database (DB) 131, a VM execution trace DB 133, and an architecture information DB 132 that stores architecture information acquired by the virtual machine analysis unit 121 and the instruction set architecture analysis unit 122.
[0063] The execution trace DB131 and the VM execution trace DB133 store the execution trace and the VM execution trace acquired by the execution trace acquisition unit 1211 and the VM execution trace acquisition unit 1221, respectively. The execution trace DB131 and the VM execution trace DB133 are managed by the analysis function providing device 10. Of course, the execution trace DB131 and the VM execution trace DB133 may be managed by other devices (such as a server). In this case, the execution trace acquisition unit 1211 and the VM execution trace acquisition unit 1221 output the acquired execution trace and the VM execution trace to a management server or the like of the execution trace DB131 and the VM execution trace DB133 via the communication interface of the output unit 14, and store them in the execution trace DB131 and the VM execution trace DB133.
[0064] The output unit 14 is, for example, a liquid crystal display or a printer, and outputs various information including information related to the analysis function imparting device 10. The output unit 14 may also be an interface that controls input and output of various data between an external device, and may output various information to an external device.
[0065] [Test script configuration] Let us explain about test scripts. A test script is a script that is input when dynamically analyzing a script engine. This test script focuses on the number of branch instruction executions and memory reads and writes, and is used to capture the difference in the behavior of the script engine that occurs when the test script is executed a different number of times. This test script is prepared before the analysis and is created manually. Creating it requires knowledge of the specifications of the target script language.
[0066] Fig. 4 shows an example of a test script used to detect VPCs. The test script uses a repetitive process (line 2). The test script changes the execution conditions and generates differences by increasing or decreasing the number of repetitions (line 2) and the number of repeated statements (lines 3 to 5) in the test script.
[0067] Configure Execution Tracing Next, the execution trace will be explained. Fig. 5 is a diagram showing an example of an execution trace. As mentioned above, an execution trace is composed of a branch trace and a memory access trace. Fig. 5 shows an excerpt of a part of an execution trace. The structure of an execution trace will be explained below with reference to Fig. 5.
[0068] An execution trace has an element called "trace." In "trace," it is indicated whether the log line is a branch trace or a memory access trace.
[0069] A branch trace log line has the format shown in lines 1 to 10 of Figure 5, for example, and consists of three elements: type, src, and dst. type indicates whether the executed branch instruction was a call instruction, a jmp instruction, or a ret instruction. src indicates the address of the branch source, and dst indicates the address of the branch destination.
[0070] A log line of a memory access trace has the format shown in lines 11 to 13 of Figure 5, for example, and consists of three elements: type, target, and value. Type indicates whether the memory access is a read or write. Target indicates the memory address that is the target of the memory access. Value stores the result of the memory access.
[0071] [Configuring VM execution tracing] Next, a VM execution trace will be described. Fig. 6 is a diagram showing an example of a VM execution trace. As described above, a VM execution trace is a record of a VM opcode and a VPC. Fig. 6 shows a part of a VM execution trace. The structure of a VM execution trace will be described below with reference to Fig. 6.
[0072] A log line of a VM execution trace is, for example, in the format shown in Figure 6 and consists of two elements: vpc and vmop (vm opcode). vpc indicates the value of the VPC. Also, vmop indicates the value of the VM opcode virtually assigned to each pointer that points to the beginning of the VM instruction handler to be executed, obtained from the pointer cache.
[0073] [VM instruction boundary detection processing] Next, a description will be given of the processing of the VM instruction boundary detection unit 1213. FIG.
[0074] The VM instruction boundary detection unit 1213 detects the boundaries of each VM instruction. At this time, the VM instruction boundary detection unit 1213 detects VM instructions and their boundaries for a threaded code type VM in which it is difficult to grasp the boundaries of VM instructions because it does not have an interpreter loop. Specifically, the VM instruction boundary detection unit 1213 extracts an execution trace from the execution trace DB 131. Then, as shown in FIG. 7, the VM instruction boundary detection unit 1213 clusters the execution trace by a predetermined method, and detects a cluster whose execution count is equal to or greater than a threshold as a VM instruction (for example, VM instruction handlers 1 to 3). The VM instruction boundary detection unit 1213 detects the start point and end point of a continuous instruction sequence constituting a VM instruction as a boundary.
[0075] [Virtual program counter detection processing] Next, the processing of the virtual program counter detection unit 1214 will be described. The virtual program counter detection unit 1214 detects VPC and pointer cache. The detection of the virtual program counter is realized by analyzing the log of the memory access trace of the acquired execution trace. The virtual program counter detection unit 1214 uses differential execution analysis focusing on the number of times memory is read. FIG. 8 is a diagram for explaining the processing of the virtual program counter detection unit 1214.
[0076] The virtual program counter detection unit 1214 extracts one execution trace by a test script from the execution trace DB 131. The number of times a VPC is read is proportional to the number of repetitions in the test script and the number of statements in the repetitive process. When the number of repetitions is N and the number of repeated statements is M, approximately MN VPCs are read. Therefore, the virtual program counter detection unit 1214 extracts memory that has increased by 4MN and 9MN in the execution trace for a test script in which N and M have been increased to 2N and 2M, respectively, and 3N and 3M. Specifically, as shown in FIG. 8, the virtual program counter detection unit 1214 extracts a memory area that has a monotonically increasing Read / Write for each VM instruction execution ((1) in FIG. 8).
[0077] Then, the virtual program counter detection unit 1214 detects, as a VPC, a memory value that always points to the start point of a VM instruction. Specifically, the virtual program counter detection unit 1214 compares the VPC's pointing destination with the address of the VM instruction handler, and narrows down the matching memory area ((2) in FIG. 8).
[0078] [Dispatcher detection processing] Next, a description will be given of the process of the dispatcher detection unit 1215. The dispatcher detection unit 1215 detects a dispatcher by analyzing the binary of the script engine using a predetermined method. FIG. 9 is a diagram for explaining the process of the dispatcher detection unit 1215.
[0079] The dispatcher detection unit 1215 detects dispatchers. Based on the boundaries of VM instructions detected by the VM instruction boundary detection unit 1213, the dispatcher detection unit 1215 extracts each VM instruction portion from the script engine binary. Then, based on the assumption that the similarity of dispatcher codes is high ((1) in FIG. 9), the dispatcher detection unit 1215 calculates the similarity between codes of each VM instruction, and detects a portion having a high similarity between all VM instructions as a dispatcher. The dispatcher detection unit 1215 can detect a code commonly executed in the latter half of a VM instruction as a dispatcher ((1) in FIG. 9).
[0080] [Hook insertion part processing] Next, a description will be given of the processing of the hook insertion unit 1231. The hook insertion unit 1231 receives as input the script engine binary and the hook points and tap points detected in the processing up to this point. The hook insertion unit 1231 inserts a hook using a hook handler into the hook point in the script engine.
[0081] Here, the hook insertion unit 1231 inserts an analysis code so that execution transitions to processing of the hook handler in the VM area when the script API corresponding to the hook is executed at the time of hooking. This analysis code can be easily generated if the hook point and the tap point are known. As a result, by calling the hooked script API from the script, the function of the hook handler implemented in the VM area can be called as a hypervisor call, and the provision of the analysis function is realized.
[0082] At this time, the hook insertion unit 1231 adds a VPC determination process (first process) and a VPC update process (second process) to the hook handler.
[0083] 10 to 12 are diagrams for explaining an example of the VPC determination process. In the VPC determination process, the VPC is constantly traced (FIG. 10(1)). In the VPC determination process, the VPC value immediately before the exception occurs is detected from the latest entry of the VPC trace based on the VPC trace (FIG. 11(2)). Then, in the VPC determination process, the VPC offset collected in advance by the VPC offset detection unit 1222 is used to determine the next VPC value (FIG. 12(3)). The next VPC value is the value of the VPC immediately before the exception occurs plus the VPC offset value.
[0084] Fig. 13 is a diagram for explaining an example of the VPC update process. In the VPC update process, the value of the next VPC determined in the VPC determination process is set as the value of the next VPC, and execution is resumed ((1) in Fig. 13). By adding this VPC determination process and VPC update process, an exception skip function can be given to the script to be analyzed.
[0085] [Processing procedure of the analysis function adding device] Next, there will be described the procedure of the analysis function imparting process performed by the analysis function imparting device 10. Fig. 14 is a flowchart showing the procedure of the analysis function imparting process according to the embodiment.
[0086] First, the input unit 11 receives a test script and a script engine binary as input (step S1).
[0087] Then, the execution trace acquisition unit 1211 executes the test script while monitoring the binary of the script engine, thereby performing an execution trace acquisition process to acquire a branch trace and a memory access trace (step S2).
[0088] The hook / tap point detection unit 1212 analyzes the virtual machine based on the execution trace acquired by the execution trace acquisition unit 1211, and performs hook / tap point detection processing to detect hook points and tap points (step S3).
[0089] The VM instruction boundary detection unit 1213 detects VM instructions and performs VM instruction boundary detection processing to detect VM instruction boundaries (step S4). The virtual program counter detection unit 1214 extracts and analyzes execution traces for test scripts stored in the execution trace DB 131, and performs virtual program counter detection processing to discover VPCs (step S5).
[0090] The dispatcher detection unit 1215 performs a dispatcher detection process in which each VM instruction portion is extracted from the script engine binary, and a portion having a high degree of similarity between the VM instructions is detected as a dispatcher (step S6).
[0091] The VM execution trace acquisition unit 1221 performs a VM execution trace acquisition process that receives a test script and a script engine binary as input, and acquires a VM execution trace by executing the test script while monitoring the execution of the script engine binary (step S7). The VPC offset detection unit 1222 performs a VPC offset detection process that acquires a pair of an opcode of a VM instruction and an offset value of a VPC before and after the execution of the instruction from the VM execution trace (step S8).
[0092] The hook insertion unit 1231 performs a hook insertion process to insert a hook into the script engine based on the architecture information acquired in the processes of steps S1 to S6 (step S9).Then, the exception handler insertion unit 1232 performs an exception handler insertion process to insert an exception handler into the script to be analyzed and to impart an exception handling function (step S10).Then, the output unit 124 outputs the script engine binary to which the exception skip function has been imparted (step S11).
[0093] [Processing procedure for acquiring execution trace] Next, a description will be given of the flow of the execution trace acquisition process shown in Fig. 14. Fig. 15 is a flowchart showing the processing procedure of the execution trace acquisition process shown in Fig. 14.
[0094] First, the execution trace acquisition unit 1211 receives a test script and a script engine binary as input (step S21). Then, the execution trace acquisition unit 1211 hooks the received script engine to acquire a branch trace (step S22). The execution trace acquisition unit 1211 also hooks the received script engine to acquire a memory access trace (step S23).
[0095] Then, the execution trace acquisition unit 1211 inputs the test script received in this state to the script engine for execution (step S24), and stores the execution trace acquired thereby in the execution trace DB 131 (step S25).
[0096] The execution trace acquisition unit 1211 judges whether or not all the input test scripts have been executed (step S26). If all the input test scripts have been executed (step S26: Yes), the execution trace acquisition unit 1211 ends the process. On the other hand, if all the input test scripts have not been executed (step S26: No), the execution trace acquisition unit 1211 returns to the execution of the test scripts in step S24 and continues the process.
[0097] [Hook / tap point detection process procedure] FIG. 16 is a flowchart showing the procedure of the hook / tap point detection process shown in FIG.
[0098] 16, in the hook tap point detection process, the hook tap point detection unit 1212 detects hook point candidates (step S31). If the hook tap point detection unit 1212 detects a hook point candidate (step S32: Yes), the hook tap point detection unit 1212 proceeds to step S35. On the other hand, if the hook point candidate is not detected (step S32: No), the hook tap point detection unit 1212 performs a differential execution analysis process to detect hook points based on differences observed between execution traces under multiple different conditions (step S33).
[0099] If no hook point candidate is detected (step S34: No), the hook / tap point detection unit 1210 ends the process since there is no hook point candidate. On the other hand, if a hook point candidate is detected (step S34: Yes), the hook / tap point detection unit 1212 proceeds to step S35. The hook / tap point detection unit 1212 detects a tap point (step S35).
[0100] [VM instruction boundary detection process procedure] Next, a description will be given of the flow of the VM instruction boundary detection process shown in Fig. 14. Fig. 17 is a flowchart showing the processing procedure of the VM instruction boundary detection process shown in Fig. 14.
[0101] First, the VM instruction boundary detection unit 1213 extracts the execution trace from the execution trace DB 131 (step S41). The VM instruction boundary detection unit 1213 clusters the execution trace using a predetermined method (step S42). Any method may be used for the clustering.
[0102] The VM instruction boundary detection unit 1213 detects a cluster whose execution count is equal to or greater than a threshold as a VM instruction (step S43).Then, the VM instruction boundary detection unit 1213 sets the start point and end point of a continuous instruction sequence that constitutes a VM instruction as a boundary (step S44).The VM instruction boundary detection unit 1213 outputs the VM instruction boundary as a return value (step S45), and ends the VM instruction boundary detection process.
[0103] [Procedure for detecting virtual program counter] Next, a description will be given of the flow of the virtual program counter detection process shown in Fig. 14. Fig. 18 is a flowchart showing the processing procedure of the virtual program counter detection process shown in Fig. 14.
[0104] First, the virtual program counter detection unit 1214 extracts one execution trace by a test script from the execution trace DB 131 (step S51). Next, the virtual program counter detection unit 1214 focuses on memory access traces among the execution traces, and counts up the number of reads for each memory read destination (step S52).
[0105] The virtual program counter detection unit 1214 receives as input the test script used to obtain the execution trace (step S53), and analyzes the test script to obtain the number of repetitions and the number of repeated statements (step S54).
[0106] Next, the virtual program counter detection unit 1214 extracts another execution trace by a test script with a different number of repetitions or number of repeated statements from the execution trace DB 131 (step S55).The virtual program counter detection unit 1214 then focuses on the memory access trace and counts up the number of reads for each memory read destination (step S56).The virtual program counter detection unit 1214 also receives as input the test script used to obtain the execution trace (step S57), analyzes the test script, and obtains the number of repetitions and the number of repeated statements (step S58).
[0107] Here, the virtual program counter detection unit 1214 narrows down the memory read destinations to only those whose read counts change in proportion to the increase or decrease in the number of repetitions or repeated statements (step S59). Furthermore, the virtual program counter detection unit 1214 narrows down the memory read destinations narrowed down in step S59 to those whose read memory values always point to the start point of the VM instruction (step S60).
[0108] Then, the virtual program counter detection unit 1214 judges whether the memory read destinations have been narrowed down to only one (step S61). If the virtual program counter detection unit 1214 has not narrowed down the memory read destinations to only one (step S61: No), the process returns to step S55, and the virtual program counter detection unit 1214 extracts the next execution trace and continues the process. On the other hand, if the virtual program counter detection unit 1214 has narrowed down the memory read destinations to only one (step S61: Yes), the virtual program counter detection unit 1214 stores the narrowed down memory read destination in the architecture information DB 132 as a virtual program counter (step S62), and ends the process.
[0109] [Dispatcher detection process procedure] Next, a description will be given of the flow of the dispatcher detection process shown in Fig. 14. Fig. 19 is a flowchart showing the processing procedure of the dispatcher detection process shown in Fig. 14.
[0110] First, the dispatcher detection unit 1215 receives a script engine binary as an input (step S71). The dispatcher detection unit 1215 receives a boundary of a VM instruction from the VM instruction boundary detection unit 1213 (step S72).
[0111] The dispatcher detection unit 1215 extracts each VM instruction portion from the script engine binary based on the boundaries of the VM instructions received from the VM instruction boundary detection unit 1213 (step S73). The dispatcher detection unit 1215 calculates the similarity between the codes of each VM instruction by a predetermined method (step S74). The method of calculating the similarity may be any method that can calculate the similarity between codes.
[0112] The dispatcher detection unit 1215 extracts a part having a high similarity among all VM instructions based on the similarity calculated in step S74 (step S75). Then, the dispatcher detection unit 1215 determines whether it is the end part of the VM instruction (step S76).
[0113] If it is not the end of the VM instruction (step S76: No), the dispatcher detection unit 1215 returns to step S75 and continues the process. If it is the end of the VM instruction (step S76: Yes), the dispatcher detection unit 1215 outputs the extracted part as a dispatcher (step S77) and ends the process.
[0114] [VM execution trace acquisition process procedure] Next, a description will be given of the flow of the VM execution trace acquisition process shown in Fig. 14. Fig. 20 is a flowchart showing the processing procedure of the VM execution trace acquisition process shown in Fig. 14.
[0115] First, the VM execution trace acquisition unit 1221 receives a test script and a script engine binary as input (step S81). Then, the VM execution trace acquisition unit 1221 hooks the received script engine to record a VPC and a VM opcode (step S82).
[0116] The VM execution trace acquisition unit 1221 inputs the received test script in this state to the script engine for execution (step S83), and stores the VM execution trace acquired thereby in the VM execution trace DB 133 (step S84).
[0117] The VM execution trace acquisition unit 1221 judges whether or not all the input test scripts have been executed (step S85). If all the input test scripts have been executed (step S85: Yes), the VM execution trace acquisition unit 1221 ends the process. If all the input test scripts have not been executed (step S85: No), the VM execution trace acquisition unit 1221 returns to the execution of the test script in step S83 and continues the process.
[0118] [Hook insertion process] Next, a description will be given of the flow of the hook insertion process shown in Fig. 14. Fig. 21 is a flowchart showing the processing procedure of the hook insertion process shown in Fig. 14.
[0119] First, the hook insertion unit 1231 receives as input the hook point and the tap point detected by the hook / tap point detection unit 1212 (step S101), and prepares a hook handler (step S102).
[0120] The hook insertion unit 1231 adds a VPC determination process to the hook handler (step S103). The hook insertion unit 1231 adds a VPC update process to the hook handler (step S104). The hook insertion unit 1231 inserts a hook using the hook handler into the hook point (step S105).
[0121] [VPC determination process] 22 is a flowchart showing the procedure of the VPC determination process. In the VPC determination process, the offset of the VPC of each VM instruction is received as an input (step S111).
[0122] In the VPC determination process, the VM instructions and the VPCs are constantly traced (step S112). In the VPC determination process, the value of the VPC immediately before the exception occurred is detected from the latest entry of the VPC trace based on the VPC trace (step S113).
[0123] In the VPC determination process, the VPC offset is obtained from the VM instruction immediately before the exception occurs (step S114). In the VPC determination process, the next VPC value is calculated from the VPC value immediately before the exception occurs and the VPC offset value (step S115). In the VPC determination process, the next VPC value is output (step S116).
[0124] [VPC update process] 23 is a flowchart showing the procedure of the VPC update process. In the VPC update process, the value of the next VPC determined in the VPC determination process is received as an input (step S121), and is set as the VPC value (step S122). In the VPC update process, execution is resumed (step S123).
[0125] [Exception handler insertion process] A description will be given of the flow of the exception handler insertion process shown in Fig. 14. Fig. 24 is a flowchart showing the processing procedure of the exception handler insertion process shown in Fig. 14.
[0126] The exception handler insertion unit 1232 receives a script to be analyzed as an input (step S141). The exception handler insertion unit 1232 analyzes the script to be analyzed using a predetermined method, and extracts an entry point (step S142).
[0127] The exception handler insertion unit 1232 extracts one entry point (step S143). The exception handler insertion unit 1232 adds an exception handler code (for example, see FIG. 1) so that an exception can be caught in the code after the entry point (step S144).
[0128] The exception handler insertion unit 1232 determines whether or not the exception handler has been added to all the entry points (step S145). If the exception handler has not been added to all the entry points (step S145: No), the exception handler insertion unit 1232 extracts the next entry point (step S146) and proceeds to step S144 to add the code of the exception handler.
[0129] If the exception handlers have been added to all the entry points (step S145: Yes), the exception handler insertion unit 1232 ends the process.
[0130] [Effects of the embodiment] In this way, the analysis function-adding device 10 according to the embodiment executes the test script while monitoring the binary of the script engine, and acquires the branch trace and the memory access trace as the execution trace. The analysis function-adding device 10 analyzes the virtual machine based on the execution trace, and acquires architecture information of hook points, tap points, VPCs, VM instruction boundaries, and dispatchers. Furthermore, the analysis function-adding device 10 executes the test script to acquire the VM execution trace, and detects the offset value of the VPC using the VM execution trace, and acquires it as the architecture information.
[0131] Then, based on the obtained architecture information, the analysis function-imparting device 10 applies a hook to the hook point of the script engine, which includes a process of setting the value of the next VPC to the value of the previous VPC plus the VPC offset value when an exception occurs, thereby imparting an analysis function including an exception handling function.
[0132] Specifically, the analysis function-imparting device 10 imparts an exception handling function to a script to be analyzed by inserting an exception handler that forcibly transfers processing to a VM area when an exception occurs and captures the occurrence of the exception. The analysis function-imparting device 10 performs hooking in the VM area using a hook handler that includes processing that sets the value of the next VPC to a value obtained by adding a VPC offset value to the value of the previous VPC. In this way, the analysis function-imparting device 10 prevents execution from being stopped due to an exception by skipping the basic block in which the exception occurred.
[0133] As a result, the analysis function-adding device 10 can detect various architectural information by analysis based on the acquisition of execution traces and VM execution traces, even for proprietary script engines for which only binaries are available, and can add exception handling functions without the need for manual reverse engineering.
[0134] Furthermore, the analysis function adding device 10 can automatically add an exception handling function to various script engines as long as a test script is prepared, so that the exception handling function can be added without requiring individual design or implementation.
[0135] As described above, the analysis function-imparting device 10 is useful for analyzing the behavior of malicious scripts written in a wide variety of script languages, and is suitable for analyzing the behavior of malicious scripts whose execution stops due to an exception during the analysis without being affected by the exception. Therefore, by using the analysis function-imparting device 10 to impart an exception handling function to various script engines, it is possible to analyze the behavior of malicious scripts while suppressing the execution from stopping due to the exception even when an exception occurs, and therefore it is possible to utilize this for measures such as detection.
[0136] The analysis function-imparting device 10 can similarly catch exceptions in multi-path execution due to forced execution paths, and continue analysis while preventing unintended stops of execution.
[0137] [System configuration of the embodiment] Each component of the analysis function-imparting device 10 shown in Fig. 3 is a functional concept, and does not necessarily have to be physically configured as shown in the figure. In other words, the specific form of distribution and integration of the functions of the analysis function-imparting device 10 is not limited to that shown in the figure, and all or part of it can be functionally or physically distributed or integrated in any unit depending on various loads, usage conditions, etc.
[0138] Further, all or any part of each process performed in the analysis function-imparting device 10 may be realized by a CPU and a program analyzed and executed by the CPU. Further, each process performed in the analysis function-imparting device 10 may be realized as hardware using wired logic.
[0139] Furthermore, among the processes described in the embodiments, all or part of the processes described as being performed automatically can be performed manually. Alternatively, all or part of the processes described as being performed manually can be performed automatically by a known method. In addition, the process procedures, control procedures, specific names, and information including various data and parameters described above and shown in the drawings can be changed as appropriate unless otherwise specified.
[0140] [program] 25 is a diagram showing an example of a computer in which a program is executed to realize the analytical function-imparting device 10. The computer 1000 has, for example, a memory 1010 and a CPU 1020. The computer 1000 also has a hard disk drive interface 1030, a disk drive interface 1040, a serial port interface 1050, a video adapter 1060, and a network interface 1070. These components are connected by a bus 1080.
[0141] The memory 1010 includes a ROM 1011 and a RAM 1012. The ROM 1011 stores a boot program such as a BIOS (Basic Input Output System). The hard disk drive interface 1030 is connected to a hard disk drive 1090. The disk drive interface 1040 is connected to a disk drive 1100. A removable storage medium such as a magnetic disk or an optical disk is inserted into the disk drive 1100. The serial port interface 1050 is connected to a mouse 1110 and a keyboard 1120, for example. The video adapter 1060 is connected to a display 1130, for example.
[0142] The hard disk drive 1090 stores, for example, an OS 1091, an application program 1092, a program module 1093, and program data 1094. That is, a program that defines each process of the analysis function-imparting device 10 is implemented as a program module 1093 in which code executable by the computer 1000 is written. The program module 1093 is stored, for example, in the hard disk drive 1090. For example, a program module 1093 for executing the same process as the functional configuration in the analysis function-imparting device 10 is stored in the hard disk drive 1090. The hard disk drive 1090 may be replaced by an SSD (Solid State Drive).
[0143] Furthermore, setting data used in the processing of the above-described embodiment is stored as program data 1094, for example, in memory 1010 or hard disk drive 1090. Then, CPU 1020 reads out program module 1093 or program data 1094 stored in memory 1010 or hard disk drive 1090 into RAM 1012 as necessary, and executes the program.
[0144] Note that the program module 1093 and the program data 1094 are not limited to being stored in the hard disk drive 1090, but may be stored in, for example, a removable storage medium and read by the CPU 1020 via the disk drive 1100 or the like. Alternatively, the program module 1093 and the program data 1094 may be stored in another computer connected via a network (such as a local area network (LAN) or wide area network (WAN)). The program module 1093 and the program data 1094 may then be read by the CPU 1020 from the other computer via the network interface 1070.
[0145] Although the embodiment of the invention made by the present inventor has been described above, the present invention is not limited by the description and drawings which form a part of the disclosure of the present invention according to the present embodiment. In other words, other embodiments, examples, operation techniques, etc. made by those skilled in the art based on the present embodiment are all included in the scope of the present invention. [Explanation of symbols]
[0146] 10. Analysis function providing device 11 Input section 12 Control section 13 Storage section 14 Output section 121 Virtual Machine Analysis Department 122 Instruction Set Architecture Analysis Department 123 Functionality Department 131 Execution Trace Database (DB) 132 Architecture Information DB 133 VM Execution Trace DB 1211 Execution trace acquisition unit 1212 Hook / tap point detector 1213 VM instruction boundary detection unit 1214 Virtual Program Counter Detector 1215 Dispatcher Detector 1221 VM Execution Trace Acquisition Unit 1222 VPC offset detector 1231 Hook insertion part 1232 Exception Handler Insertion
Claims
1. An analysis function imparting method executed by an analysis function imparting device, a first analysis step of analyzing a virtual machine of a script engine and acquiring a hook point, which is a point where an analysis code is inserted by hooking, and a virtual program counter, which is a variable indicating a next instruction of the virtual machine to be executed; a second analysis step of analyzing an instruction set architecture, which is an instruction system of the virtual machine, to detect an offset value of the virtual program counter; an attaching step of attaching an analysis function by attaching a hook to the hook point of the script engine, the hook including a process of setting the next virtual program counter value to a value obtained by adding the virtual program counter offset value to the immediately preceding virtual program counter value when an exception occurs, based on the virtual program counter and the virtual program counter offset value, which are architecture information obtained by the analyses in the first analysis step and the second analysis step; A method for imparting an analytical function, comprising:
2. The applying step includes: a first insertion step of inserting an exception handler into a script to be analyzed, the exception handler having a function of transferring processing to a virtual machine area when an exception has occurred; a second insertion step of inserting a hook at the hook point of the script engine by using a hook handler including a process of setting the next virtual program counter value in the virtual machine area to a value obtained by adding an offset value of the virtual program counter to the immediately preceding virtual program counter value; 2. The method for providing an analysis function according to claim 1, further comprising:
3. The second analysis step includes: a first acquisition step of acquiring a virtual machine execution trace, which is an execution trace executed in the virtual machine, in which a virtual machine opcode is virtually assigned as an identifier, and a pointer to an executed virtual machine instruction handler and the virtual program counter are recorded; a first detection step of acquiring, from the virtual machine execution trace, a pair of an opcode of a virtual machine instruction and an offset value of the virtual program counter before and after execution of the virtual machine instruction; Including, The hook handler: a first process for detecting a value of the virtual program counter immediately before an exception occurs, and determining the next virtual program counter value to be a value obtained by adding an offset value of the virtual program counter detected in the first detection step to the immediately previous virtual program counter value; a second process of setting the value of the virtual program counter determined in the first process to a next value of the virtual program counter and resuming execution; 3. The method for providing an analysis function according to claim 2, further comprising:
4. The first analysis step includes: a second acquisition step of acquiring a plurality of execution traces by changing execution conditions; a second detection step of analyzing the execution trace to detect the hook points; a third detection step of clustering the execution trace to detect boundaries of each virtual machine instruction; a fourth detection step of analyzing the execution traces using a differential execution analysis focusing on the number of memory reads and the boundaries of each virtual machine instruction detected in the third detection step, and detecting the virtual program counter; a fifth detection step of analyzing the binary of the script engine based on the boundaries of each virtual machine instruction detected in the first detection step, and detecting a dispatcher; 4. The method for providing an analysis function according to claim 3, further comprising:
5. 5. The analytical function providing method according to claim 1, wherein the first analysis step and the second analysis step perform analysis using a test script.
6. a first analysis unit that analyzes a virtual machine of a script engine and obtains a hook point, which is a point where an analysis code is inserted by hooking, and a virtual program counter, which is a variable indicating a next instruction of the virtual machine to be executed; a second analysis unit that analyzes an instruction set architecture, which is an instruction system of the virtual machine, to detect an offset value of the virtual program counter; an attachment unit that attaches an analysis function by applying a hook to the hook point of the script engine based on the virtual program counter and the offset value of the virtual program counter, which are architecture information obtained by the analysis by the first analysis unit and the second analysis unit, the hook including a process of setting the next value of the virtual program counter to a value obtained by adding the offset value of the virtual program counter to the immediately preceding value of the virtual program counter when an exception occurs; An analysis function-imparting device comprising:
7. a first analysis step of analyzing a virtual machine of a script engine and acquiring a hook point, which is a point where an analysis code is inserted by hooking, and a virtual program counter, which is a variable indicating a next instruction of the virtual machine to be executed; a second analysis step of analyzing an instruction set architecture, which is an instruction system of the virtual machine, to detect an offset value of the virtual program counter; an attaching step of attaching an analysis function by attaching a hook including a process of setting a next value of the virtual program counter to a value obtained by adding the offset value of the virtual program counter to the immediately preceding value of the virtual program counter when an exception occurs, at the hook point of the script engine based on the virtual program counter and the offset value of the virtual program counter, which are architecture information obtained by the analyses in the first analysis step and the second analysis step; A program that provides analytical functions to enable a computer to execute the above.
Citation Information
Patent Citations
Analysis function imparting device, analysis function imparting method, and analysis function imparting program
WO2020075335A1
Analysis function addition device, analysis function addition method, and analysis function addition program
WO2021070393A1
