KR102608014B1 - Device and method for predicting stripped binary function symbols - Google Patents

Device and method for predicting stripped binary function symbols Download PDF

Info

Publication number
KR102608014B1
KR102608014B1 KR1020210170615A KR20210170615A KR102608014B1 KR 102608014 B1 KR102608014 B1 KR 102608014B1 KR 1020210170615 A KR1020210170615 A KR 1020210170615A KR 20210170615 A KR20210170615 A KR 20210170615A KR 102608014 B1 KR102608014 B1 KR 102608014B1
Authority
KR
South Korea
Prior art keywords
function
vector
sentence
neural network
code fragment
Prior art date
Application number
KR1020210170615A
Other languages
Korean (ko)
Other versions
KR20220077894A (en
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 한양대학교 에리카산학협력단
Publication of KR20220077894A publication Critical patent/KR20220077894A/en
Application granted granted Critical
Publication of KR102608014B1 publication Critical patent/KR102608014B1/en

Links

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/55Detecting local intrusion or implementing counter-measures
    • G06F21/56Computer malware detection or handling, e.g. anti-virus arrangements
    • G06F21/562Static detection
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/10Text processing
    • G06F40/12Use of codes for handling textual entities
    • G06F40/151Transformation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/53Decompilation; Disassembly
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N20/00Machine learning

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • General Physics & Mathematics (AREA)
  • Physics & Mathematics (AREA)
  • Computer Security & Cryptography (AREA)
  • General Health & Medical Sciences (AREA)
  • Health & Medical Sciences (AREA)
  • Artificial Intelligence (AREA)
  • Computer Hardware Design (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • Data Mining & Analysis (AREA)
  • Evolutionary Computation (AREA)
  • Medical Informatics (AREA)
  • Computing Systems (AREA)
  • Mathematical Physics (AREA)
  • Audiology, Speech & Language Pathology (AREA)
  • Computational Linguistics (AREA)
  • Virology (AREA)
  • Machine Translation (AREA)

Abstract

본 발명은 스트립트 바이너리 함수 심볼 예측 방법 및 그 장치에 관한 발명이다. 본 발명의 일 실시예에 따른 함수 심볼 예측 방법은, 타겟함수에 관한 제1 소스코드에서 함수호출 및 함수호출 인자를 추출하여 제1 코드조각을 획득하는 단계; 상기 제1 소스코스보다 업데이트된 제2 소스코드에서 함수호출 및 함수호출 인자를 추출하여 제2 코드조각을 획득하는 단계; 상기 제1 코드조각 및 상기 제2 코드조각을 각각 제1 문장 및 제2 문장으로 변환하는 단계; 상기 제1 문장 및 상기 제2 문장을 바탕으로 워드 임베딩(word embedding) 모델을 이용하여 각각 제1 벡터 및 제2 벡터를 획득하는 단계; 상기 제1 벡터 및 상기 제2 벡터를 순차적으로 입력하여 신경망을 학습시키는 단계; 스트립트 바이너리(strriped binary)에서 제3 코드조각을 획득하는 단계; 상기 제3 코드조각을 제3 문장으로 변환하는 단계; 상기 제3 문장을 바탕으로 상기 워드 임베딩 모델을 이용하여 제3 벡터를 획득하는 단계; 및 상기 제3 벡터를 상기 학습된 신경망에 입력하여 출력된 결과를 상기 제3 코드조각에 해당하는 함수 심볼로 획득하는 단계; 를 포함할 수 있다. The present invention relates to a script binary function symbol prediction method and device. A function symbol prediction method according to an embodiment of the present invention includes the steps of extracting a function call and a function call argument from a first source code for a target function to obtain a first code fragment; Obtaining a second code fragment by extracting a function call and a function call argument from a second source code that is more updated than the first source code; Converting the first code fragment and the second code fragment into a first sentence and a second sentence, respectively; Obtaining a first vector and a second vector, respectively, using a word embedding model based on the first sentence and the second sentence; learning a neural network by sequentially inputting the first vector and the second vector; Obtaining a third code fragment from a stripped binary; converting the third code fragment into a third sentence; Obtaining a third vector using the word embedding model based on the third sentence; And inputting the third vector into the learned neural network and obtaining the output result as a function symbol corresponding to the third code fragment; may include.

Description

스트립트 바이너리 함수 심볼 예측 방법 및 그 장치{DEVICE AND METHOD FOR PREDICTING STRIPPED BINARY FUNCTION SYMBOLS}Script binary function symbol prediction method and device {DEVICE AND METHOD FOR PREDICTING STRIPPED BINARY FUNCTION SYMBOLS}

본 발명은 스트립트 바이너리(stripped binary) 함수 심볼 예측 방법 및 그 장치에 관한 발명이다. 보다 자세하게는 함수 심볼 정보가 삭제된 스트립트 바이너리 파일에서 함수의 심볼을 신경망 학습을 통하여 예측하는 방법 및 그 장치에 관한 것이다.The present invention relates to a stripped binary function symbol prediction method and device. More specifically, it relates to a method and device for predicting function symbols in a script binary file from which function symbol information has been deleted through neural network learning.

함수는 프로그래밍 언어에서 가장 일반적인 구조 중 하나다. 함수의 정의와 선언은 소스코드에서 명시적이지만 바이너리에서는 컴파일과정에서 많은 정보가 손실되었다. 그러나 많은 바이너리 분석기술에는 함수 정보가 필요하다. Functions are one of the most common structures in programming languages. Although function definitions and declarations are explicit in the source code, much information is lost in the binary during compilation. However, many binary analysis techniques require function information.

취약점탐지에서 어떤 함수가 사용되었는지 확인해야 되기 때문에 함수 심볼 예측기술이 많이 필요하다. 예로 들어, use-after-free 취약점은 해지된 함수 포인터를 다시 사용하여 잘못된 메모리 접근으로 인한 취약점이며 메모리 공간을 할당하는 malloc()함수와 해지 하는 함수 free()함수를 탐지하는 것 매우 중요하다. 이처럼 중요한 함수명이 탐지하지 못하면 취약점 탐지도 수행할 수 없다. Since it is necessary to check which functions are used in vulnerability detection, function symbol prediction technology is greatly needed. For example, the use-after-free vulnerability is a vulnerability caused by incorrect memory access by reusing a released function pointer, and it is very important to detect the malloc() function that allocates memory space and the free() function that frees it. If such an important function name cannot be detected, vulnerability detection cannot be performed.

그리고 디컴파일 분야에도 스트립트 바이너리에서 함수 심볼을 예측하는 것이 필요하다. 디컴파일이란 컴파일된 바이너리 코드를 다시 사람이 이해할 수 있는 높은 수준의 코드로 변환해야 되기 때문에 제거된 심볼에 대한 예측이 가능해야 코드에서 어떤 함수를 호출했는지 알 수가 있으며 디컴파일 정확성 높다고 볼 수 있다. And in the decompilation field, it is also necessary to predict function symbols in script binaries. Since decompilation requires converting the compiled binary code back into a high-level code that humans can understand, it is necessary to be able to predict the removed symbols to know which function was called in the code, and the decompilation accuracy can be considered high.

또는 멀웨어, 악성코드 탐지 분야에서도 많이 필요하다. 대부분의 악성코드는 일반 프로그램과 차이가 없다. 그냥 봤을 때 정상적인 프로그램 코드로 본다. 실제로 악의적인 코드는 매우 작고 정상적인 코드에 숨겨져 있다. 그리고 탐지할 수 없게끔 함수의 심볼을 제거한다. 바이너리를 분석할 때 함수 심볼이 예측이 되면 어떤 함수를 사용했는지 알 수 있으며 악의적인 행위를 탐지에 많은 도움이 될 것이다.It is also widely needed in the field of malware and malicious code detection. Most malicious codes are no different from regular programs. When you just look at it, it looks like normal program code. In reality, malicious code is very small and hidden in normal code. Then, we remove the symbol of the function so that it cannot be detected. When analyzing a binary, if the function symbol is predicted, you can know which function was used and it will be very helpful in detecting malicious behavior.

관련 기술로 DEBIN이 가장 많이 사용되고 있다. 함수 심볼 예측의 큰 문제점은 바이너리에 서 심볼을 예측하기 위해 사용가능한 정보가 없다는 것이다. DEBIN에서는 심볼이 있는 바이너리를 대량으로 수집하여 구조적 또는 의미적으로 학습을 시켰다. 여기서 사용된 핵심적인 기술은 데이터 의존 그래프(data dependency graph)의 생성이며 각 함수에 사용된 변수들의 전후 의뢰 관계를 표현할 수 있는 기술이다. DEBIN is the most widely used related technology. A big problem with function symbol prediction is that there is no information available to predict symbols in the binary. DEBIN collected a large number of binaries with symbols and learned them structurally or semantically. The key technology used here is the creation of a data dependency graph, a technology that can express the context of the variables used in each function.

DEBIN은 디컴파일을 수행할 때 바이너리 입력을 받으면 해당 함수의 데이터 의존성을 분석하고 학습했던 소스코드에서도 유사한 의존 그래프를 가진 것 있으면 매핑을 해서 함수의 변수 또는 함수콜을 예측한다. 즉 먼저 심볼을 가진 함수의 데이터 의존 그래프와 심볼이 없는 함수의 데이터 의존 그래프를 비교 및 매핑을 한다. 매핑 한 다음에 함수 내부에 있는 변수 및 함수콜 정보 회복을 한다.When DEBIN receives binary input when performing decompilation, it analyzes the data dependency of the function and predicts the variable or function call of the function by mapping if there is a similar dependency graph in the learned source code. That is, first, the data dependence graph of a function with a symbol is compared and mapped to the data dependence graph of a function without a symbol. After mapping, the variable and function call information inside the function is recovered.

그러나 DEBIN을 비롯한 종래의 방법은 정확도가 평균 62.6%으로 높지 않았다. 그 이유는 기존 방법의 핵심내용은 바이너리에서 함수를 구조적으로 또는 의미적적으로 학습한 것이 함수호출 명령어의 컨텍스트를 학습한다는데 있다. 즉 함수호출 명령어의 위 명령어, 아래 명령어가 어떤 명령어인지 변수들이 어떻게 값을 전달된 그 구조를 학습하고, 이를 통해 특정 명령어 조합을 식별되면 특정한 함수로 예측한다. However, the accuracy of conventional methods including DEBIN was not high, with an average of 62.6%. The reason is that the core content of the existing method is that learning the function structurally or semantically in the binary learns the context of the function call instruction. In other words, it learns what commands are above and below the function call command and the structure of how the values are passed to the variables, and when a specific command combination is identified through this, it is predicted as a specific function.

이러한 방법으로는 기준 함수 데이터에서 존재한 패턴만 식별가능하며 중간에 사용된 인자나 파라미터가 변동 발생하면 식별하지 못 하는 문제가 있어 이를 극복할 수 있는 방법이 요구되고 있다.With this method, only patterns that exist in the reference function data can be identified, and there is a problem of not being able to identify if the used factors or parameters change in the middle, so a method to overcome this problem is required.

한국등록특허 제10-1228899호Korean Patent No. 10-1228899

본 발명이 해결하고자 하는 기술적 과제는 스트립트 바이너리 함수 심볼 예측 방법 및 그 장치를 제공하는 것이다.The technical problem to be solved by the present invention is to provide a method and device for predicting script binary function symbols.

본 발명이 해결하고자 하는 기술적 과제는 신경망 학습을 통한 함수 매칭을 바탕으로 스트립트 바이너리 함수 심볼 예측 방법 및 그 장치를 제공하는 것이다.The technical problem to be solved by the present invention is to provide a method and device for predicting script binary function symbols based on function matching through neural network learning.

본 발명의 기술적 과제들은 이상에서 언급한 기술적 과제들로 제한되지 않으며, 언급되지 않은 또 다른 기술적 과제들은 아래의 기재로부터 당업자에게 명확하게 이해 될 수 있을 것이다.The technical problems of the present invention are not limited to the technical problems mentioned above, and other technical problems not mentioned will be clearly understood by those skilled in the art from the description below.

상기 기술적 과제를 달성하기 위한 본 발명의 일 실시예에 따른 함수 심볼 예측 방법은, 타겟함수에 관한 제1 소스코드에서 함수호출 및 함수호출 인자를 추출하여 제1 코드조각을 획득하는 단계; 상기 제1 소스코스보다 업데이트된 제2 소스코드에서 함수호출 및 함수호출 인자를 추출하여 제2 코드조각을 획득하는 단계; 상기 제1 코드조각 및 상기 제2 코드조각을 각각 제1 문장 및 제2 문장으로 변환하는 단계; 상기 제1 문장 및 상기 제2 문장을 바탕으로 워드 임베딩(word embedding) 모델을 이용하여 각각 제1 벡터 및 제2 벡터를 획득하는 단계; 상기 제1 벡터 및 상기 제2 벡터를 순차적으로 입력하여 신경망을 학습시키는 단계; 스트립트 바이너리(stripped binary)에서 제3 코드조각을 획득하는 단계; 상기 제3 코드조각을 제3 문장으로 변환하는 단계; 상기 제3 문장을 바탕으로 상기 워드 임베딩 모델을 이용하여 제3 벡터를 획득하는 단계; 및 상기 제3 벡터를 상기 학습된 신경망에 입력하여 출력된 결과를 상기 제3 코드조각에 해당하는 함수 심볼로 획득하는 단계; 를 포함할 수 있다.A function symbol prediction method according to an embodiment of the present invention for achieving the above technical problem includes the steps of extracting a function call and a function call argument from a first source code for a target function to obtain a first code fragment; Obtaining a second code fragment by extracting a function call and a function call argument from a second source code that is more updated than the first source code; Converting the first code fragment and the second code fragment into a first sentence and a second sentence, respectively; Obtaining a first vector and a second vector, respectively, using a word embedding model based on the first sentence and the second sentence; learning a neural network by sequentially inputting the first vector and the second vector; Obtaining a third code fragment from a stripped binary; converting the third code fragment into a third sentence; Obtaining a third vector using the word embedding model based on the third sentence; And inputting the third vector into the learned neural network and obtaining the output result as a function symbol corresponding to the third code fragment; may include.

상기와 같은 본 발명에 따르면, 소스코드 또는 심볼을 가진 바이너리를 바탕으로 함수 내용을 문장으로 만들고 이를 벡터화한 후 상기 벡터를 바탕으로 신경망을 학습시킴으로써, 종래의 함수 패턴에 기반하여 스트립트 바이너리의 함수 심볼을 예측하는 것에 비하여 정확도를 향상시킬 수 있는 효과가 있다.According to the present invention as described above, the function content is made into a sentence based on a binary with source code or symbols, vectorized, and then trained a neural network based on the vector, thereby converting the function symbol of the script binary based on the conventional function pattern. There is an effect of improving accuracy compared to predicting.

도 1은 본 발명의 일 실시예에 따른, 스트립트 바이너리 함수의 디컴파일 예시이다.
도 2는 본 발명의 일 실시예에 따른, 함수 심볼 예측 장치의 구성도이다.
도 3은 본 발명의 일 실시예에 따른, 제1 소스코드에서 제1 코드조각 및 제1 문장을 추출하는 과정을 나타내는 예시이다.
도 4은 본 발명의 일 실시예에 따른, 제2 소스코드에서 제2 코드조각 및 제2 문장을 추출하는 과정을 나타내는 예시이다.
도 5는 본 발명의 일 실시예에 따른, 워드 임베딩 중에서 Word2Vec의 알고리즘 모델이다.
도 6은 본 발명의 일 실시예에 따른, 신경망의 일종인 GRU(Gated Recurrent Unit)의 알고리즘 모델이다.
도 7은 본 발명의 일 실시예에 따른, 스트립트 바이너리의 디컴파일된 함수를 이용한 함수 심볼 예측을 설명하기 위한 예시이다.
도 8은 본 발명의 일 실시예에 따른, 함수 심볼 예측 방법의 순서도이다.
1 is an example of decompilation of a script binary function according to an embodiment of the present invention.
Figure 2 is a configuration diagram of a function symbol prediction device according to an embodiment of the present invention.
Figure 3 is an example showing the process of extracting the first code fragment and the first sentence from the first source code according to an embodiment of the present invention.
Figure 4 is an example showing the process of extracting a second code fragment and a second sentence from a second source code according to an embodiment of the present invention.
Figure 5 is an algorithm model of Word2Vec among word embeddings, according to an embodiment of the present invention.
Figure 6 is an algorithm model of GRU (Gated Recurrent Unit), a type of neural network, according to an embodiment of the present invention.
Figure 7 is an example to explain function symbol prediction using a decompiled function of a script binary, according to an embodiment of the present invention.
Figure 8 is a flowchart of a function symbol prediction method according to an embodiment of the present invention.

이하, 첨부된 도면을 참조하여 본 발명의 바람직한 실시예를 상세히 설명한다. 본 발명의 이점 및 특징, 그리고 그것들을 달성하는 방법은 첨부되는 도면과 함께 상세하게 후술되어 있는 실시 예들을 참조하면 명확해질 것이다. 그러나 본 발명은 이하에서 게시되는 실시 예들에 한정되는 것이 아니라 서로 다른 다양한 형태로 구현될 수 있으며, 단지 본 실시 예들은 본 발명의 게시가 완전하도록 하고, 본 발명이 속하는 기술분야에서 통상의 지식을 가진 자에게 발명의 범주를 완전하게 알려주기 위해 제공되는 것이며, 본 발명은 청구항의 범주에 의해 정의될 뿐이다. 명세서 전체에 걸쳐 동일 참조 부호는 동일 구성 요소를 지칭한다.Hereinafter, preferred embodiments of the present invention will be described in detail with reference to the attached drawings. The advantages and features of the present invention and methods for achieving them will become clear by referring to the embodiments described in detail below along with the accompanying drawings. However, the present invention is not limited to the embodiments disclosed below and may be implemented in various different forms. The present embodiments are merely intended to ensure that the disclosure of the present invention is complete and to provide common knowledge in the technical field to which the present invention pertains. It is provided to fully inform those who have the scope of the invention, and the present invention is only defined by the scope of the claims. Like reference numerals refer to like elements throughout the specification.

다른 정의가 없다면, 본 명세서에서 사용되는 모든 용어(기술 및 과학적 용어를 포함)는 본 발명이 속하는 기술분야에서 통상의 지식을 가진 자에게 공통적으로 이해될 수 있는 의미로 사용될 수 있을 것이다. 또 일반적으로 사용되는 사전에 정의되어 있는 용어들은 명백하게 특별히 정의되어 있지 않는 한 이상적으로 또는 과도하게 해석되지 않는다.Unless otherwise defined, all terms (including technical and scientific terms) used in this specification may be used with meanings that can be commonly understood by those skilled in the art to which the present invention pertains. Additionally, terms defined in commonly used dictionaries are not interpreted ideally or excessively unless clearly specifically defined.

도 1은 본 발명의 일 실시예에 따른, 스트립트 바이너리 함수의 디컴파일 예시이다.1 is an example of decompilation of a script binary function according to an embodiment of the present invention.

도 1을 참조하면, 함수 심볼 정보가 있는 바이너리를 디컴파일한 소스코드(10)에는 함수 심볼(symbol)이 포함되어 있다. Referring to FIG. 1, the source code 10 decompiled from the binary containing function symbol information includes function symbols.

이하의 설명에서 설명의 편의를 위하여, 함수명과 함수 심볼은 동일한 의미로 사용한다.For convenience of explanation, in the following description, function names and function symbols are used with the same meaning.

소스 코드(source code)는 c언어, java, C++, C# 등의 프로그래밍(programming language)로 작성될 수 있으며, 이하의 설명에서 사용하는 소스 코드는 슈도코드(pseudocode)이며 어느 한 언어에 한정되지 않는다.Source code can be written in a programming language such as C, java, C++, or C#, and the source code used in the following description is pseudocode and is not limited to any one language. .

일반적으로 컴파일러(compiler)는 소스코드를 바이너리로 변환할 때 디버깅(debugging) 등에 활용하기 위해 함수의 심볼에 관한 정보를 바이너리에 포함시킨다. 그러나 바이너리의 용량을 줄이거나, 디컴파일을 방지하기 위한 목적으로 함수 심볼에 관한 정보를 제거하여 컴파일 할 수도 있다. 또는 악성 코드들은 자신의 정보를 숨기기 위하여 함수 심볼 정보를 제거할 수 있다.Generally, when converting source code into binary, a compiler includes information about function symbols in the binary for use in debugging, etc. However, in order to reduce the size of the binary or prevent decompilation, it may be compiled by removing information about function symbols. Alternatively, malicious codes may remove function symbol information to hide their own information.

함수 심볼에 관한 정보가 제거된 바이너리를 스트립트 바이너리(stripped binary) 라고 한다.A binary from which information about function symbols has been removed is called a stripped binary.

도 1을 참조하면, 스트립트 바이너리를 디컴파일한 소스 코드(20)는 함수 심볼에 관한 정보가 없기 때문에 함수명이 “sub_80534BA”와 같이 임의로 정해진 것을 알 수 있다. Referring to FIG. 1, it can be seen that the source code 20 decompiled from the script binary has no information about function symbols, so the function name is arbitrarily determined, such as “sub_80534BA.”

도 2는 본 발명의 일 실시예에 따른, 함수 심볼 예측 장치의 구성도이다.Figure 2 is a configuration diagram of a function symbol prediction device according to an embodiment of the present invention.

도 2를 참조하면, 함수 심볼 예측 장치(100)는 소스코드 데이터베이스(200), 코드조각 획득부(300), 임베딩 처리부(400), 신경망 처리부(500) 및 함수 심볼 획득부(600)를 포함할 수 있다.Referring to FIG. 2, the function symbol prediction device 100 includes a source code database 200, a code fragment acquisition unit 300, an embedding processing unit 400, a neural network processing unit 500, and a function symbol acquisition unit 600. can do.

소스코드 데이터베이스(200)는 함수 심볼이 포함된 소스코드가 저장되어 있을 수 있다. 상기 소스코드는 하나의 함수에 관하여 여러 업데이트(update) 버전이 존재할 수 있다.The source code database 200 may store source code including function symbols. The source code may have multiple update versions for one function.

본 발명의 다른 실시예에 따르면, 소스코드 데이터베이스(200)는 함수 심볼이 포함된 바이너리가 저장되어 있을 수 있다. 상기 함수 심볼이 포함된 바이너리는 디컴파일을 통해서 간단하게 소스코드로 생성할 수 있고, 상기 생성된 소스코드를 본 발명의 일 실시예와 같이 활용할 수 있기 때문에, 설명의 중복을 피하기 위하여 자세한 설명은 생략한다.According to another embodiment of the present invention, the source code database 200 may store binaries containing function symbols. Since the binary containing the function symbol can be simply generated as source code through decompilation, and the generated source code can be used as in an embodiment of the present invention, a detailed description is provided to avoid duplication of explanation. Omit it.

코드조각 획득부(300)는 소스코드 데이터베이스(200)에 저장된 소스코드를 바탕으로 샘플(sample) 코드조각을 획득할 수 있다.The code fragment acquisition unit 300 may acquire a sample code fragment based on the source code stored in the source code database 200.

상기 샘플 코드조각은 상기 소스코드에 포함된 타겟(target) 함수의 코드 중에서 함수호출 및 함수호출 인자만을 추출하여 생성될 수 있다.The sample code fragment can be generated by extracting only the function call and function call arguments from the code of the target function included in the source code.

임베딩 처리부(400)는 코드조각 획득부(300)에서 생성된 샘플 코드조각을 바탕으로 벡터를 생성할 수 있다. The embedding processing unit 400 may generate a vector based on the sample code fragment generated by the code fragment acquisition unit 300.

임베딩 처리부(400)를 상기 샘플 코드조각을 하나의 샘플 문장으로 만들고, 상기 문장을 워드 임베딩(word embedding) 모델(model)에 입력하여, 상기 워드 임베딩 모델을 학습시킬 수 있다. The embedding processing unit 400 can transform the sample code fragment into one sample sentence and input the sentence into a word embedding model to learn the word embedding model.

임베딩 처리부(400)는 상기 샘플 문장의 각 단어를 상기 워드 임베딩 모델에 입력하고, 상기 각 단어의 관계에 따라 거리가 반비례하는 벡터값을 가지도록 상기 워드 임베딩 모델을 학습시킬 수 있다. The embedding processing unit 400 may input each word of the sample sentence into the word embedding model and train the word embedding model to have a vector value whose distance is inversely proportional to the relationship between each word.

임베딩 처리부(400)은 상기 학습된 워드 임베딩 모델에서 임베딩 매트릭스(matrix)를 상기 샘플 코드조각에 관한 벡터로 획득할 수 있다.The embedding processing unit 400 may obtain an embedding matrix as a vector related to the sample code fragment from the learned word embedding model.

상기 워드 임베딩 모델은, 하나 이상의 단어로 이루어진 문장을 벡터 값으로 변환시킬 수 있다. 상기 워드 임베딩 모델은, 워드투벡터(word2vec), GloVe 및 FastText 중에서 어느 하나일 수 있다. 상기 워드 임베딩 모델은, 본 발명이 속한 기술 분야의 통상의 기술자에게 널리 알려진 기술이기 때문에 자세한 설명은 생략한다.The word embedding model can convert sentences consisting of one or more words into vector values. The word embedding model may be any one of word2vec, GloVe, and FastText. Since the word embedding model is a technology widely known to those skilled in the art to which the present invention pertains, a detailed description thereof will be omitted.

신경망 처리부(500)는 임베딩 처리부(400)에서 획득된 벡터를 신경망에 입력하고, 상기 신경망이 상기 타겟 함수의 심볼을 출력하도록 상기 신경망을 학습시킬 수 있다.The neural network processing unit 500 may input the vector obtained from the embedding processing unit 400 into a neural network and train the neural network to output a symbol of the target function.

신경망 처리부(500)는 순차적인 입력을 바탕으로 신경망을 강화 학습할 수 있다. 소스코드 데이터베이스(200)에는 하나의 타겟함수에 관하여 복수의 업데이트(update) 버전(version)이 저장되어 있으며, 상기 업데이트 버전을 순차적으로 벡터화하여 상기 신경망에 입력함으로써, 상기 신경망을 강화 학습시킬 수 있다.The neural network processing unit 500 can strengthen and learn a neural network based on sequential input. A plurality of updated versions of one target function are stored in the source code database 200, and the updated versions are sequentially vectorized and input to the neural network, thereby enabling reinforcement learning of the neural network. .

상기 신경망은, RNN(Recurrent Neural Network), LSTM (Long Short Term Memory), LSTM (Long Short Term Memory) 중에서 어느 하나일 수 있다. 상기 신경망은 본 발명이 속한 기술 분야의 통상의 기술자에게 널리 알려진 기술이기 때문에 자세한 설명은 생략한다.The neural network may be any one of RNN (Recurrent Neural Network), LSTM (Long Short Term Memory), and LSTM (Long Short Term Memory). Since the neural network is a technology widely known to those skilled in the art to which the present invention pertains, a detailed description will be omitted.

함수 심볼 획득부(600)는 스트립트 바이너리를 디컴파일하여 제3 소스코드를 획득할 수 있다. 함수 심볼 획득부(600)는 상기 제3 소스코드에서 제3 코드조각을 획득하고, 이를 바탕으로 제3 문장을 생성하며, 상기 제3 문장과 상기 워드 임베딩 모델을 이용하여 제3 벡터를 획득하고, 상기 제3 벡터를 상기 신경망에 입력하여 함수 심볼을 획득할 수 있다.The function symbol acquisition unit 600 may obtain the third source code by decompiling the script binary. The function symbol acquisition unit 600 acquires a third code fragment from the third source code, generates a third sentence based on this, and obtains a third vector using the third sentence and the word embedding model. , the function symbol can be obtained by inputting the third vector into the neural network.

함수 심볼 획득부(600)가 상기 제3 코드조각을 획득하는 것을 코드조각 획득부(300)에서 코드조각을 획득하는 것과 동일한 방법을 사용하며, 상기 제3 벡터를 획득하는 것은 임베딩 처리부(400)에서 벡터를 획득하는 것과 동일한 방법을 이용한다The function symbol acquisition unit 600 acquires the third code fragment using the same method as the code fragment acquisition unit 300 obtains the code fragment, and the third vector is acquired by the embedding processing unit 400. Use the same method as obtaining the vector from

도 3은 본 발명의 일 실시예에 따른, 제1 소스코드에서 제1 코드조각 및 제1 문장을 추출하는 과정을 나타내는 예시이다.Figure 3 is an example showing the process of extracting the first code fragment and the first sentence from the first source code according to an embodiment of the present invention.

도 3을 참조하면, 제1 소스코드(210)는 타겟 함수의 심볼 정보가 포함되어 있다. 예를 들어, 도 3에 도시된 예시에서 타겟 함수의 심볼은 “test_func”이다.Referring to FIG. 3, the first source code 210 includes symbol information of the target function. For example, in the example shown in FIG. 3, the symbol of the target function is “test_func”.

코드조각 획득부(300)는 제1 소스코드(210)의 타겟 함수 코드에서 함수호출과 함수호출 인자만을 추출하여 제1 코드조각(212)을 획득할 수 있다.The code fragment acquisition unit 300 may obtain the first code fragment 212 by extracting only the function call and function call arguments from the target function code of the first source code 210.

임베딩 처리부(400)는 제1 코드조각(212)에 포함된 각 함수호출 및 함수호출 인자를 하나의 단어로 간주하고, 상기 단어를 연결하여 하나의 문장으로 생성할 수 있다. 상기 생성된 문장이 제1 문장(214)일 수 있다.The embedding processing unit 400 may regard each function call and function call argument included in the first code fragment 212 as one word, and connect the words to create one sentence. The generated sentence may be the first sentence 214.

도 4은 본 발명의 일 실시예에 따른, 제2 소스코드에서 제2 코드조각 및 제2 문장을 추출하는 과정을 나타내는 예시이다.Figure 4 is an example showing the process of extracting a second code fragment and a second sentence from a second source code according to an embodiment of the present invention.

도 4을 참조하면, 제2 소스코드(220)는 타겟 함수의 심볼 정보가 포함되어 있다. 예를 들어, 도 4에 도시된 예시에서 타겟 함수의 심볼은 “test_func”이다.Referring to FIG. 4, the second source code 220 includes symbol information of the target function. For example, in the example shown in FIG. 4, the symbol of the target function is “test_func”.

제2 소스코드(220)는 제1 소스코드(210)의 업데이터 버전일 수 있다. 제2 소스코드(220)는 제1 소스코드(210)보다 시간적으로 이후에 작성된 소스코드 일 수 있다.The second source code 220 may be an updated version of the first source code 210. The second source code 220 may be a source code written temporally later than the first source code 210.

제2 소스코드(220)은 제1 소스코드(210)와 유사한 함수호출 및 함수호출 인자를 포함할 수 있으며, 상기 함수호출의 호출 순서도 유사할 수 있다.The second source code 220 may include similar function calls and function call arguments as the first source code 210, and the calling order of the function calls may also be similar.

코드조각 획득부(300)는 제2 소스코드(220)의 타겟 함수 코드에서 함수호출과 함수호출 인자만을 추출하여 제2 코드조각(222)을 획득할 수 있다.The code fragment acquisition unit 300 may obtain the second code fragment 222 by extracting only the function call and function call arguments from the target function code of the second source code 220.

임베딩 처리부(400)는 제2 코드조각(222)에 포함된 각 함수호출 및 함수호출 인자를 하나의 단어로 간주하고, 상기 단어를 연결하여 하나의 문장으로 생성할 수 있다. 상기 생성된 문장이 제2 문장(224)일 수 있다.The embedding processing unit 400 may regard each function call and function call argument included in the second code fragment 222 as one word, and connect the words to create one sentence. The generated sentence may be the second sentence 224.

도 5는 본 발명의 일 실시예에 따른, 워드 임베딩 중에서 Word2Vec의 알고리즘 모델이다.Figure 5 is an algorithm model of Word2Vec among word embeddings, according to an embodiment of the present invention.

도 5를 참조하여, 본 발명의 일실시예에서 사용하는 워드 임베딩에 관하여 설명한다. With reference to FIG. 5, word embedding used in one embodiment of the present invention will be described.

인공지능 처리를 위해 문자로 된 단어를 숫자로 표현한 것을 인코딩(encoding)이라고 한다. 가장 단순한 인코딩이 원핫인코딩(one-hot encoding) 또는 원핫벡터(one-hot vector)라고 한다. 이하 설명의 편의를 위하여 원핫벡터라고 지칭한다.Expressing text words into numbers for artificial intelligence processing is called encoding. The simplest encoding is called one-hot encoding or one-hot vector. Hereinafter, for convenience of explanation, it is referred to as a one-hot vector.

원핫벡터는 단어를 사전 개수만큼의 차원을 가지는 벡터(vector)로 표현한 것이다. 예를 들어, “king man queen woman”라는 문장은 6개의 단어로 이루어져 있으며, 이 중에서 각 단어를 원핫벡터로 표현하면 “king”은 (1,0,0,0), “man”은 (0,1,0,0), “queen”은 (0,0,1,0), “woman”은 (0,0,0,1)로 표현될 수 있다.A one-hot vector expresses a word as a vector with dimensions equal to the number of dictionaries. For example, the sentence “king man queen woman” consists of six words. If each word is expressed as a one-hot vector, “king” is (1,0,0,0) and “man” is (0). ,1,0,0), “queen” can be expressed as (0,0,1,0), and “woman” can be expressed as (0,0,0,1).

원핫벡터는 단어 간의 거리고 모두 동일하기 때문에 단어 간의 관계를 표현하지 못하는 단점이 있다. 이를 극복하기 위하여, 단어를 특징을 가지는 N차원의 벡터로 표현하는 것을 워드 임베딩(word embedding) 이라고 한다.One-hot vectors have the disadvantage of not being able to express relationships between words because the distances between words are all the same. To overcome this, expressing words as N-dimensional vectors with characteristics is called word embedding.

예를 들어, 워드 임베딩을 통해서 “king man queen woman”의 각 단어를 성별과 지위라는 2차원 벡터로 표현하면, “king”은 (1,2), “man”은 (1,3), “queen”은 (5,1), “woman”은 (5,3)으로 표현될 수 있다. 위 워드 임베딩 결과는 예시이며 구현하는 방식에 따라 달라질 수 있다. 상기 각 단어의 벡터를 하나의 매트릭스(matrix)로 표현한 것이 임베딩 매트릭스이다.For example, if each word of “king man queen woman” is expressed as a two-dimensional vector of gender and status through word embedding, “king” is (1,2), “man” is (1,3), “ “queen” can be expressed as (5,1), and “woman” can be expressed as (5,3). The above word embedding result is an example and may vary depending on the implementation method. An embedding matrix is an embedding matrix that represents the vector of each word as a single matrix.

Word2Vec은 단어를 특징을 가지는 N차원 임베딩 벡터(embedding vector)로 만드는 워드 임베딩 방법이다. Word2Vec은 임베딩 과정에서 앞뒤 단어를 고려하기 때문에, 자주 인접해서 사용되는 단어들은 가까운 거리의 벡터값을 가지게 된다. Word2Vec은 CBOW 또는 Skip-Gram 모델을 사용해 구현될 수 있다.Word2Vec is a word embedding method that turns words into N-dimensional embedding vectors with features. Because Word2Vec considers preceding and following words during the embedding process, words that are frequently used adjacently have vector values of close distances. Word2Vec can be implemented using CBOW or Skip-Gram models.

CBOW는 문맥 단어를 보고 기준 단어가 무엇인지 예측하는 모델이고, Skip-Gram은 기준 단어를 보고 어떤 문맥 단어가 등장할지 예측하는 모델이다. CBOW is a model that predicts what the standard word will be by looking at the context word, and Skip-Gram is a model that looks at the standard word and predicts which context word will appear.

Word2Vec는 공개된 기술인 텐서플로(Tensorflow), 파이썬(python) 등을 통해서 본 발명에 속한 통상의 기술자가 용이하게 구현할 수 있기 때문에 자세한 설명은 생략한다.Since Word2Vec can be easily implemented by a person skilled in the art through public technologies such as Tensorflow and Python, a detailed description will be omitted.

도 5를 참조하면, Word2Vec은 문장의 각 단어를 원핫벡터로 변환하고, 이런 입력으로 넣었을 때 출력으로 기준 단어 (CBOW 모델) 또는 주변 단어(Skip-Gram 모델)이 나오도록, 임베딩 매트릭스(matrix) W를 수정해 가는 학습 과정을 거치게 된다. 이러한 학습 과정을 통해 나온 임베딩 매트릭스 W 의 값이 워드 임베딩의 결과물이 된다Referring to Figure 5, Word2Vec converts each word in a sentence into a one-hot vector, and creates an embedding matrix so that when entered as an input, the base word (CBOW model) or surrounding words (Skip-Gram model) are output. You go through a learning process to modify W. The value of the embedding matrix W generated through this learning process becomes the result of word embedding.

본 발명은 Word2Vec을 워드 임베딩 모델로 사용할 수 있다. 함수를 구성하는 요소 중에서 변수 선언, 연산 등을 제외하고 함수호출과 함수호출 인자만을 포함하는 코드조각은 Word2Vec를 통해 임베딩될 수 있다. 동일한 함수 또는 유사한 함수는, 코드조각에 포함된 함수호출 순서가 비슷하기 때문에, 워드임베딩을 통해서 각 함수호출은 거리가 가까운 벡터로 임베딩될 수 있다.The present invention can use Word2Vec as a word embedding model. Among the elements that make up a function, code fragments that include only function calls and function call arguments, excluding variable declarations and operations, can be embedded through Word2Vec. Because the order of function calls included in code fragments for the same function or similar functions is similar, each function call can be embedded into a vector with a short distance through word embedding.

도 3과 도 4를 참조하면, test_func()의 각 버전에 따른 코드조각은, “void test_func() malloc(100) malloc(50) memcpy(b, a, sizeof(a))”, “void test_func() malloc(100) malloc(50) memcpy(b, a, sizeof(a)) memcpy(a, b, sizeof(b))”일 수 있다. 이를 Word2Vec으로 임베딩하면, “test_func()”는 “malloc(100)”, “malloc(50)”, “memcpy(b, a, sizof(a))” 단어와 인접해 있기 때문에 위 단어들과 가까운 거리의 벡터로 임베딩될 수 있다.Referring to Figures 3 and 4, the code fragments for each version of test_func() are “void test_func() malloc(100) malloc(50) memcpy(b, a, sizeof(a))”, “void test_func () malloc(100) malloc(50) memcpy(b, a, sizeof(a)) memcpy(a, b, sizeof(b))”. If you embed this into Word2Vec, “test_func()” is adjacent to the words “malloc(100)”, “malloc(50)”, and “memcpy(b, a, sizof(a))”, so it is close to the words above. It can be embedded as a vector of distances.

본 발명의 일 실시예에 따르면, 학습된 “malloc(100)”, “malloc(50)”, “memcpy(b, a, sizof(a))”의 단어 벡터를 통해서 이 벡터와 가까운 거리에 있는 “test_func()”라는 함수 심볼을 예측할 수 있다.According to an embodiment of the present invention, through the learned word vectors of “malloc(100)”, “malloc(50)”, and “memcpy(b, a, sizof(a))”, The function symbol “test_func()” can be predicted.

도 6은 본 발명의 일 실시예에 따른, 신경망의 일종인 RNN(Recurrent Neural Network)의 알고리즘 모델이다.Figure 6 is an algorithm model of RNN (Recurrent Neural Network), a type of neural network, according to an embodiment of the present invention.

도 6을 참조하면, RNN은 순환 신경망이며, 인공 신경망을 구성하는 유닛(unit) 사이의 연결이 순환구조를 구성하는 신경망이다. RNN은 입력 Xt-1 에 대한 출력 ht-1 을 처리하는 과정에서 생성된 정보를 다음 유닛으로 전파시킨다. Referring to FIG. 6, RNN is a recurrent neural network, and the connection between units constituting the artificial neural network constitutes a recurrent structure. RNN propagates the information generated in the process of processing output ht-1 for input Xt-1 to the next unit.

예를 들면, “I Love You” 라는 문장의 각 단어를 순차적으로 입력함으로써 최종적으로 해당 문장은 “좋은 감정”이라는 분류를 할 수 있다.For example, by entering each word of the sentence “I Love You” sequentially, the sentence can ultimately be classified as a “good feeling.”

본 발명의 일 실시예에 따른 신경망은 RNN, LSTM (Long Short Term Memory) 및 GRU(Gated Recurrent Unit) 를 포함할 수 있다. LSTM과 GRU는 모두 RNN 기반으로 RNN을 개선한 신경망 모델이다. LSTM과 GRU는 RNN의 장기 의존성 문제를 해결한 신경망 모델이며, GRU는 LSTM보다 입력단 수를 줄임으로써, 구조가 간단하고 빠른 동작을 할 수 있다.A neural network according to an embodiment of the present invention may include an RNN, a Long Short Term Memory (LSTM), and a Gated Recurrent Unit (GRU). LSTM and GRU are both neural network models based on RNN and improved upon RNN. LSTM and GRU are neural network models that solve the long-term dependency problem of RNN, and GRU has a simpler structure and faster operation by reducing the number of input stages than LSTM.

본 발명의 일 실시예에 따르면, 워드 임베딩 모델의 출력인 벡터를 GRU에 입력하고, 함수 심볼이 출력되도록 상기 GRU 신경망을 학습시킬 수 있다. According to one embodiment of the present invention, a vector that is the output of a word embedding model can be input to the GRU, and the GRU neural network can be trained to output a function symbol.

예를 들어, 도 3에 예시된 제1 문장 “void test_func() malloc(100) malloc(50) memcpy(b, a, sizeof(a))”에 포함된 각 단어의 벡터를, 순차적으로 GRU 모델에 입력하고, 최종 출력값이 “test_func()”를 출력하도록 상기 GRU 모델을 학습시킬 수 있다.For example, the vector of each word included in the first sentence “void test_func() malloc(100) malloc(50) memcpy(b, a, sizeof(a))” illustrated in Figure 3 is sequentially processed by the GRU model. , and the GRU model can be trained so that the final output value is “test_func()”.

본 발명의 일 실시예에 따르면, 임베딩 처리부(400)에서 학습된 워드 임베딩의 임베딩 매트릭스를 GRU에 입력하여 GRU를 학습시킬 수 있다. 상기 임베딩 매트릭스의 각 행은 각 단어의 벡터이며, 상기 벡터를 GRU에 순차적으로 입력할 수 있다.According to one embodiment of the present invention, the GRU can be trained by inputting the embedding matrix of the word embedding learned in the embedding processing unit 400 into the GRU. Each row of the embedding matrix is a vector of each word, and the vectors can be sequentially input into the GRU.

GRU 모델을 설계하고 학습시키는 것은 본 발명이 속한 기술 분야의 통상의 기술자에게는 자명한 기술이기 때문에 자세한 설명은 생략한다.Since designing and learning a GRU model is a skill well known to those skilled in the art to which the present invention pertains, a detailed description will be omitted.

도 7은 본 발명의 일 실시예에 따른, 스트립트 바이너리의 디컴파일된 함수를 이용한 함수 심볼 예측을 설명하기 위한 예시이다.Figure 7 is an example to explain function symbol prediction using a decompiled function of a script binary, according to an embodiment of the present invention.

함수 심볼 획득부(600)는 스트립트 바이너리를 디컴파일하여 제3 소스코드(230)를 획득할 수 있다.The function symbol acquisition unit 600 may obtain the third source code 230 by decompiling the script binary.

제3 소스코드(230)는 함수 정보가 삭제된 상태로 디컴파일된 결과물이기 때문에 함수 심볼이 임의로 “sub_8030BA()”로 정해져 있다. Since the third source code 230 is a decompiled result with the function information deleted, the function symbol is arbitrarily set to “sub_8030BA()”.

함수 심볼 획득부(600)는 제3 소스코드(230)를 바탕으로 제3 코드조각(232)및 제3 문장(234)을 생성할 수 있다.The function symbol acquisition unit 600 may generate a third code fragment 232 and a third sentence 234 based on the third source code 230.

함수 심볼 획득부(600)는 제3 문장(234)을 상기 워드 임베딩 모델에 입력함으로써 제3 벡터를 획득할 수 있다.The function symbol acquisition unit 600 may obtain the third vector by inputting the third sentence 234 into the word embedding model.

제3 문장(234)을 제1 문장(214) 및 제2 문장(224)와 비교하면 포함된 함수호출 및 함수호출 인자가 유사하고 함수호출의 순서가 유사하기 때문에, 상기 제3 벡터는 상기 제1 벡터 및 상기 제2 벡터와 유사도가 높은 벡터값을 가질 수 있다.When comparing the third sentence 234 with the first sentence 214 and the second sentence 224, the included function calls and function call arguments are similar and the order of function calls is similar, so the third vector is the first sentence 214 and the second sentence 224. It may have a vector value with high similarity to the 1 vector and the second vector.

함수 심볼 획득부(600)는 상기 제3 벡터를 상기 신경망에 입력함으로써 함수 심볼을 획득할 수 있다. The function symbol acquisition unit 600 may obtain a function symbol by inputting the third vector into the neural network.

신경망 처리부(500)에서 학습시킨 상기 신경망은, 상기 제1 벡터 및 상기 제2 벡터에 의해 학습된 결과에 의해서, 상기 제3 벡터의 입력에 대하여“test_func()”을 출력할 수 있다.The neural network trained by the neural network processing unit 500 can output “test_func()” for the input of the third vector based on the results learned by the first vector and the second vector.

도 8은 본 발명의 일 실시예에 따른, 함수 심볼 예측 방법의 순서도이다. 도 8을 참조하여 본 발명의 일 실시예에 따른 함수 심볼 예측 방법을 설명하면 다음과 같다.Figure 8 is a flowchart of a function symbol prediction method according to an embodiment of the present invention. The function symbol prediction method according to an embodiment of the present invention will be described with reference to FIG. 8 as follows.

코드조각 획득부(300)는 제1 소스코드로부터 제1 코드조각을 획득할 수 있다(S110).The code fragment acquisition unit 300 may acquire the first code fragment from the first source code (S110).

코드조각 획득부(300)는 제2 소스코드로부터 제2 코드조각을 획득할 수 있다 (S120).The code fragment acquisition unit 300 may acquire the second code fragment from the second source code (S120).

임베딩 처리부(400)는 상기 제1 코드조각 및 제2 코드조각으로부터 각각 제1 문장 및 제2 문장을 생성하고, 워드 임베딩 모델을 학습시킬 수 있다(S130).The embedding processing unit 400 may generate a first sentence and a second sentence from the first and second code fragments, respectively, and learn a word embedding model (S130).

임베딩 처리부(400)는 상기 학습된 워드 임베딩 모델에 상기 제1 문장 및 상기 제2 문장을 각각 입력하였을 때 출력된 각 결과물을 제1 벡터 및 제2 벡터로 획득할 수 있다(S140).The embedding processing unit 400 may obtain the results output as a first vector and a second vector when the first sentence and the second sentence are respectively input to the learned word embedding model (S140).

신경망 처리부(500)는 상기 제1 벡터 및 상기 제2 벡터를 신경망에 입력하여 상기 신경망을 학습시킬 수 있다(S150).The neural network processing unit 500 may input the first vector and the second vector into the neural network to train the neural network (S150).

함수 심볼 획득부(600)는 스트립트 바이너리에서 제3 코드조각을 획득할 수 있다(S160).The function symbol acquisition unit 600 may acquire the third code fragment from the script binary (S160).

함수 심볼 획득부(600)는 상기 제3 코드조각을 바탕으로 제3 문장을 생성하여, 상기 제3 문장을 상기 워드 임베딩 모델에 입력하며, 그 출력값을 제3 벡터로 획득할 수 있다(S170).The function symbol acquisition unit 600 may generate a third sentence based on the third code fragment, input the third sentence into the word embedding model, and obtain the output value as a third vector (S170). .

함수 심볼 획득부(600)는 상기 제3 벡터를 상기 신경망에 입력하여 함수 심볼을 획득할 수 있다(S180).The function symbol acquisition unit 600 may obtain a function symbol by inputting the third vector into the neural network (S180).

이상 첨부된 도면을 참조하여 본 발명의 실시예들을 설명하였지만, 본 발명이 속하는 기술분야에서 통상의 지식을 가진 자는 본 발명이 그 기술적 사상이나 필수적인 특징을 변경하지 않고서 다른 구체적인 형태로 실시될 수 있다는 것을 이해할 수 있을 것이다. 그러므로 이상에서 기술한 실시예들은 모든 면에서 예시적인 것이며 한정적이 아닌 것으로 이해해야만 한다.Although embodiments of the present invention have been described above with reference to the attached drawings, those skilled in the art will understand that the present invention can be implemented in other specific forms without changing its technical idea or essential features. You will be able to understand it. Therefore, the embodiments described above should be understood in all respects as illustrative and not restrictive.

함수 심볼 획득 장치 100
소스코드 데이터베이스 200
코드조각 획득부 300
임베딩 처리부 400
신경망 처리부 500
함수 심볼 획득부 600
Function symbol acquisition device 100
Source code database 200
Code fragment acquisition unit 300
Embedding processing unit 400
Neural network processing unit 500
Function symbol acquisition unit 600

Claims (12)

함수 심볼 예측 장치가 타겟함수에 관한 제1 소스코드에서 함수호출 및 함수호출 인자를 추출하여 제1 코드조각을 획득하는 단계;
상기 함수 심볼 예측 장치가, 상기 제1 소스코드보다 업데이트된 제2 소스코드에서 함수호출 및 함수호출 인자를 추출하여 제2 코드조각을 획득하는 단계;
상기 함수 심볼 예측 장치가, 상기 제1 코드조각 및 상기 제2 코드조각을 각각 제1 문장 및 제2 문장으로 변환하는 단계;
상기 함수 심볼 예측 장치가, 상기 제1 문장 및 상기 제2 문장을 바탕으로 워드 임베딩(word embedding) 모델을 이용하여 각각 제1 벡터 및 제2 벡터를 획득하는 단계;
상기 함수 심볼 예측 장치가, 상기 제1 벡터 및 상기 제2 벡터를 순차적으로 입력하여 신경망을 학습시키는 단계;
상기 함수 심볼 예측 장치가, 스트립트 바이너리(strriped binary)에서 제3 코드조각을 획득하는 단계;
상기 함수 심볼 예측 장치가, 상기 제3 코드조각을 제3 문장으로 변환하는 단계;
상기 함수 심볼 예측 장치가, 상기 제3 문장을 바탕으로 상기 워드 임베딩 모델을 이용하여 제3 벡터를 획득하는 단계; 및
상기 함수 심볼 예측 장치가, 상기 제3 벡터를 상기 학습된 신경망에 입력하여 출력된 결과를 상기 제3 코드조각에 해당하는 함수 심볼로 획득하는 단계; 를 포함하되, 상기 제1 벡터 및 상기 제2 벡터는 상기 타겟함수의 심볼을 가리키는 벡터이고,
상기 제1 문장 및 제2 문장으로 변환하는 단계는,
상기 코드조각에 포함된 상기 함수호출 및 함수호출 인자를 하나의 단어로 간주하고, 상기 단어를 연결하여 하나의 문장으로 생성하는 것을 특징으로 하는,
함수 심볼 예측 방법.
A function symbol prediction device extracting a function call and a function call argument from a first source code for a target function to obtain a first code fragment;
obtaining, by the function symbol prediction device, a second code fragment by extracting a function call and a function call argument from a second source code that is more updated than the first source code;
converting, by the function symbol prediction device, the first code fragment and the second code fragment into a first sentence and a second sentence, respectively;
Obtaining, by the function symbol prediction device, a first vector and a second vector, respectively, using a word embedding model based on the first sentence and the second sentence;
The function symbol prediction device training a neural network by sequentially inputting the first vector and the second vector;
Obtaining, by the function symbol prediction device, a third code fragment from a stripped binary;
converting, by the function symbol prediction device, the third code fragment into a third sentence;
Obtaining, by the function symbol prediction device, a third vector using the word embedding model based on the third sentence; and
The function symbol prediction device inputting the third vector into the learned neural network to obtain an output result as a function symbol corresponding to the third code fragment; Including, wherein the first vector and the second vector are vectors indicating the symbol of the target function,
The step of converting into the first sentence and the second sentence is,
Characterized in that the function call and function call arguments included in the code fragment are regarded as one word, and the words are connected to create one sentence,
Function symbol prediction method.
제1항에 있어서,
상기 워드 임베딩(word embedding) 모델은,
워드투벡터(word2vec), GloVe 및 FastText 중에서 어느 하나인,
함수 심볼 예측 방법.
According to paragraph 1,
The word embedding model is,
One of word2vec, GloVe and FastText,
Function symbol prediction method.
제1항에 있어서,
상기 신경망은,
RNN(Recurrent Neural Network), LSTM (Long Short Term Memory), GRU(Gated Recurrent Unit) 중에서 어느 하나인,
함수 심볼 예측 방법.
According to paragraph 1,
The neural network is,
Any one of RNN (Recurrent Neural Network), LSTM (Long Short Term Memory), and GRU (Gated Recurrent Unit),
Function symbol prediction method.
제1항에 있어서,
상기 제1 벡터 및 상기 제2 벡터를 획득하는 단계는,
상기 제1 문장의 각 단어를 상기 워드 임베딩 모델에 입력하여 상기 워드 임베딩 모델을 학습시키는 단계;
상기 학습된 워드 임베딩 모델의 임베딩 매트릭스(matrix)를 제1 벡터로 획득하는 단계;
상기 제2 문장의 각 단어를 상기 워드 임베딩 모델에 입력하여 상기 워드 임베딩 모델을 학습시키는 단계; 및
상기 학습된 워드 임베딩 모델의 임베딩 매트릭스(matrix)를 제2 벡터로 획득하는 단계;를 포함하는,
함수 심볼 예측 방법.
According to paragraph 1,
The step of acquiring the first vector and the second vector is,
learning the word embedding model by inputting each word of the first sentence into the word embedding model;
Obtaining an embedding matrix of the learned word embedding model as a first vector;
learning the word embedding model by inputting each word of the second sentence into the word embedding model; and
Including, obtaining an embedding matrix of the learned word embedding model as a second vector.
Function symbol prediction method.
제1항에 있어서,
상기 신경망을 학습시키는 단계는,
상기 신경망의 입력으로 상기 제1 벡터 및 상기 제2 벡터를 입력하였을 때 상기 타겟함수의 심볼이 출력되도록 상기 신경망을 학습시키는 단계;를 포함하는,
함수 심볼 예측 방법.
According to paragraph 1,
The step of learning the neural network is,
A step of training the neural network to output a symbol of the target function when the first vector and the second vector are input to the neural network.
Function symbol prediction method.
제1항에 있어서,
상기 신경망을 학습시키는 단계는,
상기 제1 벡터가 임베딩 매트릭스를 포함하는 경우, 상기 임베딩 매트릭스에 포함된 각 행을 상기 신경망에 순차적으로 입력함으로써 상기 신경망을 학습시키는 단계; 및
상기 제2 벡터가 임베딩 매트릭스를 포함하는 경우, 상기 임베딩 매트릭스에 포함된 각 행을 상기 신경망에 순차적으로 입력함으로써 상기 신경망의 학습을 강화시키는 단계;를 포함하는,
함수 심볼 예측 방법.
According to paragraph 1,
The step of learning the neural network is,
When the first vector includes an embedding matrix, training the neural network by sequentially inputting each row included in the embedding matrix into the neural network; and
When the second vector includes an embedding matrix, reinforcing learning of the neural network by sequentially inputting each row included in the embedding matrix into the neural network.
Function symbol prediction method.
제1항에 있어서,
상기 제3 코드조각을 획득하는 단계는,
상기 스트립트 바이너리를 디컴파일(decompile) 과정을 통해 제3 소스코드를 획득하는 단계; 및
상기 제3 소스코드에서 함수호출 및 함수호출 인자를 추출하여 제3 코드조각을 획득하는 단계;를 포함하는,
함수 심볼 예측 방법.
According to paragraph 1,
The step of obtaining the third code fragment is,
Obtaining a third source code through a decompile process of the script binary; and
Including; extracting a function call and a function call argument from the third source code to obtain a third code fragment;
Function symbol prediction method.
타겟 함수가 포함된 하나 이상의 소스코드가 저장된 소스코드 데이터베이스;
상기 소스코드 데이터베이스에 포함된 소스코드에서 함수호출 및 함수호출 인자를 추출하여 샘플 코드조각을 획득하는 코드조각 획득부;
상기 획득된 샘플 코드조각을 바탕으로 샘플 문장을 생성하며, 상기 샘플 문장을 워드 임베딩 모델에 입력하여 상기 워드 임베딩 모델을 학습시키고, 상기 학습된 워드 임베딩 모델에서 상기 샘플 문장에 관한 벡터를 획득하는 임베딩 처리부;
상기 임베딩 처리부에서 획득된 벡터를 입력하면 상기 타겟 함수의 심볼을 출력하도록 신경망을 학습시키는 신경망 처리부; 및
스트립트 바이너리에서 심볼이 제거된 함수의 제3 코드조각을 획득하고, 상기 코드조각을 바탕으로 제3 문장을 생성하며, 상기 제3 문장과 상기 워드 임베딩 모델을 이용하여 제3 벡터를 획득하고, 상기 제3 벡터를 상기 신경망에 입력하여 그 출력값을 상기 심볼이 제거된 함수의 심볼로 획득하는 심볼 획득부;를 포함하고,
상기 샘플 문장을 생성하는 것으로,
상기 코드조각에 포함된 상기 함수호출 및 함수호출 인자를 하나의 단어로 간주하고, 상기 단어를 연결하여 하나의 문장으로 생성하는 것을 특징으로 하는,
함수 심볼 예측 장치.
A source code database storing one or more source codes containing target functions;
a code fragment acquisition unit that obtains a sample code fragment by extracting a function call and a function call argument from the source code included in the source code database;
Embedding that generates a sample sentence based on the obtained sample code fragment, inputs the sample sentence into a word embedding model to learn the word embedding model, and obtains a vector related to the sample sentence from the learned word embedding model. processing department;
a neural network processing unit that trains a neural network to output a symbol of the target function when the vector obtained by the embedding processing unit is input; and
Obtain a third code fragment of a function from which symbols have been removed from the script binary, generate a third sentence based on the code fragment, obtain a third vector using the third sentence and the word embedding model, and A symbol acquisition unit that inputs a third vector into the neural network and obtains the output value as a symbol of the function from which the symbol has been removed,
By generating the sample sentence above,
Characterized in that the function call and function call arguments included in the code fragment are regarded as one word, and the words are connected to create one sentence,
Function symbol prediction device.
제8항에 있어서,
상기 워드 임베딩(word embedding) 모델은,
워드투벡터(word2vec), GloVe 및 FastText 중에서 어느 하나이고,
상기 신경망은,
RNN(Recurrent Neural Network), LSTM (Long Short Term Memory), GRU(Gated Recurrent Unit) 중에서 어느 하나인,
함수 심볼 예측 장치.
According to clause 8,
The word embedding model is,
One of word2vec, GloVe, and FastText,
The neural network is,
Any one of RNN (Recurrent Neural Network), LSTM (Long Short Term Memory), and GRU (Gated Recurrent Unit),
Function symbol prediction device.
제8항에 있어서,
상기 임베딩 처리부는,
상기 샘플 문장에 포함된 각 단어를 원핫벡터로 변환시키고, 상기 원핫벡터를 상기 워드 임베딩 모델에 입력함으로써 상기 워드 임베딩 모델을 학습시키며, 상기 학습된 워드 임베딩 모델의 임베딩 매트릭스를 상기 샘플 문장의 벡터로 획득하는,
함수 심볼 예측 장치.
According to clause 8,
The embedding processing unit,
Each word included in the sample sentence is converted into a one-hot vector, the word embedding model is learned by inputting the one-hot vector into the word embedding model, and the embedding matrix of the learned word embedding model is converted to a vector of the sample sentence. acquiring,
Function symbol prediction device.
제8항에 있어서,
상기 신경망 처리부는,
상기 임베딩 처리부에서 획득된 벡터가 임베딩 매트릭스를 포함하는 경우, 상기 임베딩 매트릭스에 포함된 각 행을 상기 신경망에 순차적으로 입력함으로써 상기 신경망을 학습시키는,
함수 심볼 예측 장치.
According to clause 8,
The neural network processing unit,
When the vector obtained from the embedding processing unit includes an embedding matrix, training the neural network by sequentially inputting each row included in the embedding matrix into the neural network.
Function symbol prediction device.
제8항에 있어서,
상기 심볼 획득부는,
상기 스트립트 바이너리를 디컴파일 과정을 통해서 함수 심볼이 제거된 제3 소스코드를 획득하고, 상기 제3 소스코드에서 함수호출 및 함수호출 인자를 추출하여 제3 코드조각을 획득하며, 상기 제3 코드조각에 포함된 함수명, 함수 인자, 함수 파라미터 및 변수명을 하나의 문장으로 생성하여 제3 문장을 획득하는,
함수 심볼 예측 장치.
According to clause 8,
The symbol acquisition unit,
A third source code from which function symbols have been removed is obtained through a decompilation process of the script binary, a third code fragment is obtained by extracting a function call and a function call argument from the third source code, and the third code fragment is obtained. Obtaining a third sentence by generating the function name, function argument, function parameter, and variable name included in as one sentence,
Function symbol prediction device.
KR1020210170615A 2020-12-02 2021-12-02 Device and method for predicting stripped binary function symbols KR102608014B1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
KR1020200166393 2020-12-02
KR20200166393 2020-12-02

Publications (2)

Publication Number Publication Date
KR20220077894A KR20220077894A (en) 2022-06-09
KR102608014B1 true KR102608014B1 (en) 2023-11-30

Family

ID=81985827

Family Applications (1)

Application Number Title Priority Date Filing Date
KR1020210170615A KR102608014B1 (en) 2020-12-02 2021-12-02 Device and method for predicting stripped binary function symbols

Country Status (1)

Country Link
KR (1) KR102608014B1 (en)

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
KR101228899B1 (en) 2011-02-15 2013-02-06 주식회사 안랩 Method and Apparatus for categorizing and analyzing Malicious Code Using Vector Calculation

Non-Patent Citations (4)

* Cited by examiner, † Cited by third party
Title
Jeremy Lacomis et al., "DIRE: A Neural Approach to Decompiled Identifier Naming"(2019.)*
Jingxuan He et al., "Debin: Predicting Debug Information in Stripped Binaries"(2018.)*
Yue Duan et al., "DEEPBINDIFF: Learning Program-Wide Code Representations for Binary Diffing"(2020.02.)*
김문회 외, "Stripped 바이너리 함수 심볼 예측방법 기술동향"(2020.11.)*

Also Published As

Publication number Publication date
KR20220077894A (en) 2022-06-09

Similar Documents

Publication Publication Date Title
CN111639344B (en) Vulnerability detection method and device based on neural network
US20190265955A1 (en) Method and system for comparing sequences
Rabin et al. Understanding neural code intelligence through program simplification
CN111046679B (en) Quality information acquisition method and device of translation model and computer equipment
CN109376535B (en) Vulnerability analysis method and system based on intelligent symbolic execution
CN111475820B (en) Binary vulnerability detection method, system and storage medium based on executable program
CN114201406B (en) Code detection method, system, equipment and storage medium based on open source component
CN110610088A (en) Webshell detection method based on php
Naeem et al. Scalable mutation testing using predictive analysis of deep learning model
CN113312268A (en) Intelligent contract code similarity detection method
CN115146279A (en) Program vulnerability detection method, terminal device and storage medium
CN114942879A (en) Source code vulnerability detection and positioning method based on graph neural network
Wang et al. Explainable apt attribution for malware using nlp techniques
CN114969755A (en) Cross-language unknown executable program binary vulnerability analysis method
CN115935369A (en) Method for evaluating source code using numeric array representation of source code elements
KR102546424B1 (en) Machine learning data generating apparatus, apparatus and method for analyzing errors in source code
CN114254323A (en) Software vulnerability analysis method and system based on PCODE and Bert
CN116702160B (en) Source code vulnerability detection method based on data dependency enhancement program slice
KR102608014B1 (en) Device and method for predicting stripped binary function symbols
CN115688108B (en) Webshell static detection method and system
CN109657247B (en) Method and device for realizing self-defined grammar of machine learning
Pravin et al. An efficient programming rule extraction and detection of violations in software source code using neural networks
Zheng et al. Representation vs. model: what matters most for source code vulnerability detection
CN116628695A (en) Vulnerability discovery method and device based on multitask learning
Qian et al. Nimbus: Toward speed up function signature recovery via input resizing and multi-task learning

Legal Events

Date Code Title Description
E902 Notification of reason for refusal
E701 Decision to grant or registration of patent right
GRNT Written decision to grant