KR102341137B1 - Code converting method based on intermediate language and electronic device including the same - Google Patents

Code converting method based on intermediate language and electronic device including the same Download PDF

Info

Publication number
KR102341137B1
KR102341137B1 KR1020200148942A KR20200148942A KR102341137B1 KR 102341137 B1 KR102341137 B1 KR 102341137B1 KR 1020200148942 A KR1020200148942 A KR 1020200148942A KR 20200148942 A KR20200148942 A KR 20200148942A KR 102341137 B1 KR102341137 B1 KR 102341137B1
Authority
KR
South Korea
Prior art keywords
code
intermediate language
pattern
variable
data type
Prior art date
Application number
KR1020200148942A
Other languages
Korean (ko)
Inventor
손윤식
Original Assignee
동국대학교 산학협력단
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 동국대학교 산학협력단 filed Critical 동국대학교 산학협력단
Priority to KR1020200148942A priority Critical patent/KR102341137B1/en
Application granted granted Critical
Publication of KR102341137B1 publication Critical patent/KR102341137B1/en

Links

Images

Classifications

    • 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
    • G06F21/00Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
    • G06F21/50Monitoring users, programs or devices to maintain the integrity of platforms, e.g. of processors, firmware or operating systems
    • G06F21/57Certifying or maintaining trusted computer platforms, e.g. secure boots or power-downs, version controls, system software checks, secure updates or assessing vulnerabilities
    • G06F21/577Assessing vulnerabilities and evaluating computer system security
    • 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/14Tree-structured documents
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N20/00Machine learning

Abstract

An intermediate language converting method of an electronic device of the present disclosure for analyzing a software vulnerable point comprises: a step of receiving an input code; a step of identifying at least one variable included in a command based on the input code; a step of inferring a data type for the identified variable; and a step of converting the input code into an intermediate language based on information on the identified variable and the inferred data type.

Description

중간언어 기반 코드 변환 방법 및 이를 포함하는 전자 장치{Code converting method based on intermediate language and electronic device including the same}Code converting method based on intermediate language and electronic device including the same}

본 개시는 입력 코드의 보안 취약점을 분석하는 전자 장치 및 그의 분석 방법에 대한 것이다. 구체적으로, 본 개시는 보안 취약점 분석을 용이하게 하기 위해 입력 코드를 중간 언어(Intermediate Language; IL)로 변환하고, 중간 언어를 기반으로 보안 취약점을 분석하는 전자 장치 및 그 방법에 관한 것이다.The present disclosure relates to an electronic device for analyzing a security vulnerability of an input code and an analysis method thereof. Specifically, the present disclosure relates to an electronic device and method for converting an input code into an intermediate language (IL) to facilitate security vulnerability analysis and analyzing the security vulnerability based on the intermediate language.

지난 2014년, 정보가 유출될 수 있는 Heartbleed라는 프로그램 보안 취약점이 새롭게 발견되었다. 이는 보안 시장에서 커다란 이슈가 되었다. 보안 취약점은, 이외에도 버퍼 오버플로우(buffer overflow), 정수 오버플로우(integer overflow), 메모리 익셉션(memory exception), 기형 입력(malformed-input), 레이스 컨디션(race condition), 기호 링크(symbolic link) 및 널 포인터(null pointer)등 다양한 유형이 알려져 있다. 상기 취약점으로 인하여 입력되는 코드의 일부 기능이 부적절한 목적으로 무단 수정될 수도 있고, 코드가 실행되는 시스템이 보안상 문제를 일으킬 수 있다. 특히나, 최근에는 소스 코드나 바이너리 코드를 재사용하려는 트렌드에 따라, 코드에 포함된 보안 취약점을 분석하는 기술의 필요성이 더욱 증대되고 있다. In 2014, a new program security vulnerability called Heartbleed that could leak information was discovered. This has become a big issue in the security market. Security vulnerabilities include buffer overflow, integer overflow, memory exception, malformed-input, race condition, symbolic link and Various types are known, such as a null pointer. Due to the above vulnerability, some functions of the input code may be modified without permission for inappropriate purposes, and the system in which the code is executed may cause security problems. In particular, with the recent trend of reusing source code or binary code, the need for a technology for analyzing security vulnerabilities included in the code is increasing.

한편, 2009년 이후 이더리움, 이오스와 같은 블록체인 2.0 시대가 열리면서 DApp 개발자의 개발능력 하향평준화된 점, 블록체인 특성상 원장에 코드가 올라가는 순간 보안약점을 수정할 수 없다는 점을 고려하면, 블록체인 분야의 DApp 보안 이슈는 일반 소프트웨어의 보안 이슈보다 심각할 수 있다. On the other hand, considering that the development capabilities of DApp developers have been down-leveled as the era of block chain 2.0 such as Ethereum and EOS has opened since 2009, and that security weaknesses cannot be corrected as soon as the code is uploaded to the ledger due to the nature of the block chain, the blockchain field DApp security issues may be more serious than those of general software.

특히, 프로그래밍 언어 및 실행 환경이 갈수록 다양해짐에 따라, 다양한 언어의코드가 입력되더라도 프로그램의 보안 취약점을 용이하게 분석할 수 있는 기술의 도입이 시급한 실정이다.In particular, as programming languages and execution environments are increasingly diversified, it is urgent to introduce a technology capable of easily analyzing security vulnerabilities of programs even when codes of various languages are input.

본 발명은 상술한 필요성에 따른 것으로, 입력되는 코드의 보안 취약점을 용이하게 분석할 수 있도록, 입력 코드를 중간언어로 변환하는 장치 및 방법을 제공하는 것을 목적으로 한다.An object of the present invention is to provide an apparatus and method for converting an input code into an intermediate language so that the security vulnerability of the input code can be easily analyzed.

그러나 이러한 과제는 예시적인 것으로, 이에 의해 본 발명의 범위가 한정되는 것은 아니다.However, these problems are exemplary, and the scope of the present invention is not limited thereto.

본 발명의 일 실시 예에 따른 소프트웨어 보안 취약점 분석을 위한 전자 장치의 중간언어 변환 방법은 입력 코드를 수신하는 단계, 상기 입력 코드에 기초하여 명령어에 포함된 적어도 하나의 변수를 식별하는 단계, 상기 식별된 변수에 대한 데이터 타입을 추론하는 단계 및 상기 식별된 변수에 대한 정보 및 상기 추론된 데이터 타입을 기초로 상기 입력 코드를 중간 언어로 변환하는 단계를 포함한다.The method for converting an intermediate language of an electronic device for software security vulnerability analysis according to an embodiment of the present invention includes the steps of receiving an input code, identifying at least one variable included in a command based on the input code, the identification inferring a data type for the determined variable and converting the input code into an intermediate language based on the information on the identified variable and the inferred data type.

이때, 상기 입력 코드는 소스 코드, 바이너리 코드 및 가상 기계 코드 중 적어도 하나인 것을 특징으로 한다. In this case, the input code is characterized in that at least one of a source code, a binary code, and a virtual machine code.

상기 입력 코드가 소스 코드인 경우, 상기 중간언어 변환 방법은 추상 구문 트리(Abstract syntax tree)를 기반으로 상기 소스 코드의 문법 오류를 검사하는 단계를 더 포함하는 것을 특징으로 한다..When the input code is a source code, the intermediate language conversion method may further include checking for grammatical errors of the source code based on an abstract syntax tree.

상기 입력 코드가 바이너리 코드인 경우, 상기 중간언어 변환 방법은, 상기 바이너리 코드를 어셈블리 코드로 변환하는 단계 및 상기 어셈블리 코드를 복수의 세그먼트 코드로 구분하는 단계를 더 포함한다.When the input code is a binary code, the intermediate language conversion method further includes converting the binary code into an assembly code and dividing the assembly code into a plurality of segment codes.

한편, 상기 소스 코드는, 탈중앙화 분산형 어플리케이션(Decentralized Application)의 실행 코드인 것을 특징으로 한다.On the other hand, the source code is characterized in that the execution code of a decentralized application (Decentralized Application).

또한, 상기 소스 코드는, 이더리움 솔리디티(Ethereum Solidity) 및 하이퍼렛져 패브릭(Hyperledger Fabric) 중 적어도 하나의 언어로 구현된 것을 특징으로 한다.In addition, the source code is characterized in that it is implemented in at least one language of Ethereum Solidity (Ethereum Solidity) and Hyperledger Fabric (Hyperledger Fabric).

한편, 상기 적어도 하나의 변수를 식별하는 단계는, 상기 입력 코드의 명령어(Instruction)에 포함된 오퍼랜드(Operand)의 패턴을 분석하는 단계를 더 포함하고, 상기 패턴에 기초하여 상기 적어도 하나의 변수를 식별하는 것을 특징으로 한다.Meanwhile, the identifying of the at least one variable further includes analyzing a pattern of an operand included in an instruction of the input code, and determining the at least one variable based on the pattern characterized by identification.

이때, 상기 패턴을 분석하는 단계는 상기 오퍼랜드를 기초로 상수 패턴, 레지스터 패턴, 변수 패턴 및 포인터 패턴 중 하나의 패턴을 식별하는 것이고, 상기 추론하는 단계는 상기 패턴을 기초로 상기 데이터 타입을 추론하는 것을 특징으로 한다.At this time, the analyzing the pattern identifies one of a constant pattern, a register pattern, a variable pattern, and a pointer pattern based on the operand, and the inferring is to infer the data type based on the pattern characterized in that

한편, 상기 추론하는 단계는 상기 소스 코드의 패턴과 상기 바이너리 코드의 패턴간의 상관 관계를 기초로 학습된 LSTM(Long Short Term Memory) 학습모델을 기반으로 데이터 타입을 추론하는 것을 특징으로 한다.Meanwhile, the inferring step is characterized in that the data type is inferred based on a Long Short Term Memory (LSTM) learning model learned based on the correlation between the pattern of the source code and the pattern of the binary code.

본 개시의 일 실시예에 따른 소프트웨어 보안 약점을 분석하기 위한 전자 장치는 입력 코드를 수신하는 입력코드 처리기 및 상기 입력 코드에 기초하여 명령어에 포함된 적어도 하나의 변수를 식별하고, 상기 식별된 변수에 대한 데이터 타입을 추론하고, 상기 식별된 변수에 대한 정보 및 상기 추론된 데이터 타입을 기초로 상기 입력 코드를 중간 언어로 변환하는 중간언어 변환기를 포함한다.An electronic device for analyzing a software security weakness according to an embodiment of the present disclosure identifies at least one variable included in a command based on an input code processor receiving an input code and the input code, and assigns to the identified variable and an intermediate language converter that infers a data type for the variable and converts the input code into an intermediate language based on the information on the identified variable and the inferred data type.

이때, 상기 입력 코드는 소스 코드, 바이너리 코드 및 가상 기계 코드 중 적어도 하나인 것을 특징으로 한다..In this case, the input code is characterized in that at least one of a source code, a binary code, and a virtual machine code.

상기 중간언어 변환기는 상기 입력 코드가 소스 코드인 경우, 추상 구문 트리(Abstract syntax tree)를 기반으로 상기 소스 코드의 문법 오류를 검사하는 것을 특징으로 한다.When the input code is the source code, the intermediate language converter checks the syntax error of the source code based on an abstract syntax tree.

상기 중간언어 변환기는 상기 입력 코드가 바이너리 코드인 경우, 상기 바이너리 코드를 어셈블리 코드로 변환하고, 상기 어셈블리 코드를 복수의 세그먼트 코드로 구분하는 것을 특징으로 한다.When the input code is a binary code, the intermediate language converter converts the binary code into an assembly code and divides the assembly code into a plurality of segment codes.

이때, 상기 소스 코드는, 탈중앙화 분산형 어플리케이션(Decentralized Application)의 실행 코드인 것을 특징으로 한다.In this case, the source code is characterized in that it is an execution code of a decentralized application (Decentralized Application).

한편, 상기 소스 코드는, 이더리움 솔리디티(Ethereum Solidity) 및 하이퍼렛져 패브릭(Hyperledger Fabric) 중 적어도 하나의 언어로 구현된 것을 특징으로 한다.Meanwhile, the source code is characterized in that it is implemented in at least one language of Ethereum Solidity and Hyperledger Fabric.

상기 중간언어 변환기는 상기 입력 코드의 명령어(Instruction)에 포함된 오퍼랜드(Operand)의 패턴을 분석하고, 상기 패턴에 기초하여 상기 적어도 하나의 변수를 식별하는 것을 특징으로 한다.The intermediate language converter analyzes a pattern of an operand included in an instruction of the input code, and identifies the at least one variable based on the pattern.

이때, 상기 중간언어 변환기는 상기 오퍼랜드를 기초로 상수 패턴, 레지스터 패턴, 변수 패턴 및 포인터 패턴 중 하나의 패턴을 식별하고, 상기 패턴을 기초로 상기 데이터 타입을 추론하는 것을 특징으로 한다.In this case, the intermediate language converter identifies one of a constant pattern, a register pattern, a variable pattern, and a pointer pattern based on the operand, and infers the data type based on the pattern.

한편, 상기 중간언어 변환기는 상기 소스 코드의 패턴과 상기 바이너리 코드의 패턴간의 상관 관계를 기초로 학습된 LSTM(Long Short Term Memory) 학습모델을 기반으로 데이터 타입을 추론하는 것을 특징으로 한다.Meanwhile, the intermediate language converter infers a data type based on a Long Short Term Memory (LSTM) learning model learned based on a correlation between the pattern of the source code and the pattern of the binary code.

전술한 것 외의 다른 측면, 특징, 이점은 이하의 발명을 실시하기 위한 구체적인 내용, 청구범위 및 도면으로부터 명확해질 것이다.Other aspects, features and advantages other than those described above will become apparent from the following detailed description, claims and drawings for carrying out the invention.

상기한 바와 같이 이루어진 본 개시의 일 실시예에 따르면, 본 개시의 전자 장치는 입력언어의 종류에 무관하게 입력언어를 중간언어로 변환시킴으로써 이더리움, 하이퍼레져패브릭 등 다양한 환경에서의 보안 약점 분석을 수행할 수 있다. 즉, 중간언어 기반의 분석시스템을 이용하여 스마트컨트랙트(Solidity), 체인코드(Go, Javascript) 등의 다양한 입력 프로그래밍언어와 실행환경에서 분석 가능하다는 장점이 있다. According to an embodiment of the present disclosure made as described above, the electronic device of the present disclosure converts an input language into an intermediate language regardless of the type of input language, thereby analyzing security weaknesses in various environments such as Ethereum and Hyperledger Fabric. can be done That is, it has the advantage of being able to analyze in various input programming languages and execution environments such as smart contracts (Solidity) and chaincodes (Go, Javascript) using an intermediate language-based analysis system.

본 개시에 따르면, 상실되는 소스 코드의 타입정보(예컨대, 변수 타입 및 구조체 등의 정보)를 중간언어로 변환하는 과정에서 추론할 수 있으므로 세부적인 언어 종류에 대하여 제약없이 보안약점 분석이 가능하다. 즉, 타입 정보가 사라진 바이너리 파일에서의 변수의 타입을 추론하여 하이브리드 분석시 소스 코드내의 타입, 변수와 연관 분석 가능하다는 장점이 있다. According to the present disclosure, since type information (eg, information such as variable type and structure) of the source code that is lost can be inferred in the process of converting it into an intermediate language, security weakness analysis is possible without restrictions on the detailed language type. That is, there is an advantage in that it is possible to analyze the types and variables in the source code in the hybrid analysis by inferring the type of the variable in the binary file where the type information has disappeared.

본 개시의 전자 장치는 입력 코드가 소스코드, 중간코드, 바이너리 코드인지 여부에 상관없이 중간코드 변환한다. 특히 DApp 실행파일만 있더라도 본 발명의 중간언어 변환기는 바이너리 코드를 본 기술의 중간코드로 변환시켜 분석할 수 있으므로, 개발자로부터 소스코드는 제공받지 못하고 DApp 실행파일만을 제공받은 경우에도 보안약점 등을 수행할 수 있다는 장점이 있다.The electronic device of the present disclosure converts the intermediate code regardless of whether the input code is a source code, an intermediate code, or a binary code. In particular, even if there is only a DApp executable file, the intermediate language converter of the present invention can convert a binary code into an intermediate code of the present technology and analyze it. There are advantages to being able to

물론 이러한 효과에 의해 본 발명의 범위가 한정되는 것은 아니다.Of course, the scope of the present invention is not limited by these effects.

도 1은 본 개시의 일 실시예에 따른 전자 장치(10)의 구성요소를 설명하기 위한 블록도이다.
도 2a 및 도 2b는 본 개시의 일 실시예에 따른 전자 장치(10)의 입력코드 처리기가 입력 코드에 따라 상이하게 구현되는 실시예를 설명하기 위한 블록도이다.
도 3은 본 개시의 예시적 실시예에 따른 중간언어 변환기(200)를 설명하기 위한 블록도이다.
도 4는 본 개시의 중간언어 변환기가 입력 코드를 중간언어로 변환하는 방법을 설명하기 위한 흐름도이다.
도 5 및 도 6은 중간언어 변환기(200)가 명령어를 분석하고, 변수를 식별하는 방법을 설명하기 위한 도면이다.
도 7a 및 도 7b는 본 개시의 일 실시예에 따른 중간언어 변환기가 데이터 타입을 추론하는 방법에 대하여 설명하기 위한 흐름도이다.
도 8는 LSTM으로 구현된 인공지능 모델로 데이터 타입을 추론한 경우, 정확도를 도시한다.
도 9는 디스어셈블링된 어셈블리 코드에 대하여 변수를 추론하여, 중간언어로 변환된 것을 예시적으로 설명하기 위한 도면이다.
1 is a block diagram illustrating components of an electronic device 10 according to an embodiment of the present disclosure.
2A and 2B are block diagrams for explaining an embodiment in which an input code processor of the electronic device 10 is implemented differently according to an input code according to an embodiment of the present disclosure.
3 is a block diagram illustrating an intermediate language converter 200 according to an exemplary embodiment of the present disclosure.
4 is a flowchart illustrating a method for the intermediate language converter of the present disclosure to convert an input code into an intermediate language.
5 and 6 are diagrams for explaining a method in which the intermediate language converter 200 analyzes a command and identifies a variable.
7A and 7B are flowcharts for explaining a method of inferring a data type by an intermediate language converter according to an embodiment of the present disclosure.
8 shows the accuracy when the data type is inferred with the artificial intelligence model implemented in the LSTM.
9 is a diagram for exemplarily explaining that a variable is inferred from disassembled assembly code and converted into an intermediate language.

이하, 본 개시의 다양한 실시예가 첨부된 도면과 연관되어 기재된다. 본 개시의 다양한 실시예는 다양한 변경을 가할 수 있고 여러 가지 실시예를 가질 수 있는바, 특정 실시예들이 도면에 예시되고 관련된 상세한 설명이 기재되어 있다. 그러나 이는 본 개시의 다양한 실시예를 특정한 실시 형태에 대해 한정하려는 것이 아니며, 본 개시의 다양한 실시예의 사상 및 기술 범위에 포함되는 모든 변경 및/또는 균등물 내지 대체물을 포함하는 것으로 이해되어야 한다. 도면의 설명과 관련하여, 유사한 구성요소에 대해서는 유사한 참조 부호가 사용되었다.Hereinafter, various embodiments of the present disclosure are described in connection with the accompanying drawings. Various embodiments of the present disclosure may be subject to various modifications and may have various embodiments, and specific embodiments are illustrated in the drawings and the related detailed description is described. However, this is not intended to limit the various embodiments of the present disclosure to the specific embodiments, and should be understood to include all modifications and/or equivalents or substitutes included in the spirit and scope of the various embodiments of the present disclosure. In connection with the description of the drawings, like reference numerals have been used for like elements.

본 개시의 다양한 실시예에서, "포함하다." 또는 "가지다." 등의 용어는 명세서상에 기재된 특징, 숫자, 단계, 동작, 구성요소, 부품 또는 이들을 조합한 것이 존재함을 지정하려는 것이지, 하나 또는 그 이상의 다른 특징들이나 숫자, 단계, 동작, 구성요소, 부품 또는 이들을 조합한 것들의 존재 또는 부가 가능성을 미리 배제하지 않는 것으로 이해되어야 한다.In various embodiments of the present disclosure, "comprises." Or "have." The term such as is intended to designate that there is a feature, number, step, operation, component, part, or combination thereof described in the specification, but one or more other features or number, step, operation, component, part or It should be understood that it does not preclude the possibility of the existence or addition of combinations thereof.

본 개시의 다양한 실시예에서 "또는" 등의 표현은 함께 나열된 단어들의 어떠한, 그리고 모든 조합을 포함한다. 예를 들어, "A 또는 B"는, A를 포함할 수도, B를 포함할 수도, 또는 A 와 B 모두를 포함할 수도 있다.In various embodiments of the present disclosure, expressions such as “or” include any and all combinations of words listed together. For example, "A or B" may include A, may include B, or may include both A and B.

본 개시의 다양한 실시예에서 사용된 "제1", "제2", "첫째", 또는 "둘째" 등의 표현들은 다양한 실시예들의 다양한 구성요소들을 수식할 수 있지만, 해당 구성요소들을 한정하지 않는다. 예를 들어, 상기 표현들은 해당 구성요소들의 순서 및/또는 중요도 등을 한정하지 않으며, 한 구성요소를 다른 구성요소와 구분하기 위해 사용될 수 있다. Expressions such as “first”, “second”, “first”, or “second” used in various embodiments of the present disclosure may modify various components of various embodiments, but do not limit the components. does not For example, the above expressions do not limit the order and/or importance of corresponding components, and may be used to distinguish one component from another.

어떤 구성요소가 다른 구성요소에 "연결되어" 있다거나 "접속되어" 있다고 언급된 때에는, 상기 어떤 구성요소가 상기 다른 구성요소에 직접적으로 연결되어 있거나 또는 접속되어 있을 수도 있지만, 상기 어떤 구성요소와 상기 다른 구성요소 사이에 새로운 다른 구성요소가 존재할 수도 있다고 이해되어야 할 것이다. When a component is referred to as being “connected” or “connected” to another component, the component may be directly connected to or connected to the other component, but the component and It should be understood that other new components may exist between the other components.

본 개시의 실시 예에서 "모듈", "유닛", "부(part)" 등과 같은 용어는 적어도 하나의 기능이나 동작을 수행하는 구성요소를 지칭하기 위한 용어이며, 이러한 구성요소는 하드웨어 또는 소프트웨어로 구현되거나 하드웨어 및 소프트웨어의 결합으로 구현될 수 있다. 또한, 복수의 "모듈", "유닛", "부(part)" 등은 각각이 개별적인 특정한 하드웨어로 구현될 필요가 있는 경우를 제외하고는, 적어도 하나의 모듈이나 칩으로 일체화되어 적어도 하나의 프로세서로 구현될 수 있다.In an embodiment of the present disclosure, terms such as “module”, “unit”, “part”, etc. are terms for designating a component that performs at least one function or operation, and such component is hardware or software. It may be implemented or implemented as a combination of hardware and software. In addition, a plurality of "modules", "units", "parts", etc. are integrated into at least one module or chip, except when each needs to be implemented in individual specific hardware, and thus at least one processor. can be implemented as

일반적으로 사용되는 사전에 정의되어 있는 것과 같은 용어들은 관련 기술의 문맥상 가지는 의미와 일치하는 의미가 있는 것으로 해석되어야 하며, 본 개시의 다양한 실시예에서 명백하게 정의되지 않는 한, 이상적이거나 과도하게 형식적인 의미로 해석되지 않는다.Terms such as those defined in a commonly used dictionary should be interpreted as having a meaning consistent with the meaning in the context of the related art, and unless explicitly defined in various embodiments of the present disclosure, ideal or excessively formal terms not interpreted as meaning

이하에서, 첨부된 도면을 이용하여 본 발명의 다양한 실시 예들에 대하여 구체적으로 설명한다. Hereinafter, various embodiments of the present invention will be described in detail with reference to the accompanying drawings.

도 1은 본 개시의 일 실시예에 따른 전자 장치(10)의 구성요소를 설명하기 위한 블록도이다.1 is a block diagram illustrating components of an electronic device 10 according to an embodiment of the present disclosure.

본 개시의 전자 장치(10)는 프로그램의 보안 취약점이나 해킹 위험 요소를 사전에 도출할 수 있도록, 프로그램을 분석하는 컴퓨팅 장치일 수 있다. 구체적으로 전자 장치(10)는 입력 코드가 입력되면, 해당 입력 코드에 대응하는 중간언어를 생성(또는 변환)할 수 있다. 전자 장치(10)는 중간 언어를 기초로 보안약점을 분석할 수 있고, 분석된 결과를 기초로 요약정보 생성 및 가상 기계(500)를 실행할 수 있다. The electronic device 10 of the present disclosure may be a computing device that analyzes a program so that security vulnerabilities or hacking risk factors of the program can be derived in advance. Specifically, when an input code is input, the electronic device 10 may generate (or convert) an intermediate language corresponding to the input code. The electronic device 10 may analyze the security weakness based on the intermediate language, and may generate summary information and execute the virtual machine 500 based on the analyzed result.

도 1을 참조하면, 전자 장치(10)는 입력코드 처리기(100), 중간언어 변환기(200), 보안약점 분석기(300), 함수 요약정보 생성기(400) 및 가상 기계(500)를 포함할 수 있다. 전자 장치(10)에 포함된 구성은 각각 소프트웨어, 하드웨어 또는 펌웨어로써 구현될 수 있다. 일 예로, 전자 장치(10)에 포함된 구성들 중 적어도 하나는, 소프트웨어 모듈로써 구현되어 메모리(미도시)에 저장될 수 있으며 프로세서(미도시)에 의해 실행될 수 있다.Referring to FIG. 1 , the electronic device 10 may include an input code processor 100 , an intermediate language converter 200 , a security weakness analyzer 300 , a function summary information generator 400 , and a virtual machine 500 . have. Components included in the electronic device 10 may be implemented as software, hardware, or firmware, respectively. For example, at least one of the components included in the electronic device 10 may be implemented as a software module, stored in a memory (not shown), and executed by a processor (not shown).

본 개시의 선택적 실시예에 따른 입력코드 처리기(100)는 입력되는 코드(이하, 입력 코드)를 추후 용이하게 중간언어로 변환할 수 있도록 선행 처리(Preprocessing)를 수행할 수 있다. The input code processor 100 according to an optional embodiment of the present disclosure may perform preprocessing so that an input code (hereinafter, an input code) can be easily converted into an intermediate language later.

이때, 본 개시의 일 실시예에 따른 입력 코드는 다양한 유형의 프로그래밍 언어로 작성된 소스 코드일 수도 있고, 다양한 유형의 기계어를 포함하는 바이너리 코드일 수도 있다. In this case, the input code according to an embodiment of the present disclosure may be source code written in various types of programming languages, or may be binary codes including various types of machine language.

즉, 본 개시의 예시적 실시예에 따른 입력코드 처리기(100)에 의해 전자 장치(10)는 입력 코드의 종류에 무관하게 보안 취약점을 탐지할 수 있다.That is, by the input code processor 100 according to an exemplary embodiment of the present disclosure, the electronic device 10 may detect a security vulnerability regardless of the type of the input code.

또한, 본 개시의 일 실시예에 따른 입력코드는 하이퍼레저 패브릭(Hyperledger Fabric) 프레임워크 하에 자바(Java), 고(Go), 노드제이에스(node.js.)와 같은 프로그래밍 언어로 작성된 체인코드(Chain Code)일 수 있다. 또한, 입력코드는 트러플(truffle)과 같은 이더리움 기반 프레임워크 하에 솔리디티(Solidity)와 같은 언어로 작성된 스마트 컨트랙트일 수 있다. 본 개시의 또 다른 실시예에 따른 입력 코드는 EVM과 같은 가상 머신에서의 실행을 위해 컴파일된 바이트 코드일 수 있으나, 이에 한정하지 않는다. In addition, the input code according to an embodiment of the present disclosure is a chaincode written in a programming language such as Java, Go, and node.js. under the Hyperledger Fabric framework. (Chain Code). In addition, the input code may be a smart contract written in a language such as Solidity under an Ethereum-based framework such as Truffle. The input code according to another embodiment of the present disclosure may be a byte code compiled for execution in a virtual machine such as an EVM, but is not limited thereto.

본 개시의 입력코드 처리기(100)는 입력 코드의 유형에 따라 상이하게 구현될 수 있다. 이에 대하여는 도 2a 내지 도 3을 통해 추가로 설명하기로 한다. The input code processor 100 of the present disclosure may be implemented differently depending on the type of the input code. This will be further described with reference to FIGS. 2A to 3 .

본 개시의 선택적 실시예에 따른 중간언어 변환기(200)는 바이너리 코드 또는 소스 코드와 같은 입력 코드를 중간언어 코드로 변환할 수 있다. 이때, 중간언어 코드는 코드 형태는 입력 코드와 상이하나, 코드의 의미는 동일하도록 명령어(Instruction) 단위로 변환된 코드일 수 있다. The intermediate language converter 200 according to an optional embodiment of the present disclosure may convert an input code such as a binary code or a source code into an intermediate language code. In this case, the intermediate language code may be a code converted into an instruction unit so that the code form is different from the input code, but the meaning of the code is the same.

본 개시의 중간언어 변환기(200)는 복잡한 구문구조의 입력 코드를 단순화된 명령어(Instruction)로 분해된 중간언어로 변환할 수 있다. 본 개시의 일 실시예에 따른 중간언어는 명령어 단위로 분해되어 변환된 것이기 때문에, 제어 흐름 분석(Control Flow Analysis), 자료 흐름 분석(Data Flow Analysis) 등에 있어서 수월하다는 장점이 있다. 특히, 보안약점 분석기(300)에서의 자료 흐름 분석시, 스택 영역에서 변수의 값이 바뀔 때, 다른 변수에 어떤 영향을 주는지, 최종 취합 시 변수 값 트래킹 용이하다는 장점이 있다. The intermediate language converter 200 of the present disclosure may convert an input code having a complex syntax structure into an intermediate language decomposed into simplified instructions. Since the intermediate language according to an embodiment of the present disclosure is converted into command units, it has the advantage of being easy in control flow analysis, data flow analysis, and the like. In particular, when analyzing the data flow in the security weakness analyzer 300 , when the value of a variable is changed in the stack area, how it affects other variables, there is an advantage in that it is easy to track the value of the variable at the time of final collection.

상술한 바와 같이, 보안 취약점을 분석할 입력 코드는 소프트웨어에 따라 저급 프로그래밍 언어부터 고급 프로그래밍 언어까지 다양한 방식으로 작성된 것일 수 있고, 다양한 유형의 컴파일러에 따라 상이한 포맷의 기계어일 수 있다. 중간언어 변환기(200)는 다양한 유형의 입력 코드를 하나의 중간언어로 변환할 수 있고, 이를 통해 전자 장치(10)는 어떠한 입력 코드에 대하여도 보안 취약점 분석을 용이하게 수행할 수 있다는 효과가 있다. As described above, the input code for analyzing the security vulnerability may be written in various ways from a low-level programming language to a high-level programming language according to software, and may be a machine language of a different format according to various types of compilers. The intermediate language converter 200 can convert various types of input codes into one intermediate language, and through this, the electronic device 10 has the effect of easily performing security vulnerability analysis on any input code. .

본 개시의 선택적 실시예에 따른 보안약점 분석기(300)는 변환된 중간언어를 기반으로 코드에 포함된 보안 취약점을 분석할 수 있다. 이때, 보안 취약점을 분석하기 위한 기법으로 정적 분석 및 동적 분석이 있다. The security weakness analyzer 300 according to an optional embodiment of the present disclosure may analyze the security weaknesses included in the code based on the converted intermediate language. At this time, there are static analysis and dynamic analysis as techniques for analyzing security vulnerabilities.

정적 분석(Static Analysis)은 컴퓨터 소프트웨어를 분석 하는 방법 중의 하나로, 작성된 프로그램을 실제로 실행하지 않고, 작성된 프로그램 코드를 기반으로 분석, 검증하는 방법이다. 본 개시의 일 실시예에 따른 보안약점 분석기(300)는 중간언어 코드에 대한 데이터 흐름 그래프, 제어 흐름 그래프를 생성하고, 이를 기초로 정적분석을 수행할 수 있다.Static analysis is one of the methods of analyzing computer software. It is a method of analyzing and verifying the written program code based on the written program code without actually executing it. The security weakness analyzer 300 according to an embodiment of the present disclosure may generate a data flow graph and a control flow graph for the intermediate language code, and perform static analysis based thereon.

동적 분석(Dynamic Analysis)은 실제 프로그램의 실행을 통해 프로그램을 분석하여 검증하는 것을 의미한다. Dynamic analysis refers to analyzing and verifying a program through actual program execution.

본 개시의 또 다른 실시예에 따른 보안약점 분석기(300)는 금지 API 리스트(Banned API List)를 참조 및/또는 API에 사용되는 변수 크기 정보를 참조함으로써 보안취약점을 분석할 수 있다. 본 개시의 보안약점 분석기(300)는 상술한 방법 중 적어도 하나를 통해, 버퍼 오버플로우(Buffer Overflow; BOF), 정수 오버플로우(Interger Overflow) 등의 보안취약점을 탐지할 수 있다. The security weakness analyzer 300 according to another embodiment of the present disclosure may analyze a security vulnerability by referring to a Banned API List and/or variable size information used in the API. The security weakness analyzer 300 of the present disclosure may detect security weaknesses such as buffer overflow (BOF) and integer overflow (Interger Overflow) through at least one of the above-described methods.

본 개시의 선택적 실시예에 따른 함수 요약정보 생성기(400)는 입력 코드의 함수들 및 그에 대한 보안 취약점 정보를 포함하는 함수 요약정보를 생성할 수 있다. 예컨대, 함수 요약정보는 보안 취약점을 탐지하기 위한 분석 대상의 함수의 명칭, 함수의 시작주소, 보안 취약점 탐지 여부에 관한 식별 정보, 외부 함수 호출 목록, 매개변수의 수, 매개변수의 자료형, 매개변수의 위치 및 분석 대상 함수를 호출한 함수를 포함할 수 있다.The function summary information generator 400 according to an optional embodiment of the present disclosure may generate function summary information including functions of the input code and security vulnerability information therefor. For example, function summary information includes the name of the function to be analyzed for detecting security vulnerabilities, the starting address of the function, identification information on whether to detect security vulnerabilities, a list of external function calls, the number of parameters, data types of parameters, parameters It can include the location of the function and the function that called the analysis target function.

함수 요약정보 생성기(400)는 함수 요약정보를 생성함으로써 정적 분석에 대한 결과를 제공할 수 있다. 즉, 본 개시의 기술적 사상에 따른 하이브리드 분석을 달성하기 위하여, 함수 요약정보 생성기(400)가 제공한 함수 요약정보를 기반으로 가상 기계(500)는 효율적으로 동적 분석을 수행할 수 있다. 특히, 함수 요약정보 생성기(400)는 함수 요약정보에 보안 취약점 탐지 여부에 관한 식별 정보를 기입할 수 있으며, 이에 따라 가상 기계(500)는 효율적인 동적 분석을 수행할 수 있다.The function summary information generator 400 may provide a result for the static analysis by generating the function summary information. That is, in order to achieve the hybrid analysis according to the technical spirit of the present disclosure, the virtual machine 500 may efficiently perform dynamic analysis based on the function summary information provided by the function summary information generator 400 . In particular, the function summary information generator 400 may write identification information regarding whether a security vulnerability is detected in the function summary information, and accordingly, the virtual machine 500 may perform an efficient dynamic analysis.

본 개시의 일 실시예에 따른 가상 기계(500)는 중간언어 코드를 해석하여 소프트웨어를 실행하며, 또한, 실행된 소프트웨어에 테스트 케이스(test case)들을 입력함으로써 보안 취약점을 감지(다시 말해, 동적 분석)할 수 있다. 이 때, 가상 기계(500)는 함수 요약정보를 기반으로 동적 분석을 수행하여야 할 함수 및 이를 포함하는 구문들에 대해 집중적으로 분석을 수행할 수 있다.The virtual machine 500 according to an embodiment of the present disclosure executes software by interpreting the intermediate language code, and detects security vulnerabilities by inputting test cases into the executed software (that is, dynamic analysis). )can do. In this case, the virtual machine 500 may intensively analyze a function to be subjected to dynamic analysis based on the function summary information and syntax including the same.

도 2a 및 도 2b는 본 개시의 일 실시예에 따른 전자 장치(10)의 입력코드 처리기가 입력 코드에 따라 상이하게 구현되는 실시예를 설명하기 위한 블록도이다. 2A and 2B are block diagrams for explaining an embodiment in which an input code processor of the electronic device 10 is implemented differently according to an input code according to an embodiment of the present disclosure.

도 2a를 참조하면, 본 개시의 입력코드 처리기(100)는 입력 코드가 바이너리 코드인 경우, 디스어셈블러(Disassembler)(101)로 구현될 수 있다. 본 개시의 디스어셈블러(101)는 보안 취약점 분석의 대상이 되는 바이너리 코드를 어셈블리 코드로 변환할 수 있다. Referring to FIG. 2A , the input code processor 100 of the present disclosure may be implemented as a disassembler 101 when the input code is a binary code. The disassembler 101 of the present disclosure may convert a binary code, which is a target of security vulnerability analysis, into an assembly code.

디스어셈블러(101)는 포맷 분석부(110), PE 구조 분석부(120) 및 코드 변환부(130)를 포함할 수 있다. The disassembler 101 may include a format analyzer 110 , a PE structure analyzer 120 , and a code converter 130 .

포맷 분석부(110)는 어셈블리 코드로 리버싱(Reversing)하기 위해 입력된 바이너리 코드의 포맷을 분석하고 특정하기 위한 구성이다. The format analyzer 110 is a component for analyzing and specifying the format of the binary code input for reversing into the assembly code.

PE 구조 분석부(120)는 입력된 바이너리 코드의 PE 구조를 분석할 수 있고, Import Directory Table, Import Lookup Table, Hint/Name Tables, Raw calculation from RVA offset, Indirect Function Call, List of each function start address와 같은 정보를 수집할 수 있다. 또한 exe, dll과 같은 실행파일을 구성하기 위한 부가적인 메타정보들을 분석할 수 있다. PE structure analysis unit 120 may analyze the PE structure of the input binary code, Import Directory Table, Import Lookup Table, Hint/Name Tables, Raw calculation from RVA offset, Indirect Function Call, List of each function start address such information can be collected. In addition, additional meta information for composing executable files such as exe and dll can be analyzed.

코드 변환부(130)는 상술한 정보들을 기초로 입력된 바이너리 코드를 어셈블리 코드로 변환할 수 있다. The code conversion unit 130 may convert the input binary code into an assembly code based on the above-described information.

도 2b를 참조하면, 본 개시의 입력코드 처리기(100)는 입력 코드가 소스 코드 또는 기타 VM 언어인 경우, 프론트 엔드(Frontend)(102)로 구현될 수 있다.Referring to FIG. 2B , the input code processor 100 of the present disclosure may be implemented as a front end 102 when the input code is a source code or other VM language.

본 개시의 프론트 엔드(102)는 소스코드를 파싱하여 구문(syntax) 에러를 체크하고 해당 언어 특성에 맞는 AST (Abstract Syntax Tree)를 생성할 수 있다. 또한, 본 개시의 일 실시예에 따른 프론트 엔드(102)는 소스코드에 포함된 각 변수들을 구별하여 표시할 수 있다.The front end 102 of the present disclosure may parse the source code, check for syntax errors, and generate an Abstract Syntax Tree (AST) suitable for a corresponding language characteristic. In addition, the front end 102 according to an embodiment of the present disclosure may distinguish and display each variable included in the source code.

프론트 엔드(102)는 소스 코드의 종류에 따라 구성될 수 있다. 예컨대, 소스 코드가 탈중앙화 어플리케이션(Decentralized Application)을 구성하며, 이더리움 솔리디티(Ethereum Solidity)에 의해 작성된 경우, 프론트엔드(102)는 솔리디티 프론트엔드(solidity front-end)로 구현될 수 있으나 이에 한정하지 않는다. The front end 102 may be configured according to the type of the source code. For example, when the source code constitutes a decentralized application and is written by Ethereum Solidity, the front-end 102 may be implemented as a solidity front-end, but It is not limited to this.

또 다른 예로, 입력코드가 하이퍼레저 패브릭(Hyperledger Fabric) 프레임워크 하에 자바(Java), 고(Go), 노드제이에스(node.js.)와 같은 프로그래밍 언어로 작성된 체인코드(Chain Code)인 경우, 각각의 프로그래밍 언어에 대응하는 프론트 엔드로 구현될 수 있다. As another example, if the input code is a chain code written in a programming language such as Java, Go, or node.js. under the Hyperledger Fabric framework. , can be implemented as a front end corresponding to each programming language.

도 3은 본 개시의 예시적 실시예에 따른 중간언어 변환기(200)를 설명하기 위한 블록도이다.3 is a block diagram for explaining the intermediate language converter 200 according to an exemplary embodiment of the present disclosure.

도 3을 참조하면, 중간언어 변환기(200)는 코드 파서(code parser)(210), 코드 세그먼트 모듈(211), 분석 모듈(220) 및 중간언어 코드 생성부(230)를 포함할 수 있으며, 분석 모듈(220)은 변수 분석부(221), 데이터 타입 추론부(222), 스택 또는 힙 분석기(223) 및 시스템 함수 및 라이브러리 수집부(224)를 포함할 수 있다.Referring to FIG. 3 , the intermediate language converter 200 may include a code parser 210 , a code segment module 211 , an analysis module 220 and an intermediate language code generator 230 , The analysis module 220 may include a variable analysis unit 221 , a data type inference unit 222 , a stack or heap analyzer 223 , and a system function and library collection unit 224 .

본 개시의 코드 파서(code parser)(210)는 입력되는 코드(도 3에서는 어셈블리 코드)에 포함된 명령어(Instruction) 문장을 구성 성분별로 분해하고, 그들 사이의 위계 관계를 분석하여 문장 구조를 결정할 수 있다. The code parser 210 of the present disclosure decomposes an instruction sentence included in an input code (assembly code in FIG. 3) into constituent components, and determines a sentence structure by analyzing a hierarchical relationship between them. can

코드 파서(210)는 파싱된 어셈블리 코드를 이용하여 추상 구문 트리(abstract syntax tree)(AST)를 생성할 수 있다. 코드 파서(210)는 어셈블리 코드의 구문 오류(syntax error)를 검사할 수 있다.The code parser 210 may generate an abstract syntax tree (AST) using the parsed assembly code. The code parser 210 may check the assembly code for syntax errors.

한편, 도 3은 입력코드가 바이너리 코드로써, 입력코드 처리기(100)에서 어셈블리 코드로 변환된 코드가 중간언어 변환기(200)로 전달되는 실시예에 대하여 도시하였으나, 상술한 바와 같이 이에 한정되지 않는다. Meanwhile, FIG. 3 illustrates an embodiment in which the input code is a binary code, and the code converted from the input code processor 100 to the assembly code is transferred to the intermediate language converter 200, but as described above, the present invention is not limited thereto. .

입력코드가 소스 코드인 실시예의 경우, 중간언어 변환기(200)로 전달되는 언어는 어셈블리 코드가 아닌 소스 코드에 대한 AST(Abstract Syntax Tree)일 수 있다. 이 경우, 코드 파서(210)는 전술한 프론트엔드(102)에 포함될 수 있다. In the case of an embodiment in which the input code is a source code, the language transmitted to the intermediate language converter 200 may be an AST (Abstract Syntax Tree) for the source code, not the assembly code. In this case, the code parser 210 may be included in the aforementioned front end 102 .

본 개시의 코드 세그먼트 모듈(211)은 입력되는 코드 및 AST에 대응하여 코드 세그먼트(Segment)를 생성할 수 있다. 이때, 세그먼트는 주기억장치를 효율적으로 운영하기 위해서, 코드를 일정한 크기(대개는 64kb크기)로 나누어서 할당과 할당 해제로 관리되는 논리적 단위를 의미한다. The code segment module 211 of the present disclosure may generate a code segment in response to an input code and an AST. In this case, the segment means a logical unit managed by allocation and deallocation by dividing the code into a certain size (usually 64 kb) in order to efficiently operate the main memory device.

본 개시의 분석 모듈(220)은 변수 분석부(221), 데이터 타입 추론부(222), 스택또는 힙 분석부(223), 시스템 및 라이브러리 수집부(224)를 포함할 수 있다. The analysis module 220 of the present disclosure may include a variable analysis unit 221 , a data type inference unit 222 , a stack or heap analysis unit 223 , and a system and library collection unit 224 .

중간언어 코드 생성기(230)는 분석 모듈(220)이 분석한 정보(INFO)를 기반으로 중간언어 코드를 생성할 수 있다. 이에 더하여, 중간언어 코드 생성기(230)는 중간언어로써 정의된 자료형 심볼 테이블(Type Symbol Table)을 기초로, 중간언어 코드를 생성할 수 있다. 이때, 자료형 심볼 테이블은 언어 변환에 있어서, 프로그램(소스 코드 또는 바이너리 코드)의 각 식별자가 중간언어 코드 생성기(230)에서의 타입 외형과 관련된 정보에 매칭되도록 기정의된 데이터 구조일 수 있다.The intermediate language code generator 230 may generate an intermediate language code based on the information INFO analyzed by the analysis module 220 . In addition, the intermediate language code generator 230 may generate an intermediate language code based on a data type symbol table defined as an intermediate language. In this case, the data type symbol table may be a data structure defined so that each identifier of a program (source code or binary code) matches information related to the type appearance in the intermediate language code generator 230 in language conversion.

본 개시의 분석 모듈(200) 및 중간언어 코드 생성부(230)가 중간언어 코드를 생성하는 실시예에 대하여 도 4를 함께 참조하여 추가적으로 설명한다.An embodiment in which the analysis module 200 and the intermediate language code generator 230 of the present disclosure generate an intermediate language code will be further described with reference to FIG. 4 .

도 4는 본 개시의 중간언어 변환기가 입력 코드를 중간언어로 변환하는 방법을 설명하기 위한 흐름도이다. 4 is a flowchart illustrating a method for the intermediate language converter of the present disclosure to convert an input code into an intermediate language.

본 개시의 변수 분석부(221)는 코드 세그먼트 모듈(211)로부터 입력되는 코드 세그먼트에 포함된 명령어를 분석하고, 변수를 식별할 수 있다(S410). The variable analysis unit 221 of the present disclosure may analyze a command included in a code segment input from the code segment module 211 and identify a variable ( S410 ).

프로그램은 외부에서 들어오는 신뢰할 수 없는 취약 값을 전달함으로써, 실행에 오작동을 일으키게 되는 과정에서 해킹될 수 있다. 즉, 해커로부터 전달된 취약 값, 프로그램이 커버하지 못하는 범위의 값, 오작동을 일으킬 수 있는 값들이 보안약점이 발생할 수 있는 보안약점 함수에 도달하면, 해당 이런 값들이 전파가 되는 변수를 식별하는게 중요한 문제이다. Programs can be hacked in the process of causing malfunctions in execution by passing untrusted vulnerability values from the outside. In other words, when the vulnerability value transmitted from a hacker, a value in a range that the program does not cover, and a value that can cause a malfunction reach a security weakness function where a security weakness can occur, it is important to identify the variable to which these values are propagated. That's a problem.

이에 따라, 변수 분석부(221)는 명령어에 포함된 오퍼랜드(Operand) 중 변수에 대응하는 것이라고 판단된 오퍼랜드를 식별할 수 있다. 명령어를 분석하고, 변수를 식별하는 방법에 관해서는 도 5에서 후술하기로 한다.Accordingly, the variable analysis unit 221 may identify the operand determined to correspond to the variable from among the operands included in the instruction. A method of analyzing a command and identifying a variable will be described later with reference to FIG. 5 .

본 개시의 데이터 타입 추론부(222)는 식별된 변수에 대응하는 데이터 타입(또는 자료형)을 추론할 수 있다(S420). The data type inference unit 222 of the present disclosure may infer a data type (or data type) corresponding to the identified variable ( S420 ).

프로그램이 실행되면, 오퍼랜드가 지정하는 주소로부터 데이터 값을 로드(load)할 수 있다. 한편, 해당 데이터 값은 지정된 메모리 어드레스(예로, ebp)에서 특정 거리만큼 떨어져있는 임의의 메모리에 접근하여 불러온 값이기 때문에, 해당 데이터가 어떤 데이터 타입의 값인지 확인할 수 없다. 특히, 입력 코드가 바이너리 코드인 경우, 디스어셈블링(disassembling) 과정에서 변수에 대한 타입 정보가 유실되기 때문에, 데이터 타입에 대한 정보를 획득할 수 없다. When the program is executed, data values can be loaded from the address specified by the operand. On the other hand, since the corresponding data value is a value fetched by accessing an arbitrary memory that is a certain distance away from a specified memory address (eg, ebp), it is impossible to determine what type of data the corresponding data is. In particular, when the input code is a binary code, since type information about a variable is lost in a disassembling process, information about a data type cannot be acquired.

이에 따라, 본 개시의 데이터 타입 추론부(222)는 추후 도 7a 내지 도 8b에서 설명하는 바와 같이 데이터 타입을 추론(inference)할 수 있다. Accordingly, the data type inference unit 222 of the present disclosure may infer a data type as described later with reference to FIGS. 7A to 8B .

본 개시의 시스템 함수 및 라이브러리 수집부(224)는 중간언어로 변환 후 보안 취약점을 용이하게 추적할 수 있도록, 시스템 콜 함수(System Call function) 및 라이브러리 콜 함수(Library Call Function)에 대하여 데이터를 수집할 수 있다(S430). The system function and library collection unit 224 of the present disclosure collects data about a system call function and a library call function so that security vulnerabilities can be easily traced after conversion to an intermediate language. It can be done (S430).

 시스템 콜 함수는 커널(Kernel)에 서비스를 요청할 때에 호출하는 함수를 말한다. 대표적인 시스템 콜 함수로는 fork, execve, _exit, kill, open, read, write, close 등의 함수가 있다.A system call function is a function that is called when a service is requested from the kernel. Representative system call functions include fork, execve, _exit, kill, open, read, write, and close functions.

라이브러리 콜은 유틸리티성(Utility) 함수 및 랩핑(Wrapping) 함수를 포함한다. 유틸리티성 함수는 strcmp, strcpy, strlen, memset 등과 같이 개발을 쉽게 할 수 있도록 기능을 제공하는 함수이며, 랩핑 함수는 fopen, fclose, fread, fwrite, exit, malloc, free 등과 같이 시스템 콜을 최소화 하기 위한 함수일 수 있으나, 이에 한정하지 않는다. The library call includes a utility function and a wrapping function. Utility functions are functions that make development easier, such as strcmp, strcpy, strlen, memset, etc., and wrapping functions are used to minimize system calls such as fopen, fclose, fread, fwrite, exit, malloc, free, etc. It may be a function, but is not limited thereto.

시스템 콜 함수는 프로그램 내부에서 메모리를 할당/해제하지 않으며, 메모리 할당이 필요한 경우에는 반드시 외부에서 할당하여 매개변수로 넘긴다. 또한, 라이브러리 콜 함수는 내부에서 메모리를 할당하여 반환(return)할 수도 있다는 점에서, 상당수의 표준 라이브러리(Standard Library)가 보안에 취약할 수 있다. The system call function does not allocate/release memory inside the program, and when memory allocation is required, it must be allocated externally and passed as a parameter. In addition, since the library call function may return (return) by allocating memory internally, a significant number of standard libraries may be vulnerable to security.

즉, 외부에서 입력받은 변수 값을 추적한 결과, 해당 변수 값이 보안에 취약한 라이브러리 콜 함수에 전달되는 경우, 중간언어 변환기(200)는 해당 함수에 보안 취약점이 존재하는 것으로 판단할 수 있다. That is, as a result of tracing the variable value input from the outside, when the variable value is transmitted to a library call function that is weak in security, the intermediate language converter 200 may determine that a security vulnerability exists in the corresponding function.

이에 따라, 본 개시의 중간언어 변환기(200)는 입력 코드의 시스템 함수 및 라이브러리 함수에 대한 정보를 수집하여 재구성한 후, 이에 대한 정보를 중간언어 코드에 포함시킴으로써, 향후 보안 취약점 식별 및 트래킹을 용이하게 할 수 있다.Accordingly, the intermediate language converter 200 of the present disclosure collects and reconfigures information about the system function and library function of the input code, and then includes the information in the intermediate language code to facilitate future security vulnerability identification and tracking can do it

본 개시의 중간언어 코드 생성부(230)는 상기 식별된 변수 정보, 변수에 대한 데이터 타입 정보 및 시스템 콜 함수 및 라이브러리 콜 함수를 기초로 중간언어 코드를 생성할 수 있다(S440). 이때, 중간언어 코드 생성부(230)는 기저장된 자료형 심볼 테이블(Type Symbol Table)에 대응되도록 입력 코드를 중간언어로 변환할 수 있다. 본 개시의 전자 장치(10)는 생성된 중간언어 코드를 기초로 보안약점을 분석할 수 있고, 분석된 함수요약정보를 생성할 수 있다. The intermediate language code generating unit 230 of the present disclosure may generate an intermediate language code based on the identified variable information, data type information about the variable, and a system call function and a library call function (S440). In this case, the intermediate language code generator 230 may convert the input code into an intermediate language so as to correspond to a pre-stored data type symbol table (Type Symbol Table). The electronic device 10 of the present disclosure may analyze a security weakness based on the generated intermediate language code and may generate the analyzed function summary information.

도 5 및 도 6은 중간언어 변환기(200)가 명령어를 분석하고, 변수를 식별하는 방법을 설명하기 위한 도면이다. 5 and 6 are diagrams for explaining a method in which the intermediate language converter 200 analyzes a command and identifies a variable.

특히, 도 5는 본 개시의 일 실시예에 따른 중간언어 변환기가 명령어를 분석하는 방법에 대하여 설명하는 간단한 흐름도이다. In particular, FIG. 5 is a simple flowchart illustrating a method of analyzing a command by an intermediate language converter according to an embodiment of the present disclosure.

본 개시의 변수 분석부(221)는 입력 코드에 대응하는 세그먼트(Segment) 코드에 대하여 명령어 라인 단위로 오퍼랜드 필드를 분석할 수 있다(S510). 이때, 세그먼트 코드는 주기억장치를 효율적으로 운영하기 위해, 입력 코드를 일정한 크기(대개는 64kb크기)로 나누어서 할당과 할당 해제로 관리되는 논리적 단위를 의미한다. The variable analyzer 221 of the present disclosure may analyze the operand field in units of command lines with respect to a segment code corresponding to the input code (S510). In this case, the segment code refers to a logical unit managed by allocation and deallocation by dividing the input code into a certain size (usually 64 kb) in order to efficiently operate the main memory device.

본 개시의 변수 분석부(221)는 명령어(또는 인스트럭션; Instruction)에 포함된 변수 패턴을 분석함으로써, 해당 명령어 코드에 대응하는 변수가 지역 변수(Local Variable)인지, 전역 변수(Global Variable)인지, 매개 변수(Parameter)인지 여부 등을 판단할 수 있다(S520). 이때, 변수 패턴이란 오퍼랜드 필드의 토큰들에 대한 어휘 규칙일 수 있다. 즉, 변수 패턴은, 오퍼랜드가 참조하는 주소가 레지스터 주소에 대응하는 토큰을 통해 지정되는지, 레지스터 주소 및 상수가 결합된 토큰을 통해 지정되는지 등에 따라서 구분될 수 있다. The variable analysis unit 221 of the present disclosure analyzes a variable pattern included in an instruction (or an instruction) to determine whether a variable corresponding to the instruction code is a local variable or a global variable, Whether or not it is a parameter may be determined (S520). In this case, the variable pattern may be a lexical rule for tokens of the operand field. That is, the variable pattern may be classified according to whether an address referenced by an operand is specified through a token corresponding to a register address, or a token in which a register address and a constant are combined.

본 개시의 일 실시예에 따르면, 변수 분석부(221)는 오퍼랜드 패턴이 [레지스터 어드레스]를 참조하는 경우 제1 변수 패턴으로, [레지스터 어드레스+상수] 를 참조하는 경우 제2 변수 패턴으로 분석할 수 있다. According to an embodiment of the present disclosure, the variable analysis unit 221 analyzes the operand pattern as a first variable pattern when referring to [register address] and as a second variable pattern when referring to [register address + constant]. can

변수 분석부(221)는 제1 변수 패턴 및/또는 제2 변수 패턴으로 분석하는 경우, 해당 오퍼랜드를 지역 변수 및/또는 매개변수에 대응하는 것으로 판단할 수 있다. When analyzing the first variable pattern and/or the second variable pattern, the variable analyzing unit 221 may determine that the corresponding operand corresponds to the local variable and/or the parameter.

본 개시의 또 다른 실시예에 따르면, 변수 분석부(221)는 오퍼랜드 패턴이 [상수]를 참조하는 경우 제3 변수 패턴으로 분석할 수 있다. 변수 분석부(221)는 제3 변수 패턴으로 분석하는 경우, 해당 오퍼랜드를 전역 변수에 대응하는 것으로 판단할 수 있다. According to another embodiment of the present disclosure, when the operand pattern refers to [constant], the variable analysis unit 221 may analyze it as a third variable pattern. When analyzing the third variable pattern, the variable analyzing unit 221 may determine that the corresponding operand corresponds to the global variable.

또한, 본 개시의 변수 분석부(221)는 상기 변수 패턴에 대한 정보와 명령어에 포함된 연산자 정보를 결합하여, 변수를 구별할 수 있다. Also, the variable analysis unit 221 of the present disclosure may distinguish variables by combining the information on the variable pattern and operator information included in the command.

예를 들어, 변수 분석부(221)는 명령어의 오퍼랜드의 유형이 상기 제1 변수 패턴 내지 제3 변수 패턴이면서, 명령어에 포함된 연산자가 기설정된 연산자 그룹에 포함된 연산자인 경우, 해당 오퍼랜드가 변수에 대응하는 것으로 판단할 수 있다.For example, when the type of the operand of the command is the first variable pattern to the third variable pattern and the operator included in the command is an operator included in a preset operator group, the variable analysis unit 221 may change the operand to a variable. can be considered to correspond to

이때, 기설정된 연산자 그룹은 변수와 흔히 결합되어 실행되는 연산자들의 집합일 수 있다. 일예로, 기설정된 연산자 그룹은 mov. cmp 등을 포함하나 이에 한정하지 않는다. In this case, the preset operator group may be a set of operators that are often combined with variables and executed. For example, the preset operator group is mov. cmp, etc., but are not limited thereto.

도 6은 본 개시의 중간언어 변환기가 변수를 식별하는 실시예를 예시적으로 나타낸다. 6 exemplarily shows an embodiment in which the intermediate language converter of the present disclosure identifies a variable.

도 6은 전자 장치(10)에 입력 코드로써 바이너리 코드가 입력된 경우, 해당 바이너리 코드를 어셈블리 코드로 디스어셈블링(Disassembling)을 수행한 결과물을 도시한다. 6 illustrates a result of disassembling the binary code into an assembly code when a binary code is input as an input code to the electronic device 10 .

본 개시의 변수 분석부(221)는 라인 별로 명령어의 오퍼랜드 필드를 분석할 수 있다. 변수 분석부(221)는 mov eax, [ebp-0x14] 명령어 오퍼랜드 필드에 포함된 제1 오퍼랜드(610)에 대하여 분석할 수 있다. 제1 오퍼랜드(610)는 레지스터 어드레스로 스택 프레임의 시작 지점 주소(ebp; Extended Base Pointer)와 오프셋(offset)으로 상수(0x08)가 결합되어 참조되어 있다. 이에 따라, 변수 분석부(221)는 제1 오퍼랜드(610)가 제2 변수 패턴인 것으로 판단할 수 있다.The variable analyzer 221 of the present disclosure may analyze the operand field of the instruction for each line. The variable analyzer 221 may analyze the first operand 610 included in the mov eax, [ebp-0x14] instruction operand field. The first operand 610 is a register address, and a constant (0x08) is combined with an extended base pointer (ebp) address of the stack frame as an offset and referenced. Accordingly, the variable analysis unit 221 may determine that the first operand 610 is the second variable pattern.

마찬가지로, 변수 분석부(221)는 다른 명령어 오퍼랜드 필드에 포함된 제2 오퍼랜드(620), 제3 오퍼랜드(630)에 대하여 분석할 수 있다. 제2 오퍼랜드(620) 및 제3 오퍼랜드(630)에는 레지스터 어드레스로 스택 프레임의 시작 지점 주소(ebp; Extended Base Pointer)와 오프셋(offset)으로 상수가 결합되어 참조되어 있다. 이에 따라, 변수 분석부(221)는 제2 오퍼랜드(620) 및 제3 오퍼랜드(630)가 제2 변수 패턴인 것으로 판단할 수 있다. Similarly, the variable analyzer 221 may analyze the second operand 620 and the third operand 630 included in other instruction operand fields. The second operand 620 and the third operand 630 are referenced by combining an extended base pointer (ebp) address of a stack frame as a register address and a constant as an offset. Accordingly, the variable analysis unit 221 may determine that the second operand 620 and the third operand 630 are the second variable patterns.

본 개시의 중간언어 변환기(200)는 상기 제1 오퍼랜드(610) 내지 제3 오퍼랜드(630)를 포함하는 명령어의 연산자(640)가 기설정된 연산자 그룹에 해당하는지 판단할 수 있다. 상기 기설정된 연산자 그룹은 변수와 흔히 결합되어 수행되는 연산자들의 집합일 수 있다. 일예로, 기설정된 연산자 그룹은 move. cmp 등을 포함하나 이에 한정하지 않는다. The intermediate language converter 200 of the present disclosure may determine whether the operator 640 of the instruction including the first operand 610 to the third operand 630 corresponds to a preset operator group. The preset operator group may be a set of operators that are frequently combined with variables. For example, the preset operator group is move. cmp, etc., but are not limited thereto.

중간언어 변환기(200)는 상기와 같은 변수 패턴에 특정 연산자가 결합된 경우, 해당 오퍼랜드가 변수에 대응하는 것으로 판단할 수 있다. 도 6의 예시에서, 상기 연산자(640)가 기설정된 연산자 그룹에 포함된 연산자로 판단되고, 제2 변수 패턴인 것으로 판단하면, 중간언어 변환기(200)는 제1 오퍼랜드(610) 내지 제3 오퍼랜드(630)를 지역 변수 및/또는 매개변수로 판단할 수 있다. When a specific operator is combined with the variable pattern as described above, the intermediate language converter 200 may determine that the corresponding operand corresponds to the variable. In the example of FIG. 6 , when it is determined that the operator 640 is an operator included in a preset operator group and it is determined that it is a second variable pattern, the intermediate language converter 200 performs the first operands 610 to the third operands. 630 may be determined as a local variable and/or parameter.

도 7a 및 도 7b는 본 개시의 일 실시예에 따른 중간언어 변환기가 데이터 타입을 추론하는 방법에 대하여 설명하기 위한 흐름도이다. 7A and 7B are flowcharts for explaining a method of inferring a data type by an intermediate language converter according to an embodiment of the present disclosure.

본 개시의 데이터 타입 추론부(222)는 명령어 구조를 분석할 수 있다(S710). 이때, 명령어 구조는 1-주소 명령어(one-address instruction), 2-주소 명령어(two-address instruction) 및 3-주소 명령어(three-address instruction)일 수 있다. The data type inference unit 222 of the present disclosure may analyze the instruction structure (S710). In this case, the instruction structure may be a one-address instruction, a two-address instruction, and a three-address instruction.

본 개시의 데이터 타입 추론부(222)는 분석된 명령어 구조에 따라 위치하는 오퍼랜드의 패턴을 식별할 수 있다(S720). 이때, 오퍼랜드 패턴은 상수 패턴, 레지스터 패턴, 변수 패턴 및 포인터 패턴을 포함할 수 있다.The data type inference unit 222 of the present disclosure may identify a pattern of an operand located according to the analyzed instruction structure (S720). In this case, the operand pattern may include a constant pattern, a register pattern, a variable pattern, and a pointer pattern.

이후, 데이터 타입 추론부(222)는 명령어 구조에 대응하는 오퍼랜드의 위치 및 오퍼랜드 패턴을 기초로 패턴매칭(Pattern matching)시킴으로써, 데이터 타입을 추론할 수 있다(S730). Thereafter, the data type inference unit 222 may infer the data type by performing pattern matching based on the position of the operand corresponding to the instruction structure and the operand pattern (S730).

즉, 데이터 타입 추론부(222)는 명령어 내 오퍼랜드 위치 및 오퍼랜드 패턴을 기초로 패턴매칭을 수행함을 통해 데이터의 타입 정보를 추론할 수 있다. 이에 대하여, 도 7b 및 7c를 통해 추가적으로 설명한다. That is, the data type inference unit 222 may infer data type information by performing pattern matching based on the position of the operand in the instruction and the pattern of the operand. This will be further described with reference to FIGS. 7B and 7C.

도 7b 및 7c는 본 개시의 데이터 타입 추론부가 데이터 타입을 추론하는 방법을 예시적으로 설명하기 위한 도면이다. 7B and 7C are diagrams for exemplarily explaining a method of inferring a data type by a data type inference unit of the present disclosure.

도 7b를 함께 참조하면, 데이터 타입 추론부(222)는 명령어(710)에 대하여 전주소(711) 및 후주소(712)를 포함하는 2-주소 명령어(two-address instruction) 구조인 것으로 판단할 수 있다. 이때, 전주소와 후주소는 명령어 표현상 위치를 기준으로 구분할 것일 수 있다. Referring to FIG. 7B together, the data type inference unit 222 determines that the instruction 710 has a two-address instruction structure including a pre-address 711 and a post-address 712. can In this case, the pre-address and the post-address may be divided based on the position in the command expression.

데이터 타입 추론부(222)는 후주소(712)에 위치한 상수 패턴(0xff)을 식별하고, 전주소(711)에 위치한 변수 패턴을 식별할 수 있다. 후주소(712)의 0xff는 접두사 0x를 사용한 16진 표기이며, 통상 가장 효율적인 4 바이트의 정수형이 사용된다. 이에, 데이터 타입 추론부(222)는 전주소(711)에 위치한 변수 [ebp-0x8]의 데이터 타입을 정수(int)로 추론할 수 있다.The data type inference unit 222 may identify a constant pattern (0xff) located at the post address 712 , and identify a variable pattern located at the previous address 711 . 0xff of the post address 712 is a hexadecimal notation using the prefix 0x, and the most efficient 4-byte integer type is usually used. Accordingly, the data type inference unit 222 may infer the data type of the variable [ebp-0x8] located in the previous address 711 as an integer (int).

데이터 타입 추론부(222)는 명령어(720)에 대하여 명령어 구조가 2-주소 명령어(two-address instruction)인 것으로 판단할 수 있다. 데이터 타입 추론부(222)는 2-주소 중 후주소(722)에 위치한 상수 패턴(eax) 및 전주소(721)에 위치한 변수 패턴을 기초로 데이터 타입을 추론할 수 있다. eax 레지스터는 rax 레지스터의 하위 4바이트를 의미하는 것으로, 데이터 타입 추론부(222)는 전주소(721)에 위치한 변수 [ebp+0x8]은 integer 수준에서 연산이 수행되는 것으로 판단할 수 있고, 변수 [ebp+0x8]의 데이터 타입을 정수(int)로 추론할 수 있다.The data type reasoning unit 222 may determine that the instruction structure is a two-address instruction with respect to the instruction 720 . The data type inference unit 222 may infer the data type based on the constant pattern eax located at the rear address 722 and the variable pattern located at the front address 721 among the 2-addresses. The eax register means the lower 4 bytes of the rax register, and the data type inference unit 222 can determine that the variable [ebp+0x8] located at the previous address 721 is an integer level operation, and the variable The data type of [ebp+0x8] can be inferred as an integer (int).

상술한 예시에서와 같이, 데이터 타입 추론부(222)는 명령어 내 오퍼랜드 위치 및 오퍼랜드 패턴을 기초로 패턴매칭을 수행함을 통해 데이터의 타입 정보를 추론할 수 있다.As in the above example, the data type inference unit 222 may infer type information of data by performing pattern matching based on the operand position and the operand pattern in the instruction.

본 개시의 데이터 타입 추론부(222)는 제1 명령어의 구조의 구조를 분석함으로써, 제1 명령어 변수의 데이터 타입을 추론할 수 있다. 또한, 데이터 타입 추론부(222)는 제1 명령어의 구조 및 제1 명령어와 연관된 제2 명령어의 구조를 분석함으로써, 제1 명령어 변수의 데이터 타입을 추론할 수 있다. 이때, 제2 명령어는 상기 변수와 문맥상 연관된 적어도 하나의 명령어일 수 있다. The data type inference unit 222 of the present disclosure may infer the data type of the first instruction variable by analyzing the structure of the first instruction. Also, the data type inference unit 222 may infer the data type of the first instruction variable by analyzing the structure of the first instruction and the structure of the second instruction associated with the first instruction. In this case, the second command may be at least one command associated with the variable in context.

본 개시의 선택적 실시예에 따른 데이터 타입 추론부(222)는 도 7a 및 도 7b에서 설명한 방법(패턴매칭)에 따른 데이터 타입 추론을 학습된 인공지능 모델을 통하여 수행할 수 있다. The data type inference unit 222 according to an optional embodiment of the present disclosure may perform data type inference according to the method (pattern matching) described with reference to FIGS. 7A and 7B through the learned artificial intelligence model.

이때, 인공지능 모델은 RNN(Recurrent Neural Network), 특히 LSTM(Long Short-Term Memory)을 통해 구현된 것일 수 있으나, 이에 한정하지 않으며 다양한 AI 모델을 통해 구현될 수 있다. 상술한 인공지능 모델은 외부서버(미도시)에서 학습되어 전자 장치(10)로 전송된 것일 수 있으나, 선택적 실시예에 따라 인공지능 모델를 학습시키고 저장하는 모듈이 전자 장치(10)에 포함될 수 있다. In this case, the artificial intelligence model may be implemented through a Recurrent Neural Network (RNN), in particular, a Long Short-Term Memory (LSTM), but is not limited thereto and may be implemented through various AI models. The aforementioned artificial intelligence model may be learned from an external server (not shown) and transmitted to the electronic device 10 , but according to an optional embodiment, a module for learning and storing the artificial intelligence model may be included in the electronic device 10 . .

상술한 인공지능 모델은 소스 코드, 소스 코드에 기재된 데이터 타입 및 소스 코드와 관련된 바이너리 코드(또는 어셈블리 코드)에 대하여 학습 데이터 세트로 학습된 딥러닝 모델일 수 있다. The above-described artificial intelligence model may be a deep learning model trained as a training data set with respect to a source code, a data type described in the source code, and a binary code (or assembly code) related to the source code.

본 개시의 인공지능 모델은 입력 코드(소스 코드, 바이너리 코드 또는 어셈블리분석 코드 등)기 입력되면, 입력 코드의 소스 코드에 기재된 데이터 타입을 출력하도록 학습된 것일 수 있다. The artificial intelligence model of the present disclosure may be trained to output the data type described in the source code of the input code when an input code (source code, binary code, assembly analysis code, etc.) is input.

또한, 본 개시의 또 다른 실시예에 따른 인공지능 모델은 인공지능 모델은 지정된 레지스터 및 지정된 변수를 쓰기 위한, 앞단 코드패턴과 뒷단 코드패턴을 통한 문맥정보를 기초로 학습된 것일 수 있다. In addition, the artificial intelligence model according to another embodiment of the present disclosure may be learned based on context information through the front end code pattern and the rear end code pattern for the artificial intelligence model to write a specified register and a specified variable.

본 개시의 데이터 타입 추론부(222)가 상기 인공지능 모델을 통해 데이터 타입을 추론한 정확도 결과는 도 8과 같다. 도 8는 LSTM으로 구현된 인공지능 모델로 데이터 타입을 추론한 것이며, 전체 87.67%의 정확도로 변수의 데이터 타입을 추론할 수 있다. An accuracy result obtained by inferring a data type through the artificial intelligence model by the data type inference unit 222 of the present disclosure is shown in FIG. 8 . 8 shows data types inferred with an artificial intelligence model implemented with LSTM, and data types of variables can be inferred with an overall accuracy of 87.67%.

상술한 바와 같이 상실된 변수의 데이터 타입을 추론함으로써, 본 개시의 전자 장치(10)는 입력되는 코드의 종류에 제약 없이 중간언어로 변환이 가능하다. 예를 들어, 바이너리 코드에서 어셈블리 코드로 변환과정에서 상실되는 변수의 타입 정보를 추론함으로써, 중간언어를 생성할 수 있다는 장점이 있다. As described above, by inferring the data type of the lost variable, the electronic device 10 of the present disclosure can convert to an intermediate language without restrictions on the type of input code. For example, there is an advantage that an intermediate language can be created by inferring the type information of a variable that is lost in the process of converting from binary code to assembly code.

전자 장치(10)는 중간언어를 기반으로 보안약점을 수행한다는 점에서, 입력되는 코드에 제약없이 보안약점 분석 및 함수요약정보를 생성할 수 있다는 효과가 있다.Since the electronic device 10 performs security weaknesses based on the intermediate language, there is an effect that security weakness analysis and function summary information can be generated without restrictions on input codes.

특히, 블록체인 환경에서 작성된 프로그램에 대하여, 소스 코드 없이 Dapp 실행파일만 제공된 경우에도, 본 개시의 전자 장치(10)는 해당 실행 파일을 기초로 중간언어를 생성할 수 있고, 보안약점 분석 등 추가 작업을 실행할 수 있다는 효과가 있다. In particular, for a program written in a block chain environment, even when only a Dapp executable file is provided without a source code, the electronic device 10 of the present disclosure can generate an intermediate language based on the corresponding executable file, and add security weakness analysis, etc. It has the effect of being able to run the job.

도 9는 디스어셈블링된 어셈블리 코드에 대하여 변수를 추론하여, 중간언어로 변환된 것을 예시적으로 설명하기 위한 도면이다. 9 is a diagram for exemplarily explaining that a variable is inferred from disassembled assembly code and converted into an intermediate language.

본 개시의 전자 장치(10)는 제1 명령어(910)의 오퍼랜드 분석 결과, 변수에 대응하는 오퍼랜드임을 식별할 수 있고, 해당 명령의 구조를 분석할 수 있다. 제1 명령어(910)가 2-주소 명령어 구조인 것으로 분석할 수 있고, 후주소에 위치한 변수 패턴(ebp-0x14) 및 전주소의 레지스터 패턴(eax)을 식별할 수 있다. eax 레지스터는 rax 레지스터의 하위 4바이트를 의미하는 것이다. 이에, 전자 장치(10)는 후주소에 위치한 변수 [ebp-0x8]의 데이터 타입을 정수(int)로 추론할 수 있다.As a result of analyzing the operand of the first instruction 910 , the electronic device 10 of the present disclosure may identify the operand corresponding to the variable and analyze the structure of the corresponding instruction. It can be analyzed that the first instruction 910 has a two-address instruction structure, and a variable pattern (ebp-0x14) located at the back address and a register pattern (eax) of the previous address can be identified. The eax register means the lower 4 bytes of the rax register. Accordingly, the electronic device 10 may infer the data type of the variable [ebp-0x8] located at the back address as an integer (int).

본 개시의 전자 장치(10)는 자료형 심볼 테이블 상 정수(int)를 i로 매핑할 수 있다. 이에 따라, 전자 장치(10)는 자료형 i로 추론한 결과를 기초로 제1 명령어(920)를 중간언어 코드(920)로 변환할 수 있다. The electronic device 10 of the present disclosure may map an integer (int) to i in the data type symbol table. Accordingly, the electronic device 10 may convert the first command 920 into the intermediate language code 920 based on the inferred result of the data type i.

한편, 상술한 본 개시의 다양한 실시 예들에 따른 방법들은, 기존 전자 장치에 설치 가능한 어플리케이션 형태로 구현될 수 있다. Meanwhile, the above-described methods according to various embodiments of the present disclosure may be implemented in the form of an application that can be installed in an existing electronic device.

또한, 상술한 본 개시의 다양한 실시 예들에 따른 방법들은, 기존 전자 장치에 대한 소프트웨어 업그레이드, 또는 하드웨어 업그레이드 만으로도 구현될 수 있다. In addition, the above-described methods according to various embodiments of the present disclosure may be implemented only by software upgrade or hardware upgrade of an existing electronic device.

또한, 상술한 본 개시의 다양한 실시예들은 전자 장치에 구비된 임베디드 서버, 또는 전자장치의 외부 서버를 통해 수행되는 것도 가능하다. In addition, various embodiments of the present disclosure described above may be performed through an embedded server provided in the electronic device or an external server of the electronic device.

한편, 본 개시의 일 실시예에 따르면, 이상에서 설명된 다양한 실시예들은 소프트웨어(software), 하드웨어(hardware) 또는 이들의 조합을 이용하여 컴퓨터(computer) 또는 이와 유사한 장치로 읽을 수 있는 기록매체(computer readable recording medium)에 저장된 명령어를 포함하는 소프트웨어로 구현될 수 있다. 일부 경우에 있어 본 명세서에서 설명되는 실시예들이 프로세서 자체로 구현될 수 있다. 소프트웨어적인 구현에 의하면, 본 명세서에서 설명되는 절차 및 기능과 같은 실시 예들은 별도의 소프트웨어 모듈들로 구현될 수 있다. 소프트웨어 모듈들 각각은 본 명세서에서 설명되는 하나 이상의 기능 및 동작을 수행할 수 있다. On the other hand, according to an embodiment of the present disclosure, the various embodiments described above are a recording medium (readable by a computer or a similar device) using software, hardware, or a combination thereof. It may be implemented as software including instructions stored in a computer readable recording medium). In some cases, the embodiments described herein may be implemented by the processor itself. According to the software implementation, embodiments such as procedures and functions described in this specification may be implemented as separate software modules. Each of the software modules may perform one or more functions and operations described herein.

한편, 컴퓨터(computer) 또는 이와 유사한 장치는, 저장 매체로부터 저장된 명령어를 호출하고, 호출된 명령어에 따라 동작이 가능한 장치로서, 개시된 실시 예들에 따른 장치를 포함할 수 있다. 상기 명령이 프로세서에 의해 실행될 경우, 프로세서가 직접, 또는 상기 프로세서의 제어 하에 다른 구성요소들을 이용하여 상기 명령에 해당하는 기능을 수행할 수 있다. 명령은 컴파일러 또는 인터프리터에 의해 생성 또는 실행되는 코드를 포함할 수 있다. Meanwhile, a computer or a similar device is a device capable of calling a stored command from a storage medium and operating according to the called command, and may include the device according to the disclosed embodiments. When the instruction is executed by the processor, the processor may directly or use other components under the control of the processor to perform a function corresponding to the instruction. Instructions may include code generated or executed by a compiler or interpreter.

기기로 읽을 수 있는 기록매체는, 비일시적 기록매체(non-transitory computer readable recording medium)의 형태로 제공될 수 있다. 여기서, '비일시적'은 저장매체가 신호(signal)를 포함하지 않으며 실재(tangible)한다는 것을 의미할 뿐 데이터가 저장매체에 반영구적 또는 임시적으로 저장됨을 구분하지 않는다. 이때 비일시적 컴퓨터 판독 가능 매체란 레지스터, 캐쉬, 메모리 등과 같이 짧은 순간 동안 데이터를 저장하는 매체가 아니라 반영구적으로 데이터를 저장하며, 기기에 의해 판독(reading)이 가능한 매체를 의미한다. 비일시적 컴퓨터 판독 가능 매체의 구체적인 예로는, CD, DVD, 하드 디스크, 블루레이 디스크, USB, 메모리카드, ROM 등이 있을 수 있다.The device-readable recording medium may be provided in the form of a non-transitory computer readable recording medium. Here, 'non-transitory' means that the storage medium does not include a signal and is tangible, and does not distinguish that data is semi-permanently or temporarily stored in the storage medium. In this case, the non-transitory computer-readable medium refers to a medium that stores data semi-permanently, rather than a medium that stores data for a short moment, such as a register, cache, memory, etc., and can be read by a device. Specific examples of the non-transitory computer-readable medium may include a CD, DVD, hard disk, Blu-ray disk, USB, memory card, ROM, and the like.

이와 같이 본 개시는 도면에 도시된 실시예를 참고로 설명되었으나 이는 예시적인 것에 불과하며, 당해 기술분야에서 통상의 지식을 가진 자라면 이로부터 다양한 변형 및 균등한 다른 실시예가 가능하다는 점을 이해할 것이다. 따라서 본 개시의 진정한 기술적 보호 범위는 첨부된 청구범위의 기술적 사상에 의하여 정해져야 할 것이다.As such, the present disclosure has been described with reference to the embodiments shown in the drawings, which are merely exemplary, and those of ordinary skill in the art will understand that various modifications and equivalent other embodiments are possible therefrom. . Therefore, the true technical protection scope of the present disclosure should be determined by the technical spirit of the appended claims.

Claims (20)

소프트웨어 보안 취약점 분석을 위한 전자 장치의 중간언어 변환 방법에 있어서,
입력 코드를 수신하는 단계;
상기 입력 코드에 기초하여 명령어에 포함된 적어도 하나의 변수를 식별하는 단계;
상기 식별된 변수에 대한 데이터 타입을 추론하는 단계; 및
상기 식별된 변수에 대한 정보 및 상기 추론된 데이터 타입을 기초로 상기 입력 코드를 중간 언어로 변환하는 단계;를 포함하고,
상기 입력 코드는 소스 코드, 바이너리 코드 및 가상 기계 코드 중 적어도 하나이고,
상기 소스 코드는, 탈중앙화 분산형 어플리케이션(Decentralized Application)의 실행 코드이고, 이더리움 솔리디티(Ethereum Solidity) 및 하이퍼렛져 패브릭(Hyperledger Fabric) 중 적어도 하나의 언어로 구현된 것을 특징으로 하는 중간언어 변환 방법.
In the intermediate language conversion method of an electronic device for software security vulnerability analysis,
receiving an input code;
identifying at least one variable included in a command based on the input code;
inferring a data type for the identified variable; and
converting the input code into an intermediate language based on the information on the identified variable and the inferred data type;
the input code is at least one of source code, binary code, and virtual machine code;
The source code is an executable code of a decentralized application, and is an intermediate language conversion, characterized in that it is implemented in at least one language of Ethereum Solidity and Hyperledger Fabric. Way.
삭제delete 제1항에 있어서,
상기 입력 코드가 소스 코드인 경우,
상기 중간언어 변환 방법은 추상 구문 트리(Abstract syntax tree)를 기반으로 상기 소스 코드의 문법 오류를 검사하는 단계;를 더 포함하는 것을 특징으로 하는 중간언어 변환 방법.
According to claim 1,
If the input code is the source code,
The intermediate language conversion method further comprises the step of checking the grammatical error of the source code based on an abstract syntax tree.
제1항에 있어서,
상기 입력 코드가 바이너리 코드인 경우,
상기 중간언어 변환 방법은,
상기 바이너리 코드를 어셈블리 코드로 변환하는 단계; 및
상기 어셈블리 코드를 복수의 세그먼트 코드로 구분하는 단계;를 더 포함하는 것을 특징으로 하는 중간언어 변환 방법.
According to claim 1,
If the input code is a binary code,
The intermediate language conversion method,
converting the binary code into assembly code; and
The intermediate language conversion method further comprising; dividing the assembly code into a plurality of segment codes.
삭제delete 삭제delete 제4항에 있어서,
상기 적어도 하나의 변수를 식별하는 단계는,
상기 입력 코드의 명령어(Instruction)에 포함된 오퍼랜드(Operand)의 패턴을 분석하는 단계; 를 더 포함하고,
상기 패턴에 기초하여 상기 적어도 하나의 변수를 식별하는 것을 특징으로 하는 중간언어 변환 방법.
5. The method of claim 4,
The step of identifying the at least one variable comprises:
analyzing a pattern of an operand included in an instruction of the input code; further comprising,
and identifying the at least one variable based on the pattern.
제7항에 있어서,
상기 패턴을 분석하는 단계는 상기 오퍼랜드를 기초로 상수 패턴, 레지스터 패턴, 변수 패턴 및 포인터 패턴 중 하나의 패턴을 식별하는 것이고,
상기 추론하는 단계는 상기 패턴을 기초로 상기 데이터 타입을 추론하는 것을 특징으로 하는 중간 언어 변환 방법.
8. The method of claim 7,
analyzing the pattern is to identify one of a constant pattern, a register pattern, a variable pattern, and a pointer pattern based on the operand,
The inference step is an intermediate language conversion method, characterized in that inferring the data type based on the pattern.
제1항에 있어서,
상기 추론하는 단계는 상기 소스 코드의 패턴과 상기 바이너리 코드의 패턴간의 상관 관계를 기초로 학습된 LSTM(Long Short Term Memory) 학습모델을 기반으로 데이터 타입을 추론하는 것을 특징으로 하는 중간 언어 변환 방법.
According to claim 1,
The inference step is an intermediate language conversion method, characterized in that the data type is inferred based on a Long Short Term Memory (LSTM) learning model learned based on the correlation between the pattern of the source code and the pattern of the binary code.
입력 코드를 수신하는 입력코드 처리기; 및
상기 입력 코드에 기초하여 명령어에 포함된 적어도 하나의 변수를 식별하고, 상기 식별된 변수에 대한 데이터 타입을 추론하고, 상기 식별된 변수에 대한 정보 및 상기 추론된 데이터 타입을 기초로 상기 입력 코드를 중간 언어로 변환하는 중간언어 변환기;를 포함하고,
상기 입력 코드는 소스 코드, 바이너리 코드 및 가상 기계 코드 중 적어도 하나이고,
상기 소스 코드는, 탈중앙화 분산형 어플리케이션(Decentralized Application)의 실행 코드이고, 이더리움 솔리디티(Ethereum Solidity) 및 하이퍼렛져 패브릭(Hyperledger Fabric) 중 적어도 하나의 언어로 구현된 것을 특징으로 하는 전자 장치.
an input code processor for receiving an input code; and
Identifies at least one variable included in an instruction based on the input code, infers a data type for the identified variable, and selects the input code based on the information about the identified variable and the inferred data type Intermediate language converter for converting to an intermediate language; including;
the input code is at least one of source code, binary code, and virtual machine code;
The source code is an executable code of a decentralized application, and is implemented in at least one language of Ethereum Solidity and Hyperledger Fabric.
삭제delete 제10항에 있어서,
상기 중간언어 변환기는 상기 입력 코드가 소스 코드인 경우, 추상 구문 트리(Abstract syntax tree)를 기반으로 상기 소스 코드의 문법 오류를 검사하는 것을 특징으로 하는 전자 장치.
11. The method of claim 10,
The intermediate language converter checks the grammatical error of the source code based on an abstract syntax tree when the input code is the source code.
제10항에 있어서,
상기 중간언어 변환기는 상기 입력 코드가 바이너리 코드인 경우, 상기 바이너리 코드를 어셈블리 코드로 변환하고, 상기 어셈블리 코드를 복수의 세그먼트 코드로 구분하는 것을 특징으로 하는 전자 장치.
11. The method of claim 10,
The intermediate language converter converts the binary code into an assembly code when the input code is a binary code, and divides the assembly code into a plurality of segment codes.
삭제delete 삭제delete 제13항에 있어서,
상기 중간언어 변환기는 상기 입력 코드의 명령어(Instruction)에 포함된 오퍼랜드(Operand)의 패턴을 분석하고, 상기 패턴에 기초하여 상기 적어도 하나의 변수를 식별하는 것을 특징으로 하는 전자 장치.
14. The method of claim 13,
The intermediate language converter analyzes a pattern of an operand included in an instruction of the input code, and identifies the at least one variable based on the pattern.
제16항에 있어서,
상기 중간언어 변환기는 상기 오퍼랜드를 기초로 상수 패턴, 레지스터 패턴, 변수 패턴 및 포인터 패턴 중 하나의 패턴을 식별하고, 상기 패턴을 기초로 상기 데이터 타입을 추론하는 것을 특징으로 하는 전자 장치.
17. The method of claim 16,
The intermediate language converter identifies one of a constant pattern, a register pattern, a variable pattern, and a pointer pattern based on the operand, and infers the data type based on the pattern.
제10항에 있어서,
상기 중간언어 변환기는 상기 소스 코드의 패턴과 상기 바이너리 코드의 패턴간의 상관 관계를 기초로 학습된 LSTM(Long Short Term Memory) 학습모델을 기반으로 데이터 타입을 추론하는 것을 특징으로 하는 전자 장치.
11. The method of claim 10,
and the intermediate language converter infers a data type based on a Long Short Term Memory (LSTM) learning model learned based on a correlation between the pattern of the source code and the pattern of the binary code.
소프트웨어 보안 취약점 분석을 위한 전자 장치의 중간언어 변환 방법에 있어서, 이더리움 솔리디티(Ethereum Solidity) 및 하이퍼렛져 패브릭(Hyperledger Fabric) 중 적어도 하나의 언어로 구현된 탈중앙화 분산형 어플리케이션(Decentralized Application)의 실행 코드인 소스 코드를 수신하는 단계;
상기 소스 코드에 기초하여 명령어에 포함된 적어도 하나의 변수를 식별하는 단계;
상기 식별된 변수에 대한 데이터 타입을 추론하는 단계; 및
상기 식별된 변수에 대한 정보 및 상기 추론된 데이터 타입을 기초로 상기 소스 코드를 중간 언어로 변환하는 단계;를 포함하는 중간언어 변환 방법.
In the intermediate language conversion method of an electronic device for software security vulnerability analysis, a decentralized application implemented in at least one language of Ethereum Solidity and Hyperledger Fabric (Decentralized Application) receiving a source code that is an executable code;
identifying at least one variable included in an instruction based on the source code;
inferring a data type for the identified variable; and
and converting the source code into an intermediate language based on the information on the identified variable and the inferred data type.
제19항에 있어서,
상기 소스 코드를 구현하는 언어의 종류에 따라 달리 구성되는 프론트 엔드에 의해, 추상 구문 트리(Abstract syntax tree)를 생성하는 단계를 더 포함하는 것을 특징으로 하는 중간언어 변환 방법.
20. The method of claim 19,
and generating an abstract syntax tree by a front end configured differently according to a type of language implementing the source code.
KR1020200148942A 2020-11-09 2020-11-09 Code converting method based on intermediate language and electronic device including the same KR102341137B1 (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
KR1020200148942A KR102341137B1 (en) 2020-11-09 2020-11-09 Code converting method based on intermediate language and electronic device including the same

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
KR1020200148942A KR102341137B1 (en) 2020-11-09 2020-11-09 Code converting method based on intermediate language and electronic device including the same

Publications (1)

Publication Number Publication Date
KR102341137B1 true KR102341137B1 (en) 2021-12-20

Family

ID=79033941

Family Applications (1)

Application Number Title Priority Date Filing Date
KR1020200148942A KR102341137B1 (en) 2020-11-09 2020-11-09 Code converting method based on intermediate language and electronic device including the same

Country Status (1)

Country Link
KR (1) KR102341137B1 (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116501378A (en) * 2023-06-27 2023-07-28 武汉大数据产业发展有限公司 Implementation method and device for reverse engineering reduction source code and electronic equipment

Non-Patent Citations (5)

* Cited by examiner, † Cited by third party
Title
N. Andola et al., Vulnerabilities on Hyperledger Fabric, ELSEVIER Pervasive and Mobile Computing Vol.58 (2019.10) *
민예슬 외 5명, 중간언어 생성을 위한 바이너리 코드 자료형 및 변수 추론 기술 조사 분석, 2017년 춘계학술발표대회 논문집 제24권 제1호, pp.283-286 (2017.4) *
손윤식 외, 추상 구문 트리에서 시멘틱 트리로의 변환, 한국정보과학회, 한국정보과학회 학술발표 논문집, pp.892-894 (2005.7) *
이용현 외, 추상 구문 트리 기반의 개발자별 소스 코드 지분 분석, 한국컴퓨터정보학회 하계학술발표대회 논문집 제23권 제2호, pp.23-24 (2015.7.) 1부.* *
이태규 외, 소프트웨어 보안약점 분석을 위한 바이너리 코드-중간언어 변환기에 관한 연구, 한국정보처리학회 2017 춘계학술발표대회 논문집, pp.276-279 (2017.) 1부.* *

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116501378A (en) * 2023-06-27 2023-07-28 武汉大数据产业发展有限公司 Implementation method and device for reverse engineering reduction source code and electronic equipment
CN116501378B (en) * 2023-06-27 2023-09-12 武汉大数据产业发展有限公司 Implementation method and device for reverse engineering reduction source code and electronic equipment

Similar Documents

Publication Publication Date Title
CN111770113B (en) Method for executing intelligent contract, block chain node and node equipment
JP7201078B2 (en) Systems and methods for dynamically identifying data arguments and instrumenting source code
US8850581B2 (en) Identification of malware detection signature candidate code
US10698668B1 (en) Custom code transformations during compilation process
US8966635B2 (en) Software module object analysis
CN111770206B (en) Method for deploying intelligent contract, block chain node and storage medium
CN107526625B (en) Java intelligent contract security detection method based on bytecode inspection
US9754112B1 (en) Detection and healing of vulnerabilities in computer code
US8141035B2 (en) Method for accessing internal states of objects in object oriented programming
Arzt et al. Instrumenting android and java applications as easy as abc
KR100763177B1 (en) Method for executing Java virtual machine instructions, and apparatus for the same
CN110245467B (en) Android application program protection method based on Dex2C and LLVM
CN109101237A (en) The encryption Compilation Method and device of code
Nu1L Team Reverse engineering
CN111768187A (en) Method for deploying intelligent contract, block chain node and storage medium
CN111815330A (en) Method for deploying intelligent contract, block chain node and storage medium
KR102341137B1 (en) Code converting method based on intermediate language and electronic device including the same
Dresel et al. Artist: the android runtime instrumentation toolkit
KR102367196B1 (en) Security vulnerability analysis method based on intermediate language and electronic device including the same
CN113849397A (en) Execution engine, virtual machine, related apparatus and related methods
KR102392394B1 (en) Security vulnerability analysis method for generating function abstract information and electronic device including the same
Reynolds Modeling the java bytecode verifier
US11886589B2 (en) Process wrapping method for evading anti-analysis of native codes, recording medium and device for performing the method
CN117235746B (en) Source code safety control platform based on multidimensional AST fusion detection
CN114707124B (en) NET platform code protection method and system based on code virtualization

Legal Events

Date Code Title Description
GRNT Written decision to grant