Analysis device, analysis method, and analysis program

The analysis device analyzes script engines' ISAs by executing test scripts and interpreting execution traces, overcoming limitations in existing methods, enabling detailed VM analysis and tool development for diverse scripting languages.

WO2024214261A1PCT designated stage expired Publication Date: 2024-10-17NIPPON TELEGRAPH & TELEPHONE CORP
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
PCT/JP2023/015089
Authority / Receiving Office
WO · WO
Patent Type
Applications
Current Assignee / Owner
Filing Date
2023-04-13
Publication Date
2024-10-17

AI Technical Summary

Technical Problem

Existing methods are limited in analyzing the Instruction Set Architecture (ISA) of script engines with unknown specifications, particularly for proprietary engines, as they require reverse engineering and are not applicable to all types of VMs, and are restricted to specific operations and data flow analysis.

Method used

An analysis device and method that executes test scripts to acquire execution traces, analyze virtual machine instructions, and determine their operations and input/output, enabling the analysis of a wide variety of VMs' ISAs without manual reverse engineering.

Benefits of technology

Enables detailed analysis of VMs' ISAs, allowing for the creation of tools like bytecode disassemblers and debuggers, and supports advanced analysis engines, eliminating the need for manual reverse engineering and accommodating various scripting languages.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure JP2023015089_17102024_PF_FP_ABST
    Figure JP2023015089_17102024_PF_FP_ABST
Patent Text Reader

Abstract

An analysis device (10) includes: a virtual machine analysis unit (121) that analyzes a script engine VM on the basis of a first execution trace acquired by executing a first test script while monitoring the script engine binary; and a command set architecture analysis unit (122) that collects VM commands by analyzing a command set architecture which is the VM command scheme, that determines the operation of the collected VM commands, and that detects the input / output of the VM commands using a second test script.
Need to check novelty before this filing date? Find Prior Art

Description

Analysis device, analysis method, and analysis program

[0001] The present invention relates to an analysis device, an analysis method, and an analysis program.

[0002] Script analysis techniques are used for a variety of purposes, including compiler optimization for just-in-time (JIT) compilation, software testing and debugging, fuzzing, and malware analysis.

[0003] [Analysis Methods] There are two techniques for analyzing programs that include scripts: static analysis and dynamic analysis. Dynamic analysis is a technique that analyzes the behavior of a program by actually executing it and observing its behavior. Static analysis is a technique that analyzes the function of a program by interpreting its meaning without executing it.

[0004] [Script Execution Method and Analysis] Scripts are executed by a script engine (also called an interpreter). A script input to a script engine is generally converted into bytecode at runtime, and the bytecode is interpreted and executed by a virtual machine (VM). For this reason, it is common to statically analyze the script before execution and then dynamically analyze the bytecode at runtime.

[0005] [Bytecode and Instruction Set Architecture] Bytecode is an intermediate representation converted from a script and is composed of a set of instructions (VM instructions) that can be interpreted and executed by a VM. Each VM instruction is responsible for a small unit of operation to realize the function of the script, such as arithmetic operations, logical operations, data transfer, comparison, branching, etc.

[0006] A VM instruction consists of an opcode (called a VM opcode) that indicates the operation, and an operand (called a VM operand) that is the target of the operation.

[0007] A VM instruction receives an operation target as input and outputs the operation result as necessary. For example, an addition VM instruction receives an augend and an addend as input and outputs the sum. Input and output of a VM instruction are generally passed via a data area called a virtual stack or virtual register. Furthermore, references to constants and variables are made via a data structure called a symbol table.

[0008] The specifications of the VM, such as the VM instructions that each VM performs, the target of each instruction, and how input and output are passed between VM instructions, vary from VM to VM. These specifications are called the VM's instruction set architecture (ISA).

[0009] [Necessity of Analyzing Bytecode] In software testing and debugging, scripts are generally analyzed, but there are also cases where bytecode should be analyzed.

[0010] For example, you may want to obtain a runtime profile in order to speed up the process. As mentioned above, scripts are converted into bytecode before they are executed. Therefore, to obtain a detailed profile, you need to analyze the bytecode instead of the script.

[0011] In cybersecurity applications, obfuscated malicious scripts may also be analyzed. Obfuscation is a technique that thwarts analysis and makes the script difficult to interpret.

[0012] For example, in some cases, a script has only a bytecode loader function, which dynamically retrieves and executes compiled bytecode at runtime. In such cases, the main behavior of the script cannot be revealed unless the bytecode is analyzed.

[0013] [Importance of Fine-Grained Analysis of Bytecode] When analyzing bytecode, there are various levels of granularity, such as analysis at the function level, basic block level, and VM instruction level.

[0014] To analyze bytecode in detail, fine-grained analysis is necessary. Because a VM instruction is the smallest unit that makes up a bytecode, analysis at the VM instruction level is necessary to achieve fine-grained analysis.

[0015] For example, behavior realized by a set of VM instructions, such as a conditional branch, cannot be elucidated in detail without analysis at the VM instruction level. Understanding the conditional expressions related to the branch is important for understanding the behavior, and such analysis is indispensable. Therefore, analysis of bytecode at the VM instruction level is important.

[0016] Some script engines provide analysis support functions, such as a debugger or a bytecode disassembler, to perform the analysis, and these may be used.

[0017] However, if such a function is not provided, it is necessary to analyze the script independently. Furthermore, script debuggers generally provide analysis at the expression or statement level of the script, and often do not have the function to analyze at the VM instruction level.

[0018] Therefore, a technology is needed that can independently perform fine-grained analysis of bytecode without relying on such analysis support functions.

[0019] [Necessity of Analysis of Instruction Set Architecture] In order to analyze bytecode at the VM instruction level, it is necessary to know what values ​​each VM instruction constituting the bytecode targets and what operations it performs. Therefore, it is necessary to understand the ISA. Once the ISA is understood, analysis can be achieved by observing and interpreting the operations of each VM instruction in the bytecode one by one.

[0020] Understanding the ISA is essential for building basic analysis tools such as bytecode disassemblers and debuggers. Furthermore, the results of ISA analysis are used to build advanced analysis engines such as dynamic bytecode instrumentation, symbolic execution, and taint analysis.

[0021] However, with the exception of some implementations, the internal specifications, including the ISA, are not publicly available. In particular, for proprietary script engines, the source code is not available, so the ISA cannot be understood without reverse engineering.

[0022] However, manually analyzing each of the various script engines individually is not realistic due to the enormous amount of work required. Therefore, a technique for analyzing ISAs is required.

[0023] A method has been proposed in which an execution trace is acquired for a VM whose internal specifications are unknown, and the semantics of the VM instructions are learned and acquired by program synthesis using Monte Carlo tree search (Non-Patent Document 1).The method described in Non-Patent Document 1 makes it possible to understand the semantics of instructions in an unknown VM and analyze the ISA.

[0024] Furthermore, a method has been proposed for inferring the data flow of an instruction from a set of inputs and outputs of the instruction for a processor with an unknown instruction set architecture (Non-Patent Document 2). The method described in Non-Patent Document 2 makes it possible to partially grasp the semantics of the instructions of an unknown VM, which can be useful in elucidating the ISA.

[0025] Tim Blazytko, Moritz Contag, Cornelius Aschermann, and Thorsten Holz, “Syntia: Synthesizing the Semantics of Obfuscated Code”, In Proceedings of the 26th USENIX Security Symposium, 2017. Zheng Leong Chua, Yanhao Wang, Teodora Baluta, Prateek Saxena, Zhenkai Liang, and Purui Su, “One Engine To Serve 'em All: Inferring Taint Rules Without Architectural Semantics”, In Proceedings of the 26th Network and Distributed Systems Security Symposium, 2019.

[0026] However, the method described in Non-Patent Document 1 uses program synthesis inferred from input and output, which means that the target VM instructions are limited to limited operations such as arithmetic operations and logical operations, and the analysis of the ISA is also limited to a certain part.

[0027] Furthermore, the method described in Non-Patent Document 2 has the problem that it is limited in scope because it relies on inference from input and output, just like Non-Patent Document 1. Furthermore, the method described in Non-Patent Document 2 has the problem that it clarifies the data flow but does not clarify the operation itself.

[0028] Furthermore, the techniques described in Non-Patent Documents 1 and 2 are not intended for the VM of a script engine, and therefore have the problem of not being directly applicable.

[0029] The present invention has been made in consideration of the above, and aims to provide an analysis device, an analysis method, and an analysis program that can analyze the ISA of a wide variety of VMs whose specifications are unknown by analyzing the VM of a script engine and analyzing the operations performed by the VM instructions and their inputs and outputs.

[0030] In order to solve the above-mentioned problems and achieve the object, the analysis device of the present invention is characterized by having a first analysis unit that analyzes the virtual machine of the script engine based on a first execution trace obtained by executing a first test script while monitoring the binary of the script engine, and a second analysis unit that analyzes the instruction set architecture, which is the system of instructions for the virtual machine, to collect virtual machine instructions, determine the operation of the collected virtual machine instructions, and detect the input and output of the virtual machine instructions using a second test script.

[0031] According to the present invention, by analyzing the VM of the script engine and analyzing the operations performed by the VM instructions and their inputs and outputs, it is possible to analyze the ISAs of a wide variety of VMs whose specifications are unknown.

[0032] FIG. 1 is a diagram illustrating an example of the configuration of a script engine. FIG. 2 is a diagram illustrating pseudocode of a VM included in the script engine. FIG. 3 is a diagram illustrating an example of the configuration of an analysis device according to an embodiment. FIG. 4 is a diagram illustrating an example of a first test script used to detect a virtual program counter (VPC). FIG. 5 is a diagram illustrating an example of a second test script. FIG. 6 is a diagram illustrating an example of the second test script. FIG. 7 is a diagram illustrating an example of the second test script. FIG. 8 is a diagram illustrating an example of an execution trace. FIG. 9 is a diagram illustrating an example of a VM execution trace. FIG. 10 is a diagram illustrating processing by a VM instruction boundary detection unit. FIG. 11 is a diagram illustrating processing by a virtual program counter detection unit. FIG. 12 is a diagram illustrating processing by a dispatcher detection unit. FIG. 13 is a diagram illustrating processing by a VM instruction operation determination unit. FIG. 14 is a flowchart illustrating the processing procedure of analysis processing according to an embodiment. FIG. 15 is a flowchart illustrating the processing procedure of first execution trace acquisition processing shown in FIG. 14. FIG. 16 is a flowchart illustrating the processing procedure of VM instruction boundary detection processing shown in FIG. 14. Fig. 17 is a flowchart showing the processing procedure for virtual program counter detection processing shown in Fig. 14. Fig. 18 is a flowchart showing the processing procedure for dispatcher detection processing shown in Fig. 14. Fig. 19 is a diagram illustrating VM execution trace acquisition processing shown in Fig. 14. Fig. 20 is a flowchart showing the processing procedure for VM instruction collection processing shown in Fig. 14. Fig. 21 is a flowchart showing the processing procedure for VM instruction operation determination processing shown in Fig. 14. Fig. 22 is a flowchart showing the processing procedure for VM instruction operation determination processing shown in Fig. 14. Fig. 23 is a flowchart showing the processing procedure for second execution trace acquisition shown in Fig. 14. Fig. 24 is a flowchart showing the processing procedure for VM instruction input / output detection processing shown in Fig. 14. Fig. 25 is a diagram showing an example of a computer in which an analysis device is realized by executing a program.

[0033] DETAILED DESCRIPTION OF THE PREFERRED EMBODIMENTS The present invention will be described in detail below with reference to the accompanying drawings, in which: FIG.

[0034] An analysis device according to an embodiment executes a first test script while monitoring a binary of a script engine, and acquires a branch trace and a memory access trace as a first execution trace. The analysis device analyzes a virtual machine (VM) based on the first execution trace, and acquires a VM instruction boundary, a virtual program counter (VPC), and a dispatcher as architecture information.

[0035] The analysis device executes the second test script while monitoring the VPC and the dispatcher to acquire a first VM execution trace. The analysis device analyzes the VM execution trace to collect VM instructions and determine the operation of the VM instructions using a predetermined algorithm. The analysis device then uses the second test script and the script engine binary to acquire a second execution trace that targets only the VM instructions to be determined, and analyzes the second execution trace to detect inputs and outputs of the VM instructions and acquire information about the instruction set architecture (ISA).

[0036] The analysis device according to the embodiment analyzes the VM of a script engine, and analyzes the operations performed by the VM instructions and their inputs and outputs, thereby analyzing the ISAs of a wide variety of VMs whose specifications are unknown.

[0037] The configuration and function of a typical script engine will be described with reference to Figures 1 and 2. Figure 1 is a diagram illustrating an example of the configuration of a script engine. As shown in Figure 1, the script engine 1 has a bytecode compiler 2 and a VM 3. The bytecode compiler 2 also has a syntax analysis unit 4 and a bytecode generation unit 5. The VM 3 also has a code cache unit 6, a fetch unit 7, a decode unit 8, and an execution unit 9. The fetch unit 7, the decode unit 8, and the execution unit 9 are executed repeatedly and are called an interpreter loop. The script engine 1 then accepts a script as input.

[0038] The syntax analysis unit 4 receives a script as input, performs lexical analysis and syntax analysis, generates an Abstract Syntax Tree (AST), and outputs it to the bytecode generation unit 5. The bytecode generation unit 5 receives the AST as input, converts it into bytecode, and stores it in the code cache unit 6.

[0039] The fetch unit 7 fetches a VM opcode from the code cache unit 6 and outputs it to the decode unit 8. Here, the VM opcode refers to the opcode portion of a VM instruction. The decode unit 8 receives the VM opcode as input, interprets the VM opcode using a decoder / dispatcher, and dispatches it to the corresponding program. The execution unit 9 executes the program corresponding to the VM instruction. The contents written in the script are executed by executing the VM instructions one after another through repeated interpreter loops.

[0040] The functions of the components of the script engine will be described with reference to FIG. 2. FIG. 2 is a diagram showing pseudocode for the VM of the script engine. As shown in FIG. 2, the pseudocode first initializes the VPC (line 1). In the pseudocode, the while loop is the interpreter loop (lines 2 to 7). In the pseudocode, the fetch unit 7 obtains the VM opcode of the VM instruction at the location pointed to by the VPC in the code cache that holds the bytecode (line 3). The decoder uses a Switch statement to interpret the VM instruction (line 4), and the dispatcher invokes an instruction handler based on the VM opcode (lines 5 and onward). Then, in the pseudocode, the instruction handler performs the operation corresponding to the instruction. Input and output are performed using a virtual stack and virtual registers (line 6), and constants and variables are referenced via a symbol table (line 7).

[0041] [Configuration of Analysis Apparatus] Next, the configuration of the analysis apparatus 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 apparatus 10 according to the embodiment.

[0042] 3, the analysis device 10 includes an input unit 11, a control unit 12, a storage unit 13, and an output unit 14. The analysis device 10 receives inputs of a test script, a script engine binary, and a seed script.

[0043] The input unit 11 is composed of input devices such as a keyboard and a mouse, and receives input of information from outside and inputs it to the control unit 12. The input unit 11 also has a communication interface for sending and receiving various information to and from other devices connected via a wired connection or a network, etc., and receives input of information transmitted from other devices. The input unit 11 receives input of test scripts and script engine binaries and outputs them to the control unit 12.

[0044] The test script is a script that is input when dynamically analyzing the script engine to obtain an execution trace and a VM execution trace, and includes a first test script for VM analysis and a second test script for ISA analysis. Details of the test scripts will be described later. The script engine binary is an executable file that constitutes the script engine. The script engine binary may be composed of multiple executable files.

[0045] [Test Script Configuration] This section explains test scripts. Test scripts are input when dynamically analyzing a script engine. These test scripts focus on the number of branch instruction executions and memory read / writes, and are used to capture differences in the behavior of the script engine that occur when the test script is executed a different number of times. These test scripts are prepared in advance of the analysis and are created manually. Creating them requires knowledge of the specifications of the target script language.

[0046] 4 shows an example of a first test script used to detect VPCs. The first test script uses a repetitive process (line 2). The first 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.

[0047] The second test script is intended to execute the VM instruction to be analyzed for ISA analysis. However, the type of operation instruction the VM has is unknown at the stage of creating the second test script. Therefore, a second test script is created for each operation provided by the scripting language. By executing the second test script, the VM instruction corresponding to this operation is determined. The operation may be, for example, an arithmetic operation, a logical operation, a comparison, or an operation on a variable or constant.

[0048] 5 is a diagram showing an example of a second test script, which is created to test an addition operation.

[0049] The second test script is created according to the following criteria. First, write the minimum number of expressions and statements related to the operation to be judged (addition in the example in Figure 5). Second, use a distinctive value that is useful for matching as the value to be operated on. If there are multiple values, use different values ​​with small differences ("0x12345678" and "0x12345679" in the example in Figure 5). Third, do not operate on constants, but use one or more variables.

[0050] 6 and 7 are diagrams showing other examples of the second test script. The second test script in Fig. 6 was created to test an equality comparison operation. The second test script in Fig. 7 was created to test a local variable storage operation.

[0051] 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 processing programs that operate the analysis device 10, data used during execution of the processing programs, 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.

[0052] The execution trace DB 131 and the VM execution trace DB 133 store the execution traces and VM execution traces acquired by the first execution trace acquisition unit 1211, the second execution trace acquisition unit 1224, and the VM execution trace acquisition unit 1221, respectively. The execution trace DB 131 and the VM execution trace DB 133 are managed by the analysis device 10. Of course, the execution trace DB 131 and the VM execution trace DB 133 may be managed by another device (such as a server). In this case, the first execution trace acquisition unit 1211, the second execution trace acquisition unit 1224, and the VM execution trace acquisition unit 1221 output the acquired execution traces and VM execution traces to a management server or the like for the execution trace DB 131 and the VM execution trace DB 133 via the communication interface of the output unit 14, and store the execution traces in the execution trace DB 131 and the VM execution trace DB 133.

[0053] [Configuration of Execution Trace] Next, an execution trace will be described. Fig. 8 is a diagram showing an example of an execution trace. As mentioned above, an execution trace is made up of a branch trace and a memory access trace. Fig. 8 shows an excerpt of a part of an execution trace. The configuration of an execution trace will be explained below using Fig. 8.

[0054] An execution trace has an element called trace, which indicates whether the log line is a branch trace or a memory access trace.

[0055] A branch trace log line has the format shown in lines 1 to 10 of Figure 8, 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.

[0056] A log line of a memory access trace has the format shown in lines 11 to 13 of Figure 8, 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 value resulting from the memory access.

[0057] [Configuration of VM Execution Trace] Next, a VM execution trace will be described. Fig. 9 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. 9 shows a portion of a VM execution trace. The configuration of a VM execution trace will be described below with reference to Fig. 9.

[0058] A log line of a VM execution trace is, for example, in the format shown in FIG. 9 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.

[0059] Returning to Fig. 3, the control unit 12 will be described. 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) and an instruction set architecture analysis unit 122 (second analysis unit).

[0060] The virtual machine analysis unit 121 analyzes the VM of the script engine. The virtual machine analysis unit 121 acquires multiple first execution traces by changing runtime conditions, analyzes the multiple first execution traces using differential execution analysis, and acquires VPCs. The virtual machine analysis unit 121 also analyzes the script engine binary to acquire VM instruction boundaries and dispatchers.

[0061] The virtual machine analysis unit 121 has a first execution trace acquisition unit 1211 (first acquisition unit), a VM instruction boundary detection unit 1212 (first detection unit), a virtual program counter detection unit 1213 (second detection unit), and a dispatcher detection unit 1214 (third detection unit).

[0062] The first execution trace acquisition unit 1211 receives a first test script and a script engine binary as input, and acquires a first execution trace by executing the first test script while monitoring the execution of the script engine binary.

[0063] The execution trace is composed of a branch trace and a memory access trace. The branch trace records the type of branch instruction during execution, the branch source address, and the branch destination address. The memory access trace records the type of memory operation during execution (read / write), and the memory address and value of the operation target. It is known that branch traces and memory access traces can be acquired by hooking a memory operation instruction, inserting code for log output, and executing it. The first execution trace acquired by the first execution trace acquisition unit 1211 is stored in the execution trace DB 131.

[0064] The VM instruction boundary detection unit 1212 clusters the first execution trace to detect the boundaries of each VM instruction. The VM instruction boundary detection unit 1212 clusters the first execution trace and detects clusters with a threshold or more of execution count as VM instructions. The clustering detects consecutive code regions that are executed multiple times. For example, this may be done by grouping executed instructions that are close in code distance, by searching for common subsequences of executed code blocks, or by other methods. The analysis device 10 detects the start and end points of consecutive instruction sequences that make up the detected VM instruction as boundaries. The VM instruction boundaries detected here are used in VPC detection and dispatcher detection.

[0065] The virtual program counter detection unit 1213 extracts and analyzes the first execution trace for the first test script stored in the execution trace DB 131 to detect the VPC. The virtual program counter detection unit 1213 detects the VPC by analyzing the multiple first 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 1212. The virtual program counter detection unit 1213 utilizes the fact that a read into memory that holds the VPC always occurs after the execution of each VM instruction, and detects the VPC by finding the destination of this read.

[0066] For this reason, the virtual program counter detection unit 1213 uses differential execution analysis, focusing on the number of memory reads, to detect VPCs. The virtual program counter detection unit 1213 compares the first execution traces of multiple test scripts acquired using the first test script, and finds memories whose memory read counts change in proportion to both the number of repetitions and the number of repeated statements. The virtual program counter detection unit 1213 then references the boundaries of each VM instruction detected by the VM instruction boundary detection unit 1212 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 1213 detects these memories as VPCs.

[0067] The dispatcher detection unit 1214 extracts each VM instruction portion from the script engine binary based on the VM instruction boundaries detected by the VM instruction boundary detection unit 1212, and detects the portion with high similarity between each VM instruction as a dispatcher. As a premise, the dispatcher is realized by referencing a pointer cache and jumping to the pointer of the next VM instruction handler. Dispatchers are distributed and located behind each VM instruction handler, and their code generally has high similarity. The analysis device detects dispatchers using a predetermined method by searching for code that exists behind such VM instruction handlers and has high similarity. The detection of the portion with high similarity may use, for example, a sequence alignment algorithm or other methods.

[0068] The instruction set architecture analysis unit 122 analyzes the instruction set architecture, which is the system of VM instructions. The instruction set architecture analysis unit 122 collects VM instructions and determines the operation of the collected VM instructions. The instruction set architecture analysis unit 122 uses a second test script to acquire a memory access trace that targets only the VM instruction to be determined as a second execution trace, and analyzes the second execution trace to detect input and output of the VM instruction.

[0069] The instruction set architecture analysis unit 122 has a VM execution trace acquisition unit 1221 (second acquisition unit), a VM instruction collection unit 1222 (first collection unit), a VM instruction operation determination unit 1223 (first determination unit), a second execution trace acquisition unit 1224 (third acquisition unit), and a VM instruction input / output detection unit 1225 (fourth detection unit).

[0070] The VM execution trace acquisition unit 1221 receives as input a second test script (described later) that uses values ​​characteristic of the operation target and a script engine binary. The VM execution trace acquisition unit 1221 acquires a VM execution trace by monitoring the VPC and a pointer to a VM instruction handler dispatched by a dispatcher. The VM execution trace acquisition unit 1221 executes the second test script while monitoring the execution of the script engine binary, thereby acquiring a VM execution trace, which is an execution trace executed on the VM. When detecting a branch VM instruction, the VM execution trace acquisition unit 1221 executes a large number of second test scripts to acquire a VM execution trace. The VM execution trace acquisition unit 1221 associates a pointer to the VM instruction with the VM instruction and virtually assigns a VM opcode as an identifier to each.

[0071] The VM execution trace is an execution trace executed in a VM, to which a VM opcode is virtually assigned as an identifier, and which records a pointer to the executed VM handler and a VPC. The VM execution trace records a pointer to the executed VM instruction handler and a VPC. Specifically, the VM execution trace is composed of a VPC and a 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 1213. The VM opcode is an identifier virtually assigned to each of a pointer to a VM instruction and a 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.

[0072] The VM instruction collection unit 1222 receives the VPC and the dispatcher as input, executes the second test script while monitoring the VPC and the dispatcher, and acquires a VM execution trace. The VM instruction collection unit 1222 collects VM instructions from the VM execution trace.

[0073] The VM instruction operation determination unit 1223 determines the operation of a VM instruction using a predetermined algorithm. The VM instruction operation determination unit 1223 analyzes a VM execution trace acquired using a test script (second test script) for a specific operation and determines the VM opcode that carries out the operation. The VM opcode indicates which operation the VM instruction is.

[0074] The VM instruction operation determination unit 1223 creates a list of unknown VM opcodes for each VM execution trace. The VM instruction operation determination unit 1223 determines a priority based on the number of unknown VM opcodes in the list, and determines which VM opcode will perform the operation to be determined based on this priority and the number of unknown VM opcodes. For example, the VM instruction operation determination unit 1223 makes a determination using the inverse number of unknown VM opcodes in the list as the priority.

[0075] The second execution trace acquisition unit 1224 acquires a second execution trace that targets only the VM instruction to be determined using the second test script. The second execution trace acquisition unit 1224 executes the second test script while monitoring the execution of the script engine binary, thereby acquiring a new memory access trace as the second execution trace.

[0076] The VM instruction input / output detection unit 1225 analyzes the second execution trace to detect input / output of VM instructions. It acquires information on the instruction set architecture (ISA). Using the memory access trace, which is the second execution trace, the VM instruction input / output detection unit 1225 compares characteristic values ​​used as the operation target of the second test script, and detects code that reads and writes the matched memory as a location where input / output appears. The VM instruction input / output detection unit 1225 outputs the detected input / output of VM instructions from the output unit 14 (described below) as information on the instruction set architecture (ISA).

[0077] The output unit 14 is, for example, a liquid crystal display or a printer, and outputs various information including information related to the analysis device 10. The output unit 14 may also be an interface that controls input and output of various data between an external device and the output unit 14, and may output various information to the external device.

[0078] [Processing of VM Instruction Boundary Detection Unit] Next, a description will be given of the processing of the VM instruction boundary detection unit 1212. FIG.

[0079] The VM instruction boundary detection unit 1212 detects the boundaries of each VM instruction. At this time, the VM instruction boundary detection unit 1212 detects VM instructions and their boundaries for a threaded code VM, which does not have an interpreter loop and therefore makes it difficult to grasp the boundaries of VM instructions. Specifically, the VM instruction boundary detection unit 1212 extracts a first execution trace from the execution trace DB 131. Then, as shown in FIG. 10 , the VM instruction boundary detection unit 1212 clusters the first execution trace using a predetermined method and detects clusters whose execution count is equal to or greater than a threshold as VM instructions (e.g., VM instruction handlers 1 to 3). The VM instruction boundary detection unit 1212 detects the start and end points of a continuous instruction sequence that constitutes a VM instruction as boundaries.

[0080] [Processing of the Virtual Program Counter Detection Unit] Next, the processing of the virtual program counter detection unit 1213 will be described. The virtual program counter detection unit 1213 detects the VPC and pointer cache. The detection of the virtual program counter is achieved by analyzing the memory access trace log of the acquired first execution trace. The virtual program counter detection unit 1213 uses differential execution analysis that focuses on the number of times memory is read. FIG. 11 is a diagram explaining the processing of the virtual program counter detection unit 1213.

[0081] The virtual program counter detection unit 1213 extracts one execution trace by the first test script from the execution trace DB 131. The number of VPC reads 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 VPC reads occur. Therefore, the virtual program counter detection unit 1213 extracts memory areas that have increased by 4MN and 9MN in the execution trace for the first test script in which N and M have been increased to 2N and 2M, respectively, and 3N and 3M. Specifically, as shown in FIG. 11 , the virtual program counter detection unit 1213 extracts memory areas that have a monotonically increasing read / write for each VM instruction execution ((1) in FIG. 11 ).

[0082] The virtual program counter detection unit 1213 then 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 1213 compares the VPC pointer with the address of the VM instruction handler, and narrows down the memory area to the matching memory area ((2) in FIG. 11 ).

[0083] [Processing of the Dispatcher Detection Unit] Next, a description will be given of the processing of the dispatcher detection unit 1214. The dispatcher detection unit 1214 detects dispatchers by analyzing the binary of the script engine using a predetermined method. Fig. 12 is a diagram illustrating the processing of the dispatcher detection unit 1214.

[0084] The dispatcher detection unit 1214 detects dispatchers. Based on the boundaries of the VM instructions detected by the VM instruction boundary detection unit 1212, the dispatcher detection unit 1214 extracts each VM instruction portion from the script engine binary. Then, based on the assumption that the similarity of the dispatcher code is high ((1) in FIG. 12), the dispatcher detection unit 1214 calculates the similarity between the codes of each VM instruction, and detects the portion with high similarity among all VM instructions as a dispatcher. The dispatcher detection unit 1214 can detect the code that is commonly executed in the latter half of the VM instructions as a dispatcher ((1) in FIG. 12).

[0085] [Difficulty in Making a Determination for a Single Operation] Here, it may be difficult to make a determination for a single operation (determination of a VM opcode).

[0086] For example, a case will be described in which the VM opcode of an add instruction is determined using the add test script (second test script) illustrated in FIG. 5 .

[0087] Since the second test script only performs a single operation to be judged, it is expected that only the VM instruction responsible for that operation will be executed. In this case, it is easy to judge because only that one VM opcode appears in the VM execution trace. However, in reality, due to a semantic gap between the expressions or statements in the script and the VM instructions, multiple VM instructions may be executed even for a test script with a single operation.

[0088] For example, in the addition test script shown in Figure 5, in addition to the addition to be judged, VM instructions that read constants and variables, store them in variables, etc. are also executed. This is because there are dependencies between the VM instructions that make up the addition formula, making judgment more difficult.

[0089] [Processing of VM command operation determination unit] Therefore, the VM command operation determination unit 1223 makes a determination using an algorithm that prioritizes determining the easiest VM command. Even if there is a dependency between VM commands as described above, determination is possible as long as the VM command on which the command is dependent is identified first. Therefore, the VM command operation determination unit 1223 gradually proceeds with the determination while resolving the dependency. Figure 13 is a diagram explaining the processing of the VM command operation determination unit 1223.

[0090] The VM instruction operation determination unit 1223 analyzes the VM execution trace acquired by the second test script for a specific operation and determines the VM opcode that performs that operation. The VM instruction operation determination unit 1223 receives as input VM execution traces for multiple operations (for example, operations 1 to 5 illustrated in FIG. 13 ) acquired using multiple second test scripts, and outputs the VM opcodes that perform those operations as determination results using the algorithm described below.

[0091] Specifically, the VM instruction operation determination unit 1223 creates a list of unknown VM opcodes for each VM execution trace (see FIG. 13 ). Then, the VM instruction operation determination unit 1223 determines the priority by repeating the following first to third steps:

[0092] If the number of unknown VM opcodes in the list with the highest priority is 1, the VM instruction operation determination unit 1223 performs a first procedure of determining that this VM opcode is responsible for the operation to be determined.

[0093] If the number of unknown VM opcodes is greater than 1, the VM command operation determination unit 1223 performs a second procedure in which it detects a unique VM opcode from the difference with other lists and determines that the unknown VM opcode is responsible for the operation to be determined.

[0094] The VM command operation determining unit 1223 performs a third procedure in which the determination results from the first procedure and the second procedure are reflected in all lists and the priorities are updated.

[0095] For example, in the case of the list shown in Fig. 13, if there is one unknown opcode "VMOP1_Unknown" for operation 1, which has the highest priority, the VM instruction operation determination unit 1223 determines that this unknown opcode is the VM instruction responsible for operation 1 ((1) in Fig. 13). Then, the VM instruction operation determination unit 1223 reflects the determination result in all lists and updates the priorities ((2) in Fig. 13). As a result, all of the opcodes "VMOP1_Unknown" in the list are updated to the opcode "VMOP1_Known".

[0096] Then, if there is one unknown opcode "VMOP2_Unknown" for operation 2, which has the highest priority after the update, the VM instruction operation determination unit 1223 determines that this opcode is the VM instruction responsible for operation 2 ((3) in FIG. 13). Then, the determination result is reflected in all lists, and the priorities are updated ((4) in FIG. 13). As a result, all of the opcodes "VMOP2_Unknown" in the lists are updated to the opcode "VMOP2_Known."

[0097] Next, if the number of unknown VM opcodes is greater than 1, the VM instruction operation determination unit 1223 detects unknown VM opcodes specific to each list from the differences of other lists.

[0098] For example, for operation 3, the VM instruction operation determination unit 1223 detects the VM opcode “VMOP3_Unknown” that is not present in operations 4 and 5, and determines that this VM opcode “VMOP3_Unknown” is the VM instruction responsible for operation 3 ((5) in FIG. 13).

[0099] Furthermore, for operation 4, the VM instruction operation determination unit 1223 detects the VM opcode “VMOP6_Unknown” that is not present in operations 3 and 5, and determines that this VM opcode “VMOP6_Unknown” is the VM instruction responsible for operation 4 ((5) in FIG. 13).

[0100] Furthermore, for operation 5, the VM instruction operation determination unit 1223 detects the VM opcode “VMOP7_Unknown” that is not present in operations 3 and 4, and determines that this VM opcode “VMOP7_Unknown” is the VM instruction responsible for operation 5 ((5) in FIG. 13).

[0101] [Processing of VM Instruction Input / Output Detection Unit] Next, a description will be given of the processing of the VM instruction input / output detection unit 1225. The VM instruction input / output detection unit 1225 analyzes the memory access trace (second execution trace) acquired by the second execution trace acquisition unit 1224 using the second test script, and detects input / output of a VM instruction.

[0102] As mentioned above, in script engines, the operands of VM instructions are generally passed via a virtual stack or virtual registers, and variables and constants are managed in a symbol table. In many cases, the subscripts of records in the symbol table are passed to the operands of VM instructions, and the actual values ​​do not appear.

[0103] Therefore, to obtain the value instance, a simple reference to the operand is not sufficient; it is necessary to capture the code that retrieves the variable object from the symbol table and accesses the value instance.

[0104] The VM instruction input / output detection unit 1225 identifies code that accesses the substance of a value by comparing values ​​using memory access traces.

[0105] First, the VM instruction input / output detection unit 1225 determines, in the memory access trace, the period from the dispatch of a VM instruction to the next dispatch as a memory access by that VM instruction.

[0106] The VM command input / output detection unit 1225 then compares the read / write value with the value used for the operation target in the second test script by using a value that is characteristic of the operation target in the second test script.

[0107] For example, in the case of the test script in Fig. 5, "0x12345678" and "0x12345679" are input. The VM instruction input / output detection unit 1225 detects the code that reads and writes from and to the memory that can be matched as a location where VM instruction input / output appears. The VM instruction input / output detection unit 1225 obtains VM instruction input / output by monitoring the read / write at this location.

[0108] [Processing Procedure of Analysis Device] Next, a processing procedure of the analysis process by the analysis device 10 will be described. Fig. 14 is a flowchart showing the processing procedure of the analysis process according to the embodiment.

[0109] First, the input unit 11 receives test scripts and script engine binaries as inputs (step S1). The test scripts include a first test script and a second test script.

[0110] Then, the first execution trace acquisition unit 1211 executes the first test script while monitoring the binary of the script engine, and performs a first execution trace acquisition process to acquire a branch trace and a memory access trace (step S2).

[0111] The VM instruction boundary detection unit 1212 detects VM instructions and performs VM instruction boundary detection processing to detect VM instruction boundaries (step S3). The virtual program counter detection unit 1213 extracts and analyzes the execution trace for the first test script stored in the execution trace DB 131 and performs virtual program counter detection processing to find VPCs (step S4).

[0112] The dispatcher detection unit 1214 performs dispatcher detection processing to extract each VM instruction portion from the script engine binary and detect a portion with high similarity between each VM instruction as a dispatcher (step S5).

[0113] The VM execution trace acquisition unit 1221 receives the test script and the script engine binary as input, and executes the test script while monitoring the execution of the script engine binary, thereby performing a VM execution trace acquisition process to acquire the VM execution trace (step S6).

[0114] The VM instruction collection unit 1222 performs a VM instruction collection process to collect VM instructions from the VM execution trace (step S7).

[0115] The VM command operation determination unit 1223 performs a VM command operation determination process to determine the operation of the VM command using a predetermined algorithm (step S8).

[0116] The second execution trace acquisition unit 1224 performs a second execution trace acquisition process using the second test script to acquire a second execution trace that is targeted only at the VM instruction to be determined (step S9).

[0117] The VM instruction input / output detection unit 1225 analyzes the second execution trace to perform a VM instruction input / output detection process to detect input / output of a VM instruction (step S10). The output unit 14 outputs the operation and input / output of the VM instruction detected in steps S8 and S10 (step S11).

[0118] [Processing Procedure of First Execution Trace Acquisition Processing] Next, a flow of the first execution trace acquisition processing shown in Fig. 14 will be described. Fig. 15 is a flowchart showing the processing procedure of the first execution trace acquisition processing shown in Fig. 14.

[0119] First, the first execution trace acquisition unit 1211 receives a first test script and a script engine binary as input (step S21). Then, the first execution trace acquisition unit 1211 hooks the received script engine to acquire a branch trace (step S22). The first execution trace acquisition unit 1211 also hooks the received script engine to acquire a memory access trace (step S23).

[0120] Then, the first execution trace acquisition unit 1211 inputs the first test script received in that state into the script engine and executes it (step S24), and stores the first execution trace acquired thereby in the execution trace DB 131 (step S25).

[0121] The first execution trace acquisition unit 1211 determines whether all of the input first test scripts have been executed (step S26). If all of the input first test scripts have been executed (step S26: Yes), the first execution trace acquisition unit 1211 ends the processing. On the other hand, if all of the input first test scripts have not been executed (step S26: No), the first execution trace acquisition unit 1211 returns to the execution of the first test script in step S24 and continues the processing.

[0122] [Procedure of VM Instruction Boundary Detection Processing] Next, a flow of the VM instruction boundary detection processing shown in Fig. 14 will be described. Fig. 16 is a flowchart showing the procedure of the VM instruction boundary detection processing shown in Fig. 14.

[0123] First, the VM instruction boundary detection unit 1212 extracts a first execution trace from the execution trace DB 131 (step S31). The VM instruction boundary detection unit 1212 clusters the first execution trace using a predetermined method (step S32). Any method may be used for clustering.

[0124] The VM instruction boundary detection unit 1212 detects clusters whose execution count is equal to or greater than a threshold as VM instructions (step S33).The VM instruction boundary detection unit 1212 then determines the start and end points of a continuous instruction sequence that constitutes a VM instruction as boundaries (step S34).The VM instruction boundary detection unit 1212 outputs the VM instruction boundaries as return values ​​(step S35), and ends the VM instruction boundary detection process.

[0125] [Procedure for Virtual Program Counter Detection Processing] Next, a flow of the virtual program counter detection processing shown in Fig. 14 will be described. Fig. 17 is a flowchart showing the procedure for the virtual program counter detection processing shown in Fig. 14.

[0126] First, the virtual program counter detection unit 1213 extracts one first execution trace by the first test script from the execution trace DB 131 (step S41). Next, the virtual program counter detection unit 1213 focuses on memory access traces in the first execution trace, and counts the number of reads for each memory read destination (step S42).

[0127] The virtual program counter detection unit 1213 receives as input the first test script used to obtain the first execution trace (step S43), and analyzes the first test script to obtain the number of repetitions and the number of repeated statements (step S44).

[0128] Next, the virtual program counter detection unit 1213 extracts another first execution trace by a first test script with a different number of repetitions and number of repeated statements from the execution trace DB 131 (step S45).The virtual program counter detection unit 1213 then focuses on memory access traces and counts the number of reads for each memory read destination (step S46).The virtual program counter detection unit 1213 also receives as input the first test script used to obtain the first execution trace (step S47), analyzes the first test script, and obtains the number of repetitions and the number of repeated statements (step S48).

[0129] Here, the virtual program counter detection unit 1213 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 S49).Furthermore, the virtual program counter detection unit 1213 narrows down the memory read destinations narrowed down in step S49 to those whose read memory values ​​always point to the start point of the VM instruction (step S50).

[0130] The virtual program counter detection unit 1213 then determines whether the memory read destinations have been narrowed down to only one (step S51). If the virtual program counter detection unit 1213 has not been able to narrow down the memory read destinations to only one (step S51: No), the process returns to step S45, where the virtual program counter detection unit 1213 extracts the next first execution trace and continues processing. On the other hand, if the virtual program counter detection unit 1213 has been able to narrow down the memory read destinations to only one (step S51: Yes), the virtual program counter detection unit 1213 stores the narrowed down memory read destination as a virtual program counter in the architecture information DB 132 (step S52), and ends processing.

[0131] [Processing Procedure of Dispatcher Detection Processing] Next, a flow of the dispatcher detection processing shown in Fig. 14 will be described. Fig. 18 is a flowchart showing the processing procedure of the dispatcher detection processing shown in Fig. 14.

[0132] First, the dispatcher detection unit 1214 receives a script engine binary as an input (step S61), and receives VM instruction boundaries from the VM instruction boundary detection unit 1212 (step S62).

[0133] The dispatcher detection unit 1214 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 1212 (step S63). The dispatcher detection unit 1214 calculates the similarity between the codes of each VM instruction using a predetermined method (step S64). Any method for calculating the similarity may be used as long as it is capable of calculating the similarity between the codes.

[0134] The dispatcher detection unit 1214 extracts a part with a high degree of similarity among all VM instructions based on the similarity calculated in step S64 (step S65).The dispatcher detection unit 1214 then determines whether the part is the end of the VM instruction (step S66).

[0135] If the extracted portion is not the end of the VM instruction (step S66: No), the dispatcher detection unit 1214 returns to step S65 and continues the process. If the extracted portion is the end of the VM instruction (step S66: Yes), the dispatcher detection unit 1214 outputs the extracted portion as a dispatcher (step S67) and ends the process.

[0136] [Procedure of VM Execution Trace Acquisition Processing] Next, a flow of the VM execution trace acquisition processing shown in Fig. 14 will be described. Fig. 19 is a flowchart showing the procedure of the VM execution trace acquisition processing shown in Fig. 14.

[0137] First, the VM execution trace acquisition unit 1221 receives the second test script and the script engine binary as input (step S71). Then, the VM execution trace acquisition unit 1221 hooks the received script engine to record the VPC and VM opcode (step S72).

[0138] The VM execution trace acquisition unit 1221 inputs the second test script received in this state into the script engine and executes it (step S73), and stores the VM execution trace acquired thereby in the VM execution trace DB 133 (step S74).

[0139] The VM execution trace acquisition unit 1221 determines whether all of the input second test scripts have been executed (step S75). If all of the input second test scripts have been executed (step S75: Yes), the VM execution trace acquisition unit 1221 ends the process. If all of the input second test scripts have not been executed (step S75: No), the VM execution trace acquisition unit 1221 returns to the execution of the second test script in step S73 and continues the process.

[0140] [Procedure of VM Instruction Collection Processing] Next, a flow of the VM instruction collection processing shown in Fig. 14 will be described. Fig. 20 is a flowchart showing the procedure of the VM instruction collection processing shown in Fig. 14.

[0141] The VM command collection unit 1222 receives a VPC and a dispatcher as input (step S81), and acquires various scripts from the Internet (step S82). The VM command collection unit 1222 executes the scripts while monitoring the VPC and the dispatcher, and acquires a VM execution trace (step S83).

[0142] The VM instruction collection unit 1222 acquires VM instructions from the VM execution trace (step S84) and adds them to a list of VM instructions (step S85). If the VM instruction collection unit 1222 finds a VM instruction that is not in the list (step S86: No), the VM instruction collection unit 1222 returns to step S82. If the VM instruction collection unit 1222 finds no VM instructions that are not in the list (step S86: Yes), the VM instruction collection unit 1222 returns the list of VM instructions (step S87) and ends the VM instruction collection process.

[0143] [Procedure of VM Command Operation Determination Processing] Next, a flow of the VM command determination processing shown in Fig. 14 will be described. Fig. 21 and Fig. 22 are flowcharts showing the procedure of the VM command operation determination processing shown in Fig. 14.

[0144] The VM instruction operation determination unit 1223 receives a VM execution trace as an input (step S91), and creates a list of VM opcodes for each VM execution trace, along with known / unknown information (step S92).

[0145] The VM instruction operation determining unit 1223 calculates the reciprocal of the number of unknown VM opcodes in the list as a priority (step S93).

[0146] The VM instruction operation determining unit 1223 extracts the list with the highest priority (step S94).The VM instruction operation determining unit 1223 determines whether the number of unknown VM opcodes is 1 (step S95).

[0147] If the number of unknown VM opcodes is 1 (step S95: Yes), the VM instruction operation determining unit 1223 determines that the unknown VM opcode is responsible for the operation to be determined (step S96).

[0148] If the number of unknown VM opcodes is not 1 (step S95: No), the VM instruction operation determining unit 1223 determines whether the number of unknown VM opcodes is greater than 1 (step S97).

[0149] If the number of unknown VM opcodes is smaller than 1 (step S97: No), the VM instruction operation determining unit 1223 determines that the operation to be determined does not exist in the VM instruction (step S98).

[0150] If the number of unknown VM opcodes is greater than 1 (step S97: Yes), the VM instruction operation determining unit 1223 calculates the difference from other lists (step S99).

[0151] The VM instruction operation determination unit 1223 detects an unknown VM opcode specific to the list, and determines that the detected VM opcode is responsible for the operation to be determined (step S100).

[0152] After steps S96, S98, and S100 are completed, the VM instruction operation determination unit 1223 reflects the newly determined VM opcodes in all lists (step S101). The VM instruction operation determination unit 1223 recalculates the priorities and updates the lists (step S102).

[0153] The VM command operation determining unit 1223 determines whether all the lists have been processed (step S103).

[0154] If not all processes have been processed (step S103: No), the VM command operation determining unit 1223 extracts the next list (step S104), returns to step S95, and processes the next list.

[0155] If all the lists have been processed (step S103: Yes), the VM instruction operation determining unit 1223 outputs the VM opcode and its operation as a result of the determination (step S105).

[0156] [Second Execution Trace Acquisition Processing] Next, a description will be given of the flow of the second execution trace acquisition processing shown in Fig. 14. Fig. 23 is a flowchart showing the processing procedure of the second execution trace acquisition processing shown in Fig. 14.

[0157] The second execution trace acquisition unit 1224 receives the second test script and the script engine binary as input (step S111), and then receives the VM instruction from which the execution trace is to be acquired as input (step S112).

[0158] The second execution trace acquisition unit 1224 hooks the dispatcher of the script engine to observe VM opcodes (step S113).The second execution trace acquisition unit 1224 hooks the script engine to acquire memory access traces (step S114).

[0159] The second execution trace acquisition unit 1224 extracts one second test script (step S115), and inputs the second test script into the script engine for execution (step S116).

[0160] The second execution trace acquisition unit 1224 acquires a memory access trace from observing the VM opcode, limited to when the target VM instruction is being executed (step S117), and stores the acquired memory access trace as a second execution trace in the execution trace DB 131 (step S118).

[0161] The second execution trace acquisition unit 1224 determines whether or not all of the input second test scripts have been executed (step S119).

[0162] If all of the input second test scripts have not been executed (step S119: No), the second execution trace acquisition unit 1224 receives the next second test script (step S120), returns to step S115, and continues processing. If all of the input second test scripts have been executed (step S119: Yes), the second execution trace acquisition unit 1224 ends the second execution trace acquisition process.

[0163] [VM Command Input / Output Detection Processing] Next, a flow of the VM command input / output detection processing shown in Fig. 14 will be described. Fig. 24 is a flowchart showing the processing procedure of the VM command input / output detection processing shown in Fig. 14.

[0164] The VM command input / output detection unit 1225 receives the second test script and the second execution trace as input (step S131).

[0165] The VM command input / output detection unit 1225 extracts all characteristic values ​​used in the second test script (step S132). In the example of Fig. 5, these are "0x12345678" and "0x12345679".

[0166] The VM instruction input / output detection unit 1225 extracts one value (step S133). The VM instruction input / output detection unit 1225 searches for a memory read value in the second execution trace that can be compared with the extracted value (step S134).

[0167] The VM instruction input / output detection unit 1225 extracts the address of the found memory read code from the second execution trace (step S135), and extracts this code as code that accesses an input value (step S136).

[0168] The VM command input / output detection unit 1225 determines whether all values ​​have been processed (Step S137).

[0169] If all values ​​have not been processed (step S137: No), the VM command input / output detector 1225 extracts the next value (step S138), returns to step S134, and continues the process.

[0170] If all values ​​have been processed (step S137: Yes), the VM instruction input / output detection unit 1225 calculates the value of the operation result of the second test script (step S139). In the example of FIG. 5, this is "0x2468acf1", which is the sum of "0x12345678" and "0x12345679". The VM instruction input / output detection unit 1225 searches for a memory write value in the second execution trace that can be compared with the calculated value (step S140).

[0171] The VM instruction input / output detection unit 1225 extracts the address of the code for memory write that has been found from the second execution trace (step S141), and extracts this code as code that accesses an output value (step S142).

[0172] The VM command input / output detection unit 1225 outputs the input / output code extracted in steps S136 and S142 (step S143).

[0173] [Effects of the Embodiment] As described above, the analysis device 10 according to the present embodiment executes the first test script while monitoring the binary of the script engine, and acquires a memory access trace as a first execution trace. The analysis device 10 analyzes the VM of the script engine based on the first execution trace. The analysis device 10 acquires architecture information of the VPC and the dispatcher.

[0174] The analysis device 10 analyzes the instruction set architecture, which is the system of instructions for the virtual machine, collects VM instructions, determines the operation of the collected VM instructions, and detects the input and output of the VM instructions using a second test script, thereby obtaining ISA information on the operation of the VM instructions and the input and output of the VM instructions.

[0175] Specifically, the analysis device 10 executes a second test script while monitoring the VPC and the dispatcher to acquire a VM execution trace. The analysis device 10 analyzes the VM execution trace to collect VM instructions and create a list of unknown VM opcodes, and determines the operation of the VM instructions using the list and a predetermined algorithm. The analysis device 10 then uses the second test script to acquire a memory access trace that targets only the VM instruction to be determined as a second execution trace, and analyzes the second execution trace to detect inputs and outputs of the VM instructions.

[0176] As a result, the analysis device 10 can detect various architectural information by analyzing the execution trace and VM execution trace obtained, even for script engines whose internal VM specifications are unknown, and can elucidate the ISA without requiring manual reverse engineering.

[0177] Furthermore, the analysis device 10 can automatically determine the ISA for a variety of script engines as long as a test script is prepared, thereby enabling analysis of the ISA of a wide variety of VMs whose specifications are unknown without requiring individual design or execution.

[0178] This enables the analysis device 10 to analyze scripts written in various script languages ​​at the VM command level, thereby enabling more detailed understanding of behavior.

[0179] Therefore, the analysis device 10 according to the present embodiment can analyze script engines in a wide variety of script languages ​​at the VM command level by analyzing the script engines and determining the ISA.

[0180] As described above, the analysis device 10 according to this embodiment is useful for clarifying the ISA of VMs in a wide variety of script engines, and is suitable for performing analysis even on scripts that are difficult to analyze at the VM instruction level due to the absence of analysis support functions or the unknown ISA of the VM.

[0181] Therefore, by using the analysis device 10, analysis method, and analysis program of this embodiment to clarify the ISA of the VMs of various script engines, it is possible to realize a tool that analyzes bytecode at the VM instruction level.

[0182] By using the analysis device 10, analysis method, and analysis program according to this embodiment, a tool for analyzing scripts at the VM instruction level can be created. For example, the analysis device 10 can be used to create a bytecode disassembler, debugger, or tracer, and can also be used to realize engines for dynamic bytecode instrumentation, symbolic execution, taint analysis, and the like. As described above, these tools can be used for various purposes, such as software testing and debugging, fuzzing, and malware analysis.

[0183] 3 are conceptual functional components of the analysis device 10 and do not necessarily have to be physically configured as shown. In other words, the specific form of distribution and integration of the functions of the analysis device 10 is not limited to that shown, and all or part of the functions can be functionally or physically distributed or integrated in any unit depending on various loads, usage conditions, etc.

[0184] Furthermore, all or any part of the processes performed by analysis device 10 may be realized by a CPU and a program analyzed and executed by the CPU. Furthermore, each process performed by analysis device 10 may be realized as hardware using wired logic.

[0185] 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 using a known method. In addition, the processing procedures, control procedures, specific names, and information including various data and parameters described above and illustrated can be changed as appropriate unless otherwise specified.

[0186] 25 is a diagram showing an example of a computer in which analysis device 10 is realized by executing a program. Computer 1000 has, for example, memory 1010 and CPU 1020. Computer 1000 also has hard disk drive interface 1030, disk drive interface 1040, serial port interface 1050, video adapter 1060, and network interface 1070. These components are connected by bus 1080.

[0187] 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 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.

[0188] 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, the program that defines each process of the analysis device 10 is implemented as a program module 1093 in which code that can be executed by the computer 1000 is written. The program module 1093 is stored, for example, in the hard disk drive 1090. For example, the program module 1093 for executing the same process as the functional configuration of the analysis device 10 is stored in the hard disk drive 1090. Note that the hard disk drive 1090 may be replaced with an SSD (Solid State Drive).

[0189] 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 them.

[0190] The program module 1093 and program data 1094 may not necessarily be stored in the hard disk drive 1090, but may also be stored in a removable storage medium and read by the CPU 1020 via the disk drive 1100 or the like. Alternatively, the program module 1093 and program data 1094 may be stored in another computer connected via a network (such as a local area network (LAN) or a wide area network (WAN)). The program module 1093 and program data 1094 may then be read by the CPU 1020 from the other computer via the network interface 1070.

[0191] Although the present invention has been described above as an embodiment, the present invention is not limited to the description and drawings that form part of the disclosure of the present invention. In other words, other embodiments, examples, and operational techniques that can be made by those skilled in the art based on the present invention are all included in the scope of the present invention.

[0192] 10 Analysis device 11 Input unit 12 Control unit 13 Memory unit 14 Output unit 121 Virtual machine analysis unit 122 Instruction set architecture analysis unit 131 Execution trace database (DB) 132 Architecture information DB 133 VM execution trace DB 1211 First execution trace acquisition unit 1212 VM instruction boundary detection unit 1213 Virtual program counter detection unit 1214 Dispatcher detection unit 1221 VM execution trace acquisition unit 1222 VM instruction collection unit 1223 VM instruction operation determination unit 1224 Second execution trace acquisition unit 1225 VM instruction input / output detection unit

Claims

1. An analysis device comprising: a first analysis unit that analyzes a virtual machine of a script engine based on a first execution trace obtained by executing a first test script while monitoring the binary of the script engine; and a second analysis unit that analyzes an instruction set architecture, which is a system of instructions for the virtual machine, to collect virtual machine instructions, determine operations of the collected virtual machine instructions, and detect input / output of the virtual machine instructions using a second test script that uses values ​​characteristic of the target of operation.

2. The analysis device according to claim 1, characterized in that the first analysis unit has: a first acquisition unit that acquires multiple first execution traces by changing execution conditions; a first detection unit that clusters the first execution traces and detects boundaries of each virtual machine instruction; a second detection unit that analyzes the multiple first execution traces using differential execution analysis focusing on the number of memory reads and the boundaries of each virtual machine instruction detected by the first detection unit, and detects a virtual program counter, which is a variable indicating the next instruction of the virtual machine to be executed; and a third detection unit that analyzes the binary of the script engine based on the boundaries of each virtual machine instruction detected by the first detection unit, and detects a dispatcher.

3. The analysis device according to claim 2, characterized in that the second analysis unit has: a second acquisition unit that acquires a virtual machine execution trace, which is an execution trace executed in the virtual machine; a first collection unit that executes the second test script while monitoring the virtual program counter and the dispatcher to acquire the virtual machine execution trace and collects virtual machine instructions from the virtual machine execution trace; a first determination unit that creates a list of unknown virtual machine opcodes among virtual machine opcodes indicating which operation each virtual machine execution trace is, and determines the operation of the virtual machine instruction based on the list; a third acquisition unit that executes the second test script while monitoring the script engine to acquire a second execution trace; and a fourth detection unit that analyzes the second execution trace and detects input and output of the virtual machine instruction.

4. The analysis device described in claim 3, characterized in that the first judgment unit determines a priority based on the number of unknown virtual machine opcodes in the list, and determines which virtual machine opcode is responsible for the operation to be judged based on the priority and the number of unknown virtual machine opcodes.

5. The analysis device according to claim 4, characterized in that the first determination unit executes: a first procedure of determining that, when the number of unknown virtual machine opcodes in the list with the highest priority is 1, the unknown virtual machine opcode is responsible for the operation to be determined; a second procedure of detecting a unique unknown VM opcode based on a difference with other lists and determining that the detected unknown virtual machine opcode is responsible for the operation to be determined, when the number of unknown virtual machine opcodes is greater than 1; and a third procedure of reflecting the determination results in the first procedure and the second procedure to all the lists and updating the priority.

6. The analysis device described in claim 3, characterized in that the fourth detection unit compares characteristic values ​​used as the target of operation of the second test script, and detects code that reads and writes the matched memory as a location where input and output of the virtual machine instruction appears.

7. An analysis method executed by an analysis device, comprising: a step of analyzing a virtual machine of a script engine based on a first execution trace obtained by executing a first test script while monitoring the binary of the script engine; and a step of analyzing an instruction set architecture, which is a system of instructions for the virtual machine, to collect virtual machine instructions, determining the operation of the collected virtual machine instructions, and detecting input / output of the virtual machine instructions using a second test script that uses a value characteristic of the target of operation.

8. An analysis program for causing a computer to execute the following steps: analyzing a virtual machine of a script engine based on a first execution trace obtained by executing a first test script while monitoring the binary of the script engine; analyzing an instruction set architecture, which is a system of instructions for the virtual machine, to collect virtual machine instructions, determining operations of the collected virtual machine instructions, and detecting input / output of the virtual machine instructions using a second test script that uses values ​​characteristic of the target of operation.

Citation Information

Patent Citations

  • Analysis function imparting device, analysis function imparting method, and analysis function imparting program

    WO2022079840A1

  • Analysis function addition device, analysis function addition program, and analysis function addition method

    WO2022180702A1