WO2018116522A1 - 判定装置、判定方法及び判定プログラム - Google Patents
判定装置、判定方法及び判定プログラム Download PDFInfo
- Publication number
- WO2018116522A1 WO2018116522A1 PCT/JP2017/030038 JP2017030038W WO2018116522A1 WO 2018116522 A1 WO2018116522 A1 WO 2018116522A1 JP 2017030038 W JP2017030038 W JP 2017030038W WO 2018116522 A1 WO2018116522 A1 WO 2018116522A1
- Authority
- WO
- WIPO (PCT)
- Prior art keywords
- function
- feature information
- source code
- similarity
- determination
- Prior art date
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/70—Software maintenance or management
- G06F8/75—Structural analysis for program understanding
- G06F8/751—Code clone detection
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/44—Arrangements for executing specific programs
Definitions
- the present invention relates to a determination device, a determination method, and a determination program.
- An executable file (hereinafter referred to as a program) is a binary representation (hereinafter referred to as a bytecode) that is data generated by a compiler from source code described in a specific programming language. Processed by software so that it can be executed.
- One of the means to make the creation of this program more efficient is the use of source code (including code snippets that are fragmented source code) shared on the Internet.
- Non-Patent Document 1 provides a service for maintaining and managing the source code of a program created by a programmer, and releases a large number of source codes.
- stackoverflow for example, see non-patent document 2
- Qiita for example, refer to non-patent document 3
- Source code written by an unspecified number of users is shared.
- a method for calculating the similarity between two different programs and two different source codes has been known for a long time.
- a method of calculating the degree of similarity there is a method of creating data representing the feature amount from a program, comparing the result obtained by applying fuzzy hashing to the data, and comparing the data (for example, see Non-Patent Document 4).
- a method of constructing a program dependence graph from a program and comparing the program dependence graph for example, see Non-Patent Document 5).
- both pieces of information to be input must be data in the same format. This is because, in the above-described method for calculating the similarity of a program, when comparing the byte code of the program and the source code, it is necessary to calculate the similarity after compiling the source code into the byte code.
- the source code published on the Internet is often a fragmented code such as a code snippet, and in this case, it is difficult to compile the source code into byte code.
- a fragmented code such as a code snippet
- the above-described method for calculating the similarity of a program has a problem that it is difficult to compile source code into byte code, and it is difficult to calculate the similarity between the byte code of the program and the source code.
- the present invention has been made in view of the above, and it is possible to appropriately calculate the degree of similarity between the byte code of the program and the source code even if the byte code of the program and the source code have different data formats.
- An object is to provide a determination device, a determination method, and a determination program.
- the determination apparatus describes function definition information, which is information defining a function, and a function name executed in the function from the input source code and the byte code of the program in the order of execution.
- the feature information extraction unit that extracts the function call order information that has been generated as feature information, and the feature information extracted by the feature information extraction unit calculates the similarity between the function in the source code and the function in the bytecode And a similarity calculation unit.
- the present invention it is possible to determine whether or not a program is generated using a specific source code even when the data format of the byte code and the source code to be compared is different. .
- FIG. 1 is a block diagram showing the configuration of the determination apparatus according to the present embodiment.
- FIG. 2 is a diagram illustrating an example of source code implemented in a programming language Java (registered trademark) and feature information extracted from the source code.
- FIG. 3 is a diagram illustrating an example of bytecodes implemented in the programming language Java and feature information extracted from the bytecodes.
- FIG. 4 is a flowchart illustrating a processing procedure of determination processing by the determination device illustrated in FIG. 1.
- FIG. 5 is a flowchart showing a processing procedure of the source code feature information extraction processing shown in FIG.
- FIG. 6 is a flowchart showing a processing procedure of the bytecode feature information extraction processing shown in FIG.
- FIG. 7 is a flowchart showing a processing procedure of the similarity calculation process shown in FIG.
- FIG. 8 is a diagram illustrating an example of a computer in which the determination apparatus is realized by executing a program.
- Embodiments of the present invention will be described.
- a determination device, a determination method, and a determination program for determining whether a program is generated using a specific source code will be described.
- First, an outline of the determination apparatus in the embodiment will be described.
- FIG. 1 is a block diagram showing the configuration of the determination apparatus according to the present embodiment.
- the determination device 10 includes an input unit 11, an output unit 12, a communication unit 13, a storage unit 14, and a control unit 15.
- the input unit 11 is an input interface that accepts various operations from the operator of the determination apparatus 10.
- the input unit 11 includes a touch panel, a voice input device, and input devices such as a keyboard and a mouse.
- the output unit 12 is realized by, for example, a display device such as a liquid crystal display, a printing device such as a printer, an information communication device, or the like.
- the output unit 12 outputs a result of determination processing described later to the operator.
- the communication unit 13 is a communication interface that transmits and receives various types of information to and from other devices connected via a network or the like.
- the communication unit 13 is realized by a NIC (Network Interface Card) or the like, and performs communication between another device and the control unit 15 via a telecommunication line such as a LAN (Local Area Network) or the Internet.
- NIC Network Interface Card
- the storage unit 14 is realized by a semiconductor memory device such as a RAM (Random Access Memory) or a flash memory (Flash Memory), or a storage device such as a hard disk or an optical disk. Data used during execution is stored.
- a semiconductor memory device such as a RAM (Random Access Memory) or a flash memory (Flash Memory)
- flash memory Flash Memory
- Data used during execution is stored.
- the control unit 15 has an internal memory for storing a program that defines various processing procedures and necessary data, and executes various processes using these programs.
- the control unit 15 is an electronic circuit such as a CPU (Central Processing Unit) or MPU (Micro Processing Unit).
- the control unit 15 includes a feature information extraction unit 151, a similarity calculation unit 154, and a determination unit 155.
- the feature information extraction unit 151 describes function definition information, which is information defining a function, and a function name executed in the function from the input source code and the byte code of the program in the order of execution.
- the obtained function call order information is extracted as feature information.
- the feature information extraction unit 151 extracts, for example, a modifier, an identifier, an argument, and a return value type as the function definition information.
- the function definition information and the function call order information can be extracted without being limited to the data format of the source code and the byte code.
- the feature information extraction unit 151 outputs the feature information extracted from each of the input source code and the program bytecode to the similarity calculation unit 154.
- the feature information extraction unit 151 includes a source code feature information extraction unit 152 and a byte code feature information extraction unit 153.
- the source code feature information extraction unit 152 receives the source code or a code snippet that is a part of the source code, and extracts function definition and function call order information included in the source code as feature data. At this time, the source code feature information extraction unit 152, when the variable type information or the package structure information in the source code is missing, the missing part is replaced with any type or arbitrary package structure information. Consider and supplement information. Subsequently, the source code feature information extraction unit 152 extracts feature information.
- the bytecode feature information extraction unit 153 receives the program bytecode and extracts the feature information by analyzing the bytecode. At this time, if the function identifier in the bytecode is obfuscated and the function definition and the function call can be associated, the bytecode feature information extraction unit 153 sets the function identifier to an arbitrary one. It is regarded as a character string, and information is supplemented. Subsequently, the byte code feature information extraction unit 153 extracts feature information.
- the similarity calculation unit 154 uses the feature information extracted by the feature information extraction unit 151 to calculate the similarity between the function in the source code and the function in the byte code.
- the similarity calculation unit 154 calculates the similarity according to each of the function definition information and the function call order information.
- the similarity calculation unit 154 calculates the similarity based on the qualifier, identifier, argument, and return value type extracted as the function definition information by the feature information extraction unit 151. For example, the similarity calculation unit 154 uses the function definition information to compare whether the qualifiers, identifiers, arguments, and return values of the source code and the bytecode match each other. Similarity is calculated in consideration of the identity of.
- the similarity calculation unit 154 calculates the similarity by applying a comparison algorithm that considers the order relationship to the function call order information extracted by the feature information extraction unit 151. Specifically, the similarity calculation unit 154 applies an algorithm such as an edit distance (Levenshtein Distance) or a longest common subsequence (Longest Common Sequence) to each function call order information of the source code and the bytecode. Thus, the similarity considering the partial sequence of the function call order is calculated.
- an edit distance Longshtein Distance
- a longest common subsequence Longest Common Sequence
- the determination unit 155 determines whether or not the program is generated using a specific source code based on the similarity calculated by the similarity calculation unit 154. The determination unit 155 determines whether the program is generated using a specific source code using the similarity considering the identity of the function definition and the similarity considering the partial sequence of the function call order. judge. Subsequently, the processing content of each component in the control unit 15 will be described with a specific example.
- FIG. 2 is a diagram illustrating an example of source code implemented in the programming language Java and feature information extracted from the source code.
- 2A shows the source code La as an example
- FIG. 2B shows the feature information Ta extracted from the source code La.
- feature information Ta function definition information is described in the left column
- function call order information is described in the right column.
- the source code feature information extraction unit 152 extracts a qualifier, a return value type, an identifier, and an argument type as function definition information from the source code La (see FIG. 2A). Then, the source code feature information extracting unit 152 sequentially describes each extracted function definition information in the left column of the feature information Ta (see FIG. 2B) as indicated by arrows Y11 to Y14.
- the source code feature information extraction unit 152 extracts a modifier (public), a return value type (void), an identifier (init), and an argument type (int) from the fourth to sixth lines of the source code La.
- the function definition information is described in the cell C11A of the feature information Ta.
- the source code feature information extraction unit 152 extracts “public”, “void”, “MethodA”, and “String” from the 8th to 13th lines of the source code La, and features information Ta as indicated by an arrow Y12. Cell C12A as function definition information.
- the source code feature information extraction unit 152 extracts “private”, “void”, “MethodB”, and “void” from the 15th to 19th lines of the source code La, and the feature information Ta as indicated by an arrow Y13.
- Cell C13A as function definition information.
- the source code feature information extraction unit 152 extracts function names executed in the function in the order of execution as function call order information from the source code La (see FIG. 2A). Then, the source code feature information extraction unit 152 sets the extracted function names as function call order information, as indicated by arrows Y11 to Y14, in the right column of the feature information Ta (see FIG. 2B). List in order of execution.
- the source code feature information extraction unit 152 extracts the function name (super) executed in the function from the 4th to 6th lines of the source code La, and extracts the function name (super) as indicated by the arrow Y11. Is described as function call order information in the cell C21A of the feature information Ta. Further, the source code feature information extraction unit 152 extracts the function name (println, MethodB, send) executed in the function from the 8th to 13th lines of the source code La. Then, the source code feature information extraction unit 152 sequentially uses the extracted function names (println, MethodB, send) as the function call order information in the cell C22A of the feature information Ta as indicated by the arrow Y12 in the order of execution. Describe.
- the source code feature information extraction unit 152 extracts “getClass”, “getSimpleName”, “println”, “MethodC”, and “send” as function call order information from the 15th to 19th lines of the source code La. As shown by the arrow Y13, the information is sequentially written in the cell C23A of the feature information Ta in the order of execution.
- the source code feature information extraction unit 152 identifies the missing portion as any variable, any type, any The feature information is extracted by supplementing the information.
- the type of a variable is represented by a fully qualified name (for example, java.lang.String) that combines the name of the package to which the object class stored in the variable belongs and the class name of the object.
- a fully qualified name for example, java.lang.String
- the package name portion of the fully qualified name can be omitted by making an import declaration in advance.
- the source code feature information extraction unit 152 regards the type of “ClassB” as “(arbitrary package name) .ClassB”, supplements this “(arbitrary package name) .ClassB”, and extracts it as feature information. . Then, the source code feature information extraction unit 152 describes the extracted “(arbitrary package name) .ClassB” in the cell C14A of the feature information Ta.
- the source code feature information extraction unit 152 extracts “public”, “boolean”, and “MethodC” from the 21st to 24th lines of the source code La and supplements “(arbitrary package name) .ClassB”. Is described in the cell C14A as indicated by an arrow Y14. Note that the source code feature information extraction unit 152 extracts “getData” as function call order information from the 21st to 22nd lines of the source code La, and describes it in the cell C24A of the feature information Ta as indicated by an arrow Y14. .
- FIG. 3 is a diagram illustrating an example of bytecodes implemented in the programming language Java and feature information extracted from the bytecodes.
- FIG. 3A shows a byte code Lb as an example
- FIG. 3B shows feature information Tb extracted from the byte code Lb.
- function definition information is described in the left column
- function call order information is described in the right column.
- the byte code feature information extraction unit 153 receives the program byte code Lb and analyzes the byte code to extract feature information Tb as indicated by arrows Y21 to Y24.
- the byte code feature information extraction unit 153 may extract the information from the byte code after converting the byte code into a readable text format using, for example, a disassembler.
- the bytecode feature information extraction unit 153 extracts a qualifier, a return value type, an identifier, and an argument type as function definition information from the bytecode Lb (see FIG. 3A). Then, the byte code feature information extraction unit 153 sequentially describes the extracted function definition information in the left column of the feature information Tb (see FIG. 3B) as indicated by arrows Y21 to Y24. Further, the bytecode feature information extraction unit 153 extracts function names executed in the functions in the order of execution as function call order information from the source code Lb. Then, the byte code feature information extraction unit 153 sequentially describes the extracted functions as function call order information in the right column of the feature information Tb in the order of execution, as indicated by arrows Y21 to Y24.
- the bytecode feature information extraction unit 153 extracts a modifier (public), a return value type (void), an identifier (init), and an argument type (int) from the third to fifth lines of the bytecode Lb.
- the function definition information is described in the cell C11B of the feature information Tb.
- the bytecode feature information extraction unit 153 extracts the function name (init) to be executed in the function from the third to fifth lines of the bytecode Lb, and uses the feature information Tb as function call order information as indicated by an arrow Y21. Cell C21B.
- the byte code feature information extraction unit 153 When the function name is very short by the obfuscation process or the compression process of the source code and the function definition and the function call can be associated, the byte code feature information extraction unit 153 The function name is regarded as an arbitrary function name, and information is supplemented. Then, the bytecode feature information extraction unit 153 extracts an arbitrary function name supplemented as feature data.
- the bytecode feature information extraction unit 153 regards the function name in the function definition information of the function “a” and the function call order information of the function “MethodB” as “arbitrary value”.
- the bytecode feature information extraction unit 153 regards the function “a” on the 18th line as “arbitrary value” as the function call order information, and sets the function “a” in the order as indicated by the arrow Y23.
- “[arbitrary value]” of the cell C23B of the feature information Tb is described.
- the bytecode feature information extraction unit 153 regards the function “a” on the 22nd line as “arbitrary value” as the function definition information, and “[arbitrary] in the cell C14B of the feature information Tb as indicated by an arrow Y24. Value] ”.
- the source code feature information extraction unit 152 and the byte code feature information extraction unit 153 need not be limited to the source code or the byte code as long as the function definition information and the function call order information can be obtained. .
- the feature information extraction unit 151 does not have to limit the target to be extracted as feature information to functions in the source code and byte code.
- the feature information extraction unit 151 may extract feature information from information characterizing a program such as a class and an interface from source code and bytecode.
- the similarity calculation unit 154 receives the two pieces of analysis target feature information extracted from the feature information extraction unit 151, and calculates the similarity between the function in the source code and the function in the byte code in the two feature information, respectively. To do.
- the two pieces of feature information are function definition information and function call order information.
- the similarity calculation unit 154 calculates the similarity considering the identity of the function definition using the function definition information of the two feature information.
- the similarity calculation unit 154 considers the identity of the function definition by comparing whether the qualifier, identifier, return value type, and argument type match in the source code and the byte code. The similarity is calculated.
- the similarity calculating unit 154 when calculating the similarity considering the identity of the function definition, appropriately weights each type of the function definition information extracted by the feature information extracting unit 151 to obtain the function definition information. You can also change the type of priority. Of course, the similarity calculation unit 154 may not perform such weighting.
- the similarity calculation unit 154 calculates the similarity between the function in the source code and the function in the bytecode using the function call order information of the two pieces of feature information.
- the similarity calculation unit 154 applies an algorithm such as an edit distance or a longest common subsequence to the function call order information in the feature information, so that the function in the source code and the function in the bytecode are Calculate the similarity considering a partial sequence of the function call order.
- the similarity calculation unit 154 calculates the edit distance between the function in the source code and the function in the bytecode using the function call order information.
- the function “MethodA” of the source code La in FIG. 2B and the function “MethodC” of the byte code Lb in FIG. 3B the function “MethodC” of the byte code Lb has the function name “a” due to the obfuscation process.
- the function “a” has the function name “[arbitrary value]” in the function call order information as shown in the cell C23B of FIG. 3B.
- the cost of each procedure is determined in advance. For example, the cost for replacement is 2, and the cost for deletion is 1.
- the similarity calculation unit 154 displays the function call order (cell C22A) of the function “MethodA” (cell C12A) in FIG. 2B and the function “MethodC” (cell C14B) in FIG. ) Requires a replacement procedure (cost 2) once and a deletion procedure (cost 1) twice until the function call order (cell C24B) is matched.
- the similarity calculation unit 154 calculates the function call order (cell C23A) of the function “MethodB” of the source code La in FIG. 2B and the function “MethodA” of the byte code Lb in FIG.
- the function call order (cell C22B) is compared.
- the similarity calculation unit 154 has a function that is common in the function call order of the function “MethodB” of the source code La (cell C23A) and the function call order of the function “MethodA” of the bytecode Lb (cell C22B). Find the longest subsequence in the calling sequence. Then, the similarity calculation unit 154 obtains the length of the obtained partial sequence as the similarity.
- the function call order of the function “MethodB” of the source code La (cell C23A) and the function call order of the function “MethodA” of the bytecode Lb (cell C22B) are subsequences of the common function call order.
- the longest subsequence is two subsequences “println () ⁇ send ()”.
- the length of the longest common subsequence of “println () ⁇ send ()” is 2.
- the similarity calculation unit 154 performs the function call order for the function call order of the function “MethodB” of the source code La (cell C23A) and the function call order of the function “MethodA” of the bytecode Lb (cell C22B). 2 is calculated as the degree of similarity considering the partial sequence. The similarity using the longest common subsequence indicates that the larger the value, the higher the similarity of the series.
- the similarity calculation unit 154 can change the priority of the feature by appropriately weighting the similarity using the function definition information and the function call order information calculated as described above. Of course, the similarity calculation unit 154 may not perform such weighting.
- the determination unit 155 determines whether the program is generated using a specific source code based on the similarity calculated by the similarity calculation unit 154.
- the determination unit 155 determines the degree of similarity using one source code and one byte code as input data.
- an arbitrary threshold value used for determination is set in advance for each of the two similarities.
- the two similarities are a similarity based on the function definition information and a similarity based on the function call order information.
- the determination unit 155 when there is a combination of functions having a similarity that is equal to or greater than a threshold value in the two similarities for the source code function and the two similarities for the bytecode function, It is determined that the function inside is implemented using the function part of the source code to be compared.
- the similarity calculation unit 154 calculates in advance the similarity considering the identity of the function definition information, the edit distance that is the similarity based on the function call order information, and the three similarities of the longest common subsequence.
- a combination of three similarities calculated by may be set in advance.
- the determination apparatus 10 determines that for each of these combinations, it can be determined that the program is generated using a specific source code, or it is determined that the program is not generated using a specific source code. You may set the determination table which matched that it was possible. In this case, the determination unit 155 may refer to the determination table and use the determination content corresponding to the combination of the three similarities calculated by the similarity calculation unit 154 to perform the determination.
- the determination processing by the determination unit 155 is not limited to the determination processing by setting a threshold value for the similarity between individual functions.
- the determination apparatus 10 sets a threshold value for the total value of the similarity calculation results between the function group included in a specific class in the bytecode and the function group included in the source code. Then, the determination unit 155 may determine, for each class, whether or not this byte code has been implemented using the source code to be compared based on whether the total value exceeds the threshold value.
- the determination device 10 sets a threshold value for the calculated value when each similarity is applied to a predetermined arithmetic expression set in advance, and the determination unit 155 calculates the similarity when each similarity is applied to the arithmetic expression. The determination may be made based on the comparison result between the value and the threshold value.
- the determination unit 155 when the determination unit 155 performs determination based on the similarity considering the identity of the function definition information, the edit distance that is the similarity based on the function call order information, and the three similarities of the longest common subsequence Of course, but not limited to this.
- the determination unit 155 may perform determination based on one or two of the three similarities. For example, when the source code to be compared is short, the determination unit 155 may perform the determination using only the similarity considering the identity of the function definition information.
- the determination apparatus 10 receives a plurality of source codes and a plurality of byte codes as inputs, and determines whether any byte code is implemented using any source code based on the calculated similarity. Good.
- FIG. 4 is a flowchart showing a processing procedure of determination processing by the determination device 10 shown in FIG.
- the source code feature information extraction unit 152 performs a source code feature information extraction process for extracting feature information from the input source code (step S1). Further, the bytecode feature information extraction unit 153 performs a bytecode feature information extraction process for extracting feature information from the bytecode of the program (step S2). In addition, step S1 and step S2 may be parallel processing, and which may be processed first.
- the similarity calculation unit 154 calculates the similarity between the functions included in each of the byte code and the source code based on the feature information extracted from the source code and the feature information extracted from the byte code. Calculation processing is performed (step S3).
- the determination unit 155 performs determination processing for determining whether or not the input source code is included in the byte code (program) based on the similarity calculated in the similarity calculation processing and an arbitrary threshold value. (Step S4). In other words, the determination unit 155 determines whether or not the program is generated using the input specific source code based on the similarity calculated in the similarity calculation process and an arbitrary threshold value.
- FIG. 5 is a flowchart showing a processing procedure of the source code feature information extraction processing shown in FIG. In FIG. 5, it is assumed that the source code to be compared does not include a plurality of class definitions.
- the source code feature information extraction unit 152 performs a process of extracting all functions described in the source code (step S11). Then, the source code feature information extraction unit 152 selects a feature-unextracted function for which feature information is not extracted from the functions extracted in step S11 (step S12). Subsequently, the source code feature information extraction unit 152 extracts function definition information of the selected function (step S13). Then, the source code feature information extracting unit 152 extracts function call order information in the implementation of the selected function (step S14).
- the source code feature information extraction unit 152 determines whether or not feature information has been extracted from all the functions extracted in step S11 (step S15). When the source code feature information extraction unit 152 determines that the feature information has been extracted from all the functions extracted in step S11 (step S15: Yes), the source code feature information extraction process ends. On the other hand, if the source code feature information extraction unit 152 determines that the feature information has not been extracted from all the functions extracted in step S11 (step S15: No), the source code feature information extraction unit 152 returns to step S12 and selects a feature that has not been extracted. Then, the processing after step S13 is executed.
- FIG. 6 is a flowchart showing a processing procedure of the bytecode feature information extraction processing shown in FIG. In FIG. 6, description will be made assuming that the determination target bytecode includes a plurality of class definitions.
- the byte code feature information extraction unit 153 extracts all classes described in the byte code from the input byte code (step S21).
- the bytecode feature information extraction unit 153 selects an unanalyzed class from the extracted classes (step S22), and performs a process of extracting all functions in the selected class (step S23).
- the analysis means that function definition information and function call order information are extracted as feature information.
- the bytecode feature information extraction unit 153 selects a feature-unextracted function that has not been extracted from the extracted functions (step S24), and extracts function definition information of the selected function (step S25). Subsequently, the bytecode feature information extraction unit 153 extracts function call order information in the implementation of the selected function (step S26).
- the bytecode feature information extraction unit 153 determines whether or not feature information has been extracted from all the functions extracted in step S23 (step S27). If the bytecode feature information extraction unit 153 determines that feature information is not extracted from all the functions extracted in step S23 (step S27: No), the byte code feature information extraction unit 153 returns to step S24 and selects a function that has not been extracted. And execute the subsequent processing.
- step S27: Yes if the bytecode feature information extraction unit 153 determines that the feature information has been extracted from all the functions extracted in step S23 (step S27: Yes), it analyzes all the classes extracted in step S21. Whether or not (step S28). If the bytecode feature information extraction unit 153 determines that all the extracted classes have not been analyzed (step S28: No), the process returns to step S22 to select a class that has not been analyzed. On the other hand, if the bytecode feature information extraction unit 153 determines that all the extracted classes have been analyzed (step S28: Yes), the bytecode feature information extraction process ends.
- FIG. 7 is a flowchart showing a processing procedure of the similarity calculation process shown in FIG.
- the similarity calculation unit 154 obtains a function list (referred to as function group 1) in the source code extracted in the entire function extraction process (step S11 in FIG. 5) in the source code.
- An unanalyzed function (referred to as function A) is selected from this function group 1 (step S31).
- the similarity calculation unit 154 acquires the function list (referred to as function group 2) extracted in the entire function extraction process (step S23 in FIG. 6) in the selected class in the byte code.
- An unanalyzed function (referred to as function B) is selected (step S32).
- the similarity calculation unit 154 uses the function definition information and the function call order information of the functions A and B selected in step S31 and step S32, and the function A of the source code and the function B of the bytecode And the similarity is calculated (step S33). As described above, the similarity calculation unit 154 uses the edit distance and the longest common subsequence, which are similarities considering similarity of function definitions, and similarities considering partial sequences of the function call order, as the similarity. And calculate.
- the similarity calculation unit 154 determines whether or not all the functions included in the function group 2 acquired in step S32 have been compared (step S34). When the similarity calculation unit 154 determines that all the functions included in the function group 2 acquired in step S32 are not compared (step S34: No), the similarity calculation unit 154 returns to step S32 and returns the unanalyzed function from the function group 2 Make a selection.
- step S34 when it is determined that the functions included in the function group 2 acquired in step S32 are all compared (step S34: Yes), the similarity calculation unit 154 compares all the functions included in the function group 1. Whether or not (step S35). If the similarity calculation unit 154 determines that all functions included in the function group 1 are not compared (step S35: No), the process returns to step S31 and selects an unanalyzed function from the function group 1. .
- the similarity calculation processing ends.
- the determination unit 155 uses the similarity calculation result of all functions included in the source code obtained as the output of the similarity calculation process and all functions included in the bytecode, and the determination target program (byte code) is It is determined whether or not it has been generated using the source code to be compared. For example, as described above, the determination unit 155 uses the function portion of the source code to be compared as the function in the bytecode when there is a combination of functions having a similarity equal to or greater than the threshold using an arbitrary threshold. Is determined to have been implemented.
- function definition information which is information defining a function
- a function name executed in the function are executed from each of the input source code and the program bytecode.
- Function call order information described in order is extracted as feature information.
- the degree of similarity between the function in the source code and the function in the byte code is calculated using the function definition information and the function call order information, which are feature information.
- the function definition information and the function call order information can be extracted without being limited to the data format
- the bytecode and the source Feature information can be extracted from each code.
- the similarity between the function in the source code and the function in the byte code can be appropriately calculated based on the extracted feature information.
- the data format of the byte code and the source code of the program is different, it is possible to acquire the appropriately calculated similarity, so that the program uses a specific source code. There is an effect that it is possible to accurately determine whether or not it has been generated by use.
- the feature information extraction unit 151 when the variable type information or the package structure information in the source code is missing, identifies the missing part as an arbitrary variable, arbitrary type or The feature information is extracted by regarding the information as an arbitrary package structure. Furthermore, in the present embodiment, the feature information extraction unit 151 obfuscates the function identifier in the bytecode, and if the function definition and the function call can be associated, Is regarded as an arbitrary character string, and feature information is extracted.
- the simple process as described above is sufficient for complementing the missing part.
- the identifier in the bytecode is obfuscated, it is only necessary to replace it with an arbitrary character string. Therefore, according to the present embodiment, for example, a complicated process of supplementing information necessary for compiling source code, which has been conventionally required, is not performed.
- the similarity calculation unit 154 calculates the similarity based on the modifier, the identifier, the argument type, or the return value type extracted as the function definition information, and the function call order information.
- the similarity is calculated by applying a comparison algorithm considering the order relation. That is, in this embodiment, a plurality of similarities corresponding to each of a plurality of types of feature information are calculated. Therefore, in this embodiment, determination processing using a plurality of similarities can be performed, and a strict determination result can be obtained.
- various methods can be selected as determination processing, and determination processing contents can be set flexibly.
- each component of each illustrated device is functionally conceptual and does not necessarily need to be physically configured as illustrated.
- the specific form of distribution / integration of each device is not limited to the one shown in the figure, and all or a part of the distribution / integration is functionally or physically distributed in arbitrary units according to various loads or usage conditions. Can be integrated and configured.
- all or a part of each processing function performed in each device can be realized by a CPU and a program that is analyzed and executed by the CPU, or can be realized as hardware by wired logic.
- FIG. 8 is a diagram illustrating an example of a computer in which the determination apparatus 10 is realized by executing a program.
- the computer 1000 includes a memory 1010 and a CPU 1020, for example.
- the computer 1000 also includes 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 units 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 BIOS (Basic Input Output System).
- BIOS Basic Input Output System
- the hard disk drive interface 1030 is connected to the hard disk drive 1090.
- the disk drive interface 1040 is connected to the disk drive 1100.
- a removable storage medium such as a magnetic disk or an optical disk is inserted into the disk drive 1100.
- the serial port interface 1050 is connected to a mouse 1110 and a keyboard 1120, for example.
- the video adapter 1060 is connected to the display 1130, for example.
- the hard disk drive 1090 stores, for example, an OS 1091, an application program 1092, a program module 1093, and program data 1094. That is, a program that defines each process of the determination apparatus 10 is implemented as a program module 1093 in which a code executable by the computer 1000 is described.
- the program module 1093 is stored in the hard disk drive 1090, for example.
- a program module 1093 for executing processing similar to the functional configuration in the determination apparatus 10 is stored in the hard disk drive 1090.
- the hard disk drive 1090 may be replaced by an SSD (Solid State Drive).
- the setting data used in the processing of the above-described embodiment is stored as program data 1094 in, for example, the memory 1010 or the hard disk drive 1090. Then, the CPU 1020 reads the program module 1093 and the program data 1094 stored in the memory 1010 and the hard disk drive 1090 to the RAM 1012 and executes them as necessary.
- the program module 1093 and the program data 1094 are not limited to being stored in the hard disk drive 1090, but may be stored in, for example, a removable storage medium and read by the CPU 1020 via the disk drive 1100 or the like. Alternatively, the program module 1093 and the program data 1094 may be stored in another computer connected via a network (LAN, WAN, etc.). Then, the program module 1093 and the program data 1094 may be read by the CPU 1020 from another computer via the network interface 1070.
- LAN local area network
- WAN wide area network
Landscapes
- Engineering & Computer Science (AREA)
- Software Systems (AREA)
- Theoretical Computer Science (AREA)
- General Engineering & Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Stored Programmes (AREA)
Abstract
判定装置(10)は、入力されたソースコードとプログラムのバイトコードとのそれぞれから、関数を定義する情報である関数定義情報、及び、関数内で実行される関数名が実行される順序で記載された関数呼出順序情報を特徴情報として抽出する特徴情報抽出部(151)と、特徴情報抽出部(151)によって抽出された特徴情報を用いて、ソースコード内の関数とバイトコード内の関数との類似度を算出する類似度算出部(154)と、を有することを特徴とする。
Description
本発明は、判定装置、判定方法及び判定プログラムに関する。
実行ファイル(以下、プログラムと呼ぶ。)のバイナリ表現(以下、バイトコードと呼ぶ。)は、特定のプログラミング言語で記述されたソースコードから、コンパイラにより生成されたデータであり、特定の環境下で実行できるようソフトウェアで処理される。
このプログラムの作成を効率化させるための手段の一つとして、インターネット上で共有されているソースコード(断片的なソースコードであるコードスニペットも含む。)の活用がある。
例えば、GitHub(例えば、非特許文献1参照)は、プログラマにより作成されたプログラムのソースコードを維持、管理するサービスを提供しており、多数のソースコードを公開している。その他にも、stackoverflow(例えば、非特許文献2参照)やQiita(例えば、非特許文献3参照)は、インターネット上で、プログラマ向けに情報を共有するサービスを提供しており、これらのサービスでは、不特定多数のユーザにより記載されたソースコードが共有されている。
ただし、これらのサービスに掲載されているソースコードの中には、動作の評価はされているものの、セキュリティの観点からは評価されていないものも含まれており、セキュリティ上問題のあるソースコードが存在している。したがって、他者が作成したソースコードをそのまま流用してプログラムを作成することは推奨されておらず、プログラムが特定のソースコードを使用して作成されていることを判定することは重要である。
ここで、異なる二つのプログラムや異なる二つのソースコードを入力とし、その類似度を算出する方法は、以前から知られている。例えば、類似度を算出する方法として、プログラムからその特徴量を表すデータを作成し、このデータにファジーハッシングを適用した結果を入力とし、比較する方法(例えば、非特許文献4参照)がある。また、プログラムからプログラム依存グラフを構築し、このプログラム依存グラフを比較する方法(例えば、非特許文献5参照)等がある。
GitHub、[online]、[平成28年12月9日検索]、インターネット<URL:https://github.com>
StackOverflow、[online]、[平成28年12月9日検索]、インターネット<URL:http://stackoverflow.com/company/about>
Qiita、[online]、[平成28年12月9日検索]、インターネット<URL:https://qiita.com/about>
W. Zhou, Y. Zhou, X. Jiang, and P. Ning, "Detecting Repackaged Smartphone Applications in Third-Party Android Marketplaces", in Proceedings of the ACM Conference Data Application Security Privacy (CODASPY), pp. 317-326, 2012.
J. Crussell, C. Gibler, and H. Chen, "Attack of the Clones: Detecting Cloned Applications on Android Markets", in Proceedings of the European Symposium on Research in Computer Security (ESORICS), pp. 37-54, 2012.
しかしながら、前述したプログラムの類似度を算出する方法は、いずれも入力する二つの情報が同じ形式のデータである必要がある。前述したプログラムの類似度を算出する方法では、プログラムのバイトコードとソースコードとを比較する際、ソースコードをバイトコードへとコンパイルした後に、類似度を算出する必要があるためである。
一方、インターネット上で公開されているソースコードは、コードスニペットのような断片的なコードである場合が多く、この場合には、ソースコードをバイトコードへコンパイルすることが難しい。ソースコードが断片的なコードである場合には、少なくともコンパイルに必要な情報を補完するのに、人手での多大な労力を要するためである。したがって、前述したプログラムの類似度を算出する方法では、ソースコードをバイトコードへとコンパイルすることが難しく、プログラムのバイトコードとソースコードとの類似度を計算することが難しいという問題がある。
このように、従来の手法では、プログラムのバイトコードとソースコードとのデータ形式が異なる場合、プログラムのバイトコードとソースコードとの類似度を計算することが難しいため、プログラムが、特定のソースコードを使用して生成されているか否かを判定することが困難であった。
本発明は、上記に鑑みてなされたものであって、プログラムのバイトコードとソースコードとが異なるデータ形式であっても、プログラムのバイトコードとソースコードとの類似度を適切に計算することができる判定装置、判定方法及び判定プログラムを提供することを目的とする。
本発明の判定装置は、入力されたソースコードとプログラムのバイトコードとのそれぞれから、関数を定義する情報である関数定義情報、及び、関数内で実行される関数名が実行される順序で記載された関数呼出順序情報を特徴情報として抽出する特徴情報抽出部と、特徴情報抽出部によって抽出された特徴情報を用いて、ソースコード内の関数とバイトコード内の関数との類似度を算出する類似度算出部と、を有することを特徴とする。
本発明によれば、比較対象とするバイトコードとソースコードとのデータ形式が異なる場合であっても、プログラムが、特定のソースコードを使用して生成されているか否かを判定することができる。
以下、図面を参照して、本発明の一実施形態を詳細に説明する。なお、この実施形態により本発明が限定されるものではない。また、図面の記載において、同一部分には同一の符号を付して示している。
[実施の形態]
本発明の実施の形態について説明する。本発明の実施の形態では、プログラムが、特定のソースコードを使用して生成されているか否かを判定する判定装置、判定方法及び判定プログラムについて説明する。まず、実施の形態における判定装置の概略について説明する。
本発明の実施の形態について説明する。本発明の実施の形態では、プログラムが、特定のソースコードを使用して生成されているか否かを判定する判定装置、判定方法及び判定プログラムについて説明する。まず、実施の形態における判定装置の概略について説明する。
[判定装置の構成]
図1は、本実施の形態に係る判定装置の構成を示すブロック図である。図1に示すように、判定装置10は、入力部11、出力部12、通信部13、記憶部14及び制御部15を有する。
図1は、本実施の形態に係る判定装置の構成を示すブロック図である。図1に示すように、判定装置10は、入力部11、出力部12、通信部13、記憶部14及び制御部15を有する。
入力部11は、判定装置10の操作者からの各種操作を受け付ける入力インタフェースである。例えば、入力部11は、タッチパネル、音声入力デバイス、キーボードやマウス等の入力デバイスによって構成される。
出力部12は、例えば、液晶ディスプレイなどの表示装置、プリンター等の印刷装置、情報通信装置等によって実現される。出力部12は、後述する判定処理の結果を操作者に対して出力する。
通信部13は、ネットワーク等を介して接続された他の装置との間で、各種情報を送受信する通信インタフェースである。通信部13は、NIC(Network Interface Card)等で実現され、LAN(Local Area Network)やインターネットなどの電気通信回線を介した他の装置と制御部15との間の通信を行う。
記憶部14は、RAM(Random Access Memory)、フラッシュメモリ(Flash Memory)等の半導体メモリ素子、又は、ハードディスク、光ディスク等の記憶装置によって実現され、判定装置10を動作させる処理プログラムや、処理プログラムの実行中に使用されるデータなどが記憶される。
制御部15は、各種の処理手順などを規定したプログラム及び所要データを格納するための内部メモリを有し、これらによって種々の処理を実行する。例えば、制御部15は、CPU(Central Processing Unit)やMPU(Micro Processing Unit)などの電子回路である。制御部15は、特徴情報抽出部151、類似度算出部154及び判定部155を有する。
特徴情報抽出部151は、入力されたソースコードとプログラムのバイトコードとのそれぞれから、関数を定義する情報である関数定義情報、及び、関数内で実行される関数名が実行される順序で記載された関数呼出順序情報を特徴情報として抽出する。特徴情報抽出部151は、関数定義情報として、例えば、修飾子、識別子、引数及び戻り値の型を抽出する。この関数定義情報及び関数呼出順序情報は、ソースコード及びバイトコードのデータ形式に限らず抽出可能である。特徴情報抽出部151は、入力されたソースコードとプログラムのバイトコードとのそれぞれから抽出した各特徴情報を、類似度算出部154に出力する。特徴情報抽出部151は、ソースコード特徴情報抽出部152及びバイトコード特徴情報抽出部153を有する。
ソースコード特徴情報抽出部152は、ソースコードまたはその一部であるコードスニペットを入力とし、ソースコードに含まれる関数定義及び関数呼出順序の情報を特徴データとして抽出する。このとき、ソースコード特徴情報抽出部152は、ソースコードにおける変数の型情報或いはパッケージ構造の情報が欠落している場合には、欠落している部分を任意の型或いは任意のパッケージ構造の情報とみなして情報を補う。続いて、ソースコード特徴情報抽出部152は、特徴情報の抽出を行う。
バイトコード特徴情報抽出部153は、プログラムのバイトコードを入力とし、バイトコードを解析することによって特徴情報を抽出する。このとき、バイトコード特徴情報抽出部153は、バイトコード中の関数の識別子が難読化されており、かつ、関数の定義及び関数の呼び出しを関連付けることができる場合には、関数の識別子を任意の文字列とみなし、情報を補う。続いて、バイトコード特徴情報抽出部153は、特徴情報の抽出を行う。
類似度算出部154は、特徴情報抽出部151によって抽出された特徴情報を用いて、ソースコード内の関数とバイトコード内の関数との類似度を算出する。類似度算出部154は、関数定義情報、関数呼出順序情報のそれぞれに応じた類似度を算出する。
具体的には、類似度算出部154は、特徴情報抽出部151に関数定義情報として抽出された修飾子、識別子、引数及び戻り値の型に基づいて類似度を算出する。例えば、類似度算出部154は、関数定義情報を用いて、ソースコードとバイトコードとの修飾子、識別子、引数及び戻り値の型がそれぞれ一致しているか否かを比較することによって、関数定義の同一性を考慮した類似度を算出する。
また、類似度算出部154は、特徴情報抽出部151によって抽出された関数呼出順序情報に対して、順序関係を考慮した比較アルゴリズムを適用して類似度を算出する。具体的には、類似度算出部154は、ソースコードとバイトコードとの各関数呼出順序情報に対し、編集距離(Levenshtein Distance)や最長共通部分列(Longest Common Sequence)等といったアルゴリズムを適用することによって、関数呼出順序の部分的なシーケンスを考慮した類似度を算出する。
判定部155は、類似度算出部154によって算出された類似度に基づいて、プログラムが特定のソースコードを使用して生成されているか否かを判定する。判定部155は、関数定義の同一性を考慮した類似度及び関数呼出順序の部分的なシーケンスを考慮した類似度を用いて、プログラムが特定のソースコードを使用して生成されているか否かを判定する。続いて、制御部15における各構成部の処理内容について具体例を挙げて説明する。
[ソースコード特徴情報抽出部の処理]
まず、ソースコード特徴情報抽出部152の処理について説明する。図2は、プログラミング言語Javaで実装されたソースコードと該ソースコードから抽出された特徴情報との一例を示す図である。図2の(a)には、一例としてソースコードLaを示し、図2の(b)には、ソースコードLaから抽出された特徴情報Taを示す。特徴情報Taでは、左列に関数定義情報が記載され、右列に関数呼出順序情報が記載される。
まず、ソースコード特徴情報抽出部152の処理について説明する。図2は、プログラミング言語Javaで実装されたソースコードと該ソースコードから抽出された特徴情報との一例を示す図である。図2の(a)には、一例としてソースコードLaを示し、図2の(b)には、ソースコードLaから抽出された特徴情報Taを示す。特徴情報Taでは、左列に関数定義情報が記載され、右列に関数呼出順序情報が記載される。
ソースコード特徴情報抽出部152は、ソースコードLa(図2の(a)参照)から、関数定義情報として、修飾子、戻り値の型、識別子、引数の型を抽出する。そして、ソースコード特徴情報抽出部152は、矢印Y11~Y14のように、抽出したそれぞれの関数定義情報を、特徴情報Ta(図2の(b)参照)の左列に順次記載する。
例えば、ソースコード特徴情報抽出部152は、ソースコードLaの4~6行目から、修飾子(public)、戻り値の型(void)、識別子(init)、引数の型(int)を抽出し、矢印Y11のように、特徴情報TaのセルC11Aに関数定義情報として記載する。また、ソースコード特徴情報抽出部152は、ソースコードLaの8~13行目から、“public”、“void”、“MethodA”、“String”を抽出し、矢印Y12のように、特徴情報TaのセルC12Aに関数定義情報として記載する。また、ソースコード特徴情報抽出部152は、ソースコードLaの15~19行目から、“private”、“void”、“MethodB”、“void”を抽出し、矢印Y13のように、特徴情報TaのセルC13Aに関数定義情報として記載する。
さらに、ソースコード特徴情報抽出部152は、ソースコードLa(図2の(a)参照)から、関数呼出順序情報として、この関数内で実行される関数名を実行される順番で抽出する。そして、ソースコード特徴情報抽出部152は、関数呼出順序情報として、矢印Y11~Y14のように、抽出したそれぞれの関数名を、特徴情報Ta(図2の(b)参照)の右列に、実行される順序で順次記載する。
例えば、ソースコード特徴情報抽出部152は、ソースコードLaの4~6行目から、関数内で実行される関数名(super)を抽出し、矢印Y11のように、抽出した関数名(super)を、特徴情報TaのセルC21Aに、関数呼出順序情報として記載する。また、ソースコード特徴情報抽出部152は、ソースコードLaの8~13行目から、関数内で実行される関数名(println、MethodB、send)を抽出する。そして、ソースコード特徴情報抽出部152は、矢印Y12のように、特徴情報TaのセルC22Aに、抽出した関数名(println、MethodB、send)を、関数呼出順序情報として、実行される順番で順次記載する。また、ソースコード特徴情報抽出部152は、ソースコードLaの15~19行目から、関数呼出順序情報として、“getClass”、“getSimpleName”、“println”、“MethodC”、“send”を抽出し、矢印Y13のように、特徴情報TaのセルC23Aに、実行される順番で順次記載する。
ここで、ソースコード特徴情報抽出部152は、ソースコードが断片的であり変数や型、パッケージ構造等の情報が欠落している場合に、該欠落箇所を任意の変数や、任意の型、任意のパッケージ構造とみなし、情報を補うことで特徴情報を抽出している。
例えば、Javaにおいて、変数の型は、当該変数に格納されるオブジェクトのクラスが所属するパッケージ名と、オブジェクトのクラス名を合わせた完全修飾名(例えば、java.lang.String)によって表される。ただし、実際のソースコードにおいては、予めimport宣言を行う事で完全修飾名のうち、パッケージ名の部分を省略することが可能である。
具体的には、ソースコードLaでは、import宣言が欠落しているため、関数“MethodC”の引数である“ClassB”(21行目)の完全修飾名が不明となっている。この場合、ソースコード特徴情報抽出部152は“ClassB”の型を“(任意のパケージ名).ClassB”とみなして、この“(任意のパケージ名).ClassB”を補い、特徴情報として抽出する。そして、ソースコード特徴情報抽出部152は、抽出した“(任意のパケージ名).ClassB”を、特徴情報TaのセルC14Aに記載する。
したがって、ソースコード特徴情報抽出部152は、ソースコードLaの21~24行目から、“public”、“boolean”、“MethodC”を抽出するとともに、補った“(任意のパケージ名).ClassB”を、矢印Y14のように、セルC14Aに記載する。なお、ソースコード特徴情報抽出部152は、ソースコードLaの21~22行目から、関数呼出順序情報として、“getData”を抽出し、矢印Y14のように、特徴情報TaのセルC24Aに記載する。
[バイトコード特徴情報抽出部の処理]
次に、バイトコード特徴情報抽出部153の処理について説明する。図3は、プログラミング言語Javaで実装されたバイトコードと該バイトコードから抽出された特徴情報との一例を示す図である。図3の(a)には、一例としてバイトコードLbを示し、図3の(b)には、バイトコードLbから抽出された特徴情報Tbを示す。特徴情報Tbでは、左列に関数定義情報が記載され、右列に関数呼出順序情報が記載される。
次に、バイトコード特徴情報抽出部153の処理について説明する。図3は、プログラミング言語Javaで実装されたバイトコードと該バイトコードから抽出された特徴情報との一例を示す図である。図3の(a)には、一例としてバイトコードLbを示し、図3の(b)には、バイトコードLbから抽出された特徴情報Tbを示す。特徴情報Tbでは、左列に関数定義情報が記載され、右列に関数呼出順序情報が記載される。
バイトコード特徴情報抽出部153は、プログラムのバイトコードLbを入力とし、バイトコードを解析することによって、矢印Y21~Y24のように特徴情報Tbを抽出する。なお、バイトコード特徴情報抽出部153は、バイトコードから情報抽出を行う際には、例えば、ディスアセンブラ等を用いてバイトコードを可読テキスト形式に変換してから行ってもよい。
バイトコード特徴情報抽出部153は、バイトコードLb(図3の(a)参照)から、関数定義情報として、修飾子、戻り値の型、識別子、引数の型を抽出する。そして、バイトコード特徴情報抽出部153は、矢印Y21~Y24のように、抽出したそれぞれの関数定義情報を、特徴情報Tb(図3の(b)参照)の左列に順次記載する。また、バイトコード特徴情報抽出部153は、ソースコードLbから、関数呼出順序情報として、この関数内で実行される関数名を実行される順番で抽出する。そして、バイトコード特徴情報抽出部153は、矢印Y21~Y24のように、抽出したそれぞれの関数を、関数呼出順序情報として、特徴情報Tbの右列に、実行される順序で順次記載する。
例えば、バイトコード特徴情報抽出部153は、バイトコードLbの3~5行目から、修飾子(public)、戻り値の型(void)、識別子(init)、引数の型(int)を抽出し、矢印Y21のように、特徴情報TbのセルC11Bに関数定義情報として記載する。バイトコード特徴情報抽出部153は、バイトコードLbの3~5行目から、関数内で実行される関数名(init)を抽出し、矢印Y21のように、関数呼出順序情報として、特徴情報TbのセルC21Bに記載する。
ただし、バイトコード特徴情報抽出部153は、ソースコードの難読化処理または圧縮処理により、関数名が非常に短い場合、かつ、該関数の定義及び該関数の呼び出しを関連付けることができる場合に、該関数名を任意の関数名とみなし、情報を補う。そして、バイトコード特徴情報抽出部153は、補った任意の関数名を特徴データとして抽出している。
例えば、図3の(a)のバイトコードLbにおいて、難読化処理によりより関数名が“a”(18,22行目)となっている関数が存在する。この関数“a”は、関数“MethodB”(バイトコードLbの14行目)により呼び出されていることが分かる。この場合、バイトコード特徴情報抽出部153は、関数“a”の関数定義情報及び関数“MethodB”の関数呼出順序情報における関数名を“任意の値”としてみなす。
具体的には、バイトコード特徴情報抽出部153は、関数呼出順序情報として、18行目における関数“a”を“任意の値”とみなし、矢印Y23のように、関数“a”の順序に対応させて、特徴情報TbのセルC23Bの“[任意の値]”を記載する。また、バイトコード特徴情報抽出部153は、関数定義情報として、22行目における関数“a”を“任意の値”とみなし、矢印Y24のように、特徴情報TbのセルC14Bに“[任意の値]”を記載する。
なお、ソースコード特徴情報抽出部152及びバイトコード特徴情報抽出部153において、関数定義情報及び関数呼出順序情報を得ることができるならば、解析対象を、ソースコードまたはバイトコードに限定せずともよい。
また、特徴情報抽出部151は、特徴情報として抽出する対象を、ソースコード内及びバイトコード内の関数に限定しなくともよい。例えば、特徴情報抽出部151は、ソースコード及びバイトコードから、クラスやインタフェース等のプログラムを特徴付ける情報から、特徴情報を抽出してもよい。
[類似度算出部の処理]
次に、類似度算出部154の処理について説明する。類似度算出部154は、特徴情報抽出部151から抽出した二つの解析対象の特徴情報を入力とし、該二つの特徴情報におけるソースコード内の関数とバイトコード内の関数との類似度をそれぞれ算出する。前述したように、二つの特徴情報は、関数定義情報及び関数呼出順序情報である。
次に、類似度算出部154の処理について説明する。類似度算出部154は、特徴情報抽出部151から抽出した二つの解析対象の特徴情報を入力とし、該二つの特徴情報におけるソースコード内の関数とバイトコード内の関数との類似度をそれぞれ算出する。前述したように、二つの特徴情報は、関数定義情報及び関数呼出順序情報である。
まず、類似度算出部154が、二つの特徴情報のうちの関数定義情報を用いて、関数定義の同一性を考慮した類似度を算出する場合について説明する。この場合、類似度算出部154は、ソースコードとバイトコードとにおける、修飾子、識別子、戻り値の型、引数の型がそれぞれ一致しているかを比較することによって、関数定義の同一性を考慮した類似度を算出する。
具体的に、図2の(b)におけるソースコードLaの関数“MethodA”と、図3の(b)におけるバイトコードLbの関数“MethodA”との関数定義情報の類似度を算出する場合について説明する。図2の(b)の特徴情報TaにおけるセルC12Aに示すように、関数“MethodA”については、修飾子が“public”、戻り値の型が“void”、識別子が“MethodA”、引数の型が“String”である。一方、図3の(b)の特徴情報TbにおけるセルC12Bに示すように、関数“MethodA”については、修飾子が“public”、戻り値の型が“void”、識別子が“MethodA”、引数の型が“String”である。したがって、図2の(b)における関数“MethodA”と、図3の(b)における関数“MethodA”とでは、修飾子、識別子、戻り値の型、引数の型の四つの関数定義情報の全てが一致している。このため、類似度算出部154は、類似度として、「4/4=1」を算出する。
また、図2の(b)におけるソースコードLaの関数“MethodA”と、図3の(b)におけるバイトコードLbの関数“MethodB”との関数定義情報の類似度を算出する場合について説明する。この場合、図2の(b)の特徴情報TaにおけるセルC12Aに示すように、関数“MethodA”については、修飾子が“public”、戻り値の型が“void”、識別子が“MethodA”、引数の型が“String”である。一方、図3の(b)の特徴情報TbにおけるセルC13Bに示すように、関数“MethodB”については、修飾子が“private”、戻り値の型が“void”、識別子が“MethodB”、引数の型が“void”である。したがって、図2の(b)における関数“MethodA”と図3の(b)における“MethodB”とでは、四つの関数定義情報のうち戻り値の型のみが一致している。このため、類似度算出部154は、類似度として、「1/4=0.25」を算出する。
なお、類似度算出部154は、関数定義の同一性を考慮した類似度を算出する場合、特徴情報抽出部151によって抽出された関数定義情報の種類ごとに適宜重みをつけることによって、関数定義情報の種類の優先度を変更することもできる。もちろん、類似度算出部154は、このような重みづけを行わずともよい。
次に、類似度算出部154が、二つの特徴情報のうちの関数呼出順序情報を用いて、ソースコード内の関数とバイトコード内の関数とにおける類似度を算出する場合について説明する。この場合、類似度算出部154は、特徴情報中の関数呼出順序情報に、編集距離や最長共通部分列等といったアルゴリズムを適用することによって、ソースコード内の関数とバイトコード内の関数とにおける、関数呼出順序の部分的なシーケンスを考慮した類似度を算出する。
まず、類似度算出部154が、関数呼出順序情報を用いて、ソースコード内の関数とバイトコード内の関数とにおける、編集距離を算出する場合について説明する。例えば、図2の(b)におけるソースコードLaの関数“MethodA”と、図3の(b)におけるバイトコードLbの関数“MethodC”の編集距離を算出する場合を例に説明する。なお、図3の(b)について、バイトコードLbの関数“MethodC”は、難読化処理によって関数名が“a”となっている。そして、前述したように、この関数“a”は、図3の(b)のセルC23Bに示すように、関数呼出順序情報における関数名が“[任意の値]”としてみなされている。
そして、本実施の形態では、各手順のコストが予め定められている。例えば、置換に対するコストが2であり、削除に対するコストは1である。この例では、類似度算出部154は、図2の(b)における関数“MethodA”(セルC12A)の関数呼出順序(セルC22A)を、図3の(b)における関数“MethodC”(セルC14B)の関数呼出順序(セルC24B)に一致させるまでに、置換手順(コスト2)が1回、削除手順(コスト1)が2回必要である。
そして、類似度算出部154は、コストと手順回数との乗算の総和を編集距離として算出する。したがって、類似度算出部154は、「2×1+1×2=4」を、編集距離として算出する。なお、編集距離においては編集距離の値が小さい程、系列の類似度が高いことを表す。
次に、関数呼出順序情報を用いて、ソースコード内の関数とバイトコード内の関数とにおける、最長共通部分列を算出する場合について説明する。例えば、図2の(b)におけるソースコードLaの関数“MethodB”と、図3の(b)におけるバイトコードLbの関数“MethodA”との最長共通部分列の値を算出する場合を例に説明する。
まず、類似度算出部154は、図2の(b)におけるソースコードLaの関数“MethodB”の関数呼出順序(セルC23A)と、図3の(b)におけるバイトコードLbの関数“MethodA”の関数呼出順序(セルC22B)とを比較する。続いて、類似度算出部154は、ソースコードLaの関数“MethodB”の関数呼出順序(セルC23A)と、バイトコードLbの関数“MethodA”の関数呼出順序(セルC22B)とにおいて、共通する関数呼出順序の部分列であって最長の部分列を求める。そして、類似度算出部154は、求めた部分列の長さを類似度として求める。
この場合には、ソースコードLaの関数“MethodB”の関数呼出順序(セルC23A)と、バイトコードLbの関数“MethodA”の関数呼出順序(セルC22B)とでは、共通する関数呼出順序の部分列であって最長の部分列は、“println()→send()”の二つの部分列である。そして、この“println()→send()”の最長共通部分列の長さは、2となる。したがって、類似度算出部154は、ソースコードLaの関数“MethodB”の関数呼出順序(セルC23A)と、バイトコードLbの関数“MethodA”の関数呼出順序(セルC22B)とに対し、関数呼出順序の部分的なシーケンスを考慮した類似度として、2を算出する。なお、最長共通部分列を用いた類似度は、値が大きい程、系列の類似度が高いことを示す。
また、類似度算出部154は、上述のように算出した関数定義情報や関数呼出順序情報を用いた類似度に適宜重み付けを行うことによって、特徴の優先度を変更することもできる。もちろん、類似度算出部154は、このような重みづけを行わずともよい。
[判定部の処理]
次に、判定部155の処理について説明する。判定部155は、類似度算出部154によって算出された類似度に基づいて、プログラムが特定のソースコードを使用して生成されているか否かを判定する。ここでは、判定部155が、一つのソースコードと一つのバイトコードとを入力データとして、これらの類似度を判定する場合について説明する。
次に、判定部155の処理について説明する。判定部155は、類似度算出部154によって算出された類似度に基づいて、プログラムが特定のソースコードを使用して生成されているか否かを判定する。ここでは、判定部155が、一つのソースコードと一つのバイトコードとを入力データとして、これらの類似度を判定する場合について説明する。
具体的には、予め、判定において使用する任意の閾値を、二つの類似度のそれぞれに対して設定しておく。二つの類似度は、上述したように、関数定義情報に基づく類似度、及び、関数呼出順序情報に基づく類似度である。そして、判定部155は、ソースコードの関数に対する二つの類似度と、バイトコードの関数に対する二つの類似度とにおいて、いずれも閾値以上となる類似度を有する関数の組み合わせが存在した場合、バイトコード中の関数が、比較対象のソースコードの関数部分を用いて実装されたと判定する。
また、判定装置10では、予め、関数定義情報の同一性を考慮した類似度、関数呼出順序情報に基づく類似度である編集距離及び最長共通部分列の三つの類似度について、類似度算出部154が算出する三つの類似度の組み合わせを予め設定しておいてもよい。そして、判定装置10では、これらの組み合わせごとに、プログラムが特定のソースコードを使用して生成されていると判定できる旨、或いは、プログラムが特定のソースコードを使用して生成されていないと判定できる旨、を対応付けた判定用テーブルを設定してもよい。この場合、判定部155は、この判定用テーブルを参照し、類似度算出部154が算出した三つの類似度の組み合わせに対応する判定内容を用いて、判定を行ってもよい。
また、判定部155による判定処理は、個々の関数同士の類似度にそれぞれ閾値を設けて判定する処理に限らない。例えば、判定装置10では、バイトコード中の特定のクラスに含まれる関数群と、ソースコードに含まれる関数群との類似度算出結果の合算値に対して閾値を設定する。そして、判定部155は、合算値が閾値を超えているかを基に、クラスごとに、このバイトコードが比較対象のソースコードを用いて実装されたか否かを判定してもよい。もちろん、判定装置10では、予め設定された所定の演算式に各類似度を適用した場合の演算値に対する閾値を設定し、判定部155は、各類似度をこの演算式に適用した際の演算値と、閾値との比較結果を基に判定を行ってもよい。
また、判定部155が、関数定義情報の同一性を考慮した類似度、及び、関数呼出順序情報に基づく類似度である編集距離、最長共通部分列の三つの類似度に基づいて判定を行う場合について説明したが、もちろんこれに限らない。判定部155は、比較対象のソースコードが、単一の関数のみで短い場合には、三つの類似度のうちの一つ或いは二つの類似度に基づいて判定を行ってもよい。例えば、判定部155は、比較対象のソースコードが短い場合には、関数定義情報の同一性を考慮した類似度のみを用いて判定を行ってもよい。
また、本実施の形態に係る判定装置10では、一つのソースコードと一つのバイトコードとを入力とし、その類似度を判定する手順を説明したが、もちろん、これに限らない。判定装置10は、複数のソースコードと複数のバイトコードとを入力とし、算出した類似度に基づき、いずれかのバイトコードがいずれかのソースコードを用いて実装していることを判定してもよい。
[判定装置における処理手順]
次に、図4を参照して、判定装置10における処理手順の一例について説明する。図4は、図1に示す判定装置10による判定処理の処理手順を示すフローチャートである。
次に、図4を参照して、判定装置10における処理手順の一例について説明する。図4は、図1に示す判定装置10による判定処理の処理手順を示すフローチャートである。
まず、ソースコード特徴情報抽出部152は、入力されたソースコードから特徴情報を抽出するソースコード特徴情報抽出処理を行う(ステップS1)。また、バイトコード特徴情報抽出部153は、プログラムのバイトコードから特徴情報を抽出するバイトコード特徴情報抽出処理を行う(ステップS2)。なお、ステップS1及びステップS2は、並列処理でもよいし、どちらが先に処理されてもよい。
続いて、類似度算出部154は、ソースコードから抽出された特徴情報及びバイトコードから抽出された特徴情報に基づき、バイトコード、ソースコードのそれぞれに含まれる関数同士の類似度を算出する類似度算出処理を行う(ステップS3)。
そして、判定部155は、類似度算出処理において算出された類似度と任意の閾値とに基づき、入力されたソースコードがバイトコード(プログラム)に含まれているか否かを判定する判定処理を行う(ステップS4)。言い換えると、判定部155は、類似度算出処理において算出された類似度と任意の閾値とに基づき、プログラムが、入力された特定のソースコードを使用して生成されているか否かを判定する。
[ソースコード特徴情報抽出処理の処理手順]
図5は、図4に示すソースコード特徴情報抽出処理の処理手順を示すフローチャートである。なお、図5では、比較対象のソースコードが複数のクラス定義を含んでいない場合を想定している。
図5は、図4に示すソースコード特徴情報抽出処理の処理手順を示すフローチャートである。なお、図5では、比較対象のソースコードが複数のクラス定義を含んでいない場合を想定している。
まず、ソースコード特徴情報抽出部152は、ソースコード内に記述されている全関数を抽出する処理を行う(ステップS11)。そして、ソースコード特徴情報抽出部152は、ステップS11において抽出した関数のうち、特徴情報の抽出を行っていない特徴未抽出の関数を選択する(ステップS12)。続いて、ソースコード特徴情報抽出部152は、この選択した関数の関数定義情報を抽出する(ステップS13)。そして、ソースコード特徴情報抽出部152は、この選択した関数の実装内における関数呼出順序情報を抽出する(ステップS14)。
続いて、ソースコード特徴情報抽出部152は、ステップS11において抽出したすべての関数から特徴情報を抽出したか否かを判断する(ステップS15)。ソースコード特徴情報抽出部152は、ステップS11において抽出したすべての関数から特徴情報を抽出したと判断した場合(ステップS15:Yes)、ソースコード特徴情報抽出処理を終了する。一方、ソースコード特徴情報抽出部152は、ステップS11において抽出したすべての関数から特徴情報を抽出していないと判断した場合(ステップS15:No)、ステップS12に戻り、特徴未抽出の関数を選択し、ステップS13以降の処理を実行する。
[バイトコード特徴情報抽出処理の処理手順]
図6は、図4に示すバイトコード特徴情報抽出処理の処理手順を示すフローチャートである。なお、図6では、判定対象のバイトコードが複数のクラス定義を含んでいる場合を想定し、説明する。
図6は、図4に示すバイトコード特徴情報抽出処理の処理手順を示すフローチャートである。なお、図6では、判定対象のバイトコードが複数のクラス定義を含んでいる場合を想定し、説明する。
バイトコード特徴情報抽出部153は、入力されたバイトコードについて、バイトコードに記述されているすべてのクラスを抽出する(ステップS21)。バイトコード特徴情報抽出部153は、抽出したクラスのうち、未解析クラスを選択し(ステップS22)、選択したクラス内の全関数を抽出する処理を行う(ステップS23)。なお、図6において、解析とは、関数定義情報及び関数呼出順序情報を特徴情報として抽出することをいう。
そして、バイトコード特徴情報抽出部153は、抽出した関数の内、特徴情報抽出を行っていない特徴未抽出の関数を選択し(ステップS24)、選択した関数の関数定義情報を抽出する(ステップS25)。続いて、バイトコード特徴情報抽出部153は、選択した関数の実装内における関数呼出順序情報を抽出する(ステップS26)。
バイトコード特徴情報抽出部153は、ステップS23において抽出した全ての関数から特徴情報の抽出を行ったか否かを判断する(ステップS27)。バイトコード特徴情報抽出部153は、ステップS23において抽出した全ての関数から特徴情報の抽出を行っていないと判断した場合(ステップS27:No)、ステップS24に戻り、特徴未抽出の関数の選択を行い、以降の処理を実行する。
これに対し、バイトコード特徴情報抽出部153は、ステップS23において抽出した全ての関数から特徴情報の抽出を行ったと判断した場合(ステップS27:Yes)、ステップS21において抽出したすべてのクラスを解析したか否かを判断する(ステップS28)。バイトコード特徴情報抽出部153は、抽出したすべてのクラスを解析していないと判断した場合には(ステップS28:No)、ステップS22に戻り、解析していないクラスの選択を実行する。一方、バイトコード特徴情報抽出部153は、抽出したすべてのクラスを解析したと判断した場合には(ステップS28:Yes)、バイトコード特徴情報抽出処理を終了する。
[類似度算出処理の処理手順]
図7は、図4に示す類似度算出処理の処理手順を示すフローチャートである。図7に示すように、類似度算出部154は、ソースコード内の全関数抽出処理(図5のステップS11)において抽出したソースコード内の関数一覧(関数群1とする。)を取得し、この関数群1から未解析関数(関数Aとする。)を選択する(ステップS31)。同様に、類似度算出部154は、バイトコードにおける選択クラス内の全関数抽出処理(図6のステップS23)において抽出した関数一覧(関数群2とする。)を取得し、この関数群2から未解析関数(関数Bとする。)を選択する(ステップS32)。なお、図7において、解析とは、関数Aと関数Bとの類似度を算出することをいう。
図7は、図4に示す類似度算出処理の処理手順を示すフローチャートである。図7に示すように、類似度算出部154は、ソースコード内の全関数抽出処理(図5のステップS11)において抽出したソースコード内の関数一覧(関数群1とする。)を取得し、この関数群1から未解析関数(関数Aとする。)を選択する(ステップS31)。同様に、類似度算出部154は、バイトコードにおける選択クラス内の全関数抽出処理(図6のステップS23)において抽出した関数一覧(関数群2とする。)を取得し、この関数群2から未解析関数(関数Bとする。)を選択する(ステップS32)。なお、図7において、解析とは、関数Aと関数Bとの類似度を算出することをいう。
次に、類似度算出部154は、ステップS31及びステップS32において選択した関数A及び関数Bのそれぞれの関数定義情報及び関数呼出順序情報を用いて、ソースコードの関数Aとバイトコードの関数Bとを比較し、類似度を算出する(ステップS33)。前述したように、類似度算出部154は、類似度として、関数定義の同一性を考慮した類似度と、関数呼出順序の部分的なシーケンスを考慮した類似度である編集距離及び最長共通部分列とを算出する。
そして、類似度算出部154は、ステップS32において取得した関数群2に含まれる関数をすべて比較したか否かを判断する(ステップS34)。類似度算出部154は、ステップS32において取得した関数群2に含まれる関数をすべて比較していないと判断した場合(ステップS34:No)、ステップS32に戻り、関数群2からの未解析関数の選択を行う。
これに対し、類似度算出部154は、ステップS32において取得した関数群2に含まれる関数をすべて比較したと判断した場合(ステップS34:Yes)、関数群1に含まれるすべての関数を比較したか否かを判断する(ステップS35)。そして、類似度算出部154は、関数群1に含まれるすべての関数を比較していないと判断した場合(ステップS35:No)、ステップS31に戻り、関数群1からの未解析関数を選択する。
一方、類似度算出部154は、関数群1に含まれるすべての関数を比較したと判断した場合(ステップS35:Yes)、類似度算出処理を終了する。判定部155は、類似度算出処理の出力として得られたソースコードに含まれる全関数と、バイトコードに含まれる全関数との類似度算出結果を用いて、判定対象プログラム(バイトコード)が、比較対象のソースコードを使用して生成されているか否かを判定する。例えば、判定部155は、前述したように、任意の閾値を用いて、類似度が閾値以上の関数の組み合わせが存在した場合、バイトコード中の関数が、比較対象のソースコードの関数部分を用いて実装されたと判定する。
[実施の形態の効果]
このように、本実施の形態では、入力されたソースコードとプログラムのバイトコードとのそれぞれから、関数を定義する情報である関数定義情報、及び、関数内で実行される関数名が実行される順序で記載された関数呼出順序情報を特徴情報として抽出する。そして、本実施の形態では、この特徴情報である関数定義情報及び関数呼出順序情報を用いて、ソースコード内の関数とバイトコード内の関数との類似度を算出する。
このように、本実施の形態では、入力されたソースコードとプログラムのバイトコードとのそれぞれから、関数を定義する情報である関数定義情報、及び、関数内で実行される関数名が実行される順序で記載された関数呼出順序情報を特徴情報として抽出する。そして、本実施の形態では、この特徴情報である関数定義情報及び関数呼出順序情報を用いて、ソースコード内の関数とバイトコード内の関数との類似度を算出する。
この関数定義情報及び関数呼出順序情報はデータ形式に限らず抽出可能であるため、本実施によれば、プログラムのバイトコードとソースコードとのデータ形式が異なる場合であっても、バイトコードとソースコードとのそれぞれから特徴情報を抽出できる。この結果、本実施の形態では、抽出した特徴情報を基に、ソースコード内の関数とバイトコード内の関数との類似度を適切に算出することができる。さらに、本実施の形態では、プログラムのバイトコードとソースコードとのデータ形式が異なる場合であっても、適切に算出された類似度を取得することができるため、プログラムが、特定のソースコードを使用して生成されているか否かを正確に判定することができるという効果を奏する。
また、本実施の形態では、特徴情報抽出部151は、ソースコードにおける変数の型情報或いはパッケージ構造の情報が欠落している場合には、欠落している部分を任意の変数、任意の型或いは任意のパッケージ構造の情報とみなして、特徴情報を抽出している。さらに、本実施の形態では、特徴情報抽出部151は、バイトコード中の関数の識別子が難読化されており、かつ、関数の定義及び関数の呼び出しを関連付けることができる場合には、関数の識別子を任意の文字列とみなして、特徴情報を抽出している。
このように、本実施の形態では、ソースコードが、情報が欠落した断片的なコードであっても、欠落している部分を補完する処理は、上述のような簡易な処理で足りる。また、本実施の形態では、バイトコード中の識別子が難読化されている場合も任意の文字列に置き換えるのみでよい。したがって、本実施の形態によれば、例えば、従来必要であったソースコードのコンパイルに必要な情報を補完するという煩雑な処理を行うこともない。
また、本実施の形態では、類似度算出部154は、関数定義情報として抽出された修飾子、識別子、引数の型或いは戻り値の型に基づいて類似度を算出するとともに、関数呼出順序情報に対して順序関係を考慮した比較アルゴリズムを適用して類似度を算出する。すなわち、本実施の形態では、複数種別の特徴情報のそれぞれに応じた類似度を複数算出する。したがって、本実施の形態では、複数の類似度を用いた判定処理を行うことができ、厳密な判定結果を得ることができる。そして、本実施の形態では、複数の類似度を用いることができるため、判定処理として様々な手法を選択することができ、判定処理内容を柔軟に設定することができる。
[システム構成等]
図示した各装置の各構成要素は機能概念的なものであり、必ずしも物理的に図示の如く構成されていることを要しない。すなわち、各装置の分散・統合の具体的形態は図示のものに限られず、その全部又は一部を、各種の負荷や使用状況等に応じて、任意の単位で機能的又は物理的に分散・統合して構成することができる。さらに、各装置にて行なわれる各処理機能は、その全部又は任意の一部が、CPU及び当該CPUにて解析実行されるプログラムにて実現され、あるいは、ワイヤードロジックによるハードウェアとして実現され得る。
図示した各装置の各構成要素は機能概念的なものであり、必ずしも物理的に図示の如く構成されていることを要しない。すなわち、各装置の分散・統合の具体的形態は図示のものに限られず、その全部又は一部を、各種の負荷や使用状況等に応じて、任意の単位で機能的又は物理的に分散・統合して構成することができる。さらに、各装置にて行なわれる各処理機能は、その全部又は任意の一部が、CPU及び当該CPUにて解析実行されるプログラムにて実現され、あるいは、ワイヤードロジックによるハードウェアとして実現され得る。
また、本実施形態において説明した各処理のうち、自動的に行われるものとして説明した処理の全部又は一部を手動的におこなうこともでき、あるいは、手動的におこなわれるものとして説明した処理の全部又は一部を公知の方法で自動的におこなうこともできる。この他、上記文書中や図面中で示した処理手順、制御手順、具体的名称、各種のデータやパラメータを含む情報については、特記する場合を除いて任意に変更することができる。
[プログラム]
図8は、プログラムが実行されることにより、判定装置10が実現されるコンピュータの一例を示す図である。コンピュータ1000は、例えば、メモリ1010、CPU1020を有する。また、コンピュータ1000は、ハードディスクドライブインタフェース1030、ディスクドライブインタフェース1040、シリアルポートインタフェース1050、ビデオアダプタ1060、ネットワークインタフェース1070を有する。これらの各部は、バス1080によって接続される。
図8は、プログラムが実行されることにより、判定装置10が実現されるコンピュータの一例を示す図である。コンピュータ1000は、例えば、メモリ1010、CPU1020を有する。また、コンピュータ1000は、ハードディスクドライブインタフェース1030、ディスクドライブインタフェース1040、シリアルポートインタフェース1050、ビデオアダプタ1060、ネットワークインタフェース1070を有する。これらの各部は、バス1080によって接続される。
メモリ1010は、ROM(Read Only Memory)1011及びRAM1012を含む。ROM1011は、例えば、BIOS(Basic Input Output System)等のブートプログラムを記憶する。ハードディスクドライブインタフェース1030は、ハードディスクドライブ1090に接続される。ディスクドライブインタフェース1040は、ディスクドライブ1100に接続される。例えば磁気ディスクや光ディスク等の着脱可能な記憶媒体が、ディスクドライブ1100に挿入される。シリアルポートインタフェース1050は、例えばマウス1110、キーボード1120に接続される。ビデオアダプタ1060は、例えばディスプレイ1130に接続される。
ハードディスクドライブ1090は、例えば、OS1091、アプリケーションプログラム1092、プログラムモジュール1093、プログラムデータ1094を記憶する。すなわち、判定装置10の各処理を規定するプログラムは、コンピュータ1000により実行可能なコードが記述されたプログラムモジュール1093として実装される。プログラムモジュール1093は、例えばハードディスクドライブ1090に記憶される。例えば、判定装置10における機能構成と同様の処理を実行するためのプログラムモジュール1093が、ハードディスクドライブ1090に記憶される。なお、ハードディスクドライブ1090は、SSD(Solid State Drive)により代替されてもよい。
また、上述した実施の形態の処理で用いられる設定データは、プログラムデータ1094として、例えばメモリ1010やハードディスクドライブ1090に記憶される。そして、CPU1020が、メモリ1010やハードディスクドライブ1090に記憶されたプログラムモジュール1093やプログラムデータ1094を必要に応じてRAM1012に読み出して実行する。
なお、プログラムモジュール1093やプログラムデータ1094は、ハードディスクドライブ1090に記憶される場合に限らず、例えば着脱可能な記憶媒体に記憶され、ディスクドライブ1100等を介してCPU1020によって読み出されてもよい。あるいは、プログラムモジュール1093及びプログラムデータ1094は、ネットワーク(LAN、WAN等)を介して接続された他のコンピュータに記憶されてもよい。そして、プログラムモジュール1093及びプログラムデータ1094は、他のコンピュータから、ネットワークインタフェース1070を介してCPU1020によって読み出されてもよい。
以上、本発明者によってなされた発明を適用した実施の形態について説明したが、本実施の形態による本発明の開示の一部をなす記述及び図面により本発明は限定されることはない。すなわち、本実施の形態に基づいて当業者等によりなされる他の実施の形態、実施例及び運用技術等は全て本発明の範疇に含まれる。
10 判定装置
11 入力部
12 出力部
13 通信部
14 記憶部
15 制御部
151 特徴情報抽出部
152 ソースコード特徴情報抽出部
153 バイトコード特徴情報抽出部
154 類似度算出部
155 判定部
11 入力部
12 出力部
13 通信部
14 記憶部
15 制御部
151 特徴情報抽出部
152 ソースコード特徴情報抽出部
153 バイトコード特徴情報抽出部
154 類似度算出部
155 判定部
Claims (8)
- 入力されたソースコードとプログラムのバイトコードとのそれぞれから、関数を定義する情報である関数定義情報、及び、関数内で実行される関数名が実行される順序で記載された関数呼出順序情報を特徴情報として抽出する特徴情報抽出部と、
前記特徴情報抽出部によって抽出された特徴情報を用いて、前記ソースコード内の関数と前記バイトコード内の関数との類似度を算出する類似度算出部と、
を有することを特徴とする判定装置。 - 前記類似度算出部によって算出された類似度に基づいて、前記プログラムが特定のソースコードを使用して生成されているか否かを判定する判定部をさらに有することを特徴とする請求項1に記載の判定装置。
- 前記特徴情報抽出部は、前記ソースコードにおける変数の型情報或いはパッケージ構造の情報が欠落している場合には、欠落している部分を任意の型或いは任意のパッケージ構造の情報とみなすことを特徴とする請求項1または2に記載の判定装置。
- 前記特徴情報抽出部は、前記バイトコード中の関数の識別子が難読化されており、かつ、前記関数の定義及び前記関数の呼び出しを関連付けることができる場合には、前記関数の識別子を任意の文字列とみなすことを特徴とする請求項1~3のいずれか一つに記載の判定装置。
- 前記特徴情報抽出部は、前記関数定義情報として、修飾子、識別子、引数及び戻り値の型を抽出し、
前記類似度算出部は、前記特徴情報抽出部によって抽出された修飾子、識別子、引数及び戻り値の型に基づいて前記類似度を算出することを特徴とする請求項1~4のいずれか一つに記載の判定装置。 - 前記類似度算出部は、前記特徴情報抽出部によって抽出された関数呼出順序情報に対して、順序関係を考慮した比較アルゴリズムを適用して前記類似度を算出することを特徴とする請求項1~5のいずれか一つに記載の判定装置。
- プログラムが特定のソースコードを使用して生成されているか否かを判定する判定装置が実行する判定方法であって、
入力された前記ソースコードと前記プログラムのバイトコードとのそれぞれから、関数を定義する情報である関数定義情報、及び、関数内で実行される関数名が実行される順序で記載された関数呼出順序情報を特徴情報として抽出する特徴情報抽出工程と、
前記特徴情報抽出工程において抽出された特徴情報を用いて、前記ソースコード内の関数と前記バイトコード内の関数との類似度を算出する類似度算出工程と、
前記類似度算出工程において算出された類似度に基づいて、前記プログラムが特定のソースコードを使用して生成されているか否かを判定する判定工程と、
を含んだことを特徴とする判定方法。 - 入力されたソースコードとプログラムのバイトコードとのそれぞれから、関数を定義する情報である関数定義情報、及び、関数内で実行される関数名が実行される順序で記載された関数呼出順序情報を特徴情報として抽出する特徴情報抽出ステップと、
前記特徴情報抽出ステップにおいて抽出された特徴情報を用いて、前記ソースコード内の関数と前記バイトコード内の関数との類似度を算出する類似度算出ステップと、
前記類似度算出ステップによって算出された類似度に基づいて、前記プログラムが特定のソースコードを使用して生成されているか否かを判定する判定ステップと、
をコンピュータに実行させるための判定プログラム。
Priority Applications (3)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
EP17885299.2A EP3540596B1 (en) | 2016-12-19 | 2017-08-23 | Determination device, determination method, and determination program |
US16/466,288 US20190391806A1 (en) | 2016-12-19 | 2017-08-23 | Determination apparatus, determination method, and determination program |
JP2018557527A JP6674048B2 (ja) | 2016-12-19 | 2017-08-23 | 判定装置、判定方法及び判定プログラム |
Applications Claiming Priority (2)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
JP2016-245768 | 2016-12-19 | ||
JP2016245768 | 2016-12-19 |
Publications (1)
Publication Number | Publication Date |
---|---|
WO2018116522A1 true WO2018116522A1 (ja) | 2018-06-28 |
Family
ID=62626113
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
PCT/JP2017/030038 WO2018116522A1 (ja) | 2016-12-19 | 2017-08-23 | 判定装置、判定方法及び判定プログラム |
Country Status (4)
Country | Link |
---|---|
US (1) | US20190391806A1 (ja) |
EP (1) | EP3540596B1 (ja) |
JP (1) | JP6674048B2 (ja) |
WO (1) | WO2018116522A1 (ja) |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN113469284A (zh) * | 2021-07-26 | 2021-10-01 | 浙江大华技术股份有限公司 | 一种数据分析的方法、装置及存储介质 |
Families Citing this family (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN112199115A (zh) * | 2020-09-21 | 2021-01-08 | 复旦大学 | 基于特征相似度匹配的跨Java字节码和源代码行关联方法 |
Citations (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
JP2012234401A (ja) * | 2011-05-02 | 2012-11-29 | Kddi Corp | アプリケーション解析装置およびプログラム |
WO2016027641A1 (ja) * | 2014-08-20 | 2016-02-25 | 日本電信電話株式会社 | 脆弱性発見装置、脆弱性発見方法、及び脆弱性発見プログラム |
Family Cites Families (8)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US5699507A (en) * | 1995-01-17 | 1997-12-16 | Lucent Technologies Inc. | Method of identifying similarities in code segments |
JPH11249875A (ja) * | 1998-02-26 | 1999-09-17 | Nec Ic Microcomput Syst Ltd | プログラミング支援方法及びその装置 |
JP3736308B2 (ja) * | 2000-07-14 | 2006-01-18 | 日本電気株式会社 | ソフトウェアコンポーネント自動生成システム |
EP2011099A4 (en) * | 2006-04-06 | 2013-08-21 | Juniper Networks Inc | SYSTEM AND METHOD FOR DETECTING MALICIELS FOR LIMIT ACCESS MOBILE PLATFORMS |
US8429628B2 (en) * | 2007-12-28 | 2013-04-23 | International Business Machines Corporation | System and method for comparing partially decompiled software |
US8407667B2 (en) * | 2009-03-20 | 2013-03-26 | Microsoft Corporation | Inferring missing type information for reflection |
US8539475B2 (en) * | 2009-09-29 | 2013-09-17 | Oracle America, Inc. | API backward compatibility checking |
JP6379654B2 (ja) * | 2014-05-15 | 2018-08-29 | 富士通株式会社 | 処理実行プログラム、処理実行方法、及び情報処理装置 |
-
2017
- 2017-08-23 US US16/466,288 patent/US20190391806A1/en not_active Abandoned
- 2017-08-23 WO PCT/JP2017/030038 patent/WO2018116522A1/ja unknown
- 2017-08-23 JP JP2018557527A patent/JP6674048B2/ja active Active
- 2017-08-23 EP EP17885299.2A patent/EP3540596B1/en active Active
Patent Citations (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
JP2012234401A (ja) * | 2011-05-02 | 2012-11-29 | Kddi Corp | アプリケーション解析装置およびプログラム |
WO2016027641A1 (ja) * | 2014-08-20 | 2016-02-25 | 日本電信電話株式会社 | 脆弱性発見装置、脆弱性発見方法、及び脆弱性発見プログラム |
Non-Patent Citations (3)
Title |
---|
HIROKI HADA ET AL.: "BinGrep: Proposing the Efficient Static Analysis Method by Searching for the Function Comparing Control Flow Graphs", PROCEEDINGS OF COMPUTER SECURITY SYMPOSIUM 2016, vol. 2016, no. 2, 4 October 2016 (2016-10-04), pages 676 - 683, XP009515820 * |
J. CRUSSELLC. GIBLERH. CHEN: "Attack of the Clones: Detecting Cloned Applications on Android Markets", PROCEEDINGS OF THE EUROPEAN SYMPOSIUM ON RESEARCH IN COMPUTER SECURITY (ESORICS, 2012, pages 37 - 54 |
W. ZHOUY. ZHOUX. JIANGP. NING: "Detecting Repackaged Smartphone Applications in Third-Party Android Marketplaces", PROCEEDINGS OF THE ACM CONFERENCE DATA APPLICATION SECURITY PRIVACY (CODASPY, 2012, pages 317 - 326 |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN113469284A (zh) * | 2021-07-26 | 2021-10-01 | 浙江大华技术股份有限公司 | 一种数据分析的方法、装置及存储介质 |
Also Published As
Publication number | Publication date |
---|---|
JP6674048B2 (ja) | 2020-04-01 |
EP3540596B1 (en) | 2021-05-19 |
US20190391806A1 (en) | 2019-12-26 |
JPWO2018116522A1 (ja) | 2019-03-22 |
EP3540596A1 (en) | 2019-09-18 |
EP3540596A4 (en) | 2020-06-17 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US11740876B2 (en) | Method and system for arbitrary-granularity execution clone detection | |
Rahimian et al. | Bincomp: A stratified approach to compiler provenance attribution | |
US7975256B2 (en) | Optimizing application performance through data mining | |
JP7115552B2 (ja) | 解析機能付与装置、解析機能付与方法及び解析機能付与プログラム | |
US10747880B2 (en) | System and method for identifying and comparing code by semantic abstractions | |
CN110825363B (zh) | 智能合约获取方法、装置、电子设备及存储介质 | |
KR20170068814A (ko) | 악성 모바일 앱 감지 장치 및 방법 | |
WO2017015071A1 (en) | Incremental interprocedural dataflow analysis during compilation | |
CN106529224A (zh) | 基于rop攻击特点的二进制混淆方法 | |
Buinevich et al. | Testing of utilities for finding vulnerabilities in the machine code of telecommunication devices | |
US10409572B2 (en) | Compiled file normalization | |
JP2018005890A (ja) | 未知のプログラムバイナリのための入力発見 | |
US20220398308A1 (en) | Methods and Systems for Securing a Build Execution Pipeline | |
US12001325B2 (en) | Test data generation apparatus, test data generation method and program | |
JP2015179312A (ja) | 情報処理装置、情報処理方法およびプログラム | |
JP6674048B2 (ja) | 判定装置、判定方法及び判定プログラム | |
Cheers et al. | A novel approach for detecting logic similarity in plagiarised source code | |
EP3570173A1 (en) | Equivalence checking device and equivalence checking program | |
CN117909984A (zh) | 基于相似性分析的实时操作系统驱动漏洞挖掘系统及方法 | |
WO2016189721A1 (ja) | ソースコード評価装置及びソースコード評価方法及びソースコード評価プログラム | |
Alrabaee et al. | Compiler provenance attribution | |
Nep et al. | A research on countering virtual machine evasion techniques of malware in dynamic analysis | |
García-Díaz et al. | MCTest: towards an improvement of match algorithms for models | |
US12189788B2 (en) | Identifying and addressing potential vulnerabilities in third-party code | |
JP7620248B2 (ja) | パターン抽出可視化装置及びパターン抽出可視化方法並びにパターン抽出可視化プログラム |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
ENP | Entry into the national phase |
Ref document number: 2018557527 Country of ref document: JP Kind code of ref document: A |
|
121 | Ep: the epo has been informed by wipo that ep was designated in this application |
Ref document number: 17885299 Country of ref document: EP Kind code of ref document: A1 |
|
NENP | Non-entry into the national phase |
Ref country code: DE |
|
ENP | Entry into the national phase |
Ref document number: 2017885299 Country of ref document: EP Effective date: 20190612 |