WO2016104918A1 - Code conversion method and code conversion device - Google Patents

Code conversion method and code conversion device Download PDF

Info

Publication number
WO2016104918A1
WO2016104918A1 PCT/KR2015/009483 KR2015009483W WO2016104918A1 WO 2016104918 A1 WO2016104918 A1 WO 2016104918A1 KR 2015009483 W KR2015009483 W KR 2015009483W WO 2016104918 A1 WO2016104918 A1 WO 2016104918A1
Authority
WO
WIPO (PCT)
Prior art keywords
function
flattening
branch
software
code conversion
Prior art date
Application number
PCT/KR2015/009483
Other languages
French (fr)
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 고려대학교 산학협력단
Publication of WO2016104918A1 publication Critical patent/WO2016104918A1/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F21/00Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
    • G06F21/10Protecting distributed programs or content, e.g. vending or licensing of copyrighted material ; Digital rights management [DRM]
    • G06F21/12Protecting executable software
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F21/00Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
    • G06F21/10Protecting distributed programs or content, e.g. vending or licensing of copyrighted material ; Digital rights management [DRM]
    • G06F21/12Protecting executable software
    • G06F21/121Restricting unauthorised execution of programs
    • G06F21/125Restricting unauthorised execution of programs by manipulating the program code, e.g. source code, compiled code, interpreted code, machine code

Definitions

  • the present invention relates to a code conversion method and a code conversion device, and more particularly, to a code conversion method and a code conversion device for generating software having a modulation resistance and a modulation detection function using an intermediate language.
  • the field of software protection is the study of how to protect software from malicious software analysis (e.g., software critical logic takeover) or software tampering (e.g., bypassing software license check routines).
  • software tamper-detection relates to a method of detecting and responding to modulation when the software is tampered with, and software with tamper-resistance makes it difficult to tamper with the software and preemptively blocks it. It is about how to.
  • Hardware-based protection is a technique to protect software based on the stability of hardware that is not accessible from the outside.
  • Software-based protection is a technique that responds to software analysis or modulation without the help of hardware.
  • Hardware-based protection schemes are generally known to be safer, but they require additional hardware, which incurs additional costs, and makes it difficult to adapt to multiple software environments depending on the hardware installed. As such, software-based protection schemes have various advantages over hardware-based protection schemes.
  • Code conversion techniques to add modulation resistance and / or detection to the software.
  • Code conversion is done at the source code level (eg C, Fortran, etc.) or at the binary code level (eg machine language).
  • source code level eg C, Fortran, etc.
  • binary code level eg machine language
  • the source code level code conversion technique has limitations in preserving the code conversion effect due to optimization in the compilation process because the code conversion is performed at the source code level.
  • Binary-level code conversion techniques make it difficult to interpret machine language and modify the machine language itself, which makes it difficult to add resistance and detection while maintaining the normal functioning of the software.
  • the source code level conversion technique depends on the language in which the source code is written (for example, C, Fortran, etc.), and the binary level code conversion technique depends on the machine language (for example, x86, ARM, etc.). It is not easy to apply the same code conversion technique.
  • the present invention has been made to solve the above problems, and can easily add the functions of modulation detection and modulation resistance without affecting the original function based on software regardless of the language of the source code and the language type of the machine language. It is an object of the present invention to provide a method and a code conversion device.
  • a code conversion method for achieving the above object includes (b) selecting a function to be protected, selecting a protection function to flatten the control flow and an integrity function to be guaranteed integrity, and (c) generating labels to be used for flattening the flattening function, the label generating step of generating each branch function to be used in each of the blocks in the flattening function using the integrity function.
  • the code conversion apparatus for achieving the above object is a selector for selecting a function to be protected, and selects and flattening function for selecting a smoothing function that is to be flattened the control flow and an integrity function that is to be guaranteed integrity.
  • the code conversion method and the code conversion device according to the present invention as described above can easily add the functions of modulation detection and modulation resistance without affecting the original function based on software regardless of the language of the source code and the language type of the machine language. It has an effect.
  • FIG. 1 is a diagram illustrating an exemplary hardware block diagram of a code conversion device.
  • FIG. 2 is a diagram illustrating an exemplary control flow for code conversion.
  • FIG. 3 is a diagram illustrating an exemplary functional block diagram of a code conversion device.
  • FIG. 4 illustrates a CFG for an exemplary planarization function that is a planarization target.
  • FIG. 5 shows the planarized CFG after applying the planarization treatment to the CFG of FIG. 4.
  • FIG. 1 is a diagram illustrating an exemplary hardware block diagram of a code conversion apparatus 100.
  • the code conversion device 100 includes an input interface 101, an output interface 103, a memory 105, a storage medium 107, a system bus / control bus 111, and a processor 113. It may further include a communication interface 109.
  • the specific hardware block may be omitted according to the use or modification of the code conversion apparatus 100.
  • the code conversion device 100 is a device for converting source code (software) to enable modulation resistance and / or modulation detection.
  • the code conversion apparatus 100 may be, for example, a personal computer used by a programmer or a distributor of a program, a laptop, or a server capable of providing a program's conversion function through an internet network.
  • the input interface 101 is an interface for receiving a user input.
  • the input interface 101 includes a mouse, a keyboard and / or a touch panel, and receives a user input for performing code conversion.
  • the received input is delivered to the processor 113 as input data via the system bus / control bus 111.
  • the output interface 103 includes an LCD module, an LED module and / or a speaker, and is an interface for outputting a result or an intermediate result performed by the code conversion apparatus 100.
  • the output interface 103 makes it possible to know the results for the transcoded software, for example.
  • Memory 105 includes volatile memory.
  • the memory 105 may temporarily store various data and programs.
  • the memory 105 may be a code conversion program executed in the processor 113 or software that is an input of a code conversion program (or source code, hereinafter, the term 'software' and 'source code' are used interchangeably). Save it temporarily.
  • the storage medium 107 stores at least a code conversion program executed by the processor 113 and software that is an input target of the code conversion program.
  • the software is organized at the source code level. For example, software is written in programming languages such as C, C ++, Fortran, Java, and so on.
  • the code conversion program converts the input software into an intermediate language (hereinafter also referred to as 'IR') so that the input software on the intermediate language has modulation resistance and / or modulation detection.
  • the software translated into the designated machine language may be output to the output interface 103, stored in the storage medium 107, or output through the communication interface 109.
  • the processor 113 includes one or more execution units capable of executing instructions to execute code of a program stored in the storage medium 107.
  • the processor 113 may be referred to as a so-called CPU, MPU, or the like.
  • the processor 113 loads the code conversion program stored in the storage medium 107 into the memory 105 and performs a code conversion program to convert the input software to have modulation resistance and / or modulation detectability.
  • the processor 113 preferably adds code to translate the input software into the intermediate language and adds code to have modulation resistance and / or modulation detectability for the input software converted to the intermediate language or convert the input software to the designated machine language.
  • the processor 113 particularly the code conversion program, will be described in detail with reference to FIGS. 2 and 3.
  • the system bus / control bus 111 is a bus capable of transmitting and receiving various analog / digital data between hardware blocks.
  • the system bus / control bus 111 may be a parallel bus or a serial bus or a dedicated bus for a particular hardware block.
  • the system bus / control bus 111 may transmit and receive analog or digital data depending on the type of bus.
  • the communication interface 109 which can be further included is an interface for transmitting and receiving network packets connected to the Internet network.
  • the communication interface 109 includes, for example, a PHY chip for connecting to Wi-Fi or a wired LAN.
  • FIG. 2 is a diagram illustrating an exemplary control flow for code conversion.
  • the code conversion control flow of FIG. 2 is performed, for example, on a hardware block diagram of the code conversion apparatus 100 of FIG.
  • the code conversion control flow of FIG. 2 is performed by the processor 113 of the code conversion apparatus 100 and preferably consists of the instruction execution of the processor 113 by the code conversion program.
  • the code conversion control flow of FIG. 2 starts as the processor 113 of the code conversion apparatus 100 starts to perform the code conversion program stored in the storage medium 107 (S100) and ends as the code conversion program ends. S200).
  • the code conversion apparatus 100 receives a selection for the software to be converted by the user through the input interface 101 (or the communication interface 109) (S101). In the selective reception of the software, the code conversion apparatus 100 loads the software stored in the storage medium 107 or received via the communication interface 109 into the memory 105 or the like.
  • the code conversion device 100 converts the loaded source code level software into a representation of an intermediate language (S103).
  • the intermediate language can be, for example, instructions used in the known low level virtual machine (LLVM) compiler platform.
  • the intermediate language of LLVM is an independent language that is independent of any kind of language at the source level and is also a language that is not dependent on machine language.
  • LLVM's intermediate language supports machine-independent labels and can express various execution paths through labels.
  • the data based on the software converted into the intermediate language may be output to the output interface 103 by the code conversion apparatus 100.
  • the code conversion apparatus 100 outputs a function list included in the converted software through the output interface 103.
  • the user provides an input indicating the selection of a function that needs to be protected in the outputted function list through the input interface 101 and the code conversion apparatus 100 selects a function to be protected corresponding to the input according to the reception of the selection input. (S105).
  • the code conversion apparatus 100 selects a specific type of function from the function list by selecting a function that needs to be protected.
  • the code conversion device 100 selects a function (hereinafter, referred to as a 'flattening function' or 'FF' (Flattening Function)) to which the control flow is to be flattened to make code analysis difficult.
  • a function hereinafter, also referred to as 'integrity function' or 'IF' (Integrity Function)
  • the code conversion apparatus 100 selects a function (hereinafter, also referred to as an 'encryption function' or an encryption function (EF)) to be encrypted.
  • the selection of one or more functions may be determined by user input.
  • Each type of function can be one or more.
  • the flattening function is a function that must first be performed on the integrity function and the encryption function, and is set by the code conversion apparatus 100 or guided through the output interface 103.
  • the flattening function is a target function for flattening the control flow of the function to obfuscate the analysis.
  • various information for checking the integrity of the integrity function and generating a dynamic key to encrypt the encryption function ( Data) is generated.
  • An integrity function is a target function whose integrity is to be guaranteed. It indicates a function that is not necessarily hidden but must not be tampered with.
  • the integrity function may be an anti-debugging routine or a license check routine.
  • the encryption function is a function that must be protected by encryption, and a function that must be hidden to prevent the analysis itself can be specified. For example, an encryption function may be a fatal function when exposed to the outside including important logic of the software.
  • the code conversion apparatus 100 converts the selected flattening function into a control flow graph (CFG) and classifies the flattening function into flattenable blocks according to the conversion of the CFG.
  • CFG control flow graph
  • 4 shows CFG for a particular flattening function
  • FIG. 5 shows CFG after flattening application according to the invention (BB0 of FIG. 4 corresponds to BBa of FIG. 5 and the other blocks also have the same correspondence).
  • BB0 of FIG. 4 corresponds to BBa of FIG. 5 and the other blocks also have the same correspondence.
  • each block in the CFG is configured such that the code in the block does not branch to other blocks at execution and branches to other blocks after all the code in each block is completed.
  • the code conversion apparatus 100 first determines a label (for each block in the CFG of the flattening function). , In the example of FIG. 5, i is a to f, and the branch function for each block ( ) And the function to be used in the switch statement ( )
  • the label of the block indicates the execution start position of the corresponding block and the label may be represented by a variable.
  • the branch function corresponding to each block is configured to be different from each other.
  • Branch function of each block Depends on the branch condition after completion of the block, for example, if there is no branch (i.e., only one subsequent block is performed). + mask + Expressed as ", and if a branch exists" + mask + "Is expressed. Is a hash function that takes an integrity function mapped to each block as an input argument. here Represents a hash value of an IF (integrity function) mapped to each block.
  • the code conversion apparatus 100 determines which IF integrity is checked for each block. For example, the code conversion apparatus 100 randomly maps each block of the flattening function to a specific one IF. here, Denotes any indicator indicating the starting position (branch position) at which block i starts on the transformed software. May consist of a combination of numbers, a combination of letters, or a combination of numbers and letters and may be represented by a variable.
  • Branch function The branch function is not hardcoded as we will see below. It is configured to itself (i.e. the code for the calculation of the branch function of each block) with the corresponding block embedded in the software converted to the code block. Accordingly branch function Is the label value at actual execution of the converted software ( Is safe for static analysis methods. Denotes the condition of the i block, allowing branching to a particular label according to true (1) or false (0) according to one or more conditions.
  • Function F () has a specific label ( As a function for generating), F () can be expressed as a hash function whose output argument is a branch function. The function F () allows the switch statement to select the exact block position to be executed next time.
  • the branch function according to the present invention consists of applying a hash function to the integrity function.
  • the hash value produced by the application of the hash function to the integrity function is also different. this is Is changed and execution of each block does not work normally. If a change due to the modulation of the integrity function can be detected, it can correspond to the modulation.
  • the modulation can be determined by the hash value used in the branch of the smoothing function to the integrity function. This will be described below.
  • the code conversion apparatus 100 generates a dynamic key for encryption of the encryption function (S109).
  • the dynamic key generated by the present invention is not stored anywhere in the converted software. If the dynamic key is stored in the converted software, the encryption loses its meaning if the dynamic key is found externally.
  • the present invention generates a dynamic key using the label generated in the label generation step S107.
  • each block (i) of the smoothing function is ( , ) Pairs. Therefore, each and every block of the smoothing function , ), And the code conversion device 100 generates a dynamic key using these ordered pairs having i as an index.
  • This secret splitting technique is a technique for recovering a secret when t or more splittings are collected among n splittings.
  • the code conversion apparatus 100 derives the number of all blocks (n, 6 in the example of FIG. 4) through the CFG of the flattening function and the shortest execution path through the CFG.
  • the length t (4 in the example of FIG. 4) is derived.
  • the length t represents the number of blocks on the shortest execution path.
  • the derivation of n and t can be easily performed by the code conversion apparatus 100.
  • the code conversion apparatus 100 generates a secret dynamic key using the derived n and t.
  • the code conversion apparatus 100 flattens the flattening function using the generated label (S111).
  • FIG. 5 shows the CFG after planarization is performed with respect to the CFG of FIG. 4.
  • the inter-block execution dependency order on the original execution path is flattened through a switch statement.
  • Each block (see BBa, BBb, etc. of FIG. 5) constitutes one code block together with a corresponding branch function (see Ba (), Bb (), etc. of FIG. 5).
  • the branch function is not hardcoded and is coupled to the corresponding block as a function in accordance with the present invention.
  • the converted software is executed and a specific block of the flattening function is executed, the corresponding branch function is executed immediately after completion of the execution of this specific block.
  • the branch function dynamically calculates the labels to branch. Thus, static analysis of the planarization function is not possible.
  • Flattened code by flattening is the default label ( ).
  • the branch function of a particular block generates a branch label (or branch value) by applying a specified function (eg a hash function) to a specific integrity function. Therefore, when the integrity function is modulated, the branch label produced by the branch function also changes.
  • the tampering of the integrity function can be detected using a default label (a label used when there is no matching label).
  • Block of default labels ( ) May output the modulation detection result of the software, including a modulation correspondence routine (eg, program termination, modulation detection output, modulation detection output to a designated server, etc.).
  • the code conversion apparatus 100 After generation of the dynamic key, the code conversion apparatus 100 encrypts the encryption function with the generated dynamic key (S113).
  • the dynamic key according to the invention is not embedded in the software to be converted. Instead, in code execution of the flattened function, the flattened function performs t (shortest execution path length) blocks and branch functions through at least the shortest execution path, and thus transforms the dynamic key using these t branch functions. Software can be restored.
  • the code conversion device 100 performs an optimization process when necessary and converts the machine language through a compilation and linking process for the machine language designated by the user (S115).
  • the code conversion apparatus 100 stores the converted machine language, that is, the converted software having the modulation resistance and the detection function, in the storage medium 107 (S117) or outputs it through the communication interface 109.
  • the code conversion method of FIG. 2 may be configured as a computer program that can be stored in a medium.
  • the computer program is stored on a USB, CD, DVD, smart card or removable hard disk, or an internal hard disk.
  • the computer program is executed on the hardware block (s) of FIG. 1, in particular the processor 113.
  • FIG. 3 is a diagram illustrating an exemplary functional block diagram of a code conversion apparatus 100.
  • the code conversion device 100 includes an intermediate language conversion unit 151, a module loader unit 153, a selection unit 155, a label generation unit 157, a dynamic key generation unit 159, and a flattening unit ( 161, an encryption unit 163, an optimizer 165, and a machine language converter 167.
  • Some functional blocks in the functional block diagram of FIG. 3 may be omitted according to design variations.
  • the functional blocks of FIG. 3 are performed on the hardware block diagram of FIG. 1 and are preferably constituted by a code conversion program executed by the processor 113.
  • the code conversion program may be stored and distributed in various storage media 107 and executed by the processor 113 on the hardware block diagram of FIG.
  • the functional block diagram of FIG. 3 may constitute one software development platform.
  • the functional block diagram of FIG. 3 is configured within a Low Level Virtual Machine (LLVM) compilation platform to convert source level software to a specific binary level machine language.
  • the known LLVM platform consists of the intermediate language conversion unit 151, the module loader unit 153, the optimization unit 165, and the machine language conversion unit 167.
  • the known LLVM platform converts software into an intermediate level intermediate language. It is then translated into machine language.
  • the intermediate language converter 151 converts the input software selected by the user into a representation of the intermediate language.
  • the intermediate language conversion unit 151 outputs software in the expression of the converted intermediate language.
  • the output intermediate software is then transmitted to the module loader unit 153 or the like.
  • the module loader unit 153 loads various program modules to be used for software conversion according to the present invention.
  • the module loader 153 loads an encryption module, a hash function module, and a secret partition module.
  • Such an encryption module, hash function module, secret division module and the like are included in the converted software at the time of software conversion. Then, when the converted software is executed, such a module is also performed as necessary to enable the original function of the software.
  • the module loader section 153 preferably links these modules to software in an intermediate language representation.
  • the modules loaded also consist of intermediate language representations.
  • the selector 155 selects a function to be protected.
  • the selector 155 selects at least one flattening function that is an object to flatten the control flow and at least one integrity function whose integrity is to be guaranteed.
  • the selector 155 selects one or more encryption functions to be encrypted.
  • the flattening function may be a function preceding a particular one or more integrity functions and a particular one or more cryptographic functions.
  • the label generator 157 generates labels to be used in flattening for the flattening function.
  • the label generator 157 generates a CFG for the flattening function and generates each branch function to be used in each block in the CFG.
  • the particular branch function for a particular block contains a specified function whose argument is a mapped integrity function. This specified function can be a hash function, for example.
  • the dynamic key generation unit 159 generates a dynamic key to encrypt the encryption function using the branch functions.
  • the dynamic key is generated using a secret partitioning technique that utilizes the length of the shortest execution path of the flattening function and the total number of blocks.
  • the dynamic key is recoverable using branch functions of the length (number) of the shortest execution path of the smoothing function on the transformed software.
  • the flattening unit 161 flattens the selected flattening function.
  • the planarization unit 161 configures one code block with each branch function corresponding to each of the blocks of the planarization function.
  • the code in the flattened function thus dynamically executes the branch function after execution of the block, and the branch function dynamically calculates the label to branch to later with dynamic execution.
  • the code of the flattening function generated in the flattening unit 161 includes a default label, and the default label is configured to detect tampering of the software.
  • the encryption unit 163 encrypts the encryption function with the dynamic key generated by the dynamic key generation unit 159.
  • the optimizer 165 optimizes the intermediate language software generated or converted through each block.
  • the optimization here is such that the code conversion result is maintained even after the application of the code conversion technique according to the invention.
  • the machine language converter 167 performs a link process using compilation or library of a designated or selected machine language. By converting the software of the intermediate language by the machine language conversion unit 167 into machine language, the converted software having the modulation resistance and the detection function is generated.
  • the converted software can be stored in the storage medium 107 or output via the communication interface 109.

Abstract

The present invention relates to a code conversion method and a code conversion device comprising: a protection function selection step (b) of, in order to select a function to be protected, selecting a flattening function, the control flow of which is to be flattened, and an integrity function, the integrity of which is to be guaranteed; and a label generating step (c) of, in order to generate labels to be used in flattening for the flattening function, generating each bounding function to be used in each block of the flattening function. Use of the present invention enables generation of software having modulation resistance and a modulation detection function by utilizing an intermediate language.

Description

코드 변환 방법 및 코드 변환 장치Transcoding method and transcoding device
본 발명은 코드 변환 방법 및 코드 변환 장치에 관한 것으로서, 구체적으로는 중간 언어를 이용하여 변조 저항성 및 변조 탐지 기능을 갖는 소프트웨어를 생성하기 위한 코드 변환 방법 및 코드 변환 장치에 관한 것이다.The present invention relates to a code conversion method and a code conversion device, and more particularly, to a code conversion method and a code conversion device for generating software having a modulation resistance and a modulation detection function using an intermediate language.
소프트웨어 보호 분야는 악의적인 목적의 소프트웨어 분석(예를 들어 소프트웨어 중요 로직 탈취)이나 소프트웨어 변조(예를 들어 소프트웨어 라이센스 체크 루틴 우회) 등으로부터 소프트웨어를 보호하는 방법을 연구하는 분야이다. 그 중에서 소프트웨어 변조 탐지(tamper-detection)는 소프트웨어가 변조되었을 때 변조를 탐지하여 대응하는 방법에 관한 것이고, 변조 저항성(tamper-resistance)을 갖는 소프트웨어는 소프트웨어의 변조를 어렵게 하여 선제적으로 변조를 차단하는 방법에 관한 것이다.The field of software protection is the study of how to protect software from malicious software analysis (e.g., software critical logic takeover) or software tampering (e.g., bypassing software license check routines). Among them, software tamper-detection relates to a method of detecting and responding to modulation when the software is tampered with, and software with tamper-resistance makes it difficult to tamper with the software and preemptively blocks it. It is about how to.
소프트웨어 보호 기법은 그 기반에 따라 분류될 수 있다. 하드웨어 기반의 보호 기법은 외부에서 접근할 수 없는 하드웨어의 안정성에 기반하여 소프트웨어를 보호하는 기법이다. 소프트웨어 기반의 보호 기법은 하드웨어의 도움 없이 소프트웨어 자체적으로 분석이나 변조 등에 대응하는 기법이다. 하드웨어 기반의 보호 기법이 일반적으로 더 안전하다고 알려져 있지만 추가적인 하드웨어가 필요하여 추가 비용이 발생하고 하드웨어의 장착에 의존하여 여러 소프트웨어 환경에서의 유연한 적용이 어려운 점이 있다. 이와 같이, 소프트웨어 기반의 보호 기법이 하드웨어 기반의 보호 기법에 비해서 다양한 장점이 존재한다.Software protection techniques can be classified according to their basis. Hardware-based protection is a technique to protect software based on the stability of hardware that is not accessible from the outside. Software-based protection is a technique that responds to software analysis or modulation without the help of hardware. Hardware-based protection schemes are generally known to be safer, but they require additional hardware, which incurs additional costs, and makes it difficult to adapt to multiple software environments depending on the hardware installed. As such, software-based protection schemes have various advantages over hardware-based protection schemes.
소프트웨어 기반의 보호 기법은 소프트웨어에 변조 저항성 및/또는 탐지 기능을 추가하기 위해 코드 변환 기법을 이용한다. 코드 변환은 소스코드(예를 들어 C, Fortran 등) 레벨에서 이루어지거나 바이너리 코드(예를 들어 기계어) 레벨에서 이루어진다. 하지만 소스코드 레벨 및 바이너리 레벨의 코드 변환 기법 각각은 다양한 한계점을 가지고 있다. Software-based protection techniques use code conversion techniques to add modulation resistance and / or detection to the software. Code conversion is done at the source code level (eg C, Fortran, etc.) or at the binary code level (eg machine language). However, each of the source code level and binary level code conversion techniques has various limitations.
소스코드 레벨의 코드 변환 기법은 소스코드 레벨에서 코드 변환이 이루어지기에 컴파일 과정에서의 최적화로 코드 변환 효과를 보존하기 힘든 한계가 존재한다. 바이너리 레벨의 코드 변환 기법은 기계어 해석과 기계어 자체의 수정이 어려워 코드 변환 자체가 어렵고 이에 따라 소프트웨어의 정상적인 기능을 유지하면서 저항성 및 탐지 기능을 추가하는 것이 용이치 않다. 또한 소스코드 레벨의 변환 기법은 소스코드를 작성한 언어(예를 들어 C, Fortran 등)에 의존적이고 바이너리 레벨의 코드 변환 기법은 기계어(예를 들어 x86, ARM 등)에 의존적이기에 각 언어나 기계어마다 동일한 코드 변환 기법을 적용하는 것이 용이치 않다.The source code level code conversion technique has limitations in preserving the code conversion effect due to optimization in the compilation process because the code conversion is performed at the source code level. Binary-level code conversion techniques make it difficult to interpret machine language and modify the machine language itself, which makes it difficult to add resistance and detection while maintaining the normal functioning of the software. In addition, the source code level conversion technique depends on the language in which the source code is written (for example, C, Fortran, etc.), and the binary level code conversion technique depends on the machine language (for example, x86, ARM, etc.). It is not easy to apply the same code conversion technique.
따라서, 소프트웨어 기반의 보호 기법을 적용하여 비용 감소 및 유연성을 제공하면서 소프트웨어 기반의 보호 기법의 기존에 알려져 있는 여러 문제점을 해소할 수 있도록 하는 코드 변환 방법 및 코드 변환 장치가 필요하다.Accordingly, there is a need for a code conversion method and a code conversion device that can apply a software-based protection scheme to provide cost reduction and flexibility while solving various problems known in the software-based protection scheme.
본 발명은 상술한 문제점을 해결하기 위해서 안출한 것으로서, 소스코드의 언어 및 기계어의 언어 유형에 상관없이 소프트웨어 기반으로 본래 기능에 영향을 미치지 않고 용이하게 변조 탐지 및 변조 저항의 기능을 추가할 수 있는, 코드 변환 방법 및 코드 변환 장치를 제공하는 데 그 목적이 있다.SUMMARY OF THE INVENTION The present invention has been made to solve the above problems, and can easily add the functions of modulation detection and modulation resistance without affecting the original function based on software regardless of the language of the source code and the language type of the machine language. It is an object of the present invention to provide a method and a code conversion device.
상기와 같은 목적을 달성하기 위한 코드 변환 방법은 (b) 보호될 함수를 선택하는 단계로서, 제어 흐름을 평탄화할 대상인 평탄화 함수 및 무결성이 보장되어야 할 대상인 무결성 함수를 선택하는, 보호 함수 선택 단계 및 (c) 평탄화 함수에 대한 평탄화에 이용될 레이블들을 생성하는 단계로서, 무결성 함수를 이용하여 평탄화 함수 내의 블록들 각각에서 이용될 분기 함수 각각을 생성하는, 레이블 생성 단계를 포함한다. A code conversion method for achieving the above object includes (b) selecting a function to be protected, selecting a protection function to flatten the control flow and an integrity function to be guaranteed integrity, and (c) generating labels to be used for flattening the flattening function, the label generating step of generating each branch function to be used in each of the blocks in the flattening function using the integrity function.
또한 상기와 같은 목적을 달성하기 위한 코드 변환 장치는 보호될 함수를 선택하는 선택부로서, 제어 흐름을 평탄화할 대상인 평탄화 함수 및 무결성이 보장되어야 할 대상인 무결성 함수를 선택하는, 선택부 및 평탄화 함수에 대한 평탄화에 이용될 레이블들을 생성하는 레이블 생성부로서, 무결성 함수를 이용하여 평탄화 함수 내의 블록들 각각에서 이용될 분기 함수 각각을 생성하는, 레이블 생성부를 포함한다.In addition, the code conversion apparatus for achieving the above object is a selector for selecting a function to be protected, and selects and flattening function for selecting a smoothing function that is to be flattened the control flow and an integrity function that is to be guaranteed integrity. A label generator for generating labels to be used for the flattening for the flattening, the label generating unit for generating each branch function to be used in each of the blocks in the flattening function using the integrity function.
상기와 같은 본 발명에 따른 코드 변환 방법 및 코드 변환 장치는 소스코드의 언어 및 기계어의 언어 유형에 상관없이 소프트웨어 기반으로 본래 기능에 영향을 미치지 않고 용이하게 변조 탐지 및 변조 저항의 기능을 추가할 수 있는 효과가 있다. The code conversion method and the code conversion device according to the present invention as described above can easily add the functions of modulation detection and modulation resistance without affecting the original function based on software regardless of the language of the source code and the language type of the machine language. It has an effect.
도 1은 코드 변환 장치의 예시적인 하드웨어 블록도를 도시한 도면이다. 1 is a diagram illustrating an exemplary hardware block diagram of a code conversion device.
도 2는 코드 변환을 위한 예시적인 제어 흐름을 도시한 도면이다. 2 is a diagram illustrating an exemplary control flow for code conversion.
도 3은 코드 변환 장치의 예시적인 기능 블록도를 도시한 도면이다. 3 is a diagram illustrating an exemplary functional block diagram of a code conversion device.
도 4는 평탄화 대상인 예시적인 평탄화 함수에 대한 CFG를 나타내는 도면이다.4 illustrates a CFG for an exemplary planarization function that is a planarization target.
도 5는 도 4의 CFG에 대한 평탄화 처리 적용후의 평탄화된 CFG를 나타낸다.FIG. 5 shows the planarized CFG after applying the planarization treatment to the CFG of FIG. 4.
상술한 목적, 특징 및 장점은 첨부된 도면을 참조하여 상세하게 후술 되어 있는 상세한 설명을 통하여 더욱 명확해 질 것이며, 그에 따라 본 발명이 속하는 기술 분야에서 통상의 지식을 가진 자가 본 발명의 기술적 사상을 용이하게 실시할 수 있을 것이다. 또한, 본 발명을 설명함에 있어서 본 발명과 관련된 공지 기술에 대한 구체적인 설명이 본 발명의 요지를 불필요하게 흐릴 수 있다고 판단되는 경우에 그 상세한 설명을 생략하기로 한다. 이하, 첨부된 도면을 참조하여 본 발명에 따른 바람직한 실시 예를 상세히 설명하기로 한다. The above objects, features, and advantages will become more apparent from the following detailed description with reference to the accompanying drawings, and as such, those skilled in the art to which the present invention pertains may share the technical idea of the present invention. It will be easy to implement. In addition, in describing the present invention, when it is determined that the detailed description of the known technology related to the present invention may unnecessarily obscure the gist of the present invention, the detailed description thereof will be omitted. Hereinafter, exemplary embodiments of the present invention will be described in detail with reference to the accompanying drawings.
도 1은 코드 변환 장치(100)의 예시적인 하드웨어 블록도를 도시한 도면이다. 1 is a diagram illustrating an exemplary hardware block diagram of a code conversion apparatus 100.
도 1에 따르면 코드 변환 장치(100)는 입력 인터페이스(101), 출력 인터페이스(103), 메모리(105), 저장 매체(107), 시스템 버스/제어 버스(111) 및 프로세서(113)를 포함하고 통신 인터페이스(109)를 더 포함할 수 있다. 특정 하드웨어 블록은 코드 변환 장치(100)의 용도나 변형예에 따라 생략될 수 있다. 코드 변환 장치(100)는 변조 저항성 및/또는 변조 탐지를 가능하도록 소스코드(소프트웨어)를 변환하는 장치이다. 코드 변환 장치(100)는 예를 들어 프로그래머 또는 프로그램의 배포자에 의해서 이용되는 개인용 컴퓨터이거나 노트북이거나 프로그램의 변환 기능을 인터넷망을 통해서 제공가능한 서버 등일 수 있다. According to FIG. 1, the code conversion device 100 includes an input interface 101, an output interface 103, a memory 105, a storage medium 107, a system bus / control bus 111, and a processor 113. It may further include a communication interface 109. The specific hardware block may be omitted according to the use or modification of the code conversion apparatus 100. The code conversion device 100 is a device for converting source code (software) to enable modulation resistance and / or modulation detection. The code conversion apparatus 100 may be, for example, a personal computer used by a programmer or a distributor of a program, a laptop, or a server capable of providing a program's conversion function through an internet network.
코드 변환 장치(100)의 각 하드웨어 블록들을 간단히 살펴보면, 입력 인터페이스(101)는 사용자 입력을 수신하기 위한 인터페이스이다. 입력 인터페이스(101)는 마우스, 키보드 및/또는 터치 패널 등을 구비하고 코드 변환을 수행하고자 하는 사용자 입력을 수신한다. 수신된 입력은 시스템 버스/제어 버스(111)를 통해 입력 데이터로 프로세서(113)에 전달된다. Looking briefly at each hardware block of the code conversion apparatus 100, the input interface 101 is an interface for receiving a user input. The input interface 101 includes a mouse, a keyboard and / or a touch panel, and receives a user input for performing code conversion. The received input is delivered to the processor 113 as input data via the system bus / control bus 111.
출력 인터페이스(103)는 LCD 모듈, LED 모듈 및/또는 스피커 등을 구비하여 코드 변환 장치(100)에서 수행된 결과나 중간 결과를 출력하기 위한 인터페이스이다. 출력 인터페이스(103)는 예를 들어 코드 변환된 소프트웨어에 대한 결과를 알 수 있도록 한다. The output interface 103 includes an LCD module, an LED module and / or a speaker, and is an interface for outputting a result or an intermediate result performed by the code conversion apparatus 100. The output interface 103 makes it possible to know the results for the transcoded software, for example.
메모리(105)는 휘발성 메모리를 포함한다. 메모리(105)는 각종 데이터와 프로그램을 임시로 저장할 수 있다. 예를 들어, 메모리(105)는 프로세서(113)에서 수행되는 코드 변환 프로그램이나 코드 변환 프로그램의 입력인 소프트웨어(또는 소스코드, 이하에서는 '소프트웨어'와 '소스코드'란 용어를 혼용해서 사용함.)를 임시로 저장한다. Memory 105 includes volatile memory. The memory 105 may temporarily store various data and programs. For example, the memory 105 may be a code conversion program executed in the processor 113 or software that is an input of a code conversion program (or source code, hereinafter, the term 'software' and 'source code' are used interchangeably). Save it temporarily.
저장 매체(107)는 적어도 프로세서(113)에서 수행되는 코드 변환 프로그램과 코드 변환 프로그램의 입력 대상인 소프트웨어들을 저장한다. 소프트웨어는 소스코드 레벨로 구성된다. 예를 들어 소프트웨어는 C, C++, 포트란(Fortran), Java 등과 같은 프로그래밍 언어로 작성된다. The storage medium 107 stores at least a code conversion program executed by the processor 113 and software that is an input target of the code conversion program. The software is organized at the source code level. For example, software is written in programming languages such as C, C ++, Fortran, Java, and so on.
코드 변환 프로그램은 입력 소프트웨어를 중간 언어(Intermediate Representation, 이하 'IR'이라고도 지칭함.)로 변환하여 중간 언어 상에서 입력 소프트웨어가 변조 저항성 및/또는 변조 탐지성을 가지도록 변환한다. 지정된 기계어로 변환된 소프트웨어는 출력 인터페이스(103)로 출력되거나 저장 매체(107)에 저장되거나 통신 인터페이스(109)를 통해 출력될 수 있다. The code conversion program converts the input software into an intermediate language (hereinafter also referred to as 'IR') so that the input software on the intermediate language has modulation resistance and / or modulation detection. The software translated into the designated machine language may be output to the output interface 103, stored in the storage medium 107, or output through the communication interface 109.
프로세서(113)는 명령어(instruction)을 실행할 수 있는 하나 이상의 실행 유닛(execution unit)을 포함하여 저장 매체(107)에 저장된 프로그램의 코드를 실행한다. 프로세서(113)는 소위 CPU, MPU 등으로 지칭될 수 있다. The processor 113 includes one or more execution units capable of executing instructions to execute code of a program stored in the storage medium 107. The processor 113 may be referred to as a so-called CPU, MPU, or the like.
특히, 프로세서(113)는 저장 매체(107)에 저장된 코드 변환 프로그램을 메모리(105) 등에 로딩하고 코드 변환 프로그램을 수행하여 입력 소프트웨어를 변조 저항성 및/또는 변조 탐지성을 가지도록 변환한다. 프로세서(113)는 바람직하게는 입력 소프트웨어를 중간 언어로 변환하고 중간 언어로 변환된 입력 소프트웨어에 대해서 변조 저항성 및/또는 변조 탐지성을 가지도록 하는 코드를 추가하거나 입력 소프트웨어를 지정된 기계어로 변환한다. In particular, the processor 113 loads the code conversion program stored in the storage medium 107 into the memory 105 and performs a code conversion program to convert the input software to have modulation resistance and / or modulation detectability. The processor 113 preferably adds code to translate the input software into the intermediate language and adds code to have modulation resistance and / or modulation detectability for the input software converted to the intermediate language or convert the input software to the designated machine language.
프로세서(113), 특히 코드 변환 프로그램에 대해서는 도 2 및 도 3을 통해서 상세히 살펴보도록 한다. The processor 113, particularly the code conversion program, will be described in detail with reference to FIGS. 2 and 3.
시스템 버스/제어 버스(111)는 하드웨어 블록들 사이의 각종 아날로그/디지털의 데이터를 송수신할 수 있는 버스이다. 시스템 버스/제어 버스(111)는 병렬 버스이거나 시리얼 버스이거나 특정 하드웨어 블록을 위한 전용 버스일 수 있다. 시스템 버스/제어 버스(111)는 버스의 타입에 따라 아날로그나 디지털의 데이터를 송수신할 수 있다. The system bus / control bus 111 is a bus capable of transmitting and receiving various analog / digital data between hardware blocks. The system bus / control bus 111 may be a parallel bus or a serial bus or a dedicated bus for a particular hardware block. The system bus / control bus 111 may transmit and receive analog or digital data depending on the type of bus.
더 포함가능한 통신 인터페이스(109)는 인터넷망에 연결되어 네트워크 패킷을 송수신하기 위한 인터페이스이다. 통신 인터페이스(109)는 예를 들어 와이파이나 유선 랜에 연결되기 위한 파이(PHY) 칩 등을 포함한다. The communication interface 109 which can be further included is an interface for transmitting and receiving network packets connected to the Internet network. The communication interface 109 includes, for example, a PHY chip for connecting to Wi-Fi or a wired LAN.
도 2는 코드 변환을 위한 예시적인 제어 흐름을 도시한 도면이다. 도 2의 코드 변환 제어 흐름은 예를 들어 도 1의 코드 변환 장치(100)의 하드웨어 블록도 상에서 수행된다. 도 2의 코드 변환 제어 흐름은 코드 변환 장치(100)의 프로세서(113)에 의해서 수행되고 바람직하게는 코드 변환 프로그램에 의한 프로세서(113)의 명령어 수행으로 이루어진다.2 is a diagram illustrating an exemplary control flow for code conversion. The code conversion control flow of FIG. 2 is performed, for example, on a hardware block diagram of the code conversion apparatus 100 of FIG. The code conversion control flow of FIG. 2 is performed by the processor 113 of the code conversion apparatus 100 and preferably consists of the instruction execution of the processor 113 by the code conversion program.
도 2의 코드 변환 제어 흐름은 코드 변환 장치(100)의 프로세서(113)가 저장 매체(107)에 저장된 코드 변환 프로그램을 수행 시작함에 따라 시작(S100)하고 코드 변환 프로그램이 수행 종료됨에 따라 종료(S200)한다. The code conversion control flow of FIG. 2 starts as the processor 113 of the code conversion apparatus 100 starts to perform the code conversion program stored in the storage medium 107 (S100) and ends as the code conversion program ends. S200).
먼저 코드 변환 장치(100)(프로세서(113))는 입력 인터페이스(101)(또는 통신 인터페이스(109))를 통해 사용자가 변환할 소프트웨어에 대한 선택을 수신(S101)한다. 소프트웨어에 대한 선택 수신으로 코드 변환 장치(100)는 저장 매체(107)에서 저장된 또는 통신 인터페이스(109)를 통해 수신된 소프트웨어를 메모리(105) 등에 로딩한다. First, the code conversion apparatus 100 (the processor 113) receives a selection for the software to be converted by the user through the input interface 101 (or the communication interface 109) (S101). In the selective reception of the software, the code conversion apparatus 100 loads the software stored in the storage medium 107 or received via the communication interface 109 into the memory 105 or the like.
이후, 코드 변환 장치(100)는 로딩된 소스코드 레벨의 소프트웨어를 중간 언어의 표현으로 변환(S103)한다. 중간 언어는 예를 들어 알려져 있는 LLVM(Low Level Virtual Machine) 컴파일러 플랫폼에서 이용되는 명령어일 수 있다. LLVM의 중간 언어는 소스 레벨의 언어의 종류에 상관없는 독립적인 언어이고 또한 기계어에 의존되지 않는 언어이다. LLVM의 중간 언어는 기계어에 독립적인 레이블(Label)을 지원하고 레이블을 통해 다양한 수행 경로를 표현할 수 있다. Thereafter, the code conversion device 100 converts the loaded source code level software into a representation of an intermediate language (S103). The intermediate language can be, for example, instructions used in the known low level virtual machine (LLVM) compiler platform. The intermediate language of LLVM is an independent language that is independent of any kind of language at the source level and is also a language that is not dependent on machine language. LLVM's intermediate language supports machine-independent labels and can express various execution paths through labels.
또한, 중간 언어로 변환된 소프트웨어에 기초한 데이터는 코드 변환 장치(100)에 의해서 출력 인터페이스(103)로 출력될 수 있다. 예를 들어 코드 변환 장치(100)는 변환된 소프트웨어에 포함된 함수 리스트를 출력 인터페이스(103)를 통해 출력한다. In addition, the data based on the software converted into the intermediate language may be output to the output interface 103 by the code conversion apparatus 100. For example, the code conversion apparatus 100 outputs a function list included in the converted software through the output interface 103.
사용자는 출력된 함수 리스트에서 보호될 필요가 있는 함수의 선택을 나타내는 입력을 입력 인터페이스(101)를 통해 제공하고 코드 변환 장치(100)는 선택 입력의 수신에 따라 입력에 대응하는 보호될 함수를 선택(S105)한다. The user provides an input indicating the selection of a function that needs to be protected in the outputted function list through the input interface 101 and the code conversion apparatus 100 selects a function to be protected corresponding to the input according to the reception of the selection input. (S105).
코드 변환 장치(100)는 보호될 필요가 있는 함수의 선택으로 특정 유형의 함수를 함수 리스트에서 선택한다. 구체적으로 코드 변환 장치(100)는 코드 분석을 어렵게 하기 위해 제어 흐름을 평탄화(flattening)할 대상인 함수(이하 '평탄화 함수' 또는 'FF'(Flattening Function)라고도 함)를 선택하고 무결성(Integrity)이 보장되어야 하는 대상인 함수(이하 '무결성 함수' 또는 'IF'(Integrity Function)라고도 함)를 선택한다. 나아가 코드 변환 장치(100)는 암호화되어야 하는 대상인 함수(이하 '암호화 함수' 또는 EF(Encryption Function)라고도 함)를 선택한다. 하나 이상의 함수의 선택은 사용자 입력에 의해서 결정될 수 있다. 각 유형의 함수는 하나 이상일 수 있다. 또한 평탄화 함수는 무결성 함수 및 암호화 함수에 먼저 수행되어야 하는 함수로서 코드 변환 장치(100)가 설정하거나 출력 인터페이스(103)를 통해 가이드한다. The code conversion apparatus 100 selects a specific type of function from the function list by selecting a function that needs to be protected. In detail, the code conversion device 100 selects a function (hereinafter, referred to as a 'flattening function' or 'FF' (Flattening Function)) to which the control flow is to be flattened to make code analysis difficult. Select the function that is to be guaranteed (hereinafter also referred to as 'integrity function' or 'IF' (Integrity Function)). Furthermore, the code conversion apparatus 100 selects a function (hereinafter, also referred to as an 'encryption function' or an encryption function (EF)) to be encrypted. The selection of one or more functions may be determined by user input. Each type of function can be one or more. In addition, the flattening function is a function that must first be performed on the integrity function and the encryption function, and is set by the code conversion apparatus 100 or guided through the output interface 103.
평탄화 함수는 함수의 제어 흐름(Control Flow)을 평탄화하여 분석을 난해화 하기 위한 대상 함수로서 평탄화 함수에 대한 평탄화 작업 과정에서 무결성 함수의 무결성 확인 및 암호화 함수를 암호화할 동적 키 생성을 위한 각종 정보(데이터)가 생성된다. 무결성 함수는 무결성이 보장되어야 하는 대상 함수로서 반드시 숨길 필요는 없으나 변조가 되면 안되는 함수를 나타낸다. 예를 들어 무결성 함수는 안티디버깅 루틴(Routine)이나 라이센스 체크 루틴 등일 수 있다. 암호화 함수는 암호화로 보호되어야 하는 함수로서 분석 자체를 막도록 숨겨져야 하는 함수가 지정될 수 있다. 예를 들어 암호화 함수는 소프트웨어의 중요 로직을 포함하여 외부로 노출되면 치명적인 함수 등일 수 있다. The flattening function is a target function for flattening the control flow of the function to obfuscate the analysis. During the flattening function of the flattening function, various information for checking the integrity of the integrity function and generating a dynamic key to encrypt the encryption function ( Data) is generated. An integrity function is a target function whose integrity is to be guaranteed. It indicates a function that is not necessarily hidden but must not be tampered with. For example, the integrity function may be an anti-debugging routine or a license check routine. The encryption function is a function that must be protected by encryption, and a function that must be hidden to prevent the analysis itself can be specified. For example, an encryption function may be a fatal function when exposed to the outside including important logic of the software.
본 발명에서 주목해야 하는 점은, 평탄화 함수에 대한 각종 평탄화 처리 과정에서 무결성 함수에 대한 무결성 확인이 가능하도록 하고 나아가 동적 키 생성이 가능하도록 한다. 이와 관련해서는 이하에서 상세히 살펴보도록 한다. It should be noted that in the present invention, it is possible to check the integrity of the integrity function in various flattening processes for the flattening function, and further enable dynamic key generation. This will be described in detail below.
이후, 단계 S105에서 선택된 평탄화 함수에 대한 평탄화에 이용될 각종 레이블을 생성(S107)한다. Thereafter, various labels to be used for the flattening for the flattening function selected in step S105 are generated (S107).
레이블의 생성을 위해, 코드 변환 장치(100)는 선택된 평탄화 함수를 CFG(Control Flow Graph)로 변환하고 CFG의 변환에 따라 평탄화 함수를 평탄화 가능한 블록들로 분류한다. 도 4는 특정 평탄화 함수에 대한 CFG를 나타내고 도 5는 본 발명에 따른 평탄화 적용후의 CFG(도 4의 BB0는 도 5의 BBa에 대응하고 다른 블록 역시 동일한 대응 관계를 가짐.)를 나타낸다. 도 4에서 알 수 있는 바와 같이, CFG 내의 각 블록들은 수행시에 블록내의 코드가 다른 블록들로 분기(branch)하지 않도록 구성되고 각 블록의 모든 코드가 수행 완료된 후에 다른 블록으로 분기된다.To generate a label, the code conversion apparatus 100 converts the selected flattening function into a control flow graph (CFG) and classifies the flattening function into flattenable blocks according to the conversion of the CFG. 4 shows CFG for a particular flattening function and FIG. 5 shows CFG after flattening application according to the invention (BB0 of FIG. 4 corresponds to BBa of FIG. 5 and the other blocks also have the same correspondence). As can be seen in FIG. 4, each block in the CFG is configured such that the code in the block does not branch to other blocks at execution and branches to other blocks after all the code in each block is completed.
도 4 및 도 5를 참조해서, 본 발명에 따른 레이블의 생성 과정을 살펴보면, 코드 변환 장치(100)는 먼저 평탄화 함수의 CFG 내의 각 블록에 대한 레이블(
Figure PCTKR2015009483-appb-I000001
, 도 5의 예에서 i는 a ~ f임)을 생성하고 각 블록에 대한 분기 함수(
Figure PCTKR2015009483-appb-I000002
) 및 스위치문에서 이용될 함수(
Figure PCTKR2015009483-appb-I000003
)를 생성한다.
Referring to FIG. 4 and FIG. 5, referring to a label generation process according to the present invention, the code conversion apparatus 100 first determines a label (for each block in the CFG of the flattening function).
Figure PCTKR2015009483-appb-I000001
, In the example of FIG. 5, i is a to f, and the branch function for each block (
Figure PCTKR2015009483-appb-I000002
) And the function to be used in the switch statement (
Figure PCTKR2015009483-appb-I000003
)
블록의 레이블은 대응하는 블록의 수행 시작 위치를 나타내며 레이블은 변수로 표현될 수 있다. 각 블록에 대응하는 분기 함수는 서로 상이하도록 구성된다.The label of the block indicates the execution start position of the corresponding block and the label may be represented by a variable. The branch function corresponding to each block is configured to be different from each other.
각 블록의 분기 함수
Figure PCTKR2015009483-appb-I000004
는, 블록의 수행 완료후의 분기 조건에 따라 예를 들어 분기가 없는 경우(즉, 하나의 후속하는 블록만이 수행되는 경우) "
Figure PCTKR2015009483-appb-I000005
+ mask +
Figure PCTKR2015009483-appb-I000006
"로 표현되고, 분기가 존재하는 경우 "
Figure PCTKR2015009483-appb-I000007
+ mask+
Figure PCTKR2015009483-appb-I000008
"로 표현된다.
Figure PCTKR2015009483-appb-I000009
는 해쉬(Hash) 함수로서 각 블록에 맵핑된 무결성 함수를 입력 인자로 한다. 여기서
Figure PCTKR2015009483-appb-I000010
는 각 블록에 맵핑된 IF(무결성 함수)의 해쉬값을 나타내는 데, 레이블 생성 과정에서 코드 변환 장치(100)는 각 블록마다 어떠한 IF의 무결성을 체크할 것인지를 결정한다. 예를 들어 코드 변환 장치(100)는 랜덤하게 평탄화 함수의 각 블록들을 특정 하나의 IF에 맵핑한다. 여기서,
Figure PCTKR2015009483-appb-I000011
는 변환된 소프트웨어 상에서 블록 i가 시작하는 시작 위치(분기 위치)를 나타내는 임의의 지시자를 나타낸다.
Figure PCTKR2015009483-appb-I000012
는 숫자의 조합, 문자의 조합 또는 숫자와 문자의 조합으로 구성되고 변수로 표현될 수도 있다.
Branch function of each block
Figure PCTKR2015009483-appb-I000004
Depends on the branch condition after completion of the block, for example, if there is no branch (i.e., only one subsequent block is performed).
Figure PCTKR2015009483-appb-I000005
+ mask +
Figure PCTKR2015009483-appb-I000006
Expressed as ", and if a branch exists"
Figure PCTKR2015009483-appb-I000007
+ mask +
Figure PCTKR2015009483-appb-I000008
"Is expressed.
Figure PCTKR2015009483-appb-I000009
Is a hash function that takes an integrity function mapped to each block as an input argument. here
Figure PCTKR2015009483-appb-I000010
Represents a hash value of an IF (integrity function) mapped to each block. In the label generation process, the code conversion apparatus 100 determines which IF integrity is checked for each block. For example, the code conversion apparatus 100 randomly maps each block of the flattening function to a specific one IF. here,
Figure PCTKR2015009483-appb-I000011
Denotes any indicator indicating the starting position (branch position) at which block i starts on the transformed software.
Figure PCTKR2015009483-appb-I000012
May consist of a combination of numbers, a combination of letters, or a combination of numbers and letters and may be represented by a variable.
mask는 입력 소프트웨어의 본래 기능에 따라 다음에 실행될 블록을 보정하기 위한 값이다. 분기 함수
Figure PCTKR2015009483-appb-I000013
는 이하에서 살펴볼 바와 같이 하드코딩되지 않고 분기 함수
Figure PCTKR2015009483-appb-I000014
자체(즉 각 블록의 분기 함수의 계산을 위한 코드)가 대응하는 블록과 함께 코드 블록으로 변환된 소프트웨어에 내장되도록 구성된다. 이에 따라 분기 함수
Figure PCTKR2015009483-appb-I000015
는 변환된 소프트웨어의 실제 실행시에 레이블 값(
Figure PCTKR2015009483-appb-I000016
)을 산출하기에 정적 분석 방법에 안전하다.
Figure PCTKR2015009483-appb-I000017
는 i 블록의 조건을 나타내어 하나 이상의 각 조건에 따른 참(1) 또는 거짓(0)에 따라 특정 레이블로 분기할 수 있도록 한다. 함수 F()는 특정 레이블(
Figure PCTKR2015009483-appb-I000018
)을 생성하기 위한 함수로서 F()는 분기 함수의 출력을 입력 인자로 하는 해쉬 함수로 표현될 수 있다. 함수 F()를 통해 다음번에 수행되어야 하는 정확한 블록 위치를 스위치문이 선택할 수 있다.
The mask is a value for correcting the block to be executed next according to the original function of the input software. Branch function
Figure PCTKR2015009483-appb-I000013
The branch function is not hardcoded as we will see below.
Figure PCTKR2015009483-appb-I000014
It is configured to itself (i.e. the code for the calculation of the branch function of each block) with the corresponding block embedded in the software converted to the code block. Accordingly branch function
Figure PCTKR2015009483-appb-I000015
Is the label value at actual execution of the converted software (
Figure PCTKR2015009483-appb-I000016
Is safe for static analysis methods.
Figure PCTKR2015009483-appb-I000017
Denotes the condition of the i block, allowing branching to a particular label according to true (1) or false (0) according to one or more conditions. Function F () has a specific label (
Figure PCTKR2015009483-appb-I000018
As a function for generating), F () can be expressed as a hash function whose output argument is a branch function. The function F () allows the switch statement to select the exact block position to be executed next time.
여기서, 본 발명에 따른 분기 함수는 무결성 함수에 대한 해쉬 함수 적용으로 구성된다. 따라서, 만일 무결성 함수가 변조되는 경우에 무결성 함수에 대한 해쉬 함수의 적용으로 산출되는 해쉬값 또한 달라진다. 이는
Figure PCTKR2015009483-appb-I000019
의 값이 달라지고 각 블록의 실행이 정상적으로 동작하지 않게 된다. 만일 무결성 함수의 변조에 따른 변화를 탐지 가능하다면 변조에 대응할 수 있다. 본 발명에서는 무결성 함수에 대한 평탄화 함수의 분기에서 이용되는 해쉬값으로 변조를 판별할 수 있다. 이에 대해서는 이하에서 좀 더 살펴보도록 한다.
Here, the branch function according to the present invention consists of applying a hash function to the integrity function. Thus, if the integrity function is modulated, the hash value produced by the application of the hash function to the integrity function is also different. this is
Figure PCTKR2015009483-appb-I000019
Is changed and execution of each block does not work normally. If a change due to the modulation of the integrity function can be detected, it can correspond to the modulation. In the present invention, the modulation can be determined by the hash value used in the branch of the smoothing function to the integrity function. This will be described below.
이후 코드 변환 장치(100)는 암호화 함수에 대한 암호화를 위해 동적 키를 생성(S109)한다. 본 발명에 의해 생성된 동적 키는 변환된 소프트웨어 어디에도 저장되지 않는다. 만일 변환된 소프트웨어 내에 동적 키가 저장되는 경우 이 동적 키를 외부에 의해서 찾게 된다면 암호화는 그 의미가 상실된다. Thereafter, the code conversion apparatus 100 generates a dynamic key for encryption of the encryption function (S109). The dynamic key generated by the present invention is not stored anywhere in the converted software. If the dynamic key is stored in the converted software, the encryption loses its meaning if the dynamic key is found externally.
대신에, 본 발명은 레이블 생성 단계(S107)에서 생성된 레이블을 이용하여 동적 키를 생성한다. 구체적으로 살펴보면, 평탄화 함수의 각 블록(i)은 (
Figure PCTKR2015009483-appb-I000020
,
Figure PCTKR2015009483-appb-I000021
)의 쌍을 가진다. 따라서 평탄화 함수의 모든 블록들 각각은 모두 (
Figure PCTKR2015009483-appb-I000022
,
Figure PCTKR2015009483-appb-I000023
)를 가지고 i를 인덱스로 하는 이 순서쌍들을 이용하여 동적 키를 코드 변환 장치(100)가 생성한다.
Instead, the present invention generates a dynamic key using the label generated in the label generation step S107. Specifically, each block (i) of the smoothing function is (
Figure PCTKR2015009483-appb-I000020
,
Figure PCTKR2015009483-appb-I000021
) Pairs. Therefore, each and every block of the smoothing function
Figure PCTKR2015009483-appb-I000022
,
Figure PCTKR2015009483-appb-I000023
), And the code conversion device 100 generates a dynamic key using these ordered pairs having i as an index.
Figure PCTKR2015009483-appb-I000024
(또는
Figure PCTKR2015009483-appb-I000025
)는 대응하는 블록이 실행되는 경우에 분기 함수 B()에 의해서 동적으로 생성되는 값인데, 평탄화 함수의 특정 블록이 소프트웨어의 조건에 따라 실행될 수도 있고 실행되지 않을 수도 있다. 항상 동일한 동적 키를 변환된 소프트웨어로부터 도출해 낼 수 있어야 정상적으로 암호화된 암호화 함수를 복호화할 수 있고 이에 대한 대응 방안이 요구된다.
Figure PCTKR2015009483-appb-I000024
(or
Figure PCTKR2015009483-appb-I000025
) Is a value dynamically generated by the branch function B () when the corresponding block is executed, and a particular block of the smoothing function may or may not be executed depending on the condition of the software. Only when the same dynamic key can be derived from the converted software can the normal encrypted encryption function be decrypted and a corresponding solution is required.
본 발명은 알려져 있는 Shamir의 비밀 분할(Secret Sharing) 기법((t,n)-threshold secret sharing)을 이용하여 이 문제를 해결한다. 이 비밀 분할 기법은 n 개의 분할(sharing) 중에서 t 개 이상의 분할이 모이면 비밀을 복원해낼 수 있는 기법이다. The present invention solves this problem by using the known Shamir's Secret Sharing technique ((t, n) -threshold secret sharing). This secret splitting technique is a technique for recovering a secret when t or more splittings are collected among n splittings.
비밀 분할 기법의 적용으로 동적 키 복원이 가능하도록, 코드 변환 장치(100)는 평탄화 함수의 CFG를 통해서 모든 블록들의 개수(n개, 도 4의 예에서 6)를 도출하고 CFG를 통해 최단 실행 경로의 길이(t)(도 4의 예에서 4)를 도출한다. 길이(t)는 최단 실행 경로상의 블록들의 개수를 나타낸다. 이러한 n과 t의 도출은 코드 변환 장치(100)에 의해서 용이하게 수행될 수 있다. 코드 변환 장치(100)는 도출된 n과 t를 이용하여 비밀인 동적 키를 생성한다. In order to enable dynamic key recovery by applying the secret partitioning scheme, the code conversion apparatus 100 derives the number of all blocks (n, 6 in the example of FIG. 4) through the CFG of the flattening function and the shortest execution path through the CFG. The length t (4 in the example of FIG. 4) is derived. The length t represents the number of blocks on the shortest execution path. The derivation of n and t can be easily performed by the code conversion apparatus 100. The code conversion apparatus 100 generates a secret dynamic key using the derived n and t.
코드 변환 장치(100)는 평탄화 함수를 생성된 레이블을 이용하여 평탄화(S111)한다. 도 5는 도 4의 CFG에 대해서 평탄화가 이루어진 후의 CFG를 나타낸다. 도 4 및 도 5를 통해서 알 수 있는 바와 같이, 원래 수행 경로 상의 각 블록간 수행 의존 순서는 스위치문을 통해 평탄화된다. 각 블록(도 5의 BBa, BBb 등 참조)들은 대응하는 분기 함수(도 5의 Ba(), Bb() 등 참조)와 함께 하나의 코드 블록을 구성한다. 분기 함수는 하드코딩되지 않고 본 발명에 따라 함수로서 대응하는 블록에 결합된다. 따라서 변환된 소프트웨어가 실행되고 평탄화 함수의 특정 블록이 수행되면 이 특정 블록의 수행 완료후에는 대응하는 분기 함수가 바로 수행된다. 분기 함수는 분기할 레이블을 동적으로 계산한다. 이에 따라 평탄화 함수의 정적 분석이 불가능하다. The code conversion apparatus 100 flattens the flattening function using the generated label (S111). FIG. 5 shows the CFG after planarization is performed with respect to the CFG of FIG. 4. As can be seen from FIGS. 4 and 5, the inter-block execution dependency order on the original execution path is flattened through a switch statement. Each block (see BBa, BBb, etc. of FIG. 5) constitutes one code block together with a corresponding branch function (see Ba (), Bb (), etc. of FIG. 5). The branch function is not hardcoded and is coupled to the corresponding block as a function in accordance with the present invention. Therefore, when the converted software is executed and a specific block of the flattening function is executed, the corresponding branch function is executed immediately after completion of the execution of this specific block. The branch function dynamically calculates the labels to branch. Thus, static analysis of the planarization function is not possible.
평탄화에 의한 평탄화된 코드는 디폴트 레이블(
Figure PCTKR2015009483-appb-I000026
)을 포함한다. 특정 블록의 분기 함수는 특정 무결성 함수에 대한 지정된 함수(예를 들어 해쉬 함수)의 적용으로 분기 레이블(또는 분기값)이 생성된다. 따라서 무결성 함수가 변조되게 되면 분기 함수에 의해서 산출되는 분기 레이블 또한 달라지게 된다. 본 발명에서는 디폴트 레이블(매칭되는 레이블이 존재하지 않는 경우에 이용되는 레이블)을 이용하여 무결성 함수의 변조를 탐지할 수 있다. 디폴트 레이블의 블록(
Figure PCTKR2015009483-appb-I000027
)은 변조 대응 루틴(예를 들어, 프로그램 종료, 변조 탐지 출력, 지정된 서버로의 변조 탐지 출력 등)을 포함하여 소프트웨어의 변조 탐지 결과를 출력할 수 있다.
Flattened code by flattening is the default label (
Figure PCTKR2015009483-appb-I000026
). The branch function of a particular block generates a branch label (or branch value) by applying a specified function (eg a hash function) to a specific integrity function. Therefore, when the integrity function is modulated, the branch label produced by the branch function also changes. In the present invention, the tampering of the integrity function can be detected using a default label (a label used when there is no matching label). Block of default labels (
Figure PCTKR2015009483-appb-I000027
) May output the modulation detection result of the software, including a modulation correspondence routine (eg, program termination, modulation detection output, modulation detection output to a designated server, etc.).
동적 키의 생성 이후에, 코드 변환 장치(100)는 암호화 함수를 생성된 동적 키로 암호화(S113)한다. 본 발명에 따른 동적 키는 변환되는 소프트웨어에 내장되지 않는다. 대신에, 평탄화된 함수의 코드 수행 시에 평탄화된 함수는 최소한 최단 실행 경로를 통해 t(최단 실행 경로 길이)개의 블록과 분기 함수를 수행하고 이에 따라 이 t 개의 분기 함수들을 이용하여 동적 키를 변환된 소프트웨어가 복원가능하다. After generation of the dynamic key, the code conversion apparatus 100 encrypts the encryption function with the generated dynamic key (S113). The dynamic key according to the invention is not embedded in the software to be converted. Instead, in code execution of the flattened function, the flattened function performs t (shortest execution path length) blocks and branch functions through at least the shortest execution path, and thus transforms the dynamic key using these t branch functions. Software can be restored.
이후 코드 변환 장치(100)는 필요시 최적화 과정을 진행하고 사용자에 의해서 지정된 기계어를 위한 컴파일 및 링크 과정을 통해 기계어로 변환(S115)한다. 그리고 코드 변환 장치(100)는 변환된 기계어, 즉 변조 저항성 및 탐지 기능을 갖는 변환된 소프트웨어를 저장 매체(107)에 저장(S117)하거나 통신 인터페이스(109)를 통해 출력한다. Thereafter, the code conversion device 100 performs an optimization process when necessary and converts the machine language through a compilation and linking process for the machine language designated by the user (S115). The code conversion apparatus 100 stores the converted machine language, that is, the converted software having the modulation resistance and the detection function, in the storage medium 107 (S117) or outputs it through the communication interface 109.
도 2의 코드 변환 방법은 매체에 저장될 수 있는 컴퓨터 프로그램으로 구성될 수 있다. 이 컴퓨터 프로그램은 USB, CD, DVD, 스마트 카드나 이동형 하드 디스크, 내장형 하드 디스크 등에 저장된다. 컴퓨터 프로그램은 도 1의 하드웨어 블록(들), 특히 프로세서(113),상에서 수행된다. The code conversion method of FIG. 2 may be configured as a computer program that can be stored in a medium. The computer program is stored on a USB, CD, DVD, smart card or removable hard disk, or an internal hard disk. The computer program is executed on the hardware block (s) of FIG. 1, in particular the processor 113.
도 3은 코드 변환 장치(100)의 예시적인 기능 블록도를 도시한 도면이다. 3 is a diagram illustrating an exemplary functional block diagram of a code conversion apparatus 100.
도 3에 따르면 코드 변환 장치(100)는 중간 언어 변환부(151), 모듈 로더부(153), 선택부(155), 레이블 생성부(157), 동적 키 생성부(159), 평탄화부(161), 암호화부(163), 최적화부(165) 및 기계어 변환부(167)를 포함한다. 도 3의 기능 블록도의 일부 기능 블록은 설계 변형에 따라 생략될 수 있다. 도 3의 기능 블록들은 도 1의 하드웨어 블록도상에서 수행되며 바람직하게는 프로세서(113)에 의해서 수행되는 코드 변환 프로그램에 의해서 구성된다. 코드 변환 프로그램은 각종 저장 매체(107)에 저장되어 배포될 수 있고 도 1의 하드웨어 블록도 상의 프로세서(113)에 의해서 수행된다. According to FIG. 3, the code conversion device 100 includes an intermediate language conversion unit 151, a module loader unit 153, a selection unit 155, a label generation unit 157, a dynamic key generation unit 159, and a flattening unit ( 161, an encryption unit 163, an optimizer 165, and a machine language converter 167. Some functional blocks in the functional block diagram of FIG. 3 may be omitted according to design variations. The functional blocks of FIG. 3 are performed on the hardware block diagram of FIG. 1 and are preferably constituted by a code conversion program executed by the processor 113. The code conversion program may be stored and distributed in various storage media 107 and executed by the processor 113 on the hardware block diagram of FIG.
도 3의 기능 블록도에 대한 설명은 도 2의 설명을 고려하여 도 2와의 차이점을 중심으로 설명하며 생략된 설명은 대응하는 도 2의 설명으로 대체된다. The description of the functional block diagram of FIG. 3 will be described based on the differences from FIG. 2 in consideration of the description of FIG. 2, and the description omitted will be replaced with the corresponding description of FIG. 2.
도 3의 기능 블록도는 하나의 소프트웨어 개발 플랫폼을 구성할 수 있다. 예를 들어 도 3의 기능 블록도는 LLVM(Low Level Virtual Machine) 컴파일 플랫폼 내에서 구성되어 소스 레벨의 소프트웨어를 특정 바이너리 레벨의 기계어로 변환한다. 기존 알려진 LLVM 플랫폼은 중간 언어 변환부(151), 모듈 로더부(153), 최적화부(165) 및 기계어 변환부(167)로 구성되고 알려진 이 LLVM 플랫폼은 소프트웨어를 중간 레벨의 중간 언어로 변환하고 이후 기계어로 변환한다. The functional block diagram of FIG. 3 may constitute one software development platform. For example, the functional block diagram of FIG. 3 is configured within a Low Level Virtual Machine (LLVM) compilation platform to convert source level software to a specific binary level machine language. The known LLVM platform consists of the intermediate language conversion unit 151, the module loader unit 153, the optimization unit 165, and the machine language conversion unit 167. The known LLVM platform converts software into an intermediate level intermediate language. It is then translated into machine language.
도 3의 각 기능 블록들을 간단히 살펴보면, 중간 언어 변환부(151)는 사용자에 의해 선택된 입력 소프트웨어를 중간 언어의 표현으로 변환한다. 변환된 중간 언어의 표현으로 된 소프트웨어를 중간 언어 변환부(151)가 출력한다. 출력된 중간 언어의 소프트웨어는 이후 모듈 로더부(153) 등에 전달된다. 3, the intermediate language converter 151 converts the input software selected by the user into a representation of the intermediate language. The intermediate language conversion unit 151 outputs software in the expression of the converted intermediate language. The output intermediate software is then transmitted to the module loader unit 153 or the like.
모듈 로더부(153)는 본 발명에 따라 소프트웨어 변환에 이용될 각종 프로그램 모듈을 로딩한다. 예를 들어 모듈 로더부(153)는 암호화 모듈, 해쉬 함수 모듈, 비밀 분할 모듈을 로딩한다. 이러한 암호화 모듈, 해쉬 함수 모듈 및 비밀 분할 모듈 등은 소프트웨어의 변환시에 변환된 소프트웨어에 포함된다. 이후 변환된 소프트웨어가 수행되는 경우 이러한 모듈도 또한 필요시 수행되어 소프트웨어 원래의 기능을 수행 가능하도록 한다. 바람직하게는 모듈 로더부(153)는 이러한 모듈들을 중간 언어의 표현으로된 소프트웨어에 링크한다. 로딩되는 모듈들 또한 중간 언어의 표현으로 구성되어 있다. The module loader unit 153 loads various program modules to be used for software conversion according to the present invention. For example, the module loader 153 loads an encryption module, a hash function module, and a secret partition module. Such an encryption module, hash function module, secret division module and the like are included in the converted software at the time of software conversion. Then, when the converted software is executed, such a module is also performed as necessary to enable the original function of the software. The module loader section 153 preferably links these modules to software in an intermediate language representation. The modules loaded also consist of intermediate language representations.
선택부(155)는 보호될 함수를 선택한다. 선택부(155)는 적어도 제어 흐름을 평탄화할 대상인 하나 이상의 평탄화 함수, 무결성이 보장되어야 할 하나 이상의 무결성 함수를 선택한다. 또한, 선택부(155)는 암호화될 대상인 하나 이상의 암호화 함수를 선택한다. 평탄화 함수는 특정 하나 이상의 무결성 함수 및 특정 하나 이상의 암호화 함수에 선행하는 함수일 수 있다. The selector 155 selects a function to be protected. The selector 155 selects at least one flattening function that is an object to flatten the control flow and at least one integrity function whose integrity is to be guaranteed. In addition, the selector 155 selects one or more encryption functions to be encrypted. The flattening function may be a function preceding a particular one or more integrity functions and a particular one or more cryptographic functions.
레이블 생성부(157)는 평탄화 함수에 대한 평탄화에서 이용될 레이블들을 생성한다. 레이블 생성부(157)는 평탄화 함수에 대한 CFG를 생성하고 CFG 내의 각 블록들에서 이용될 분기 함수 각각을 생성한다. 특정 블록을 위한 특정 분기 함수는 맵핑된 무결성 함수를 인자로 하는 지정된 함수를 포함한다. 이 지정된 함수는 예를 들어 해쉬 함수일 수 있다. The label generator 157 generates labels to be used in flattening for the flattening function. The label generator 157 generates a CFG for the flattening function and generates each branch function to be used in each block in the CFG. The particular branch function for a particular block contains a specified function whose argument is a mapped integrity function. This specified function can be a hash function, for example.
동적 키 생성부(159)는 암호화 함수를 암호화할 동적 키를 분기 함수들을 이용하여 생성한다. 동적 키는 평탄화 함수의 최단 실행 경로의 길이 및 총 블록 개수를 활용하는 비밀 분할 기법을 이용하여 생성된다. 동적 키는 변환된 소프트웨어 상에서 평탄화 함수의 최단 실행 경로의 길이(개수)의 분기 함수들을 이용하여 복원가능하다. The dynamic key generation unit 159 generates a dynamic key to encrypt the encryption function using the branch functions. The dynamic key is generated using a secret partitioning technique that utilizes the length of the shortest execution path of the flattening function and the total number of blocks. The dynamic key is recoverable using branch functions of the length (number) of the shortest execution path of the smoothing function on the transformed software.
평탄화부(161)는 선택된 평탄화 함수를 평탄화한다. 평탄화부(161)는 평탄화 함수의 블록들 각각을 대응하는 분기 함수 각각과 함께 하나의 코드 블록을 구성한다. 이에 따라 평탄화된 함수의 코드는 블록의 실행 후에 분기 함수가 동적으로 실행되고 분기 함수는 동적인 실행으로 이후 분기할 레이블을 동적으로 계산한다. The flattening unit 161 flattens the selected flattening function. The planarization unit 161 configures one code block with each branch function corresponding to each of the blocks of the planarization function. The code in the flattened function thus dynamically executes the branch function after execution of the block, and the branch function dynamically calculates the label to branch to later with dynamic execution.
평탄화부(161)에서 생성되는 평탄화 함수의 코드는 디폴트 레이블을 포함하고 디폴트 레이블은 소프트웨어의 변조를 탐지할 수 있도록 구성된다. The code of the flattening function generated in the flattening unit 161 includes a default label, and the default label is configured to detect tampering of the software.
암호화부(163)는 동적 키 생성부(159)에서 생성된 동적 키로 암호화 함수를 암호화한다. The encryption unit 163 encrypts the encryption function with the dynamic key generated by the dynamic key generation unit 159.
최적화부(165)는 각 블록들을 통해 생성되거나 변환된 중간 언어의 소프트웨어를 최적화한다. 여기서의 최적화는 적어도 본 발명에 따른 코드 변환 기법의 적용 후에도 코드 변환 결과는 유지되도록 구성된다. The optimizer 165 optimizes the intermediate language software generated or converted through each block. The optimization here is such that the code conversion result is maintained even after the application of the code conversion technique according to the invention.
기계어 변환부(167)는 지정 또는 선택된 기계어로의 컴파일과 라이브리 등을 이용한 링크 과정을 수행한다. 기계어 변환부(167)에 의한 중간 언어의 소프트웨어를 기계어로 변환함으로써 변조 저항성 및 탐지 기능을 갖는 변환된 소프트웨어를 생성한다. The machine language converter 167 performs a link process using compilation or library of a designated or selected machine language. By converting the software of the intermediate language by the machine language conversion unit 167 into machine language, the converted software having the modulation resistance and the detection function is generated.
변환된 소프트웨어는 저장 매체(107)에 저장되거나 통신 인터페이스(109)를 통해 출력될 수 있다. The converted software can be stored in the storage medium 107 or output via the communication interface 109.
이상에서 설명한 본 발명은, 본 발명이 속하는 기술 분야에서 통상의 지식을 가진 자에게 있어 본 발명의 기술적 사상을 벗어나지 않는 범위 내에서 여러 가지 치환, 변형 및 변경이 가능하므로 전술한 실시 예 및 첨부된 도면에 의해 한정되는 것이 아니다. The present invention described above is capable of various substitutions, modifications, and changes without departing from the technical spirit of the present invention for those skilled in the art to which the present invention pertains. It is not limited by the drawings.

Claims (11)

  1. (b) 보호될 함수를 선택하는 단계로서, 제어 흐름을 평탄화할 대상인 평탄화 함수 및 무결성이 보장되어야 할 대상인 무결성 함수를 선택하는, 보호 함수 선택 단계; 및 (b) selecting a function to be protected, selecting a protection function to be flattened for the control flow and an integrity function to be guaranteed for integrity; And
    (c) 상기 평탄화 함수에 대한 평탄화에 이용될 레이블들을 생성하는 단계로서, 상기 무결성 함수를 이용하여 상기 평탄화 함수 내의 블록들 각각에서 이용될 분기 함수 각각을 생성하는, 레이블 생성 단계;를 포함하는,(c) generating labels to be used for flattening the flattening function, the label generating step of generating each branch function to be used in each of the blocks in the flattening function using the integrity function;
    코드 변환 방법.How to transcode.
  2. 제1항에서 있어서, The method of claim 1,
    상기 단계 (b) 이전에, (a) 입력 소프트웨어를 중간 언어로 변환하는 단계;를 더 포함하며,Before the step (b), (a) further converting the input software into the intermediate language;
    상기 (b) 및 (c)는 상기 중간 언어로 변환된 소프트웨어에 대해서 수행하며,(B) and (c) are performed on software converted into the intermediate language,
    상기 분기 함수 각각은 블록에 맵핑된 무결성 함수를 인자로 하는 지정된 함수를 포함하는, Each of the branch functions comprises a designated function whose argument is an integrity function mapped to a block;
    코드 변환 방법.How to transcode.
  3. 제1항에 있어서,The method of claim 1,
    상기 단계 (b)는 암호화될 대상인 암호화 함수를 더 선택하고,Step (b) further selects an encryption function to be encrypted,
    상기 코드 변환 방법은 (d) 상기 암호화 함수를 암호화할 동적 키를 분기 함수들을 이용하여 생성하는 단계; 및 (f) 상기 동적 키를 이용하여 상기 암호화 함수를 암호화하는 단계;를 더 포함하며, The code conversion method comprises the steps of: (d) generating a dynamic key to encrypt the encryption function using branch functions; And (f) encrypting the encryption function using the dynamic key;
    상기 동적 키는 상기 평탄화 함수의 최단 실행 경로의 블록들 개수의 분기 함수들을 이용하여 복원가능한, The dynamic key is recoverable using branch functions of the number of blocks of the shortest execution path of the flattening function,
    코드 변환 방법.How to transcode.
  4. 제1항에 있어서, The method of claim 1,
    (e) 상기 평탄화 함수를 평탄화하는 단계로서, 상기 블록들 각각은 대응하는 상기 분기 함수 각각과 하나의 코드 블록을 구성하는, 평탄화 단계;를 더 포함하며,(e) flattening the flattening function, wherein each of the blocks constitutes one code block with each corresponding branch function;
    상기 분기 함수는 실행시에 분기할 레이블을 동적으로 계산하는, The branch function dynamically calculates a label to branch at runtime,
    코드 변환 방법.How to transcode.
  5. 제4항에 있어서,The method of claim 4, wherein
    상기 단계 (e)의 평탄화 함수의 코드는 디폴트 레이블를 포함하고, The code of the flattening function of step (e) includes a default label,
    상기 디폴트 레이블은 소프트웨어의 변조를 탐지할 수 있도록 구성되는, The default label is configured to detect tampering with the software,
    코드 변환 방법.How to transcode.
  6. 하드웨어에 결합되어 제1항의 코드 변환 방법의 각 단계를 실행시키기 위해 매체에 저장된 컴퓨터 프로그램. A computer program coupled to hardware and stored on a medium for executing each step of the code conversion method of claim 1.
  7. 보호될 함수를 선택하는 선택부로서, 제어 흐름을 평탄화할 대상인 평탄화 함수 및 무결성이 보장되어야 할 대상인 무결성 함수를 선택하는, 선택부; A selection unit for selecting a function to be protected, the selection unit selecting a flattening function as an object to flatten the control flow and an integrity function as an object to be guaranteed;
    상기 평탄화 함수에 대한 평탄화에 이용될 레이블들을 생성하는 레이블 생성부로서, 상기 무결성 함수를 이용하여 상기 평탄화 함수 내의 블록들 각각에서 이용될 분기 함수 각각을 생성하는, 레이블 생성부;를 포함하는, A label generator for generating labels to be used for flattening the flattening function, the label generating unit generating each branch function to be used in each of the blocks in the flattening function using the integrity function;
    코드 변환 장치.Transcoding device.
  8. 제7항에 있어서,The method of claim 7, wherein
    입력 소프트웨어를 중간 언어로 변환하고 변환된 중간 언어의 소프트웨어를 상기 선택부로 출력하는 중간 언어 변환부;를 더 포함하며,An intermediate language conversion unit converting input software into an intermediate language and outputting the converted intermediate language software to the selection unit;
    상기 분기 함수 각각은 블록에 맵핑된 무결성 함수를 인자로 하는 지정된 함수를 포함하는, Each of the branch functions comprises a designated function whose argument is an integrity function mapped to a block;
    코드 변환 장치.Transcoding device.
  9. 제7항에 있어서,The method of claim 7, wherein
    상기 선택부는 암호화될 대상인 암호화 함수를 더 선택하고,The selection unit further selects an encryption function to be encrypted,
    상기 코드 변환 장치는 상기 암호화 함수를 암호화할 동적 키를 분기 함수들을 이용하여 생성하는 동적 키 생성부; 및 상기 동적 키를 이용하여 상기 암호화 함수를 암호화하는 암호화부;를 더 포함하며, The code conversion device may include a dynamic key generation unit generating a dynamic key to encrypt the encryption function using branch functions; And an encryption unit for encrypting the encryption function using the dynamic key.
    상기 동적 키는 상기 평탄화 함수의 최단 실행 경로의 블록들 개수의 분기 함수들을 이용하여 복원가능한,The dynamic key is recoverable using branch functions of the number of blocks of the shortest execution path of the flattening function,
    코드 변환 장치.Transcoding device.
  10. 제7항에 있어서, The method of claim 7, wherein
    블록들 각각과 대응하는 분기 함수 각각이 하나의 코드 블록으로 구성되도록 상기 평탄화 함수를 평탄화하는 평탄화부;를 더 포함하며,And a flattening unit to flatten the flattening function such that each branch function corresponding to each of the blocks is composed of one code block.
    상기 분기 함수는 실행시에 분기할 레이블을 동적으로 계산하는, The branch function dynamically calculates a label to branch at runtime,
    코드 변환 장치.Transcoding device.
  11. 제10항에 있어서,The method of claim 10,
    상기 평탄화부에서 생성되는 평탄화 함수의 코드는 디폴트 레이블를 포함하고,The code of the flattening function generated by the flattener includes a default label,
    상기 디폴트 레이블은 소프트웨어의 변조를 탐지할 수 있도록 구성되는,The default label is configured to detect tampering with the software,
    코드 변환 장치.Transcoding device.
PCT/KR2015/009483 2014-12-24 2015-09-09 Code conversion method and code conversion device WO2016104918A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
KR1020140188492A KR101628923B1 (en) 2014-12-24 2014-12-24 Code transformation method and code transformation apparatus
KR10-2014-0188492 2014-12-24

Publications (1)

Publication Number Publication Date
WO2016104918A1 true WO2016104918A1 (en) 2016-06-30

Family

ID=56150904

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/KR2015/009483 WO2016104918A1 (en) 2014-12-24 2015-09-09 Code conversion method and code conversion device

Country Status (2)

Country Link
KR (1) KR101628923B1 (en)
WO (1) WO2016104918A1 (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113031930A (en) * 2019-12-24 2021-06-25 武汉斗鱼鱼乐网络科技有限公司 Source code confusion generation method and device for control flow flattening

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
KR101269089B1 (en) * 2011-08-19 2013-05-29 고려대학교 산학협력단 Software modulation prevention method using own encryption
KR20130085535A (en) * 2011-12-16 2013-07-30 주식회사 케이티 Apparatus for protecting forgery/alteration of application and verification apparatus
KR20130116408A (en) * 2012-03-12 2013-10-24 삼성전자주식회사 Method and apparatus for detecting leak of information resources data
KR101350390B1 (en) * 2013-08-14 2014-01-16 숭실대학교산학협력단 A apparatus for code obfuscation and method thereof

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
KR101269089B1 (en) * 2011-08-19 2013-05-29 고려대학교 산학협력단 Software modulation prevention method using own encryption
KR20130085535A (en) * 2011-12-16 2013-07-30 주식회사 케이티 Apparatus for protecting forgery/alteration of application and verification apparatus
KR20130116408A (en) * 2012-03-12 2013-10-24 삼성전자주식회사 Method and apparatus for detecting leak of information resources data
KR101350390B1 (en) * 2013-08-14 2014-01-16 숭실대학교산학협력단 A apparatus for code obfuscation and method thereof

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
GRADUATE SCHOOL OF INFORMATION SECURITY, KOREA UNIVERSITY: "TSTR: Two-stage Tamper Response in Tamper-Resistant Software", THE 3RD WEAPON SYSTEM SOFTWARE CONFERENCE, 17 September 2014 (2014-09-17), pages 1 - 20 *

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113031930A (en) * 2019-12-24 2021-06-25 武汉斗鱼鱼乐网络科技有限公司 Source code confusion generation method and device for control flow flattening
CN113031930B (en) * 2019-12-24 2022-07-05 武汉斗鱼鱼乐网络科技有限公司 Source code confusion generation method and device for control flow flattening

Also Published As

Publication number Publication date
KR101628923B1 (en) 2016-06-22

Similar Documents

Publication Publication Date Title
WO2015046655A1 (en) Application code obfuscation device based on self-conversion and method therefor
WO2015023024A1 (en) Device for obfuscating application code and method for same
EP3201819B1 (en) Automated verification of a software system
CN105683990B (en) Method and apparatus for protecting dynamic base
CN107346401B (en) Information security system for securely executing program
CN105095772B (en) Method and apparatus for safely saving and restoring computing platform state
WO2015023023A1 (en) Device for obfuscating code and method for same
WO2017026739A1 (en) System and method for obfuscating application code
WO2015026091A1 (en) Method for providing security for common intermediate language-based program
US8090959B2 (en) Method and apparatus for protecting .net programs
WO2016054303A1 (en) End-to-end security for hardware running verified software
WO2021217980A1 (en) Java code packing method and system
CN102831342A (en) Method for improving protection strength of application program in Android system
US20170024230A1 (en) Method, apparatus, and computer-readable medium for ofuscating execution of an application on a virtual machine
WO2016024838A1 (en) Method and system for providing cloud-based application security service
CN109885990B (en) Script management method
CN103413074B (en) A kind of method and apparatus being realized software protection by API
WO2015093671A1 (en) Arm processor based file obfuscation method
CN109614774A (en) A kind of program control flow based on SGX obscures method and system
US10656855B2 (en) Memory management in a programmable device
WO2016104918A1 (en) Code conversion method and code conversion device
CN104639313B (en) A kind of detection method of cryptographic algorithm
US20210342174A1 (en) Privacy preserving introspection for trusted execution environments
CN110135131A (en) A kind of encryption method of application program, storage medium and terminal device
CN111163056B (en) Data confidentiality method and system aiming at MapReduce calculation

Legal Events

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

Ref document number: 15873446

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 15873446

Country of ref document: EP

Kind code of ref document: A1