WO2024079794A1 - 解析機能付与装置、解析機能付与方法および解析機能付与プログラム - Google Patents

解析機能付与装置、解析機能付与方法および解析機能付与プログラム Download PDF

Info

Publication number
WO2024079794A1
WO2024079794A1 PCT/JP2022/037925 JP2022037925W WO2024079794A1 WO 2024079794 A1 WO2024079794 A1 WO 2024079794A1 JP 2022037925 W JP2022037925 W JP 2022037925W WO 2024079794 A1 WO2024079794 A1 WO 2024079794A1
Authority
WO
WIPO (PCT)
Prior art keywords
unit
execution
information
bytecode
architecture
Prior art date
Application number
PCT/JP2022/037925
Other languages
English (en)
French (fr)
Inventor
利宣 碓井
裕平 川古谷
誠 岩村
Original Assignee
日本電信電話株式会社
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 日本電信電話株式会社 filed Critical 日本電信電話株式会社
Priority to PCT/JP2022/037925 priority Critical patent/WO2024079794A1/ja
Publication of WO2024079794A1 publication Critical patent/WO2024079794A1/ja

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F21/00Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
    • G06F21/50Monitoring users, programs or devices to maintain the integrity of platforms, e.g. of processors, firmware or operating systems
    • G06F21/57Certifying or maintaining trusted computer platforms, e.g. secure boots or power-downs, version controls, system software checks, secure updates or assessing vulnerabilities

Definitions

  • the present invention relates to an analysis function providing device, an analysis function providing method, and an analysis function providing program.
  • Instrumentation is one of the techniques for analyzing software. This involves adding code with analytical functions to the program being analyzed, and obtaining information about the execution state of the target program at run time. For example, by using instrumentation to insert recording code for each instruction, it is possible to count the number of instructions executed, and by inserting similar code for each branch, it is possible to recognize the control flow that was executed.
  • This type of instrumentation is an important technique that is widely used for software testing as well as cybersecurity purposes such as analyzing malware and discovering vulnerabilities.
  • Instrumentation can be added statically before a program is executed, or dynamically at runtime.
  • the targets of instrumentation are diverse, including source code, scripts, executable binaries (hereafter referred to as binaries), and bytecode.
  • binaries executable binaries
  • bytecode bytecode
  • instrumentation that is dynamically added to binaries is called dynamic binary instrumentation.
  • scripts being tested, but there are also increasing opportunities for malicious scripts to be used in attacks, making instrumentation of scripts important.
  • the former static addition method has the problem that it can be difficult to comprehensively find the locations where analysis scripts should be added. There is also the problem that static addition may not be possible for scripts that are dynamically evaluated at runtime. Furthermore, if the script is obfuscated, comprehensive addition is also difficult, and there is also the problem that it is not effective for analyzing malicious scripts. Therefore, the latter method is generally used to dynamically add scripts to bytecode at runtime. This makes it possible to achieve instrumentation even in the above-mentioned cases.
  • Non-Patent Document 1 proposes a method for implementing dynamic instrumentation for Java (registered trademark) bytecode.
  • Non-Patent Document 2 proposes a method for implementing dynamic instrumentation for ActionScript3 bytecode.
  • 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 virtual machine (VM) in the script engine that controls the execution of the script are often not made public, making it difficult to monitor the execution state and transition between execution states required for instrumentation without support functions.
  • VM virtual machine
  • the present invention was made in consideration of the above, and aims to make it possible to provide dynamic bytecode instrumentation functionality to script engines that do not have support functions such as a debugger and whose internal specifications are unknown, without the need for manual individual analysis, design, and implementation.
  • the analysis function providing device is characterized by having a first acquisition unit that analyzes the virtual machine of the script engine and acquires information about the architecture of the script engine, a second acquisition unit that acquires information about the instruction set architecture, which is the instruction system of the virtual machine, based on the information about the architecture, an extraction unit that extracts bytecode for instrumentation based on the acquired information about the architecture and the information about the instruction set architecture, and an insertion unit that inserts the extracted bytecode for instrumentation into the bytecode to be analyzed.
  • FIG. 1 is a schematic diagram illustrating a schematic configuration of an analysis function imparting device according to the present embodiment.
  • FIG. 2 is a diagram showing an example of a test script used for detecting a virtual program counter.
  • FIG. 3 is a diagram illustrating an example of an execution trace.
  • FIG. 4 is a diagram illustrating an example of a VM execution trace.
  • FIG. 5 is a flowchart showing the procedure of the analysis function providing process.
  • FIG. 6 is a flowchart showing the procedure of the execution trace acquisition process.
  • FIG. 7 is a flowchart showing the procedure of the virtual program counter detection process.
  • FIG. 8 is a flowchart illustrating a procedure for the VM instruction boundary detection process.
  • FIG. 9 is a flowchart showing the procedure of the dispatcher detection process.
  • FIG. 1 is a schematic diagram illustrating a schematic configuration of an analysis function imparting device according to the present embodiment.
  • FIG. 2 is a diagram showing an example of a test script used for detecting
  • FIG. 10 is a flowchart showing the procedure of the code cache detection process.
  • FIG. 11 is a flowchart illustrating a procedure for the VM execution trace acquisition process.
  • FIG. 12 is a flowchart illustrating a procedure for the VM command collection process.
  • FIG. 13 is a flowchart illustrating a procedure for the VM command determination process.
  • FIG. 14 is a flowchart showing the procedure of the instrumentation bytecode extraction process.
  • FIG. 15 is a flowchart showing the procedure of the insertion process.
  • FIG. 16 is a flowchart showing the procedure of the execution process.
  • FIG. 17 is a diagram illustrating an example of a computer that executes an analysis function providing program.
  • the analysis function adding device of this embodiment is applied to a script engine, executes a test script while monitoring the binary of the script engine, and acquires a branch trace and a memory access trace as an execution trace.
  • the analysis function adding device then analyzes the VM based on the execution trace, and acquires a VPC (Virtual Program Counter), a dispatcher, a conditional branch flag, and a code cache, which are architectural information related to the architecture of the script engine.
  • VPC Virtual Program Counter
  • the analysis function providing device executes the test script while monitoring the VPC and the dispatcher to obtain a VM execution trace. By analyzing this VM execution trace, it collects VM instructions, determines the VM instructions, and obtains information on the instruction set architecture.
  • the analysis function adding device extracts bytecode for instrumentation based on the obtained architecture information, embeds it into the bytecode to be analyzed, and executes it to realize dynamic bytecode instrumentation. In this way, even for script engines where the internal specifications of the VM are unknown, the analysis function adding device detects various architectural information through analysis based on the acquisition of execution traces and VM execution traces, and realizes the addition of dynamic bytecode instrumentation functionality without the need for manual reverse engineering.
  • the analysis function adding device can automatically add dynamic bytecode instrumentation functionality to a variety of script engines by preparing test scripts, eliminating the need for individual design and implementation. Therefore, it is possible to perform dynamic bytecode instrumentation and perform analysis on a wide variety of script engine implementations.
  • FIG. 1 is a schematic diagram illustrating a schematic configuration of an analysis function imparting device of the present embodiment.
  • an analysis function imparting device 10 of the present embodiment is realized by a general-purpose computer such as a personal computer, and includes an input unit 11, a control unit 12, a storage unit 13, and an output unit 14.
  • the input unit 11 is realized using input devices such as a keyboard and a mouse, and accepts information input from an operator or from outside, and inputs it to the control unit 12. For example, the input unit 11 accepts input of a test script or a virtual machine binary. The input unit 11 also accepts input of information transmitted from an external device via a telecommunications line.
  • test script is a script that is input when dynamically analyzing a script engine to obtain an execution trace and a VM execution trace. This test script focuses on the number of branch instruction executions and memory reads and writes, and is used to capture differences in the behavior of the script engine that arise when the test script is executed a different number of times. This test script is prepared in advance of analysis and is created manually. Creating it requires knowledge of the specifications of the target scripting language.
  • Figure 2 shows an example of a test script used for VPC detection.
  • This test script uses a repetitive process (line 2).
  • the test script changes the execution conditions by increasing or decreasing the number of repetitions (line 2) and the number of repeated statements (lines 3 to 5) in the test script, thereby generating differences.
  • a script engine binary is an executable file that makes up a script engine.
  • a script engine binary may consist of multiple executable files.
  • the output unit 14 is realized by a display device such as a liquid crystal display, a printing device such as a printer, etc. For example, the output unit 14 displays the results of the analysis function imparting process described below. The output unit 14 may also output various information to an external device.
  • 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.
  • the storage unit 13 stores in advance the processing program that operates the analysis function imparting device 10, data used during the execution of the processing program, etc., or stores it temporarily each time processing is performed.
  • the memory unit 13 stores an execution trace database (DB) 131, a VM execution trace DB 133, and an architecture information DB 132.
  • DB execution trace database
  • the execution trace DB 131 and the VM execution trace DB 133 store the execution traces and VM execution traces acquired by the execution trace acquisition unit 1211 and the VM execution trace acquisition unit 1221, respectively.
  • the execution trace DB 131 and the VM execution trace DB 133 are managed by the analysis function providing device 10.
  • the execution trace DB 131 and the VM execution trace DB 133 may be managed by another device (such as a server), in which case the execution trace acquisition unit 1211 and the VM execution trace acquisition unit 1221 output the acquired execution traces and VM execution traces to the management server of the execution trace DB 131 and the VM execution trace DB 133, etc., via the communication interface of the output unit 14, and store them in the execution trace DB 131 and the VM execution trace DB 133.
  • another device such as a server
  • the execution trace acquisition unit 1211 and the VM execution trace acquisition unit 1221 output the acquired execution traces and VM execution traces to the management server of the execution trace DB 131 and the VM execution trace DB 133, etc., via the communication interface of the output unit 14, and store them in the execution trace DB 131 and the VM execution trace DB 133.
  • the control unit 12 is realized using a CPU (Central Processing Unit) or an MPU (Micro Processing Unit), and executes processing programs stored in memory. As a result, the control unit 12 functions as a virtual machine analysis unit 121 (first acquisition unit), an instruction set architecture analysis unit 122 (second acquisition unit), and an instrumentation unit 123, as illustrated in FIG. 1.
  • a CPU Central Processing Unit
  • MPU Micro Processing Unit
  • the control unit 12 functions as a virtual machine analysis unit 121 (first acquisition unit), an instruction set architecture analysis unit 122 (second acquisition unit), and an instrumentation unit 123, as illustrated in FIG. 1.
  • the virtual machine analysis unit 121 (first acquisition unit) analyzes the VM of the script engine and acquires information about the architecture of the script engine. Specifically, the virtual machine analysis unit 121 executes a test script while monitoring the binary of the script engine, and acquires branch traces and memory access traces as execution traces. The analysis function providing device then analyzes the virtual machine VM based on the execution traces and acquires architecture information.
  • the architecture information includes any one of a virtual program counter, a dispatcher, a conditional branch flag, or a code cache.
  • the virtual machine analysis unit 121 has an execution trace acquisition unit 1211, a virtual program counter detection unit 1212, a VM instruction boundary detection unit 1213, a dispatcher detection unit 1214, and a code cache detection unit 1215.
  • the execution trace acquisition unit 1211 accepts the test script and the script engine binary as input.
  • the execution trace acquisition unit 1211 acquires an execution trace by executing the test script while monitoring the execution of the script engine binary.
  • An execution trace consists of a branch trace and a memory access trace.
  • a branch trace records the type of branch instruction at the time of execution, the branch source address, and the branch destination address.
  • a memory access trace records the type of memory operation and the memory address of the operation target. It is known that branch traces and memory access traces can be acquired by instruction hooks.
  • the execution trace acquired by the execution trace acquisition unit 1211 is stored in the execution trace DB 131.
  • Figure 3 shows an example of an execution trace.
  • An execution trace has an element called trace. Trace indicates whether the log line is a branch trace or a memory access trace.
  • a branch trace log line has the format shown, for example, in lines 1 to 10 of Figure 3, 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.
  • a log line of a memory access trace has the format shown, for example, in lines 11 to 13 of Figure 3, and consists of three elements: type, target, and value.
  • Type indicates whether the memory access is a read or write.
  • Target indicates the memory address that is the target of the memory access. Value stores the result of the memory access.
  • the virtual program counter detection unit 1212 extracts and analyzes the execution trace for the first test script stored in the execution trace DB 131 to detect the VPC.
  • the virtual program counter detection unit 1212 analyzes multiple execution traces using differential execution analysis focusing on the number of memory reads and the boundaries of each VM instruction detected by the VM instruction boundary detection unit 1213 to detect the VPC.
  • the virtual program counter detection unit 1212 makes use of the fact that a read into the memory that holds the VPC always occurs after the execution of each VM instruction, and detects the VPC by discovering the destination of this read.
  • the virtual program counter detection unit 1212 uses differential execution analysis that focuses on the number of memory reads to detect VPCs.
  • the virtual program counter detection unit 1212 compares execution traces of multiple test scripts acquired using the test scripts, and finds memories whose memory read counts change in proportion to both the increase or decrease in the number of repetitions and the number of repeated statements.
  • the virtual program counter detection unit 1212 then refers to the boundaries of each VM instruction detected by the VM instruction boundary detection unit 1213, and narrows down the memory values that have been read to those that always point to the start point of the VM instruction.
  • the virtual program counter detection unit 1212 detects this memory as a VPC.
  • the VM instruction boundary detection unit 1213 clusters the execution trace to detect the boundaries of each VM instruction.
  • the VM instruction boundary detection unit 1213 clusters the execution trace to detect clusters with a threshold or more of execution count as VM instructions. In clustering, consecutive code regions that are executed multiple times are detected. For example, executed instructions that are close to each other in code may be grouped together, common subsequences of executed code blocks may be searched for, or other methods may be used.
  • 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.
  • the dispatcher detection unit 1214 extracts each VM instruction portion from the script engine binary based on the boundaries of the VM instructions detected by the VM instruction boundary detection unit 1213, and detects the portion with high similarity between each VM instruction as a dispatcher. To detect the portion with high similarity, for example, a sequence alignment algorithm may be used, or other methods may be used.
  • the code cache detection unit 1215 receives the execution trace and VM execution trace as input, and obtains the memory area pointed to by the VPC from the VM execution trace. The code cache detection unit 1215 also obtains from the execution trace the code location that called the memory allocation function that allocated the memory area. The code cache detection unit 1215 also detects all areas allocated at that code location as code caches. The code cache detection unit 1215 then obtains from the execution trace the code locations that are writing to the code cache. The code cache detection unit 1215 also detects all areas written to at that code location as updates to the code cache, and returns the code cache and the update locations.
  • the instruction set architecture analysis unit (second acquisition unit) 122 acquires information on the instruction set architecture, which is the instruction system of the VM, based on the acquired information on the architecture. Specifically, the instruction set architecture analysis unit 122 monitors the VPC and the dispatcher and analyzes the virtual machine execution trace executed in the VM to collect VM instructions, determine the VM instructions, and acquire information on the instruction set architecture.
  • the instruction set architecture analysis unit 122 has a VM execution trace acquisition unit 1221, a VM instruction collection unit 1222, and a VM instruction determination unit 1223.
  • the VM execution trace acquisition unit 1221 accepts a test script and a script engine binary as input.
  • the VM execution trace acquisition unit 1221 executes a test script while monitoring the execution of the script engine binary, thereby acquiring a VM execution trace, which is an execution trace executed on a VM.
  • the VM execution trace consists of the VPC and 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 1212.
  • the VM opcode here is an identifier virtually assigned to each of the pointer to the VM instruction and the VM instruction that are linked to each other.
  • the VM execution trace acquired by the VM execution trace acquisition unit 1221 is stored in the VM execution trace DB 133.
  • FIG. 4 is a diagram showing an example of a VM execution trace.
  • FIG. 4 shows an excerpt of a portion of a VM execution trace.
  • a log line of a VM execution trace is, for example, in the format shown in FIG. 4, and consists of two elements, vpc and pointer.
  • vpc indicates the value of the VPC.
  • pointer indicates the value of the pointer obtained from the pointer cache that points to the beginning of the VM instruction handler to be executed.
  • the VM instruction collection unit 1222 accepts the VPC and the dispatcher as input.
  • the VM instruction collection unit 1222 also acquires various scripts from the Internet.
  • the VM instruction collection unit 1222 then executes the scripts while monitoring the VPC and the dispatcher to acquire a VM execution trace.
  • the VM instruction collection unit 1222 also acquires VM instructions from the VM execution trace and adds them to a list of VM instructions. When the VM instruction collection unit 1222 finds no VM instructions that are not on the list, it returns the list of VM instructions.
  • the VM instruction determination unit 1223 uses the symbol table and information on the instruction set architecture to determine the VM instruction that corresponds to the variable held in the symbol table. Specifically, the VM instruction determination unit 1223 receives as input a list of VM instructions, VM instruction boundaries, and the symbol table. The VM instruction determination unit 1223 also extracts the execution trace and VM execution trace from the execution trace DB 131.
  • the VM instruction determination unit 1223 associates the executed VM instruction with the relevant portion of the execution trace from the list of VM instructions, VM instruction boundaries, execution trace, and VM execution trace.
  • the VM instruction determination unit 1223 also searches for a VM instruction that reads the memory area of a value held in the symbol table from reading the memory access trace, and determines that it is a VM instruction that reads the value of a variable held in the symbol table.
  • the VM instruction determination unit 1223 also searches for a VM instruction that writes to the memory area of a value held in the symbol table from reading the memory access trace, and determines that it is a VM instruction that updates the value of a variable held in the symbol table.
  • the instrumentation unit 123 receives an instrumentation script and a script to be analyzed as input, and inserts the instrumentation bytecode extracted from the instrumentation script into the bytecode to be analyzed, and executes it.
  • the instrumentation unit 123 has an instrumentation bytecode extraction unit 1231, an insertion unit 1232, and an execution unit 1233.
  • the instrumentation bytecode extraction unit (extraction unit) 1231 extracts bytecode for instrumentation based on the acquired information about the architecture and the information about the instruction set architecture. Specifically, the instrumentation bytecode extraction unit 1231 accepts an instrumentation script as input, executes it, and extracts the bytecode written to the code cache.
  • the insertion unit 1232 inserts the extracted instrumentation bytecode into the bytecode to be analyzed. Specifically, the insertion unit 1232 accepts the script to be analyzed and the extracted bytecode as input, temporarily stops the execution of the script to be analyzed, and expands the extracted bytecode into memory space. The insertion unit 1232 then outputs the memory address where the bytecode has been expanded.
  • the execution unit 1233 executes the script into which the instrumentation bytecode has been inserted. In other words, the execution unit 1233 executes the script to be analyzed into which the instrumentation bytecode has been inserted, and outputs the input value in which the problem occurred as the analysis result to the output unit 14.
  • the execution unit 1233 receives as input the memory address where the insertion unit 1232 expanded the bytecode.
  • the execution unit 1233 also receives as input the VPC and the dispatcher and monitors them.
  • the execution unit 1233 resumes the execution of the analysis target script that was temporarily stopped by the insertion unit 1232, and if the VM instruction obtained from the dispatcher is a VM instruction to be instrumented, it saves the current VPC and rewrites the VPC to the memory address where the bytecode was expanded, and executes the inserted bytecode. Furthermore, once the execution unit 1233 has executed the bytecode up to the end, it restores the VPC to the saved value. Once the execution of the analysis target script has ended, the execution unit 1233 outputs the analysis result.
  • Fig. 5 is a flowchart showing the procedure of the analysis function imparting process.
  • the input unit 11 receives a test script and a script engine binary as input (step S1).
  • the execution trace acquisition unit 1211 performs an execution trace acquisition process in which the test script is executed while monitoring the binary of the script engine to acquire branch traces and memory access traces (step S2).
  • the virtual program counter detection unit 1212 performs a virtual program counter detection process to extract and analyze the execution trace for the first test script stored in the execution trace DB 131 and discover the VPC (step S3).
  • the VM instruction boundary detection unit 1213 performs a VM instruction boundary detection process to detect VM instructions and detect VM instruction boundaries (step S4).
  • the dispatcher detection unit 1214 performs a dispatcher detection process 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).
  • the code cache detection unit 1215 receives the execution trace and the VM execution trace as input and performs a code cache detection process to detect the updated portion of the code cache (step S6).
  • the VM execution trace acquisition unit 1221 receives a test script and a script engine binary as input, and executes the test script while monitoring the execution of the script engine binary to perform a VM execution trace acquisition process to acquire a VM execution trace (step S7).
  • the VM instruction collection unit 1222 receives and monitors the VPC and dispatcher, and performs a VM instruction collection process to collect a list of VM instructions (step S8).
  • the VM instruction determination unit 1223 receives a list of VM instructions, VM instruction boundaries, and a symbol table as input, and performs a VM instruction determination process to determine the VM instruction that corresponds to the symbol table (step S9).
  • the instrumentation bytecode extraction unit 1231 receives the instrumentation script (step S10). Then, the instrumentation bytecode extraction unit 1231 performs an instrumentation bytecode extraction process to extract bytecode for instrumentation based on the acquired information about the architecture and the information about the instruction set architecture (step S11).
  • the insertion unit 1232 also accepts a script to be analyzed (step S12).
  • the insertion unit 1232 then accepts the analysis script as input and performs an insertion process to insert an instrumentation bytecode (step S13).
  • the execution unit 1233 also performs an execution process to execute the analysis script into which the instrumentation bytecode has been inserted (step S14).
  • the execution unit 1233 then outputs the input value in which the problem occurred to the output unit 14 (step S15). This completes the series of analysis function addition processes.
  • FIG. 6 is a flowchart showing the procedure of the execution trace acquisition process shown in FIG.
  • the execution trace acquisition unit 1211 receives a test script and a script engine binary as input (step S21). Then, the execution trace acquisition unit 1211 hooks the received script engine to acquire a branch trace (step S22). The execution trace acquisition unit 1211 also hooks the received script engine to acquire a memory access trace (step S23).
  • the execution trace acquisition unit 1211 inputs the test script received in this state into the script engine and executes it (step S24), and stores the execution trace acquired thereby in the execution trace DB 131 (step S25).
  • the execution trace acquisition unit 1211 determines whether or not all of the input test scripts have been executed (step S26). If all of the input test scripts have been executed (step S26: Yes), the execution trace acquisition unit 1211 ends the process. On the other hand, if all of the input test scripts have not been executed (step S26: No), the execution trace acquisition unit 1211 returns to the execution of the test scripts in step S24 and continues the process.
  • FIG. 7 is a flowchart showing the procedure of the virtual program counter detection process shown in FIG.
  • the virtual program counter detection unit 1212 extracts one execution trace by the first test script from the execution trace DB 131 (step S31). Next, the virtual program counter detection unit 1212 focuses on memory access traces among the execution traces, and counts up the number of reads for each memory read destination (step S32).
  • the virtual program counter detection unit 1212 receives as input the first test script used to obtain the execution trace (step S33), and analyzes the first test script to obtain the number of repetitions and the number of repeated statements (step S34).
  • the virtual program counter detection unit 1212 extracts from the execution trace DB 131 another execution trace by the first test script, which has a different number of repetitions and number of repeated statements (step S35). Then, the virtual program counter detection unit 1212 focuses on the memory access trace, and counts up the number of reads for each memory read destination (step S36). The virtual program counter detection unit 1212 also receives as input the first test script used to obtain the execution trace (step S37), and analyzes the test script to obtain the number of repetitions and the number of repeated statements (step S38).
  • the virtual program counter detection unit 1212 narrows down the memory read destinations to only those whose read counts change in proportion to the number of repetitions or the increase or decrease in the number of repeated statements (step S39). Furthermore, the virtual program counter detection unit 1212 narrows down the memory read destinations narrowed down in step S39 to those whose read memory values always point to the start point of the VM instruction (step S40).
  • the virtual program counter detection unit 1212 determines whether the memory read destinations have been narrowed down to only one (step S41). If the virtual program counter detection unit 1212 has not narrowed down the memory read destinations to only one (step S41: No), the process returns to step S35, where the virtual program counter detection unit 1212 retrieves the next execution trace and continues processing. On the other hand, if the virtual program counter detection unit 1212 has narrowed down the memory read destinations to only one (step S41: Yes), the virtual program counter detection unit 1212 stores the narrowed down memory read destination in the architecture information DB 132 as a virtual program counter (step S42), and ends processing.
  • FIG. 8 is a flowchart showing the procedure of the VM instruction boundary detection process shown in FIG.
  • the VM instruction boundary detection unit 1213 extracts execution traces from the execution trace DB 131 (step S51).
  • the VM instruction boundary detection unit 1213 clusters the execution traces using a predetermined method (step S52). Any method may be used for clustering.
  • the VM instruction boundary detection unit 1213 detects clusters whose execution count is equal to or exceeds a threshold as VM instructions (step S53). Then, the VM instruction boundary detection unit 1213 determines the start and end points of a sequence of consecutive instructions that constitute a VM instruction as boundaries (step S54). The VM instruction boundary detection unit 1213 outputs the VM instruction boundary as a return value (step S55), and ends the VM instruction boundary detection process.
  • FIG. 9 is a flowchart showing the procedure of the dispatcher detection process shown in FIG.
  • the dispatcher detection unit 1214 receives the script engine binary as an input (step S61).
  • the dispatcher detection unit 1214 receives the boundaries of the VM commands from the VM command boundary detection unit 1213 (step S62).
  • the dispatcher detection unit 1214 extracts each VM command portion from the script engine binary based on the boundaries of the VM commands received from the VM command boundary detection unit 1213 (step S63).
  • the dispatcher detection unit 1214 calculates the similarity between the codes of each VM command 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 codes.
  • the dispatcher detection unit 1214 extracts the part with high similarity among all VM commands based on the similarity calculated in step S64 (step S65). The dispatcher detection unit 1214 then determines whether it is the end part of the VM command (step S66).
  • step S66: No If it is not the end of the VM command (step S66: No), the dispatcher detection unit 1214 returns to step S65 and continues processing. If it is the end of the VM command (step S66: Yes), the dispatcher detection unit 1214 outputs the extracted part as a dispatcher (step S67) and ends processing.
  • FIG. 10 is a flowchart showing the procedure of the conditional branch flag detection process shown in FIG.
  • the code cache detection unit 1215 receives the execution trace and VM execution trace as input (step S71), and obtains the memory area indicated by the VPC from the VM execution trace (step S72). The code cache detection unit 1215 also obtains from the execution trace the code location that called the memory allocation function that allocated the memory area (step S73). The code cache detection unit 1215 also detects all areas allocated at the code location as code caches (step S74). The code cache detection unit 1215 then obtains the code location that is writing to the code cache from the execution trace (step S75). The code cache detection unit 1215 also detects all areas written at the code location as updates to the code cache (step S76), returns the code cache and the updated location (step S77), and ends the process.
  • FIG. 11 is a flowchart showing the procedure of the VM execution trace acquisition process shown in FIG.
  • the VM execution trace acquisition unit 1221 receives a test script and a script engine binary as input (step S81). Then, the VM execution trace acquisition unit 1221 hooks the received script engine to record the VPC and VM opcode (step S82).
  • the VM execution trace acquisition unit 1221 inputs the received test script in this state into the script engine and executes it (step S83), and stores the VM execution trace acquired thereby in the VM execution trace DB 133 (step S84).
  • the VM execution trace acquisition unit 1221 determines whether or not all of the input test scripts have been executed (step S85). If all of the input test scripts have been executed (step S85: Yes), the VM execution trace acquisition unit 1221 ends the process. If all of the input test scripts have not been executed (step S85: No), the VM execution trace acquisition unit 1221 returns to the execution of the test scripts in step S83 and continues the process.
  • FIG. 12 is a flowchart showing the procedure of the conditional branch flag detection process shown in FIG.
  • the VM command collection unit 1222 receives the VPC and the dispatcher as input (step S91).
  • the VM command collection unit 1222 also acquires various scripts from the Internet (step S92).
  • the VM command collection unit 1222 then executes the scripts while monitoring the VPC and the dispatcher to acquire a VM execution trace (step S93).
  • the VM command collection unit 1222 also acquires VM commands from the VM execution trace and adds them to a list of VM commands (steps S94-S95).
  • the VM instruction collection unit 1222 checks whether there are any VM instructions not on the list (step S96). If there are any VM instructions not on the list (step S96: No), the VM instruction collection unit 1222 returns the process to step S92. On the other hand, if there are no more VM instructions not on the list (step S96: Yes), the VM instruction collection unit 1222 returns a list of VM instructions (step S97) and ends the process.
  • FIG. 13 is a flowchart showing the procedure of the VM command determination process shown in FIG.
  • the VM command determination unit (determination unit) 1223 receives as input a list of VM commands, VM command boundaries, and a symbol table (steps S101 to S102).
  • the symbol table manages information about variables held by the script and the values held therein, and is obtained by a predetermined method.
  • the VM command determination unit 1223 also extracts the execution trace and VM execution trace from the execution trace DB 131 (step S103).
  • the VM instruction determination unit 1223 associates the executed VM instruction with the relevant portion of the execution trace from the list of VM instructions, VM instruction boundaries, execution trace, and VM execution trace (step S104).
  • the VM instruction determination unit 1223 also searches for a VM instruction that reads the memory area of a value held in the symbol table from the reading of the memory access trace, and determines that it is a VM instruction that reads the value of a variable held in the symbol table (steps S105 to S106).
  • the VM instruction determination unit 1223 also searches for a VM instruction that writes to the memory area of a value held in the symbol table from the reading of the memory access trace, and determines that it is a VM instruction that updates the value of a variable held in the symbol table (steps S107 to S108), and ends the process.
  • FIG. 14 is a flowchart showing the procedure of the instrumentation bytecode extraction process shown in FIG.
  • the instrumentation bytecode extraction unit 1231 accepts an instrumentation script as input (step S111), monitors writing to the code cache (step S112), and executes the instrumentation script (step S113). If there is writing to the code cache (step S114, Yes), the instrumentation bytecode extraction unit 1231 extracts the written bytecode (step S115).
  • step S114 if there is no writing to the code cache (step S114, No), the instrumentation bytecode extraction unit 1231 continues executing the instrumentation script until completion (step S116, No ⁇ S117 ⁇ S114). Also, when the instrumentation script execution is completed (step S116, Yes), the instrumentation bytecode extraction unit 1231 outputs the extracted bytecode (step S118) and ends the process.
  • FIG. 15 is a flowchart showing the procedure of the insertion process shown in FIG.
  • the insertion unit 1232 accepts as input the script to be analyzed and the bytecode extracted by the instrumentation bytecode extraction unit 1231 (steps S121 to S122), and executes the script to be analyzed (step S123).
  • the insertion unit 1232 temporarily stops the execution of the script to be analyzed (step S124), expands the extracted bytecode into memory space (step S125), outputs the memory address where the bytecode was expanded (step S126), and ends the process.
  • FIG. 16 is a flowchart showing the procedure of the execution process shown in FIG.
  • the execution unit 1233 receives as input the memory address into which the bytecode has been expanded, output by the insertion unit 1232 (step S131).
  • the execution unit 1233 also receives as input the VPC and the dispatcher (step S132), and monitors the VPC and the dispatcher (steps S133 to S134).
  • the execution unit 1233 also resumes the execution of the analysis target script that was temporarily stopped in processing S124 of the insertion unit 1232 (step S135).
  • the execution unit 1233 acquires a VM instruction from the dispatcher (step S136). If the acquired VM instruction is a VM instruction to be instrumented (step S137, Yes), the execution unit 1233 saves the current VPC (step S138). In addition, the execution unit 1233 rewrites the VPC to the memory address where the bytecode is expanded (step S139), and executes the inserted bytecode (step S140).
  • the execution unit 1233 executes the inserted bytecode until the end (step S141, No -> S140), and if it has executed until the end (step S141, Yes), it restores the VPC to the value saved in step S138 (step S142) and continues execution of the script to be analyzed (step S143).
  • step S137 if the acquired VM command is not a VM command to be instrumented (step S137, No), the execution unit 1233 continues execution of the script to be analyzed (step S143).
  • step S144 If the execution of the script to be analyzed has not finished (step S144, No), the execution unit 1233 returns to step S136, and if the execution has finished (step S144, Yes), it outputs the analysis result (step S145) and ends the process.
  • the virtual machine analysis unit 121 analyzes the VM of the script engine and acquires information about the architecture of the script engine.
  • the instruction set architecture analysis unit 122 acquires information about the instruction set architecture, which is the instruction system of the virtual machine, based on the information about the architecture.
  • the instrumentation bytecode extraction unit 1231 extracts bytecode for instrumentation based on the acquired information about the architecture and the information about the instruction set architecture.
  • the insertion unit 1232 inserts the extracted bytecode for instrumentation into the bytecode to be analyzed.
  • the information about the architecture includes any one of a virtual program counter, a dispatcher, a conditional branch flag, or a code cache.
  • the second acquisition unit acquires the information about the instruction set architecture by monitoring the virtual program counter and the dispatcher and analyzing a virtual machine execution trace executed in the virtual machine.
  • the execution unit 1233 also executes the script into which the instrumentation bytecode has been inserted. This makes it possible to analyze the script executed on the script engine.
  • the analysis function adding device 10 can automatically add dynamic bytecode instrumentation functionality to a variety of script engines by simply preparing a test script, so dynamic bytecode instrumentation can be realized without the need for individual design or execution. Therefore, it is possible to realize and analyze dynamic bytecode instrumentation even for the implementation of a wide variety of script engines.
  • the analysis function-imparting device 10 of this embodiment enables dynamic bytecode instrumentation in a wide variety of script engines, making it possible to analyze the execution state of scripts. Therefore, by imparting dynamic bytecode instrumentation functionality to various script engines, it becomes possible to analyze scripts executed on the script engines.
  • a program in which the process executed by the analysis function-imparting device 10 according to the above embodiment is written in a language executable by a computer can also be created.
  • the analysis function-imparting device 10 can be implemented by installing an analysis function-imparting program that executes the above analysis function-imparting process as package software or online software on a desired computer.
  • the information processing device can function as the analysis function-imparting device 10 by executing the above analysis function-imparting program on an information processing device.
  • the information processing device referred to here includes desktop or notebook personal computers.
  • the information processing device also includes mobile communication terminals such as smartphones, mobile phones, and PHS (Personal Handyphone System), as well as slate terminals such as PDAs (Personal Digital Assistants).
  • mobile communication terminals such as smartphones, mobile phones, and PHS (Personal Handyphone System), as well as slate terminals such as PDAs (Personal Digital Assistants).
  • slate terminals such as PDAs (Personal Digital Assistants).
  • the functions of the analysis function-imparting device 10 may be implemented on a cloud server.
  • FIG. 17 is a diagram showing an example of a computer that executes an analysis function adding program.
  • the computer 1000 has, for example, a memory 1010, a CPU 1020, 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.
  • the memory 1010 includes a ROM (Read Only Memory) 1011 and a RAM 1012.
  • the ROM 1011 stores a boot program such as a BIOS (Basic Input Output System).
  • BIOS Basic Input Output System
  • the hard disk drive interface 1030 is connected to a hard disk drive 1031.
  • the disk drive interface 1040 is connected to a disk drive 1041.
  • a removable storage medium such as a magnetic disk or optical disk is inserted into the disk drive 1041.
  • the serial port interface 1050 is connected to a mouse 1051 and a keyboard 1052, for example.
  • the video adapter 1060 is connected to a display 1061, for example.
  • the hard disk drive 1031 stores, for example, an OS 1091, an application program 1092, a program module 1093, and program data 1094. Each piece of information described in the above embodiment is stored, for example, in the hard disk drive 1031 or memory 1010.
  • the analysis function-imparting program is stored in the hard disk drive 1031, for example, as a program module 1093 in which instructions to be executed by the computer 1000 are written. Specifically, the program module 1093 in which each process executed by the analysis function-imparting device 10 described in the above embodiment is written is stored in the hard disk drive 1031.
  • data used for information processing by the analysis function-imparting program is stored as program data 1094, for example, in the hard disk drive 1031.
  • the CPU 1020 reads the program module 1093 and program data 1094 stored in the hard disk drive 1031 into the RAM 1012 as necessary, and executes each of the above-mentioned procedures.
  • the program module 1093 and program data 1094 related to the analysis function-imparting program are not limited to being stored in the hard disk drive 1031, but may be stored in a removable storage medium, for example, and read by the CPU 1020 via the disk drive 1041 or the like.
  • the program module 1093 and program data 1094 related to the analysis function-imparting program may be stored in another computer connected via a network, such as a LAN or WAN (Wide Area Network), and read by the CPU 1020 via the network interface 1070.

Landscapes

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

Abstract

仮想機械解析部(121)が、スクリプトエンジンのVMを解析し、スクリプトエンジンのアーキテクチャに関する情報を取得する。命令セットアーキテクチャ解析部(122)が、アーキテクチャに関する情報を基に、仮想機械の命令の体系である命令セットアーキテクチャの情報を取得する。計装用バイトコード抽出部(1231)が、取得されたアーキテクチャに関する情報および命令セットアーキテクチャの情報を基に、計装用のバイトコードを抽出する。挿入部(1232)が、抽出された計装用のバイトコードを解析対象のバイトコードへ挿入する。

Description

解析機能付与装置、解析機能付与方法および解析機能付与プログラム
 本発明は、解析機能付与装置、解析機能付与方法および解析機能付与プログラムに関する。
 ソフトウェアを解析するための技術の一つに、計装が存在する。これは、解析対象のプログラムに対して、解析のための機能を持ったコードを付加することで、実行時に対象のプログラムの実行状態に関する情報を獲得するものである。たとえば、命令ごとに記録用のコードを計装で挿入すれば、実行された命令数をカウントでき、分岐ごとに同様に挿入すれば、実行された制御フローを認識できる。こうした計装は、ソフトウェアのテストを始め、マルウェアの解析や脆弱性の発見といったサイバーセキュリティの目的にも多用されており、重要な技術である。
 計装には、プログラムの実行前に静的に付加する方式と、実行時に動的に付加する方式がある。また、計装の対象も、ソースコードやスクリプト、実行可能バイナリ(以降、バイナリ)、バイトコードなど多岐に渡る。たとえば、バイナリに対して動的な付加をする計装は、動的バイナリ計装と呼ばれる。現在では、スクリプトに対するテストのみならず、悪性なスクリプトが攻撃に用いられる機会も増しており、スクリプトに対する計装は重要となっている。
 スクリプトに対する計装では、おもに2つの方式が用いられる。実行前にスクリプトに対して静的に解析用のスクリプトを付加する方式と、実行時にスクリプトエンジン(またはインタプリタと呼ぶ)によってスクリプトがバイトコードに変換された際に、動的に解析用のバイトコードを付加する方式である。
 前者の静的に付加する方式においては、解析用のスクリプトを付加するべき箇所を網羅的に発見するのが難しい場合があるという問題があった。また、実行時に動的に評価されるスクリプトには静的な付加ができない場合があるという問題があった。さらに、スクリプトが難読化されている場合には、やはり網羅的な付加が難しく、悪性スクリプトの解析に有効でないという問題があった。そこで、後者の方式によって、バイトコードに対して実行時に動的に付加するのが一般的となっている。これによれば、前述の場合においても、計装を実現できる。
 プログラムに対する動的な計装では、まず、対象のプログラムに対して、どのような挙動の条件で、どのような解析用のプログラムを付加するかを定義する。そして、対象のプログラムの実行状態を監視し、条件に合致する特定の挙動が見られた際には、実行を停止して、解析用のプログラムに実行を遷移させる。そして、解析用のプログラムの実行が完了したところで、実行を停止前の位置に戻し、再開する。これにより、対象のプログラムの持つ本来の動作を損なわずに、解析用のプログラムを実行させる。
 バイトコードに対する計装の実現には、おもに2つの方法がある。一つは、スクリプトエンジンの提供するデバッグ機能を利用する方法であり、もう一つは、デバッグ機能によらずに、独自にバイトコードの命令実行の監視とバイトコードの付加を実施する方法である。
 なお、非特許文献1では、Java(登録商標)のバイトコードに対して動的な計装を実現する手法が提案されている。また、非特許文献2では、ActionScript3のバイトコードに対して動的な計装を実現する手法が提案されている。
W. Binder, J. Hulaas, 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年
 しかしながら、従来技術によれば、動的バイトコード計装機能の付与が困難な場合がある。例えば、スクリプトでの動的バイトコード計装には、一般に、スクリプトエンジンによって提供されているデバッガなどの支援機能を用いる必要がある。これは、スクリプトの実行を司るスクリプトエンジン内の仮想機械(VM, Virtual Machine)の内部仕様が公開されていない場合が多く、計装に要する実行状態の監視や実行の遷移を、支援機能なしに実現するのが難しいためである。
 しかしながら、そうした支援機能が提供されていない場合、VMをリバースエンジニアリングして内部仕様を明らかにし、独自に実行経路の観測やバイトコードの解析を実現し、計装するための情報を獲得する必要がある。
 従来の技術では、個別のVMに特有の情報を用いており、多様なスクリプト言語に対して、個別の設計と実装を要するが、これをスクリプトエンジンに対して手動で個別に解析や設計および実装をすることは、かかる労力の観点から現実的でない。
 本発明は、上記に鑑みてなされたものであって、デバッガなどの支援機能がなく、内部仕様が未知のスクリプトエンジンに対しても、手動での個別の解析や設計および実装を要さず、動的バイトコード計装機能の付与を実現可能とすることを目的とする。
 上述した課題を解決し、目的を達成するために、本発明に係る解析機能付与装置は、スクリプトエンジンの仮想機械を解析し、スクリプトエンジンのアーキテクチャに関する情報を取得する第1の取得部と、前記アーキテクチャに関する情報を基に、仮想機械の命令の体系である命令セットアーキテクチャの情報を取得する第2の取得部と、取得された前記アーキテクチャに関する情報および前記命令セットアーキテクチャの情報を基に、計装用のバイトコードを抽出する抽出部と、抽出された前記計装用のバイトコードを解析対象のバイトコードへ挿入する挿入部と、を有することを特徴とする。
 本発明によれば、デバッガなどの支援機能がなく、内部仕様が未知のスクリプトエンジンに対しても、手動での個別の解析や設計および実装を要さず、動的バイトコード計装機能の付与を実現することが可能となる。
図1は、本実施形態の解析機能付与装置の概略構成を例示する模式図である。 図2は、仮想プログラムカウンタ検出に用いるテストスクリプトの一例を示す図である。 図3は、実行トレースの一例を示す図である。 図4は、VM実行トレースの一例を示す図である。 図5は、解析機能付与処理の処理手順を示すフローチャートである。 図6は、実行トレース取得処理の処理手順を示すフローチャートである。 図7は、仮想プログラムカウンタ検出処理の処理手順を示すフローチャートである。 図8は、VM命令境界検出処理の処理手順を示すフローチャートである。 図9は、ディスパッチャ検出処理の処理手順を示すフローチャートである。 図10は、コードキャッシュ検出処理の処理手順を示すフローチャートである。 図11は、VM実行トレース取得処理の処理手順を示すフローチャートである。 図12は、VM命令収集処理の処理手順を示すフローチャートである。 図13は、VM命令判定処理の処理手順を示すフローチャートである。 図14は、計装用バイトコード抽出処理の処理手順を示すフローチャートである。 図15は、挿入処理の処理手順を示すフローチャートである。 図16は、実行処理の処理手順を示すフローチャートである。 図17は、解析機能付与プログラムを実行するコンピュータの一例を示す図である。
 以下、図面を参照して、本発明の一実施形態を詳細に説明する。なお、この実施形態により本発明が限定されるものではない。また、図面の記載において、同一部分には同一の符号を付して示している。
[解析機能付与装置の概要]
 本実施形態の解析機能付与装置は、スクリプトエンジンに適用され、スクリプトエンジンのバイナリを監視しながらテストスクリプトを実行して、ブランチトレースとメモリアクセストレースを実行トレースとして取得する。そして、解析機能付与装置は、その実行トレースに基づいてVMを解析し、スクリプトエンジンのアーキテクチャに関するアーキテクチャ情報であるVPC(仮想プログラムカウンタ)、ディスパッチャ、条件分岐フラグ、コードキャッシュを取得する。
 さらに、解析機能付与装置は、VPCおよびディスパッチャを監視しながらテストスクリプトを実行して、VM実行トレースを取得する。このVM実行トレースを解析することで、VM命令を収集するとともに、VM命令の判定を行い、命令セットアーキテクチャの情報を取得する。
 解析機能付与装置は、得られたアーキテクチャ情報を基に、計装用のバイトコードの抽出と解析対象のバイトコードへの埋め込みとを行った上で実行し、動的バイトコード計装を実現する。このように、解析機能付与装置は、VMの内部仕様が未知であるスクリプトエンジンに対しても、実行トレースおよびVM実行トレースの取得に基づく解析により、各種アーキテクチャ情報を検出し、人手によるリバースエンジニアリングを要することなく、動的バイトコード計装の機能の付与を実現する。
 また、解析機能付与装置では、多様なスクリプトエンジンに対して、テストスクリプトを用意すれば自動で動的バイトコード計装の機能を付与することが可能であり、個別の設計や実装を要しない。したがって、多種多様なスクリプトエンジンの実装に対しても、動的バイトコード計装を行い、解析を実現可能となる。
[解析機能付与装置の構成]
 図1は、本実施形態の解析機能付与装置の概略構成を例示する模式図である。図1に例示するように、本実施形態の解析機能付与装置10は、パソコン等の汎用コンピュータで実現され、入力部11、制御部12、記憶部13、および出力部14を備える。
 入力部11は、キーボードやマウス等の入力デバイスを用いて実現され、操作者や外部からの情報の入力を受け付けて、制御部12に対して入力する。例えば、入力部11は、テストスクリプトや仮想機械バイナリの入力を受け付ける。また、入力部11は、電気通信回線を介した外部の装置から送信された情報の入力を受け付ける。
 テストスクリプトは、スクリプトエンジンを動的解析して実行トレースおよびVM実行トレースを取得する際に、入力されるスクリプトである。このテストスクリプトは、分岐命令の実行やメモリ読み書きの回数に着目し、異なる回数のテストスクリプトを実行したときに生じるスクリプトエンジンの挙動の差分を捉えるために用いられる。このテストスクリプトは、解析の前に予め準備するものであり、手動で作成するものである。この作成には、対象のスクリプト言語の仕様に関する知識が必要となる。
 ここで、図2は、VPC検出に用いるテストスクリプトの一例を示す図である。このテストスクリプトでは、繰り返し処理を用いる(2行目)。テストスクリプトでは、テストスクリプト内の繰り返し回数(2行目)や繰り返される文の数(3行目から5行目)を増減させることで、実行時の条件を変更し、差分を発生させる。
 スクリプトエンジンバイナリは、スクリプトエンジンを構成する実行可能ファイルである。スクリプトエンジンバイナリは、複数の実行可能ファイルによって構成される場合がある。
 出力部14は、液晶ディスプレイなどの表示装置、プリンター等の印刷装置等によって実現される。例えば、出力部14には、後述する解析機能付与処理の結果が表示される。また、出力部14は、外部の装置に各種情報を出力してもよい。
 記憶部13は、RAM(Random Access Memory)、フラッシュメモリ(Flash Memory)等の半導体メモリ素子、または、ハードディスク、光ディスク等の記憶装置によって実現される。記憶部13には、解析機能付与装置10を動作させる処理プログラムや、処理プログラムの実行中に使用されるデータなどが予め記憶され、あるいは処理の都度一時的に記憶される。
 記憶部13は、実行トレースデータベース(DB)131、VM実行トレースDB133およびアーキテクチャ情報DB132を記憶する。
 実行トレースDB131およびVM実行トレースDB133は、それぞれ実行トレース取得部1211およびVM実行トレース取得部1221によって取得された実行トレースおよびVM実行トレースを格納する。実行トレースDB131およびVM実行トレースDB133は、解析機能付与装置10によって管理される。もちろん、実行トレースDB131およびVM実行トレースDB133は、他の装置(サーバ等)によって管理されていてもよく、この場合には、実行トレース取得部1211およびVM実行トレース取得部1221は、出力部14の通信インタフェースを介して、取得した実行トレースおよびVM実行トレースを、実行トレースDB131およびVM実行トレースDB133の管理サーバ等に出力して、実行トレースDB131およびVM実行トレースDB133に記憶させる。
 制御部12は、CPU(Central Processing Unit)やMPU(Micro Processing Unit)等を用いて実現され、メモリに記憶された処理プログラムを実行する。これにより、制御部12は、図1に例示するように、仮想機械解析部121(第1の取得部)、命令セットアーキテクチャ解析部122(第2の取得部)および計装部123として機能する。
 仮想機械解析部121(第1の取得部)は、スクリプトエンジンのVMを解析し、スクリプトエンジンのアーキテクチャに関する情報を取得する。具体的には、仮想機械解析部121は、スクリプトエンジンのバイナリを監視しながらテストスクリプトを実行して、ブランチトレースとメモリアクセストレースを実行トレースとして取得する。そして、解析機能付与装置は、その実行トレースに基づいて仮想機械VMを解析し、アーキテクチャ情報を取得する。アーキテクチャ情報は、仮想プログラムカウンタ、ディスパッチャ、条件分岐フラグ、またはコードキャッシュのいずれかを含む。
 仮想機械解析部121は、実行トレース取得部1211、仮想プログラムカウンタ検出部1212、VM命令境界検出部1213、ディスパッチャ検出部1214およびコードキャッシュ検出部1215を有する。
 実行トレース取得部1211は、テストスクリプトおよびスクリプトエンジンバイナリを入力として受け付ける。実行トレース取得部1211は、スクリプトエンジンバイナリの実行を監視しながら、テストスクリプトを実行することで、実行トレースを取得する。
 実行トレースは、ブランチトレースとメモリアクセストレースとによって構成される。ブランチトレースは、実行の際の分岐命令の種類と、分岐元アドレスと分岐先アドレスを記録する。メモリアクセストレースは、メモリ操作の種類と、操作対象のメモリアドレスを記録する。ブランチトレースおよびメモリアクセストレースは、命令フックによって取得可能であることが知られている。実行トレース取得部1211が取得した実行トレースは、実行トレースDB131に格納される。
 ここで、図3は、実行トレースの一例を示す図である。実行トレースは、traceという要素を有する。traceには、そのログ行がブランチトレースか、メモリアクセストレースかが示される。
 ブランチトレースのログ行は、例えば、図3の1行目から10行目に記載の書式になっており、type、src、dstの三つの要素からなる。typeは、実行された分岐命令がcall命令によるものか、jmp命令によるものか、ret命令によるものかを示す。また、srcは、分岐元のアドレスを示し、dstは、分岐先のアドレスを示す。
 メモリアクセストレースのログ行は、たとえば、図3の11行目から13行目に記載の書式になっており、type、target、valueの三つの要素からなる。typeは、メモリアクセスが読み込みか書き込みかを示す。targetは、メモリアクセスの対象となるメモリアドレスを示す。また、valueには、メモリアクセスの結果の値が格納される。
 仮想プログラムカウンタ検出部1212は、実行トレースDB131に格納された第一のテストスクリプトに対する実行トレースを取り出して解析し、VPCを検出する。仮想プログラムカウンタ検出部1212は、メモリの読み込み回数に着目した差分実行解析とVM命令境界検出部1213によって検出された各VM命令の境界とを用いて複数の実行トレースを解析し、VPCを検出する。仮想プログラムカウンタ検出部1212は、各VM命令の実行後には、必ずVPCを保持するメモリへの読み込みが発生することを利用し、この読み込み先を発見することで、VPCを検出する。
 このため、仮想プログラムカウンタ検出部1212は、VPCの検出として、メモリの読み込み回数に着目した差分実行解析を用いる。仮想プログラムカウンタ検出部1212は、テストスクリプトを用いて取得された複数のテストスクリプトの実行トレースを比較し、メモリ読み込み回数が、繰り返される回数及び繰り返される文の数との双方の増減に比例して変化するメモリを発見する。そして、仮想プログラムカウンタ検出部1212は、VM命令境界検出部1213によって検出された各VM命令の境界を参照して、読み込んだメモリの値が常にVM命令の開始点を指しているものに絞り込む。仮想プログラムカウンタ検出部1212は、このメモリをVPCとして検出する。
 VM命令境界検出部1213は、実行トレースをクラスタリングして、各VM命令の境界を検出する。VM命令境界検出部1213は、実行トレースをクラスタリングして、実行回数が閾値以上のクラスタをVM命令として検出する。クラスタリングでは、複数回実行される連続したコード領域を検出する。これにはたとえば、実行された命令間のコード上の距離が近いものをまとめてもよいし、実行されたコードブロックの共通部分列を探してもよいし、他の方法によってもよい。解析機能付与装置10は、検出したVM命令を構成する連続した命令列の開始点と終了点とを境界として検出する。ここで検出したVM命令の境界は、VPC検出、ディスパッチャ検出において用いられる。
 ディスパッチャ検出部1214は、VM命令境界検出部1213が検出したVM命令の境界を基に、スクリプトエンジンバイナリから各VM命令部分を切り出し、各VM命令間で類似度が高い部分をディスパッチャとして検出する。類似度の高い部分の検出には、たとえば系列アライメントアルゴリズムを用いてもよく、その他の方法によってもよい。
 コードキャッシュ検出部1215は、実行トレースおよびVM実行トレースを入力として受け付けて、VPCが指し示すメモリ領域をVM実行トレースから取得する。また、コードキャッシュ検出部1215は、当該メモリ領域を確保したメモリ割り当て関数の呼び出し元のコード箇所を実行トレースから取得する。また、コードキャッシュ検出部1215は、当該コード箇所で確保された全ての領域をコードキャッシュとして検出する。そして、コードキャッシュ検出部1215は、コードキャッシュに書き込みをしているコード箇所を実行トレースから取得する。また、コードキャッシュ検出部1215は、当該コード箇所で書き込みされた全ての領域をコードキャッシュの更新として検出し、コードキャッシュおよび更新箇所を返す。
 命令セットアーキテクチャ解析部(第2の取得部)122は、取得されたアーキテクチャに関する情報を基に、VMの命令の体系である命令セットアーキテクチャの情報を取得する。具体的には、命令セットアーキテクチャ解析部122は、VPCおよびディスパッチャを監視するとともにVMにおいて実行された仮想機械実行トレースを解析することにより、VM命令を収集するとともに、VM命令の判定を行い、命令セットアーキテクチャの情報を取得する。
 命令セットアーキテクチャ解析部122は、VM実行トレース取得部1221、VM命令収集部1222およびVM命令判定部1223を有する。
 VM実行トレース取得部1221は、実行トレース取得部1211と同じく、テストスクリプトおよびスクリプトエンジンバイナリを入力として受け付ける。VM実行トレース取得部1221は、スクリプトエンジンバイナリの実行を監視しながら、テストスクリプトを実行することで、VM上で実行された実行トレースであるVM実行トレースを取得する。
 VM実行トレースは、実行されたVM命令ごとのVPCとVMオペコードで構成される。VPCの記録は、仮想プログラムカウンタ検出部1212で検出されたVPCのメモリを監視することで実現できる。ここでのVMオペコードは、VM命令へのポインタとVM命令とを紐づけた各々に仮想的に割り振られた識別子である。VM実行トレース取得部1221が取得したVM実行トレースは、VM実行トレースDB133に格納される。
 ここで、図4は、VM実行トレースの一例を示す図である。図4は、VM実行トレースの一部を切り出したものである。VM実行トレースのログ行は、たとえば、図4に記載の書式になっており、vpc及びpointerの二つの要素からなる。vpcは、VPCの値を示す。また、pointerは、ポインタキャッシュから取得された、実行されるVM命令ハンドラの先頭を指すポインタの値を示す。
 VM命令収集部1222は、VPCおよびディスパッチャを入力として受け付ける。また、VM命令収集部1222は、インターネット上から多様なスクリプトを取得する。そして、VM命令収集部1222は、VPCおよびディスパッチャを監視しながら、スクリプトを実行して、VM実行トレースを取得する。また、VM命令収集部1222は、VM実行トレースからVM命令を取得して、VM命令のリストに追加する。そして、VM命令収集部1222は、リストにないVM命令が見られなくなった場合に、VM命令のリストとして返す。
 VM命令判定部1223は、記号表と、命令セットアーキテクチャの情報とを用いて、該記号表が保持する変数に対応するVMの命令を判定する。具体的には、VM命令判定部1223は、VM命令のリスト、VM命令境界、および記号表を入力として受け付ける。また、VM命令判定部1223は、実行トレースDB131から実行トレースおよびVM実行トレースを取り出す。
 そして、VM命令判定部1223は、VM命令のリストおよびVM命令境界、実行トレース、VM実行トレースから、実行されたVM命令と、関連する実行トレースの部分とを対応付ける。また、VM命令判定部1223は、メモリアクセストレースの読み込みから、記号表の保持する値のメモリ領域を読み込んでいるVM命令を探索し、記号表が保持している変数の値を読み込むVM命令と判定する。また、VM命令判定部1223は、メモリアクセストレースの読み込みから、記号表の保持する値のメモリ領域に書き込んでいるVM命令を探索し、記号表が保持している変数の値を更新するVM命令と判定する。
 計装部123は、計装用スクリプトおよび解析対象スクリプトを入力として受け付けて、計装用スクリプトから抽出した計装用のバイトコードを、解析対象のバイトコードに挿入して実行する。計装部123は、計装用バイトコード抽出部1231、挿入部1232、および実行部1233を有する。
 計装用バイトコード抽出部(抽出部)1231は、取得されたアーキテクチャに関する情報および命令セットアーキテクチャの情報を基に、計装用のバイトコードを抽出する。具体的には、計装用バイトコード抽出部1231は、計装用スクリプトを入力として受け付けて実行し、コードキャッシュに書き込まれたバイトコードを抽出する。
 挿入部1232は、抽出された計装用のバイトコードを解析対象のバイトコードへ挿入する。具体的には、挿入部1232は、解析対象スクリプトと抽出されたバイトコードとを入力とし受け付けて、解析対象スクリプトの実行を一旦停止して、抽出されたバイトコードをメモリ空間に展開する。そして、挿入部1232は、バイトコードを展開したメモリアドレスを出力する。
 実行部1233は、計装用のバイトコードが挿入されたスクリプトを実行する。つまり、実行部1233は、計装用のバイトコードが挿入された解析対象のスクリプトを実行し、問題の発生した入力値を解析結果として、出力部14に出力する。
 具体的には、実行部1233は、挿入部1232がバイトコードを展開したメモリアドレスを入力として受け付ける。また、実行部1233は、VPCとディスパッチャとを入力として受け付けて監視する。
 そして、実行部1233は、挿入部1232で一旦停止された解析対象スクリプトの実行を再開し、ディスパッチャから取得したVM命令が計装対象のVM命令であれば、現在のVPCを保存するとともに、VPCを、バイトコードを展開したメモリアドレスに書き換えて、挿入したバイトコードを実行する。また、実行部1233は、バイトコードの終端まで実行したら、VPCを保存していた値に復元する。実行部1233は、解析対象スクリプトの実行が終了したら、解析結果を出力する。
[解析機能付与処理の処理手順]
 次に、本実施形態に係る解析機能付与装置10による解析機能付与処理の処理手順について説明する。図5は、解析機能付与処理の処理手順を示すフローチャートである。
 まず、入力部11は、テストスクリプトおよびスクリプトエンジンバイナリを入力として受け取る(ステップS1)。
 そして、実行トレース取得部1211は、スクリプトエンジンのバイナリを監視しながらテストスクリプトを実行してブランチトレースとメモリアクセストレースを取得する実行トレース取得処理を行う(ステップS2)。
 仮想プログラムカウンタ検出部1212は、実行トレースDB131に格納された第一のテストスクリプトに対する実行トレースを取り出して解析し、VPCを発見する仮想プログラムカウンタ検出処理を行う(ステップS3)。VM命令境界検出部1213は、VM命令を検出し、VM命令の境界を検出するVM命令境界検出処理を行う(ステップS4)。ディスパッチャ検出部1214は、スクリプトエンジンバイナリから各VM命令部分を切り出し、各VM命令間で類似度が高い部分をディスパッチャとして検出するディスパッチャ検出処理を行う(ステップS5)。コードキャッシュ検出部1215は、実行トレースおよびVM実行トレースを入力として受け付け、コードキャッシュの更新箇所を検出するコードキャッシュ検出処理を行う(ステップS6)。
 VM実行トレース取得部1221は、テストスクリプトおよびスクリプトエンジンバイナリを入力として受け付け、スクリプトエンジンバイナリの実行を監視しながら、テストスクリプトを実行することで、VM実行トレースを取得するVM実行トレース取得処理を行う(ステップS7)。VM命令収集部1222は、VPCおよびディスパッチャを受け付けて監視しながら、VM命令のリストを収集するVM命令収集処理を行う(ステップS8)。VM命令判定部1223は、VM命令のリスト、VM命令境界および記号表を入力として受け付け、記号表に対応するVM命令を判定するVM命令判定処理を行う(ステップS9)。
 計装用バイトコード抽出部1231は、計装用スクリプトを受け付ける(ステップS10)。そして、計装用バイトコード抽出部1231は、取得されたアーキテクチャに関する情報および命令セットアーキテクチャの情報を基に、計装用のバイトコードを抽出する計装用バイトコード抽出処理を行う(ステップS11)。
 また、挿入部1232は、解析対象スクリプトを受け付ける(ステップS12)。そして、挿入部1232は、解析用スクリプトを入力とし受け付けて、計装用バイトコードを挿入する挿入処理を行う(ステップS13)。また、実行部1233は、計装用のバイトコードが挿入された解析用スクリプトを実行する実行処理を行う(ステップS14)。そして、実行部1233は、問題の発生した入力値を出力部14に出力する(ステップS15)。これにより、一連の解析機能付与処理が終了する。
[実行トレース取得処理の処理手順]
 次に、図6は、図5に示す実行トレース取得処理の処理手順を示すフローチャートである。
 まず、実行トレース取得部1211は、テストスクリプトおよびスクリプトエンジンバイナリを入力として受け取る(ステップS21)。そして、実行トレース取得部1211は、受け取ったスクリプトエンジンに対して、ブランチトレースを取得するためのフックを施す(ステップS22)。また、実行トレース取得部1211は、受け取ったスクリプトエンジンに対して、メモリアクセストレースを取得するためのフックも施す(ステップS23)。
 そして、実行トレース取得部1211は、その状態で受け取ったテストスクリプトをスクリプトエンジンに入力して実行させ(ステップS24)、それによって取得される実行トレースを実行トレースDB131に格納する(ステップS25)。
 実行トレース取得部1211は、入力されたテストスクリプトを全て実行し終えているか否かを判定する(ステップS26)。実行トレース取得部1211は、入力されたテストスクリプトを全て実行し終えている場合(ステップS26:Yes)、処理を終了する。これに対し、実行トレース取得部1211は、入力されたテストスクリプトを全て実行していない場合(ステップS26:No)、ステップS24のテストスクリプトの実行に戻って処理を続ける。
[仮想プログラムカウンタ検出処理の処理手順]
 次に、図7は、図5に示す仮想プログラムカウンタ検出処理の処理手順を示すフローチャートである。
 まず、仮想プログラムカウンタ検出部1212は、実行トレースDB131から第一のテストスクリプトによる実行トレースを一つ取り出す(ステップS31)。続いて、仮想プログラムカウンタ検出部1212は、実行トレースのうちのメモリアクセストレースに着目し、メモリ読み込み先ごとに読み込み回数を数え上げる(ステップS32)。
 仮想プログラムカウンタ検出部1212は、実行トレースの取得に用いた第一のテストスクリプトを入力として受け取り(ステップS33)、その第一のテストスクリプトを解析して繰り返しの回数と繰り返される文の数とを取得する(ステップS34)。
 続いて、仮想プログラムカウンタ検出部1212は、実行トレースDB131から、繰り返し回数や繰り返される文の数の異なる第一のテストスクリプトによる実行トレースを、さらに一つ取り出す(ステップS35)。そして、仮想プログラムカウンタ検出部1212は、メモリアクセストレースに着目し、メモリ読み込み先ごとに読み込み回数を数え上げる(ステップS36)。また、仮想プログラムカウンタ検出部1212は、実行トレースの取得に用いた第一のテストスクリプトを入力として受け取り(ステップS37)、テストスクリプトを解析して、繰り返しの回数と繰り返される文の数とを取得する(ステップS38)。
 ここで、仮想プログラムカウンタ検出部1212は、繰り返し回数や繰り返される文の増減に比例して読み込み回数が変化するメモリ読み込み先のみに絞り込む(ステップS39)。さらに、仮想プログラムカウンタ検出部1212は、ステップS39において絞り込んだメモリ読み込み先を、読み込んだメモリの値が常にVM命令の開始点を指しているものに絞り込む(ステップS40)。
 そして、仮想プログラムカウンタ検出部1212は、メモリ読み込み先を一つのみに絞り込めたか否かを判定する(ステップS41)。仮想プログラムカウンタ検出部1212は、メモリ読み込み先を一つのみに絞り込めていない場合(ステップS41:No)、ステップS35に戻り、次の実行トレースを一つ取り出して処理を継続する。一方、仮想プログラムカウンタ検出部1212は、メモリ読み込み先を一つのみに絞り込めた場合(ステップS41:Yes)、絞り込まれたメモリ読み込み先を仮想プログラムカウンタとしてアーキテクチャ情報DB132に格納して(ステップS42)、処理を終了する。
[VM命令境界検出処理の処理手順]
 次に、図8は、図5に示すVM命令境界検出処理の処理手順を示すフローチャートである。
 まず、VM命令境界検出部1213は、実行トレースDB131から実行トレースを取り出す(ステップS51)。VM命令境界検出部1213は、実行トレースを所定の方法でクラスタリングする(ステップS52)。クラスタリングは、いずれの手法を用いてもよい。
 VM命令境界検出部1213は、実行回数が閾値以上のクラスタをVM命令として検出する(ステップS53)。そして、VM命令境界検出部1213は、VM命令を構成する連続した命令列の開始点と終了点とを境界とする(ステップS54)。VM命令境界検出部1213は、VM命令の境界を返り値として出力して(ステップS55)、VM命令境界検出処理を終了する。
[ディスパッチャ検出処理の処理手順]
 次に、図9は、図5に示すディスパッチャ検出処理の処理手順を示すフローチャートである。
 まず、ディスパッチャ検出部1214は、スクリプトエンジンバイナリを入力として受け取る(ステップS61)。ディスパッチャ検出部1214は、VM命令境界検出部1213から、VM命令の境界を受け取る(ステップS62)。
 ディスパッチャ検出部1214は、VM命令境界検出部1213から受け取ったVM命令の境界を基に、スクリプトエンジンバイナリから各VM命令部分を切り出す(ステップS63)。ディスパッチャ検出部1214は、各VM命令間でコード間の類似度を所定の方法で算出する(ステップS64)。類似度の算出手法は、コード間の類似度を算出できる手法であれば、どの手法でもよい。
 ディスパッチャ検出部1214は、ステップS64において算出した類似度を基に、全VM命令間で類似度が高い部分を取り出す(ステップS65)。そして、ディスパッチャ検出部1214は、VM命令の終端部分であるかを判定する(ステップS66)。
 VM命令の終端部分でない場合(ステップS66:No)、ディスパッチャ検出部1214は、ステップS65に戻り処理を続ける。また、VM命令の終端部分である場合(ステップS66:Yes)、ディスパッチャ検出部1214は、取り出した部分をディスパッチャとして出力して(ステップS67)、処理を終了する。
[コードキャッシュ検出処理の処理手順]
 次に、図10は、図5に示す条件分岐フラグ検出処理の処理手順を示すフローチャートである。
 コードキャッシュ検出部1215は、実行トレースおよびVM実行トレースを入力として受け付けて(ステップS71)、VPCが指し示すメモリ領域をVM実行トレースから取得する(ステップS72)。また、コードキャッシュ検出部1215は、当該メモリ領域を確保したメモリ割り当て関数の呼び出し元のコード箇所を実行トレースから取得する(ステップS73)。また、コードキャッシュ検出部1215は、当該コード箇所で確保された全ての領域をコードキャッシュとして検出する(ステップS74)。そして、コードキャッシュ検出部1215は、コードキャッシュに書き込みをしているコード箇所を実行トレースから取得する(ステップS75)。また、コードキャッシュ検出部1215は、当該コード箇所で書き込みされた全ての領域をコードキャッシュの更新として検出し(ステップS76)、コードキャッシュおよび更新箇所を返して(ステップS77)、処理を終了する。
[VM実行トレース取得処理の処理手順]
 次に、図11は、図5に示すVM実行トレース取得処理の処理手順を示すフローチャートである。
 まず、VM実行トレース取得部1221は、テストスクリプトおよびスクリプトエンジンバイナリを入力として受け取る(ステップS81)。そして、VM実行トレース取得部1221は、受け取ったスクリプトエンジンに対して、VPCおよびVMオペコードを記録するためのフックを施す(ステップS82)。
 VM実行トレース取得部1221は、その状態で受け取ったテストスクリプトをスクリプトエンジンに入力して実行させ(ステップS83)、それによって取得されるVM実行トレースをVM実行トレースDB133に格納する(ステップS84)。
 VM実行トレース取得部1221は、入力されたテストスクリプトを全て実行したか否かを判定する(ステップS85)。VM実行トレース取得部1221は、入力されたテストスクリプトを全て実行し終えている場合(ステップS85:Yes)、処理を終了する。VM実行トレース取得部1221は、入力されたテストスクリプトを全て実行し終えていない場合(ステップS85:No)、ステップS83のテストスクリプトの実行に戻って処理を続ける。
[VM命令収集処理の処理手順]
 次に、図12は、図5に示す条件分岐フラグ検出処理の処理手順を示すフローチャートである。
 VM命令収集部1222は、VPCおよびディスパッチャを入力として受け付ける(ステップS91)。また、VM命令収集部1222は、インターネット上から多様なスクリプトを取得する(ステップS92)。そして、VM命令収集部1222は、VPCおよびディスパッチャを監視しながら、スクリプトを実行して、VM実行トレースを取得する(ステップS93)。また、VM命令収集部1222は、VM実行トレースからVM命令を取得して、VM命令のリストに追加する(ステップS94~S95)。
 そして、VM命令収集部1222は、リストにないVM命令の有無を確認する(ステップS96)。VM命令収集部1222は、リストにないVM命令が見られる場合に(ステップS96:No)、ステップS92に処理を戻す。一方、VM命令収集部1222は、リストにないVM命令が見られなくなった場合に(ステップS96:Yes)、VM命令のリストとして返し(ステップS97)、処理を終了する。
[VM命令判定処理の処理手順]
 次に、図13は、図5に示すVM命令判定処理の処理手順を示すフローチャートである。
 VM命令判定部(判定部)1223は、VM命令のリスト、VM命令境界、および記号表を入力として受け付ける(ステップS101~S102)。ここで、記号表は、スクリプトの保持する変数に関する情報や保持している値を管理するもので、所定の方法で取得される。また、VM命令判定部1223は、実行トレースDB131から実行トレースおよびVM実行トレースを取り出す(ステップS103)。
 そして、VM命令判定部1223は、VM命令のリストおよびVM命令境界、実行トレース、VM実行トレースから、実行されたVM命令と、関連する実行トレースの部分とを対応付ける(ステップS104)。また、VM命令判定部1223は、メモリアクセストレースの読み込みから、記号表の保持する値のメモリ領域を読み込んでいるVM命令を探索し、記号表が保持している変数の値を読み込むVM命令と判定する(ステップS105~S106)。また、VM命令判定部1223は、メモリアクセストレースの読み込みから、記号表の保持する値のメモリ領域に書き込んでいるVM命令を探索し、記号表が保持している変数の値を更新するVM命令と判定し(ステップS107~S108)、処理を終了する。
[計装用バイトコード抽出処理の処理手順]
 次に、図14は、図5に示す計装用バイトコード抽出処理の処理手順を示すフローチャートである。
 計装用バイトコード抽出部1231は、計装用スクリプトを入力として受け付けて(ステップS111)、コードキャッシュへの書き込みを監視しつつ(ステップS112)、計装用スクリプトを実行する(ステップS113)。そして、計装用バイトコード抽出部1231は、コードキャッシュへの書き込みがあった場合には(ステップS114、Yes)、書き込まれたバイトコードを抽出する(ステップS115)。
 一方、計装用バイトコード抽出部1231は、コードキャッシュへの書き込みがない場合には(ステップS114、No)、完了するまで計装用スクリプトの実行を継続する(ステップS116、No→S117→S114)。また、計装用バイトコード抽出部1231は、計装用スクリプトの実行が完了したら(ステップS116、Yes)、抽出されたバイトコードを出力し(ステップS118)、処理を終了する。
[挿入処理の処理手順]
 次に、図15は、図5に示す挿入処理の処理手順を示すフローチャートである。
 まず、挿入部1232は、解析対象スクリプトと、計装用バイトコード抽出部1231により抽出されたバイトコードとを入力として受け付けて(ステップS121~S122)、解析対象スクリプトを実行する(ステップS123)。
 次に、挿入部1232は、解析対象スクリプトの実行を一旦停止して(ステップS124)、抽出されたバイトコードをメモリ空間に展開し(ステップS125)、バイトコードを展開したメモリアドレスを出力して(ステップS126)、処理を終了する。
[実行処理の処理手順]
 次に、図16は、図5に示す実行処理の処理手順を示すフローチャートである。
 実行部1233は、挿入部1232より出力された、バイトコードを展開したメモリアドレスを入力として受け付ける(ステップS131)。また、実行部1233は、VPCとディスパッチャとを入力として受け付けて(ステップS132)、VPCとディスパッチャとを監視する(ステップS133~S134)。また、実行部1233は、挿入部1232の処理S124で一旦停止された解析対象スクリプトの実行を再開する(ステップS135)。
 実行部1233は、ディスパッチャからVM命令を取得する(ステップS136)。実行部1233は、取得したVM命令が計装対象のVM命令であれば(ステップS137、Yes)、現在のVPCを保存する(ステップS138)。また、実行部1233は、VPCを、バイトコードを展開したメモリアドレスに書き換えて(ステップS139)、挿入したバイトコードを実行する(ステップS140)。
 そして、実行部1233は、挿入したバイトコードの終端まで実行し(ステップS141、No→S140)、終端まで実行した場合に(ステップS141、Yes)、VPCをステップS138で保存しておいた値に復元し(ステップS142)、解析対象スクリプトの実行を継続する(ステップS143)。
 一方、実行部1233は、取得したVM命令が計装対象のVM命令でなければ(ステップS137、No)、解析対象スクリプトの実行を継続する(ステップS143)。
 そして、実行部1233は、解析対象スクリプトの実行が終了していなければ(ステップS144、No)、ステップS136に処理を戻し、終了したら(ステップS144、Yes)、解析結果を出力して(ステップS145)、処理を終了する。
[効果]
 以上、説明したように、本実施形態の解析機能付与装置10において、仮想機械解析部121が、スクリプトエンジンのVMを解析し、スクリプトエンジンのアーキテクチャに関する情報を取得する。命令セットアーキテクチャ解析部122が、アーキテクチャに関する情報を基に、仮想機械の命令の体系である命令セットアーキテクチャの情報を取得する。計装用バイトコード抽出部1231が、取得されたアーキテクチャに関する情報および命令セットアーキテクチャの情報を基に、計装用のバイトコードを抽出する。挿入部1232が、抽出された計装用のバイトコードを解析対象のバイトコードへ挿入する。
 具体的には、アーキテクチャに関する情報は、仮想プログラムカウンタ、ディスパッチャ、条件分岐フラグ、またはコードキャッシュのいずれかを含む。また、第2の取得部は、前記仮想プログラムカウンタおよび前記ディスパッチャを監視するとともに前記仮想機械において実行された仮想機械実行トレースを解析することにより、命令セットアーキテクチャの情報を取得する。
 これにより、VMの内部仕様が未知のスクリプトエンジンに対しても、実行トレースおよびVM実行トレースの取得に基づく解析により各種アーキテクチャ情報を検出し、人手でのリバースエンジニアリングを要することなく、動的バイトコード計装を実現できる。
 また、実行部1233が、計装用のバイトコードが挿入されたスクリプトを実行する。これにより、スクリプトエンジン上で実行されるスクリプトの解析が可能となる。
 また、解析機能付与装置10では、多様なスクリプトエンジンに対して、テストスクリプトさえ用意すれば自動で動的バイトコード計装の機能を付与できるため、個別の設計や実行を要することなく、動的バイトコード計装を実現できる。したがって、多種多様なスクリプトエンジンの実装に対しても、動的バイトコード計装を実現し、解析することが可能となる。
 このように、本実施形態の解析機能付与装置10によれば、多種多様なスクリプトエンジンにおける動的なバイトコードの計装が可能となり、スクリプトの実行状態を解析することが可能となる。したがって、様々なスクリプトエンジンに動的バイトコード計装の機能を付与することにより、スクリプトエンジン上で実行されるスクリプトの解析が可能となる。
[プログラム]
 上記実施形態に係る解析機能付与装置10が実行する処理をコンピュータが実行可能な言語で記述したプログラムを作成することもできる。一実施形態として、解析機能付与装置10は、パッケージソフトウェアやオンラインソフトウェアとして上記の解析機能付与処理を実行する解析機能付与プログラムを所望のコンピュータにインストールさせることによって実装できる。例えば、上記の解析機能付与プログラムを情報処理装置に実行させることにより、情報処理装置を解析機能付与装置10として機能させることができる。ここで言う情報処理装置には、デスクトップ型またはノート型のパーソナルコンピュータが含まれる。また、その他にも、情報処理装置にはスマートフォン、携帯電話機やPHS(Personal Handyphone System)などの移動体通信端末、さらには、PDA(Personal Digital Assistant)などのスレート端末などがその範疇に含まれる。また、解析機能付与装置10の機能を、クラウドサーバに実装してもよい。
 図17は、解析機能付与プログラムを実行するコンピュータの一例を示す図である。コンピュータ1000は、例えば、メモリ1010と、CPU1020と、ハードディスクドライブインタフェース1030と、ディスクドライブインタフェース1040と、シリアルポートインタフェース1050と、ビデオアダプタ1060と、ネットワークインタフェース1070とを有する。これらの各部は、バス1080によって接続される。
 メモリ1010は、ROM(Read Only Memory)1011およびRAM1012を含む。ROM1011は、例えば、BIOS(Basic Input Output System)等のブートプログラムを記憶する。ハードディスクドライブインタフェース1030は、ハードディスクドライブ1031に接続される。ディスクドライブインタフェース1040は、ディスクドライブ1041に接続される。ディスクドライブ1041には、例えば、磁気ディスクや光ディスク等の着脱可能な記憶媒体が挿入される。シリアルポートインタフェース1050には、例えば、マウス1051およびキーボード1052が接続される。ビデオアダプタ1060には、例えば、ディスプレイ1061が接続される。
 ここで、ハードディスクドライブ1031は、例えば、OS1091、アプリケーションプログラム1092、プログラムモジュール1093およびプログラムデータ1094を記憶する。上記実施形態で説明した各情報は、例えばハードディスクドライブ1031やメモリ1010に記憶される。
 また、解析機能付与プログラムは、例えば、コンピュータ1000によって実行される指令が記述されたプログラムモジュール1093として、ハードディスクドライブ1031に記憶される。具体的には、上記実施形態で説明した解析機能付与装置10が実行する各処理が記述されたプログラムモジュール1093が、ハードディスクドライブ1031に記憶される。
 また、解析機能付与プログラムによる情報処理に用いられるデータは、プログラムデータ1094として、例えば、ハードディスクドライブ1031に記憶される。そして、CPU1020が、ハードディスクドライブ1031に記憶されたプログラムモジュール1093やプログラムデータ1094を必要に応じてRAM1012に読み出して、上述した各手順を実行する。
 なお、解析機能付与プログラムに係るプログラムモジュール1093やプログラムデータ1094は、ハードディスクドライブ1031に記憶される場合に限られず、例えば、着脱可能な記憶媒体に記憶されて、ディスクドライブ1041等を介してCPU1020によって読み出されてもよい。あるいは、解析機能付与プログラムに係るプログラムモジュール1093やプログラムデータ1094は、LANやWAN(Wide Area Network)等のネットワークを介して接続された他のコンピュータに記憶され、ネットワークインタフェース1070を介してCPU1020によって読み出されてもよい。
 以上、本発明者によってなされた発明を適用した実施形態について説明したが、本実施形態による本発明の開示の一部をなす記述および図面により本発明は限定されることはない。すなわち、本実施形態に基づいて当業者等によりなされる他の実施形態、実施例および運用技術等は全て本発明の範疇に含まれる。
 10 解析機能付与装置
 11 入力部
 12 制御部
 13 記憶部
 14 出力部
 121 仮想機械解析部
 122 命令セットアーキテクチャ解析部
 123 計装部
 131 実行トレースDB
 132 アーキテクチャ情報DB
 133 VM実行トレースDB
 1211 実行トレース取得部
 1212 仮想プログラムカウンタ検出部
 1213 VM命令境界検出部
 1214 ディスパッチャ検出部
 1215 コードキャッシュ検出部
 1221 VM実行トレース取得部
 1222 VM命令収集部
 1223 VM命令判定部
 1231 計装用バイトコード抽出部
 1232 挿入部
 1233 実行部

Claims (6)

  1.  スクリプトエンジンの仮想機械を解析し、スクリプトエンジンのアーキテクチャに関する情報を取得する第1の取得部と、
     前記アーキテクチャに関する情報を基に、仮想機械の命令の体系である命令セットアーキテクチャの情報を取得する第2の取得部と、
     取得された前記アーキテクチャに関する情報および前記命令セットアーキテクチャの情報を基に、計装用のバイトコードを抽出する抽出部と、
     抽出された前記計装用のバイトコードを解析対象のバイトコードへ挿入する挿入部と、
     を有することを特徴とする解析機能付与装置。
  2.  前記計装用のバイトコードが挿入されたスクリプトを実行する実行部をさらに有することを特徴とする請求項1に記載の解析機能付与装置。
  3.  前記アーキテクチャに関する情報は、仮想プログラムカウンタ、ディスパッチャ、条件分岐フラグ、またはコードキャッシュのいずれかを含むことを特徴とする請求項1に記載の解析機能付与装置。
  4.  前記第2の取得部は、前記仮想プログラムカウンタおよび前記ディスパッチャを監視するとともに前記仮想機械において実行された仮想機械実行トレースを解析することにより、前記命令セットアーキテクチャの情報を取得することを特徴とする請求項3に記載の解析機能付与装置。
  5.  解析機能付与装置が実行する解析機能付与方法であって、
     スクリプトエンジンの仮想機械を解析し、スクリプトエンジンのアーキテクチャに関する情報を取得する第1の取得工程と、
     前記アーキテクチャに関する情報を基に、仮想機械の命令の体系である命令セットアーキテクチャの情報を取得する第2の取得工程と、
     取得された前記アーキテクチャに関する情報および前記命令セットアーキテクチャの情報を基に、計装用のバイトコードを抽出する抽出工程と、
     抽出された前記計装用のバイトコードを解析対象のバイトコードへ挿入する挿入工程と、
     を含んだことを特徴とする解析機能付与方法。
  6.  スクリプトエンジンの仮想機械を解析し、スクリプトエンジンのアーキテクチャに関する情報を取得する第1の取得ステップと、
     前記アーキテクチャに関する情報を基に、仮想機械の命令の体系である命令セットアーキテクチャの情報を取得する第2の取得ステップと、
     取得された前記アーキテクチャに関する情報および前記命令セットアーキテクチャの情報を基に、計装用のバイトコードを抽出する抽出ステップと、
     抽出された前記計装用のバイトコードを解析対象のバイトコードへ挿入する挿入ステップと、
     をコンピュータに実行させるための解析機能付与プログラム。
PCT/JP2022/037925 2022-10-11 2022-10-11 解析機能付与装置、解析機能付与方法および解析機能付与プログラム WO2024079794A1 (ja)

Priority Applications (1)

Application Number Priority Date Filing Date Title
PCT/JP2022/037925 WO2024079794A1 (ja) 2022-10-11 2022-10-11 解析機能付与装置、解析機能付与方法および解析機能付与プログラム

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
PCT/JP2022/037925 WO2024079794A1 (ja) 2022-10-11 2022-10-11 解析機能付与装置、解析機能付与方法および解析機能付与プログラム

Publications (1)

Publication Number Publication Date
WO2024079794A1 true WO2024079794A1 (ja) 2024-04-18

Family

ID=90668968

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/JP2022/037925 WO2024079794A1 (ja) 2022-10-11 2022-10-11 解析機能付与装置、解析機能付与方法および解析機能付与プログラム

Country Status (1)

Country Link
WO (1) WO2024079794A1 (ja)

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20100153939A1 (en) * 2008-12-12 2010-06-17 Microsoft Corporation Remapping debuggable code
WO2015122872A1 (en) * 2014-02-11 2015-08-20 Hewlett Packard Development Company, L.P. Client application profiling
WO2022180702A1 (ja) * 2021-02-24 2022-09-01 日本電信電話株式会社 解析機能付与装置、解析機能付与プログラム及び解析機能付与方法

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20100153939A1 (en) * 2008-12-12 2010-06-17 Microsoft Corporation Remapping debuggable code
WO2015122872A1 (en) * 2014-02-11 2015-08-20 Hewlett Packard Development Company, L.P. Client application profiling
WO2022180702A1 (ja) * 2021-02-24 2022-09-01 日本電信電話株式会社 解析機能付与装置、解析機能付与プログラム及び解析機能付与方法

Similar Documents

Publication Publication Date Title
EP3330879B1 (en) Vulnerability discovering device, vulnerability discovering method, and vulnerability discovering program
WO2020075335A1 (ja) 解析機能付与装置、解析機能付与方法及び解析機能付与プログラム
CN107239392B (zh) 一种测试方法、装置、终端及存储介质
US20080289042A1 (en) Method for Identifying Unknown Virus and Deleting It
CN109101815B (zh) 一种恶意软件检测方法及相关设备
WO2022180702A1 (ja) 解析機能付与装置、解析機能付与プログラム及び解析機能付与方法
EP2881877A1 (en) Program execution device and program analysis device
CN112149136A (zh) loT设备固件漏洞的检测方法、系统及电子设备
CN114386045B (zh) 一种Web应用程序漏洞检测方法、装置及存储介质
Zhang et al. An adaptive approach for Linux memory analysis based on kernel code reconstruction
WO2024079794A1 (ja) 解析機能付与装置、解析機能付与方法および解析機能付与プログラム
US20230141948A1 (en) Analysis and Testing of Embedded Code
WO2023067668A1 (ja) 解析機能付与方法、解析機能付与装置及び解析機能付与プログラム
WO2023067665A1 (ja) 解析機能付与方法、解析機能付与装置及び解析機能付与プログラム
CN114741700B (zh) 基于符号化污点分析的公共组件库漏洞可利用性分析方法及装置
WO2024079800A1 (ja) 解析機能付与装置、解析機能付与方法および解析機能付与プログラム
JP7380851B2 (ja) テストスクリプト生成装置、テストスクリプト生成方法及びプログラム
JP5952218B2 (ja) 情報処理装置および情報処理方法
Jiang et al. Revealing Performance Issues in Server-side WebAssembly Runtimes via Differential Testing
WO2024079793A1 (ja) 脆弱性発見装置、脆弱性発見方法及び脆弱性発見プログラム
US11886589B2 (en) Process wrapping method for evading anti-analysis of native codes, recording medium and device for performing the method
WO2023067663A1 (ja) 解析機能付与方法、解析機能付与装置及び解析機能付与プログラム
WO2023067667A1 (ja) 解析機能付与方法、解析機能付与装置及び解析機能付与プログラム
KR102421394B1 (ko) 하드웨어와 소프트웨어 기반 트레이싱을 이용한 악성코드 탐지 장치 및 방법
KR102416292B1 (ko) 안드로이드 앱 동적 분석 방법, 이를 수행하기 위한 기록 매체 및 장치

Legal Events

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

Ref document number: 22962014

Country of ref document: EP

Kind code of ref document: A1