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

The analysis function imparting device and method automate the analysis of script engines' virtual machine architecture and instruction set architecture, enabling dynamic bytecode instrumentation and overcoming the challenge of unknown internal specifications, thus facilitating detailed analysis and instrumentation across various scripting languages.

WO2024214262A1PCT designated stage expired Publication Date: 2024-10-17NT T INC
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
PCT/JP2023/015090
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

Current dynamic binary instrumentation technologies face challenges in analyzing bytecode without support functions like debuggers, especially for script engines with unknown internal specifications, requiring manual reverse engineering which is impractical due to the effort involved.

Method used

An analysis function imparting device and method that automatically analyzes the virtual machine architecture and instruction set architecture, allowing dynamic bytecode instrumentation to be added to script engines without manual analysis or design, by executing test scripts to gather execution traces and detect VM instructions and their operations.

Benefits of technology

Enables dynamic bytecode instrumentation for script engines without known internal specifications, facilitating detailed analysis and instrumentation without the need for manual reverse engineering, supporting fine-grained analysis and instrumentation across various scripting languages.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure JP2023015090_17102024_PF_FP_ABST
    Figure JP2023015090_17102024_PF_FP_ABST
Patent Text Reader

Abstract

This analysis function addition device (10) comprises: a virtual machine analysis unit (121) that analyzes a VM of a script engine on the basis of a first execution trace acquired by executing a first test script while monitoring the binary of the script engine; an instruction set architecture analysis unit (122) that analyzes an instruction set architecture, which is a system of instructions of the VM, collects the VM instructions, determines an operation of the collected VM instructions, and detects the input / output of the VM instructions using a second test script; and a dynamic byte code instrumentation function addition unit (123) that monitors the execution of the VM instructions on the basis of the result of analyzing the VM instructions and the result of analyzing the instruction set architecture, and adds, to the binary of the script engine, an analysis function for performing an analysis process in conjunction with the input / output values of the VM instructions.
Need to check novelty before this filing date? Find Prior Art

Description

Analysis function providing device, analysis function providing method, and analysis function providing program

[0001] The present invention relates to an analytical function providing device, an analytical function providing method, and an analytical function providing 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] [Program Instrumentation] One of the techniques for dynamically analyzing programs is instrumentation, which is a technique for obtaining information about the execution state of a program during execution by adding code with analytical functions to the program being analyzed and then executing it.

[0005] For example, instrumentation can insert logging code after each execution of a program to determine the total number of instructions executed, and similarly inserting logging code after each execution of a branch to determine the control flow that was followed.

[0006] This type of instrumentation is an important technology that is widely used for software testing as well as cybersecurity purposes such as malware analysis and vulnerability detection.

[0007] There are two types of instrumentation: dynamic instrumentation and static instrumentation. Dynamic instrumentation is a technique for dynamically adding analytical code during program execution using a technique for dynamically changing the program's behavior. Static instrumentation is a technique for statically adding analytical code before the program is executed using a technique for rewriting the program.

[0008] Furthermore, the targets of instrumentation are diverse, including source code, scripts, executable binaries (hereafter referred to as binaries), bytecode, etc. Nowadays, the need for not only debugging and testing scripts but also analyzing malicious scripts is increasing, making instrumentation of scripts important.

[0009] One of the most common instrumentation techniques is dynamic binary instrumentation. Dynamic binary instrumentation is a technique for obtaining information about the execution state by dynamically adding analytical code to the binary program being analyzed at runtime. In dynamic binary instrumentation, the injection of analytical code is mainly achieved by using hooks.

[0010] Specifically, the injection of analysis code follows the following process: First, the code to be injected is placed in memory. Then, when a specific, predetermined command or function is executed, a hook is placed so that a branch is made to the injected code. The code is then executed. At the end of the code, execution is returned to the branch source and the original processing is resumed.

[0011] In current dynamic binary instrumentation technology, this is generally achieved by a technique called inline hooks or by hooks during conversion called dynamic binary conversion in a virtual machine (VM).

[0012] [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 VM. For this reason, it is common to statically analyze the script before execution and then dynamically analyze the bytecode at runtime.

[0013] Therefore, there are two main approaches to instrumenting scripts: statically injecting analysis scripts into scripts before they are executed, and dynamically injecting analysis code when the script is converted to bytecode at runtime.

[0014] [The Need for Bytecode Instrumentation] While scripts are typically instrumented for software testing and debugging, there are also cases where bytecode should be instrumented.

[0015] For example, you may want to obtain a runtime profile to improve performance. As mentioned above, scripts are converted into bytecode before execution. Therefore, to obtain a detailed profile, you need to use instrumentation that targets the bytecode rather than the script.

[0016] In addition, when analyzing obfuscated scripts, the bytecode must also be the target. Obfuscation is a technique that hinders analysis and makes the script difficult to interpret. For example, in some cases, the script only has the functionality of a bytecode loader, which dynamically obtains and executes compiled bytecode at runtime.

[0017] In such cases, the main behavior cannot be revealed unless the bytecode is instrumented with analytical code. For example, malicious scripts and scripts protected to protect intellectual property rights are generally obfuscated, and analysis requires instrumentation of the bytecode.

[0018] From the above, in order to realize script analysis by instrumentation, dynamic instrumentation of bytecode, i.e., dynamic bytecode instrumentation, is also an important technology.

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

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

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

[0022] 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).

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

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

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

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

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

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

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

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

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

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

[0033] Here, a method for implementing dynamic instrumentation for Java bytecode has been proposed (Non-Patent Document 1), and a method for implementing dynamic instrumentation for ActionScript 3 bytecode has also been proposed (Non-Patent Document 2).

[0034] W. Binder, J. Hulaas, and P. Moret, “Advanced Java Bytecode Instrumentation”, In Proceedings of the 5th International Symposium on Principles and Practice of Programming in Java, pp. 135-144, 2007. Jarkko Turkulainen, “Reflash: practical ActionScript3 instrumentation with RABCDAsm”, 2016.

[0035] However, the techniques described in Non-Patent Documents 1 and 2 only realize dynamic bytecode instrumentation for VMs with known ISAs, and there was a problem in that in order to achieve the same for a variety of scripting languages, it was necessary to analyze the VM and design and implement an instrumentation engine individually.

[0036] Furthermore, dynamic bytecode instrumentation in scripts generally requires the use of support functions such as a debugger provided by the script engine. This is because the internal specifications of the VM in the script engine that controls the execution of the script are often not publicly available, making it difficult to monitor the execution state and transitions required for instrumentation without such support functions.

[0037] However, if such support functions are not provided, it is necessary to reverse engineer the VM to reveal the internal specifications, including the ISA, and independently analyze the bytecode to obtain information for instrumentation.

[0038] It is not realistic to manually analyze, design, and implement this individually for each script engine, in view of the amount of effort required.

[0039] The present invention has been made in consideration of the above, and aims to provide an analysis function-imparting device, an analysis function-imparting method, and an analysis function-imparting program that can realize the addition of dynamic bytecode instrumentation functions, even for script engines that do not have support functions such as a debugger and whose internal specifications, including ISA, are unknown, without requiring manual individual analysis, design, and implementation.

[0040] In order to solve the above-mentioned problems and achieve the object, the analysis function-imparting 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; a second analysis unit that analyzes the instruction set architecture, which is the system of instructions of 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; and an imposition unit that monitors the execution of the virtual machine instructions based on the analysis results of the virtual machine and the analysis results of the instruction set architecture, and imposes an analysis function to the binary of the script engine that performs analysis processing according to the input and output values ​​of the virtual machine instructions.

[0041] According to the present invention, it is possible to provide dynamic bytecode instrumentation functionality to script engines that do not have support functions such as a debugger and whose internal specifications, including ISA, are unknown, without requiring manual individual analysis, design, and implementation.

[0042] FIG. 1 is a diagram illustrating an example of the configuration of a malicious script to be analyzed. FIG. 2 is a diagram illustrating an example of the configuration of a script engine. FIG. 3 is a diagram illustrating pseudocode of a VM included in the script engine. FIG. 4 is a diagram illustrating an example of a dynamic bytecode instrumentation engine. FIG. 5 is a diagram illustrating an example of the configuration of an analysis function providing device according to an embodiment. FIG. 6 is a diagram illustrating an example of a first test script used to detect a virtual program counter (VPC). FIG. 7 is a diagram illustrating an example of a second test script. FIG. 8 is a diagram illustrating an example of the second test script. FIG. 9 is a diagram illustrating an example of the second test script. FIG. 10 is a diagram illustrating an example of analysis function source code. FIG. 11 is a diagram illustrating an example of analysis function source code. FIG. 12 is a diagram illustrating an example of an execution trace. FIG. 13 is a diagram illustrating an example of a VM execution trace. FIG. 14 is a diagram illustrating an example of the data configuration of an analysis function information database (DB). FIG. 15 is a diagram illustrating processing by a VM instruction boundary detection unit. FIG. 16 is a diagram illustrating processing by a virtual program counter detection unit. FIG. 17 is a diagram illustrating processing by a dispatcher detection unit. FIG. 18 is a diagram illustrating processing by a VM instruction operation determination unit. FIG. 19 is a flowchart illustrating a processing procedure for analysis processing according to an embodiment. FIG. 20 is a flowchart illustrating a processing procedure for first execution trace acquisition processing shown in FIG. 19. FIG. 21 is a flowchart illustrating a processing procedure for VM instruction boundary detection processing shown in FIG. 19. FIG. 22 is a flowchart illustrating a processing procedure for virtual program counter detection processing shown in FIG. 19. FIG. 23 is a flowchart illustrating a processing procedure for dispatcher detection processing shown in FIG. 19. FIG. 24 is a diagram illustrating VM execution trace acquisition processing shown in FIG. 19. FIG. 25 is a flowchart illustrating a processing procedure for VM instruction collection processing shown in FIG. 19. FIG. 26 is a flowchart illustrating a processing procedure for VM instruction operation determination processing shown in FIG. 19. FIG. 27 is a flowchart illustrating a processing procedure for VM instruction operation determination processing shown in FIG. 19. FIG. 28 is a flowchart illustrating a processing procedure for second execution trace acquisition shown in FIG. 19. FIG. 29 is a flowchart illustrating a processing procedure for VM instruction input / output detection processing shown in FIG. 19.Fig. 30 is a flowchart showing the processing procedure for the analysis function generation processing shown in Fig. 19. Fig. 31 is a flowchart showing the processing procedure for the analysis function addition processing shown in Fig. 19. Fig. 32 is a flowchart showing the processing procedure for VM command input / output acquisition processing. Fig. 33 is a flowchart showing the processing procedure for analysis processing. Fig. 34 is a diagram showing an example of a computer in which analysis is realized by executing a program.

[0043] Hereinafter, embodiments of an analytical function providing device, an analytical function providing method, and an analytical function providing program according to the present application will be described in detail with reference to the accompanying drawings. However, the present invention is not limited to the embodiments described below.

[0044] [Embodiment] A malicious script to be analyzed by an analysis function providing device according to an embodiment will be described. Fig. 1 is a diagram for explaining an example of the configuration of a malicious script to be analyzed. The malicious script shown in Fig. 1 is an actual malicious script that has been manually deobfuscated and then partially excerpted and formatted.

[0045] The malicious script shown in Figure 1 has an analysis interference mechanism using conditional branching. It obtains the system locale (line 1) and terminates execution if it does not meet a specific value (lines 2 and 3). Therefore, if the analysis environment does not meet this condition, the malicious behavior (line 4) cannot be observed. Furthermore, this behavior is also locale-dependent (lines 4, 6, and 7). If the path is forcibly changed and the script is executed even in a locale that does not meet the condition, the script may not maintain consistency and may exhibit unexpected behavior. For example, it may open a non-existent file or write to a different file than intended (lines 7 and onward).

[0046] The analysis function-imparting device according to the embodiment imparts dynamic bytecode instrumentation functionality to a script engine whose internal specifications are unknown, after obtaining information about the script engine's instruction set architecture (ISA) related to dynamic bytecode instrumentation.

[0047] [Dynamic Bytecode Instrumentation] Next, dynamic bytecode instrumentation will be described. Dynamic bytecode instrumentation constantly monitors the execution of bytecodes, and inserts analysis processing when a specific event occurs.

[0048] Events include virtual machine (VM) instructions, basic block execution, function calls, etc. At the start and end points of such events, a callback is made to a pre-registered analysis handler (called an analysis function) to observe the state before and after execution.

[0049] The analysis function is called with information about the execution state as an argument, which allows you to observe the behavior by logging the information, or change the behavior by rewriting the execution state.

[0050] For example, to analyze Figure 1, we first need to understand the conditional expression (line 2) that must be satisfied. To do this, we need to track the loc variable, record operations on the variable (here, comparisons with !=), and reconstruct the expression.

[0051] Therefore, the execution of each VM instruction is monitored, and when the analysis function is called back, the value of the operation target is passed as an argument. This allows the analysis function to restore the expression from the operation on the loc variable and rewrite the loc variable to a value that satisfies the expression, thereby achieving a bypass.

[0052] Dynamic bytecode instrumentation is typically implemented as an add-on feature to the VM of a script engine.

[0053] So, let's explain the architecture of the VM. A script engine generally analyzes the input script and generates bytecode through an abstract syntax tree. The generated bytecode is then interpreted and executed by the VM to execute the script. Therefore, understanding the VM architecture is important to understand and control the execution status of the script.

[0054] There are two main types of interpretive execution VMs. The first is a decode-dispatch type, and the second is a threaded code type. Here, the decode-dispatch type, which is highly common, will be used as an example. Note that this embodiment can accommodate both the decode-dispatch type and the threaded code type.

[0055] The configuration and function of a typical script engine will be described with reference to Figures 2 and 3. Figure 2 is a diagram illustrating an example of the configuration of a script engine. As shown in Figure 2, 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 input.

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

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

[0058] The functions of the components of the script engine will be described with reference to FIG. 3. FIG. 3 is a diagram showing pseudocode for the VM of the script engine. As shown in FIG. 3, 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).

[0059] [Design of the Required Dynamic Bytecode Instrumentation Engine] Figure 4 shows an example of a dynamic bytecode instrumentation engine. With reference to Figure 4, the design of the required instrumentation engine will be described.

[0060] To bypass the analysis interference of malicious scripts as shown in Figure 1, fine-grained analysis is required, so it is desirable to monitor the execution of VM instructions as an event to be monitored. For this purpose, we design the system to monitor the VM opcodes interpreted by the decoder / dispatcher ((1) in Figure 4).

[0061] Then, each time a VM opcode to be monitored is executed, a callback is made to the corresponding analysis function ((2) in Figure 4). At that time, the value of the VM instruction's operation target is acquired and passed as an argument, thereby realizing behavior monitoring and modification ((3) in Figure 4). Note that the analysis function is implemented in a binary outside the VM, not in bytecode within the VM.

[0062] To realize the design of a dynamic bytecode instrumentation engine, it is necessary to understand the implementation of the decoder / dispatcher within the script engine in order to observe the VM instructions being executed.

[0063] In order to understand this and observe the execution state of the VM, it is necessary to identify the data corresponding to the VPC. Furthermore, to identify the VM instruction and perform a callback, it is necessary to identify the VM opcode. In addition, to pass execution state information to the argument of the analysis function, it is necessary to understand the value of the operation target of the VM instruction.

[0064] The analysis function providing device according to the embodiment first automatically analyzes the architecture and ISA of a VM in order to provide a dynamic bytecode instrumentation engine.

[0065] [Configuration of the analysis function-imparting device] Fig. 5 is a diagram illustrating an example of the configuration of the analysis function-imparting device 10 according to the embodiment. The configuration of the analysis function-imparting device 10 according to the embodiment will be specifically described with reference to Fig. 5.

[0066] The analysis function-imparting device 10 executes a first test script while monitoring the binary of the script engine, and acquires a branch trace and a memory access trace as a first execution trace. The analysis function-imparting device 10 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.

[0067] The analysis function-adding device 10 executes a second test script while monitoring the VPC and the dispatcher to acquire a first VM execution trace. The analysis function-adding device analyzes the VM execution trace to collect VM instructions and determine the operation of the VM instructions using a predetermined algorithm. The analysis function-adding device 10 uses the second test script and the script engine binary to acquire a second execution trace that targets only the VM instruction to be determined, and analyzes the second execution trace to detect the input and output of the VM instruction and acquire ISA information.

[0068] Next, the analysis function adding device 10 adds a dynamic bytecode instrumentation engine (see FIG. 4) to the script engine binary based on the obtained VM architecture and ISA information. The analysis function adding device 10 can add a dynamic bytecode instrumentation function to a script engine that does not have a support function such as a debugger and whose internal specifications, including the ISA, are unknown, without requiring manual individual analysis, design, and implementation.

[0069] 5, 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 seed script.

[0070] 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, script engine binaries, and analysis function source codes, and outputs them to the control unit 12.

[0071] 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. The script engine binary is an executable file that constitutes the script engine. The script engine binary may be composed of multiple executable files. The analysis function source code is source code that includes the analysis function.

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

[0073] 6 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.

[0074] The second test script is intended to execute the VM instructions to be analyzed for ISA analysis. However, the instructions that the VM has are 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 instructions corresponding to each operation are determined. Examples of operations include arithmetic operations, logical operations, comparisons, and manipulation of variables and constants.

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

[0076] The second test script is created according to the following criteria. First, write the minimum number of expressions or statements related to the operation to be judged (addition in the example of Figure 7). 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 of Figure 7). Third, do not operate on constants, but use one or more variables.

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

[0078] [Analysis Function Source Code] The analysis function source code is source code that includes an analysis function. Figures 10 and 11 are diagrams showing examples of analysis function source code.

[0079] The analysis function source code shown in Figure 10 contains an analysis function named analysis_func_VMOP1_enter. This analysis function is injected at the entrance of the VM instruction to be monitored, "VMOP1" (box W1). This analysis function takes as arguments the VM opcode to be monitored and the input value of the VM instruction to be operated on (boxes W2 and W3), and includes processing to record and rewrite the input value.

[0080] 11 contains an analysis function named analysis_func_VMOP1_exit. The VM instruction to be monitored is "VMOP1," and this analysis function is injected into its exit (box W11). This analysis function takes the VM opcode to be monitored and the output value of the VM instruction to be manipulated as arguments (box W13), and includes processing to record and rewrite the output value.

[0081] 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 function providing device 10, data used during execution of the processing programs, etc. The storage unit 13 has an execution trace DB 131, a VM execution trace DB 133, 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, and an analysis function information DB 134.

[0082] 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 (described later), the second execution trace acquisition unit 1224, and the VM execution trace acquisition unit 1221 (described later), respectively. The execution trace DB 131 and the VM execution trace DB 133 are managed by the analysis function-imparting 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.

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

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

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

[0086] A log line of a memory access trace has the format shown in lines 11 to 13 of FIG. 12, 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.

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

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

[0089] The analytic function information DB 134 stores the analytic functions generated by the analytic function generating unit 1231. Fig. 14 is a diagram showing an example of the data configuration of the analytic function information DB 134.

[0090] The VM instruction item shown in FIG. 14 is an area that stores which VM instruction the analysis function is for. Entry / Exit is an area that stores whether the analysis function is for the entry or exit of the VM instruction. Binary is an area that stores the binary of the compiled analysis function. Entry point address is an area that additionally stores the address of the entry point of the analysis function expanded in memory space during analysis using the generated product.

[0091] Returning to Fig. 5, 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), an instruction set architecture analysis unit 122 (second analysis unit), and a dynamic bytecode instrumentation function addition unit 123 (addition unit).

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

[0093] 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).

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

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

[0096] 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 function providing 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.

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

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

[0099] 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 function providing 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.

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

[0101] 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).

[0102] 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. The VM execution trace acquisition unit 1221 executes a large number of test scripts to acquire VM execution traces. 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.

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

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

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

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

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

[0108] 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). The VM instruction input / output detection unit 1225 uses the memory access trace, which is the second execution trace, to compare characteristic values ​​used as the operation target of the second test script, and detects code that reads and writes from the matched memory as a location where input / output occurs.

[0109] The dynamic bytecode instrumentation function adding unit 123 monitors the execution of VM instructions and adds to the script engine binary an analysis function that performs analysis processing according to input and output values ​​of the VM instructions, based on the analysis result of the VM by the virtual machine analysis unit 121 and the analysis result of the ISA by the instruction set architecture analysis unit 122. The dynamic bytecode instrumentation function adding unit 123 outputs a script engine with dynamic bytecode instrumentation function by inserting analysis code that realizes the design of FIG. 4 into the script engine binary, based on the VM architecture acquired by the virtual machine analysis unit 121 and the ISA information acquired by the instruction set architecture analysis unit 122.

[0110] That is, the dynamic bytecode instrumentation function adding unit 123 monitors the execution of an instruction as an event based on the VM architecture and ISA information, and adds the dynamic bytecode instrumentation function to the script engine binary by calling back the analysis function along with the input and output values. The dynamic bytecode instrumentation function adding unit 123 has an analysis function generation unit 1231 and an analysis function adding unit 1232.

[0111] The analytic function generating unit 1231 compiles the input analytic function source code, acquires the corresponding binary, and stores the generated analytic function in the analytic function information DB 134 .

[0112] The analysis function adding unit 1232 adds a code for implementing analysis processing to the script engine binary. The analysis function adding unit 1232 monitors the execution of VM instructions based on the analysis results for the VM and the analysis results for the instruction set architecture, and adds an analysis function to the script engine binary that performs analysis processing in accordance with input / output values ​​of the VM instructions.

[0113] The analysis function assigning unit 1232 includes a first code assigning unit 1233 and a second code assigning unit 1234 .

[0114] The first code assigning unit 1233 assigns to the script engine binary a code that realizes a VM instruction input / output acquisition process. The first code assigning unit 1233 monitors instruction execution as an event based on the VM architecture and ISA information, and assigns to the script engine binary a code that realizes a VM instruction input / output acquisition process that acquires the input / output values ​​of the instruction.

[0115] The second code adding unit 1234 adds a code that executes a corresponding analysis function for each operation of a VM command and realizes analysis processing to the script engine binary.

[0116] 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 the output unit 14, and may output various information to the external device.

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

[0118] 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. 15 , 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.

[0119] [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. 16 is a diagram explaining the processing of the virtual program counter detection unit 1213.

[0120] 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. 16 , 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. 16 ).

[0121] 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. 16 ).

[0122] [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. 17 is a diagram illustrating the processing of the dispatcher detection unit 1214.

[0123] 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. 17), 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. 17).

[0124] [Processing of VM Command Operation Determination Unit] Next, a description will be given of the processing of the VM command operation determination unit 1223. FIG.

[0125] The VM instruction operation determination unit 1223 analyzes the VM execution trace acquired by the second test script of a specific operation, and determines the VM opcode that carries out that operation.

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

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

[0128] For example, in the addition test script shown in Figure 7, 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.

[0129] Therefore, the VM command operation determination unit 1223 performs the determination using an algorithm that prioritizes clarifying commands that are easier to determine. Even when there is a dependency relationship as described above, the determination is possible if 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 relationship.

[0130] An outline of the algorithm used by the VM instruction operation determination unit 1223 will be described with reference to Fig. 18. The VM instruction operation determination unit 1223 creates a list of unknown VM opcodes for each VM execution trace (see Fig. 18). The VM instruction operation determination unit 1223 sets the reciprocal of the number of unknown VM opcodes in the list as a priority and makes a determination by repeating the following procedure.

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

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

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

[0134] For example, in the case of the list shown in Fig. 18 , 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. 18 ). Then, the VM instruction operation determination unit 1223 reflects the determination result in all lists and updates the priorities ((2) in Fig. 18 ). As a result, all of the opcodes "VMOP1_Unknown" in the list are updated to the opcode "VMOP1_known".

[0135] 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. 18). Then, the determination result is reflected in all lists, and the priorities are updated ((4) in FIG. 18). As a result, all of the opcodes "VMOP2_Unknown" in the lists are updated to the opcode "VMOP2_known".

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

[0137] 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. 18).

[0138] 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. 18).

[0139] 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. 18).

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

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

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

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

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

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

[0146] For example, in the case of the test script in Fig. 7, "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.

[0147] [Processing Procedure of Analysis Function-Providing Device] Next, a processing procedure of the analysis processing by the analysis function-providing device 10 will be described. Fig. 19 is a flowchart showing the processing procedure of the analysis processing according to the embodiment.

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

[0149] 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).

[0150] 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).

[0151] 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).

[0152] 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).

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

[0154] 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).

[0155] 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).

[0156] The VM instruction input / output detection unit 1225 analyzes the second execution trace and performs a VM instruction input / output detection process to detect input / output of a VM instruction (step S10).

[0157] The analytical function generating unit 1231 compiles the input analytical function source code and performs analytical function generating processing to generate an analytical function (step S11).

[0158] The analysis function providing unit 1232 performs an analysis function providing process to provide the script engine binary with an analysis function that monitors the execution of VM instructions and performs analysis processing according to input / output values ​​of the VM instructions based on the VM architecture and ISA information (step S12). The analysis function providing unit 1232 provides the script engine binary with a code that realizes the VM instruction input / output acquisition process and a code that realizes the analysis processing.

[0159] The output unit 14 outputs the script engine with the dynamic bytecode instrumentation function (step S13).

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

[0161] 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).

[0162] 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).

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

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

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

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

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

[0168] 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).

[0169] 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).

[0170] 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).

[0171] 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).

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

[0173] [Processing Procedure of Dispatcher Detection Processing] Next, a flow of dispatcher detection processing will be described with reference to Fig. 19. Fig. 23 is a flowchart showing the processing procedure of dispatcher detection processing shown in Fig. 19.

[0174] 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).

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

[0176] 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).

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

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

[0179] 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).

[0180] 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).

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

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

[0183] 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).

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

[0185] [Procedure of VM Command Operation Determination Processing] Next, a flow of the VM command determination processing shown in Fig. 19 will be described. Fig. 26 and Fig. 27 are flowcharts showing the procedure of the VM command operation determination processing shown in Fig. 19.

[0186] 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).

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

[0188] 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).

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

[0190] 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).

[0191] 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).

[0192] 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).

[0193] 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).

[0194] 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).

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

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

[0197] 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).

[0198] [Second Execution Trace Acquisition Processing] Next, a flow of the second execution trace acquisition processing shown in Fig. 19 will be described. Fig. 28 is a flowchart showing the processing procedure of the second execution trace acquisition processing shown in Fig. 19.

[0199] 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).

[0200] 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).

[0201] 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).

[0202] 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).

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

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

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

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

[0207] 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. 7, these are "0x12345678" and "0x12345679".

[0208] 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).

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

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

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

[0212] 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).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).

[0213] 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).

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

[0215] [Processing Procedure of Analytical Function Generation Processing] Next, a flow of the analytical function generation processing shown in Fig. 19 will be described. Fig. 30 is a flowchart showing the processing procedure of the analytical function generation processing shown in Fig. 19.

[0216] The analysis function generation unit 1231 receives as input an analysis function source code created for each operation of a VM instruction determined by the VM instruction operation determination unit 1223 (step S151). Note that the analysis function source code input to the analysis function providing device 10 is created for each operation of a VM instruction in accordance with that operation.

[0217] The analysis function generation unit 1231 compiles the input analysis function source code to obtain the corresponding binary (step S152). The analysis function generation unit 1231 stores information of the analysis function in the analysis function information DB 134 for each operation of the VM instruction (step S153).

[0218] [Procedure of Analysis Function Assignment Processing] Next, a flow of the analysis function assignment processing shown in Fig. 19 will be described. Fig. 31 is a flowchart showing the procedure of the analysis function assignment processing shown in Fig. 19.

[0219] The analysis function adding unit 1232 receives a script engine binary as input (step S161), and the first code adding unit 1233 adds a code for implementing a VM command input / output acquisition process to the script engine binary (step S162).The second code adding unit 1234 adds a code for implementing an analysis process to the script engine binary (step S163).

[0220] [Procedure of VM Command Input / Output Acquisition Processing] Next, a flow of the VM command input / output acquisition processing shown in Fig. 31 will be described. Fig. 32 is a flowchart showing the procedure of the VM command input / output acquisition processing.

[0221] In the VM instruction input / output acquisition process, a code that accesses an input / output value is received as input (step S171). Then, in the VM instruction input / output acquisition process, memory reads by the code that accesses the input value are monitored (step S172). In the VM instruction input / output acquisition process, memory writes by the code that accesses the output value are monitored (step S173). In the processes of steps S171 to S173, the detection results of the VM instruction input / output detection unit 1225 are used.

[0222] In the VM command input / output acquisition process, it is determined whether a memory read is observed (step S174). If a memory read is observed (step S174: Yes), the read value is output as an input value (step S175).

[0223] In the VM command input / output acquisition process, if no memory read is observed (step S174: No), it is determined whether or not a memory write is observed (step S176).

[0224] If memory writing is observed (step S176: Yes), the VM instruction input / output acquisition process outputs the written value as an output value (step S177).

[0225] In the VM instruction input / output acquisition process, it is determined whether or not the execution of the bytecode has finished (step S178). In the VM instruction input / output acquisition process, if the execution of the bytecode has not finished (step S178: No), monitoring continues (step S179) and the process returns to the determination process of step S174.

[0226] If the execution of the bytecode has finished (step S178: Yes), the VM instruction input / output acquisition process ends.

[0227] [Procedure of Analysis Processing] Next, the flow of the analysis processing shown in Fig. 31 will be described. Fig. 33 is a flowchart showing the procedure of the analysis processing.

[0228] In the analysis process, the bytecode to be analyzed is received as input (step S181). Then, in the analysis process, the analysis function information DB 134 is referenced and the analysis function binary is expanded in memory space (step S182). In the analysis process, the address of the expanded entry point is stored in the analysis function information DB 134 (step S183).

[0229] In the analysis process, the dispatcher is monitored, and the VM opcode to be executed is monitored (step S184). In the analysis process, the decoder / dispatcher detected by the dispatcher detection unit 1214 is used. Then, in the analysis process, the execution of the bytecode is started (step S185).

[0230] In the analysis process, it is determined whether a VM command in the analysis function information DB 134 has been executed (step S186). If the VM command in the analysis function information DB 134 has been executed (step S186: Yes), the input of the VM command is acquired from the VM command input / output acquisition process and set as an argument of the analysis function (step S187).

[0231] In the analysis process, the analysis function information DB is searched for the VM opcode, and execution is transferred to the entry point of the input analysis function (step S188). In the analysis process, the analysis function is executed to its end (step S189). In the analysis process, execution of the VM instruction is continued (step S190).

[0232] In the analysis process, the output of the VM instruction is acquired from the VM instruction input / output acquisition process and set as an argument of the analysis function (step S191). In the analysis process, the analysis function information DB 134 is searched for the VM opcode, and execution is transferred to the entry point of the analysis function of the output (step S192). In the analysis process, the analysis function is executed until its end (step S193).

[0233] If the VM instruction in the analytical function information DB 134 has not been executed (step S186: No), or after the process of step S193, the execution of the bytecode continues (step S194).

[0234] In the analysis process, it is determined whether the execution of the bytecode has finished (step S195). If the execution of the bytecode has not finished (step S195: No), the process returns to step S186. If the execution of the bytecode has finished (step S195: Yes), the analysis process ends.

[0235] [Effects of the embodiment] As described above, the analysis function-imparting 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 function-imparting device 10 analyzes the VM of the script engine based on the first execution trace. The analysis function-imparting device 10 acquires architecture information of the VPC and the dispatcher.

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

[0237] Specifically, the analysis function-adding device 10 executes a second test script while monitoring the VPC and the dispatcher to acquire a VM execution trace. The analysis function-adding device 10 analyzes the VM execution trace to collect VM instructions and create a list of unknown virtual machine opcodes among the virtual machine opcodes, and determines the operation of the VM instructions using the list and a predetermined algorithm. The analysis function-adding 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 the input and output of the VM instruction.

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

[0239] Furthermore, the analysis function-imparting device 10 monitors the execution of VM instructions as events based on the obtained VM architecture and ISA information, and realizes dynamic bytecode instrumentation by calling back to the analysis function along with its input and output values.

[0240] As a result, the analysis function-imparting device 10 can obtain information about the VM's architecture and ISA through analysis based on the acquisition of execution traces and VM execution traces, even for script engines whose VM internal specifications are unknown, and can impart dynamic bytecode instrumentation functions without the need for manual reverse engineering.

[0241] Furthermore, the analysis function-imparting device 10 can automatically elucidate VM architecture and ISA information for a variety of script engines as long as a test script is prepared, thereby realizing dynamic bytecode instrumentation functions without the need for individual design or execution.

[0242] Therefore, the analysis function-imparting device 10 enables dynamic bytecode instrumentation at the VM instruction level for scripts written in various script languages, thereby enabling more detailed behavioral understanding.

[0243] In this way, the analysis function providing device 10 can analyze the script engine and determine the ISA, thereby realizing analysis at the VM command level for script engines of a wide variety of script languages.

[0244] As described above, the analysis function-imparting device 10 of this embodiment is useful for realizing dynamic bytecode instrumentation in a wide variety of script engines, and is suitable for realizing bytecode instrumentation even for 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.

[0245] Therefore, by using the analysis function-imparting device 10, analysis function-imparting method, and analysis function-imparting program of this embodiment to impart dynamic bytecode instrumentation functions to various script engines, it is possible to realize tools that analyze bytecode at the VM instruction level.

[0246] By using the analysis function providing device 10, analysis function providing method, and analysis function providing program according to this embodiment, it is possible to provide a dynamic bytecode instrumentation function to a script engine that does not have a support function such as a debugger and whose internal specifications are unknown, without the need for manual individual analysis, design, and implementation. As described above, the analysis function providing device 10 can create a tool that analyzes scripts using dynamic bytecode instrumentation, which can be expected to be used, for example, to support debugging through analysis of scripts at the bytecode level, or to analyze the detailed behavior of malware.

[0247] 5 are conceptual functional components of the analysis function-imparting 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 function-imparting 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.

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

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

[0250] 34 is a diagram showing an example of a computer in which the analysis function-imparting device 10 is realized by executing a program. 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.

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

[0252] 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 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, the program module 1093 for executing the same process as the functional configuration of 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).

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

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

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

[0256] 10 Analysis function adding device 11 Input unit 12 Control unit 13 Memory unit 14 Output unit 121 Virtual machine analysis unit 122 Instruction set architecture analysis unit 123 Dynamic bytecode instrumentation function adding unit 131 Execution trace database (DB) 132 Architecture information DB 133 VM execution trace DB 134 Analysis function information 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 1231 Analysis function generation unit 1232 Analysis function adding unit 1233 First code adding unit 1234 Second code assigning unit

Claims

1. An analysis function adding 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; a second analysis unit that analyzes an instruction set architecture, which is the instruction system of the virtual machine, to collect virtual machine instructions, determine the operation of the collected virtual machine instructions, and detect input / output of the virtual machine instructions using a second test script; and an adding unit that monitors the execution of the virtual machine instructions based on the analysis results of the virtual machine and the analysis results of the instruction set architecture, and adds an analysis function to the binary of the script engine that performs analysis processing according to the input / output values ​​of the virtual machine instructions.

2. The analysis function-providing device according to claim 1, characterized in that the first analysis unit comprises: a first acquisition unit that acquires a plurality of 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 plurality of 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 function-providing 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 a 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 is performed for each virtual machine execution trace and determines the operation of the virtual machine instruction based on the list; a third acquisition unit that executes a second test script using a value characteristic of the operation target 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 function-providing device described in claim 3, characterized in that the first judgment unit sets a priority to the inverse of 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 function-providing device according to claim 4, characterized in that the first judgment unit executes: a first procedure of judging 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 judged; a second procedure of detecting a unique unknown VM opcode based on a difference with other lists and judging that the detected unknown virtual machine opcode is responsible for the operation to be judged, when the number of unknown virtual machine opcodes is greater than 1; and a third procedure of reflecting the judgment results in the first procedure and the second procedure to all the lists and updating the priority.

6. The analysis function-adding 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 function providing method executed by an analysis function providing device, comprising: a step of analyzing a virtual machine of the script engine based on a first execution trace obtained by executing a first test script while monitoring the binary of a script engine; a step of analyzing an instruction set architecture, which is the instruction system of the virtual machine, to collect virtual machine instructions, determining the operation of the collected virtual machine instructions, and detecting input and output of the virtual machine instructions using a second test script; and a step of monitoring the execution of the virtual machine instructions based on the analysis results of the virtual machine and the analysis results of the instruction set architecture, and providing the binary of the script engine with an analysis function that performs analysis processing in accordance with the input and output values ​​of the virtual machine instructions.

8. An analysis function-imparting 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 the instruction system of 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; and monitoring the execution of the virtual machine instructions based on the analysis results of the virtual machine and the analysis results of the instruction set architecture, and imparting to the binary of the script engine an analysis function that performs analysis processing according to the input / output values ​​of the virtual machine instructions.

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