KR20070041800A - The method of api hook by modifying call instructions in code sections of modules in address space of application - Google Patents

The method of api hook by modifying call instructions in code sections of modules in address space of application Download PDF

Info

Publication number
KR20070041800A
KR20070041800A KR1020050097281A KR20050097281A KR20070041800A KR 20070041800 A KR20070041800 A KR 20070041800A KR 1020050097281 A KR1020050097281 A KR 1020050097281A KR 20050097281 A KR20050097281 A KR 20050097281A KR 20070041800 A KR20070041800 A KR 20070041800A
Authority
KR
South Korea
Prior art keywords
application
function
call
system api
control
Prior art date
Application number
KR1020050097281A
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 KR1020050097281A priority Critical patent/KR20070041800A/en
Publication of KR20070041800A publication Critical patent/KR20070041800A/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/445Program loading or initiating
    • G06F9/44568Immediately runnable code

Abstract

본 발명은 컴퓨터 응용프로그램의 소스 코드 수정 없이 임의로 기능을 수정하거나 새로운 기능을 추가하는데 사용하는 응용프로그램 제어 방법에 관한 것으로서, 기존에 사용하던 응용프로그램 제어 방법들과는 달리, 응용프로그램의 실행 코드 영역(Code Section)을 수정하는 방식이기 때문에 응용프로그램으로부터 가장 근접한 위치에서 시스템 API 호출을 제어할 수 있고 응용프로그램이 시스템 API를 호출하는 과정에서 제일 처음으로 제어권을 획득하게 되는 특징이 있다. 이런 특징으로 인하여, 응용프로그램과 제어기 사이에서 다른 기존의 응용프로그램 제어 방식이 간섭할 수 있는 여지를 원천적으로 봉쇄하는 효과가 있다. 특히 응용프로그램이 입출력하는 디지털 데이터의 보안을 위해서 실시간 디지털 데이터 암복호화 기능을 추가하는데 사용할 경우에는 응용프로그램과 제어기 사이의 안전한 데이터 교환을 보장함으로써 기존의 제어 방식을 사용했을 때 고질적으로 발생하는 데이터 가로채기 방식에 의한 원본 디지털 데이터 유출이 근본적으로 불가능해지는 효과가 있다. 또한 기존의 응용프로그램 제어 방법을 무력화시킬 수 있기 때문에, 불의의 응용프로그램 제어기에 의해서 응용프로그램의 동작이 조종 당하지 않도록 하는 기능을 추가할 때 매우 유용하다.The present invention relates to a method for controlling an application used to arbitrarily modify a function or add a new function without modifying a source code of a computer application, and unlike an existing application control method, an executable code area of an application program (Code Because it is a method of modifying a section, it is possible to control the system API call from the position closest to the application and to gain control first in the process of calling the system API. Due to this feature, there is an effect that the original blocking of the space that can interfere with other existing application control scheme between the application and the controller. Especially when it is used to add the real-time digital data encryption / decryption function for the security of digital data input / output by application program, it ensures the safe data exchange between the application program and the controller. The original digital data leakage by the squeeze method is essentially impossible. It is also very useful when adding a function that prevents the operation of an application from being controlled by an unexpected application controller because it can disable existing application control methods.

응용프로그램 제어, 실행 코드 영역, Code Section, CALL  Application Control, Executable Code Area, Code Section, CALL

Description

응용프로그램의 실행 코드 영역 수정을 통한 응용프로그램 제어 방법 { The method of API hook by modifying call instructions in code sections of modules in address space of application }How to control application by modifying execution code area of application {The method of API hook by modifying call instructions in code sections of modules in address space of application}

도 1은 일반적인 응용프로그램에서 시스템 API(Application Programming Interface)를 호출했을 때 호출 명령이 실행되는 과정을 나타내는 기능 블록도.1 is a functional block diagram illustrating a process of executing a call command when a system API (Application Programming Interface) is called in a general application.

도 2는 기존의 응용프로그램 제어 방법인 IAT(Import Address Table)를 수정하는 방법을 사용했을 때 제어된 시스템 API가 호출되는 과정을 나타내는 기능 블록도.FIG. 2 is a functional block diagram illustrating a process in which a controlled system API is called when a method of modifying an import address table (IAT), which is an existing application control method, is used.

도 3은 본 발명의 일 실시 예에 따른 응용프로그램이 시스템 API를 호출했을 때 호출 명령이 제어되는 과정을 나타내는 기능 블록도.3 is a functional block diagram illustrating a process of controlling a call command when an application program calls a system API according to an exemplary embodiment of the present invention.

본 발명은 이미 유통 중인 컴퓨터 응용프로그램에 대하여 응용프로그램의 소스 코드를 수정하지 않은 상태에서 임의로 기능을 수정하거나 새로운 기능을 추가하는 방법에 관한 것이다. 이런 종류의 방법들은 응용프로그램이 실행하는 도중에 실시간으로 시스템 API(Application Programming Interface)로의 호출을 가로채는 방법을 사용하는데, 메모리 영역에 존재하는 응용프로그램의 일부 영역을 실시간에 수정함으로써 이루어진다. 대표적으로는, 응용프로그램의 IAT(Import Address Table)를 수정하는 방법과, 시스템 API 함수 자체를 기계어 수준에서 재작성(Code Rewrite)하는 방법이 있다. 실행 중인 응용프로그램 내부에서 이런 제어기가 동작을 시작하면 응용프로그램이 호출하는 모든 시스템 API는 제어기가 제공하는 함수를 경유해서 호출되므로 제어기는 임의로 응용프로그램의 동작을 조종할 수 있다. 도 1은 일반적인 응용프로그램에서 시스템 API를 호출했을 때 호출 명령이 실행되는 과정을 나타내는 기능 블록도이다. 도 1을 참조하여 일반적인 시스템 API 호출 과정을 살펴보면, 응용프로그램(100)의 주소 공간에 로드되어 있는 모듈 A.exe(110)가 B.dll(140)이 제공하는 F() 함수를 호출하면 A.exe(110)의 IAT(130)에 저장되어 있는 F() 함수의 주소를 참조하여 F() 함수를 호출하게 된다. 도 2는 기존의 응용프로그램 제어 방법인 IAT를 수정하는 방법을 사용했을 때 제어된 시스템 API가 호출되는 과정을 나타내는 기능 블록도이다. 도 2를 참조하여 IAT 수정 방식을 적용했을 때의 동작을 살펴보면, 응용프로그램(100)의 주소 공간에 로드되어 있는 모듈 A.exe(110)가 B.dll(140)이 제공하는 F() 함수를 호출하면 A.exe(110)의 IAT(130)에 저장되어 있는 F() 함수의 주소를 참조하는데, F() 함수의 주소는 제어기 모듈(160)이 제공하는 F2() 함수의 주소로 교체된 상태이기 때문에 F() 함수의 주소를 참조하려고 한 위치에 F2() 함수의 주소가 있으므로 결국은 F2() 함수를 호출하게 된다. F2() 함수는 다시 원래의 API 함수인 B.dll(140)의 F() 함수를 호출하거나 자체에서 리턴하거나 함으로써 제어 작업을 진행한다.The present invention relates to a method for arbitrarily modifying a function or adding a new function to a computer application that is already in circulation without modifying the source code of the application. This kind of method uses a method of intercepting a call to a system API (Application Programming Interface) in real time while an application is executing, by modifying a part of an application program existing in a memory area in real time. Representative methods include modifying the import address table (IAT) of an application program and rewriting system API functions themselves at the machine language level. When such a controller starts running inside a running application, all system APIs called by the application are called through functions provided by the controller, so the controller can arbitrarily control the operation of the application. 1 is a functional block diagram illustrating a process of executing a call command when a system API is called in a general application program. Looking at the general system API call process with reference to Figure 1, if the module A.exe (110) loaded in the address space of the application 100 calls the F () function provided by B.dll (140) A The F () function is called by referring to the address of the F () function stored in the IAT 130 of the .exe 110. 2 is a functional block diagram illustrating a process of calling a controlled system API when a method of modifying an IAT, which is an existing method of controlling an application program, is used. Looking at the operation when the IAT modification method is applied with reference to Figure 2, the module A.exe (110) loaded in the address space of the application 100 is the F () function provided by B.dll (140) Calls the address of the F () function stored in the IAT 130 of A.exe 110. The address of the F () function is the address of the F2 () function provided by the controller module 160. Since it is in the swapped state, the address of the F2 () function is located at the point where we tried to refer to the address of the F () function, which eventually calls the F2 () function. The F2 () function performs control by calling the F () function of B.dll 140, which is the original API function, or returning it from itself.

그러나 상기한 기존의 방식들은 자신보다 앞서서 시스템 API 호출을 가로챌 수 있는 방식이 존재할 수 있는 여지를 가지고 있다. 실제로, IAT를 수정하는 방식이 시스템 API 함수를 수정하는 방식보다 한 발 앞서서 제어권을 얻게 된다. 이런 식으로, 어떤 제어 방식이 또 다른 제어 방식에 의해서 제어의 우선권을 빼앗긴다면, 우선권을 잃은 제어 방식은 앞서서 우선권을 가지는 제어 방식에 의해서 무력화될 수도 있고, 특히 디지털 데이터 보안 시스템에서는 앞서 제어권을 가지는 제어기에 의해서 원본 디지털 데이터가 쉽게 유출될 수 있는 문제점을 가진다.However, the above existing methods have a possibility that there may be a way to intercept system API calls ahead of themselves. In fact, modifying the IAT takes control one step ahead of modifying system API functions. In this way, if a control method is deprived of control priority by another control method, the control method that has lost its priority may be overridden by the control method that has priority, especially in a digital data security system. There is a problem that the original digital data can be easily leaked by the controller.

본 발명의 목적은 이와 같은 종래 기술의 문제점을 해결하기 위한 것으로, 기존 방식인 IAT(Import Address Table)를 수정하는 시스템 API 제어 방식보다 먼저 시스템 API로의 호출을 가로채서 최우선으로 응용프로그램에 대한 제어권을 얻는 방법을 제공하고자 한다. 그리고 본 발명이 제공하는 방식보다 먼저 시스템 API 호출을 가로챌 수 있는 방식이 더 이상 존재할 수 있는 여지가 없어야 함은 물론이다. 본 발명은 상기와 같은 목적을 달성하기 위하여, 응용프로그램의 IAT를 수정하거나 시스템 API 함수 자체를 수정하지 않고, 응용프로그램의 실행 코드 영역(Code Section)을 수정하는 방법을 사용한다. 이 영역은 기존의 시스템 API 제어 방법들이 사용하지 않는 영역이기 때문에 기존 방법을 사용하는 제어기들과 충돌없이 동작할 수 있고, 응용프로그램의 실행 코드 영역을 수정하기 때문에 이 방식보다 먼저 시스템 API 호출을 가로챌 수 있는 방식이 더 이상 존재할 수 있는 여지가 전혀 없다.An object of the present invention is to solve such a problem of the prior art, the first to intercept the call to the system API prior to the system API control method for modifying the existing import address table (IAT), the first priority to control the application program We want to provide a way to get it. And of course, there should be no way that there can be any more way to intercept system API calls before the method provided by the present invention. In order to achieve the above object, the present invention uses a method of modifying an executable code section of an application program without modifying the IAT of the application program or the system API function itself. Since this area is not used by the existing system API control methods, it can operate without conflict with the controllers that use the existing method. There is no longer any way to go.

본 발명은 실행 중인 응용프로그램의 메모리 영역 중에서 실행 코드 영역(Code Section)에 설치되어 동작하는 시스템 API 제어기로 구성된다. 마이크로소프트 윈도우즈(Windows) 운영체제는 응용프로그램마다 각각 일정한 크기의 가상 주소 공간(Virtual Address Space)을 부여한다. 이 주소 공간 안에 응용프로그램과 응용프로그램이 사용하는 시스템 API 모듈(Module)들이 적절한 위치에 로드되어 실행을 시작하게 된다. 응용프로그램 모듈과 시스템 API 모듈들은 모두 PE(Portable Executable) 포맷을 따라 만들어져 있고, 저장 매체에 저장된 상태이거나 응용프로그램의 메모리 영역에 로드된 상태의 각 모듈들은 PE 포맷에 의거하여 구조 분석이 가능하다. PE 포맷은 헤더(Header) 부분과 여러 개의 섹션(Section)으로 구성되어 있고, 본 발명이 제어기를 설치하는 위치는 각 모듈 속의 섹션들 중에서 코드 섹션(Code Section)이라고 불리는 실행 코드 영역이다. 도 1을 참조하여 실행 코드 영역을 살펴보면, 응용프로그램(100)의 주소 공간에 로드된 A.exe(110), B.dll(140)은 모두 PE 포맷을 따르는 모듈들이며 이들은 각각 실행 코드 영역(120, 150)을 가지고 있다. 실행 코드 영역은 컴퓨터의 프로세서(Processor)가 실제 실행하는 기계어 명령들과 파라미터(Parameter)의 연속으로 이루어져 있는 영역이다. 이 기계어 명령들 중에서 다른 모듈이 제공하는 API 함수를 호출하는 부분이 있는데, 이 기계어 명령을 어셈블리(Assembly) 언어로 CALL 명령이라고 표현한다. 이때 CALL 명령의 호출 대상이 되는 API 함수들은 이 모듈에 임포트(Import)된 상태이며, 이렇게 임포트된 시스템 API 함수들의 주소 정보는 윈도우즈(Windows) 운영체제가 응용프 로그램을 로드하는 과정에서 초기화된다. 이 임포트된 API들의 주소 정보들을 보관하는 곳이 IAT(Import Address Table)라는 테이블이다. IAT는 각 모듈의 PE 포맷 안에 각각 존재하고, 해당 모듈이 참조(임포트)하는 다른 모듈의 API 함수의 주소가 기록되어 있다. IAT에 저장되어 있는 API 함수 주소를 변경함으로써 시스템 API 함수 호출을 가로채는 방법이 기존에 사용하는 시스템 API 제어 방법 중의 하나이다. 도 2는 기존의 응용프로그램 제어 방법인 IAT를 수정하는 방법을 사용했을 때 시스템 API가 호출되는 과정을 나타내는 기능 블록도이다. 이렇게 임포트된 시스템 API 함수는 프로세서(Processor)의 특정한 기계어 명령이 IAT에 저장되어 있는 함수 주소 정보를 참조하여 호출하도록 되어 있다. 일례로, 도 1을 참조하여 살펴보면, A.exe(110)에 임포트된 B.dll(140)의 API 함수 F()에 대해서 그 주소를 nF라고 하고 nF가 저장되어 있는 A.exe(110)의 IAT(130) 내부 위치의 주소를 nT라고 했을 때, 이 기계어 명령을 어셈블리(Assembly) 언어로 표현하면 'call dword ptr [nT]'이다. 이런 구조 때문에 윈도우즈 운영체제가 응용프로그램을 로드하면서 각 모듈이 임포트하는 시스템 API 함수 주소 정보를 초기화할 때 각 모듈의 실행 코드 영역을 전부 뒤지지 않고 단지 IAT만을 초기화한다. 본 발명이 제공하는 방법은 실행 코드 영역 안에 존재하는 모든 CALL 명령들에 대하여, 가로채고자 하는 API 함수를 호출하는 CALL 명령인 경우에는 원래의 API 함수 대신에 대체 함수를 호출하도록 CALL 명령을 수정하여 시스템 API 함수로의 호출을 가로챈다. 이하 본 발명에 따른 실시 예 두 가지를 설명한다. 하기 설명에서는 구체적인 구성 소자 등과 같은 특정 사항들이 나타나는데 이는 본 발명에 대한 전반적인 이해를 돕기 위해서 제공되는 것일 뿐 이러한 특정 사항들이 본 발명의 범주 내에서 소정의 변형 혹은 변경이 이루어질 수 있음은 이 기술 분야에서 통상의 지식을 가진 자에게는 자명하다 할 것이다. The present invention is composed of a system API controller which is installed and operates in an executable code section of a memory area of an executing application program. The Microsoft Windows operating system gives each application a certain amount of virtual address space. In this address space, the application and the system API modules used by the application are loaded in the appropriate locations and started to run. Both application program modules and system API modules are built according to the Portable Executable (PE) format, and each module in a state stored in a storage medium or loaded in an application memory area can be structurally analyzed according to the PE format. The PE format is composed of a header part and several sections, and the location in which the controller is installed in the present invention is an executable code area called a code section among sections in each module. Referring to FIG. 1, in the execution code area, A.exe 110 and B.dll 140 loaded in the address space of the application 100 are all modules that conform to the PE format. , 150). An executable code area is an area consisting of a series of machine instructions and parameters that are actually executed by a computer processor. Some of these machine instructions call API functions provided by other modules. These machine instructions are called CALL instructions in Assembly language. At this time, API functions that are called by CALL command are imported to this module, and the address information of the imported system API functions is initialized when the Windows operating system loads the application. The place to store the address information of these imported APIs is a table called IAT (Import Address Table). Each IAT exists in the PE format of each module, and records the address of API functions of other modules that the module references (imports). Interception of system API function calls by changing the API function addresses stored in the IAT is one of the existing system API control methods. 2 is a functional block diagram illustrating a process of calling a system API when a method of modifying an IAT, which is an existing method of controlling an application, is used. The imported system API function is to call a specific machine instruction of a processor by referring to the function address information stored in the IAT. For example, referring to FIG. 1, the API function F () of B.dll 140 imported into A.exe 110 is called nF and A.exe 110 in which nF is stored. When the address of the internal location of the IAT 130 is nT, the machine instruction is expressed in an assembly language, which is 'call dword ptr [nT]'. Because of this structure, when the Windows operating system loads an application and initializes the system API function address information that each module imports, it initializes only the IAT, not all of the executable code area for each module. The method provided by the present invention modifies the CALL command to call an alternative function instead of the original API function in the case of a CALL command calling an API function to be intercepted for all CALL commands existing in the execution code area. Intercept calls to system API functions. Hereinafter, two embodiments according to the present invention will be described. In the following description, specific matters such as specific elements appear, which are provided to help the overall understanding of the present invention, and it is understood that certain specific changes or modifications can be made within the scope of the present invention. It will be self-evident to those of ordinary knowledge.

첫 번째 실시 예를 설명하면, CALL 명령에 뒤따르는 주소 정보, 즉 CALL 명령의 파라미터(Parameter)를 변경하는 방법이다. 이 파라미터 값은 IAT 내부를 가리키는 주소인데, 이값을 별도의 다른 영역을 가리키는 주소로 교체한다. 새로 교체된 주소가 가리키는 메모리 영역에는, 임포트된 시스템 API 함수를 가로채기 위해서 대체용으로 제공하는 함수를 F2()라고 하면, F2() 함수의 주소가 기록되어 있다. 두 번째 실시 예를 설명하면, 대체 함수 주소 자체를 파라미터로 받아서 함수를 호출하는 형식으로 CALL 명령을 수정하는 방법이다. F() 함수를 대신하여 호출을 받을 대체 함수 F2()의 주소를 nF2라고 했을 때, 수정된 CALL 명령을 어셈블리 언어로 표현하면 'call nF2'가 된다. 상기 실시 예들의 방법을 이용해서 실행 중인 응용프로그램의 주소 공간에 로드된 모든 모듈의 실행 코드 영역에 대한 변경 작업을 마치면 임포트한 API 함수 F()를 호출할 때마다 F() 함수의 대체 함수인 F2() 쪽으로 먼저 호출이 들어오게 된다. 이 시점은 기존 방식인 IAT를 수정하는 방식이나 임포트한 API 함수 자체를 수정하는 방식이 호출을 가로채기 이전이다.Referring to the first embodiment, a method of changing address information following a CALL command, that is, a parameter of a CALL command. The value of this parameter is an address that points inside the IAT. Replace this value with an address that points to another area. The address of the F2 () function is recorded in the memory area indicated by the newly replaced address if F2 () is a function provided as a replacement for intercepting the imported system API functions. Referring to the second embodiment, a method of modifying a CALL instruction by receiving an alternate function address itself as a parameter and calling a function is described. If the address of the replacement function F2 () to be called on behalf of the F () function is nF2, the modified CALL instruction in assembly language would be 'call nF2'. After changing the execution code area of all modules loaded in the address space of the executing application program using the method of the above embodiments, whenever the imported API function F () is called, it is a substitute function of the F () function. The call comes first to F2 (). At this point, before modifying the existing IAT or modifying the imported API function itself, the call is intercepted.

상기 두 가지 실시 예 중에서 첫 번째 실시 예를 도 3을 참조하여 구체적으로 설명하면 다음과 같다. 아래에서 언급하는 모든 주소는 응용프로그램이 사용하는 가상 주소 공간 속에서의 주소를 의미한다. A.exe(110)가 B.dll(140)이 제공하는 F() 함수를 임포트한다고 하자. 그러면 A.exe(110)의 IAT(130)에는 F() 함수의 주소가 기록되는데, 이 기록된 위치의 주소를 nT라고 하면, nT가 A.exe(110)의 실행 코드 영역 안에서 F() 함수를 호출하는 CALL 명령의 파라미터로 되어 있다. 이 명령을 어셈블리 언어로 표시하면 'call dword ptr [nT]'가 된다. 이런 상황에서 A.exe(110)에서 F() 함수로의 호출을 가로채기 위해서는 첫째로, 제어기 모듈(180)에 F() 함수와 똑같은 타입을 가진 F2() 함수를 만들고, 제어기 모듈(180)의 변수 P에 F2() 함수의 주소를 기록해 놓는다. 이때 변수 P의 주소를 nP라고 하자. F2() 함수는 A.exe(110)가 F() 함수를 호출하는 순간에 F() 함수 대신에 호출을 전해 받을 F() 함수의 대체용 함수이며, nP는 CALL 명령의 새로운 파라미터로 교체될 값이다. 둘째로, A.exe(110)의 실행 코드 영역(120) 안에 있는 모든 CALL 명령들에 대해서 그 파라미터 값을 조사하는데, 그 파라미터 값이 nT와 일치하는 경우에는, 해당 CALL 명령의 파라미터 값을 nT에서 변수 P의 주소인 nP로 교체한다. 이를 어셈블리 언어로 표시하면 'call dword ptr [nP]'가 된다. 이 CALL 명령의 의미는, nP가 가리키는 위치에 저장되어 있는 값은 어떤 함수의 주소인데 그 함수를 호출하라는 의미이다. 변수 P에는 F2() 함수의 주소가 저장되어 있기 때문에, 상기한 방식으로 A.exe(110)의 실행 코드 영역(120)을 변경해 놓으면 A.exe(110)에서 F() 함수를 호출할 때마다 F2() 함수가 F() 함수에 앞서서 먼저 호출을 받게 된다. 상기 과정을 B.dll(140)이 이 외의 다른 모듈이 제공하는 API 함수를 임포트하는 경우에도 그대로 적용할 수 있음은 이 기술 분야의 숙련자라면 잘 이해할 수 있을 것이다.A first embodiment of the two embodiments will be described in detail with reference to FIG. 3. All addresses mentioned below refer to addresses in the virtual address space used by the application. Suppose A.exe 110 imports the F () function provided by B.dll 140. Then, the address of the F () function is recorded in the IAT 130 of A.exe 110. If the address of the recorded position is nT, nT is the F () in the executable code area of A.exe 110. It is a parameter of the CALL instruction that calls a function. When this command is expressed in assembly language, it is called 'call dword ptr [nT]'. In this situation, to intercept a call from A.exe (110) to the F () function, first, create a F2 () function with the same type as the F () function in the controller module 180, and then the controller module 180 Record the address of the F2 () function in the variable P of). Let's call the address of variable P nP. The F2 () function is an alternative to the F () function that will receive the call instead of the F () function at the moment A.exe (110) calls the F () function, and nP is replaced with the new parameter of the CALL command. The value to be. Second, all CALL commands in the execution code area 120 of A.exe 110 are examined for the parameter value. If the parameter value matches nT, the parameter value of the CALL command is nT. Replace with nP, the address of variable P in. If it is expressed in assembly language, it becomes 'call dword ptr [nP]'. This CALL command means that the value stored in the location pointed to by nP is the address of a function, and that function is called. Since the address of the F2 () function is stored in the variable P, when the execution code area 120 of the A.exe 110 is changed in the above manner, the A.exe 110 calls the F () function. Each time the F2 () function is called before the F () function. It will be understood by those skilled in the art that the above process can be applied even when B.dll 140 imports API functions provided by other modules.

상기 두 가지 실시 예 중에서 두 번째 실시 예를 도 3을 참조하여 구체적으로 설명하면 다음과 같다. 첫 번째 실시 예에서와 마찬가지로, A.exe(110)가 B.dll(140)이 제공하는 F() 함수를 임포트한다고 하자. 그러면 A.exe(110)의 IAT(130)에는 F() 함수의 주소가 기록되고, 이 기록된 위치의 주소를 nT라고 하면, nT가 A.exe(110)의 실행 코드 영역(120) 안에서 F() 함수를 호출하는 CALL 명령의 파라미터가 된다. 이제 A.exe(110)에서 F() 함수로의 호출을 가로채기 위해서는 첫째로, 제어기 모듈(180)에 F() 함수와 똑같은 타입을 가진 F2() 함수를 만든다. 이때 F2() 함수의 주소를 nF2라고 하자. F2() 함수는 A.exe(110)가 F() 함수를 호출하는 순간에 F() 함수 대신에 호출을 전해 받을 F() 함수의 대체용 함수이다. 둘째로, A.exe(110)의 실행 코드 영역(120) 안에 있는 모든 CALL 명령들에 대해서 그 파라미터 값을 조사하는데, 그 파라미터 값이 nT와 일치하는 경우에는, 'call dword ptr[nT]' 명령을 'call nF2' 명령으로 수정한다. 수정된 CALL 명령의 뜻은, nF2는 함수의 주소인데 그 함수를 호출하라는 의미이다. 이 경우 nF2는 제어기 모듈(180)이 제공하는 F2() 함수의 주소이므로 F2() 함수를 호출하라는 의미가 된다. 이때, 원래 CALL 명령의 총 길이는 6바이트(Byte)이고 수정된 CALL 명령의 총 길이는 5바이트이기 때문에 남는 1바이트의 공간에는 NOP 명령을 저장하여 1바이트는 그냥 건너뛰도록 설정한다. 상기 방식으로 A.exe(110)의 실행 코드 영역을 변경해 놓으면 A.exe(110)에서 F() 함수를 호출할 때마다 F2() 함수가 F() 함수에 앞서서 먼저 호출을 받게 된다. 상기 방식을 B.dll이 이 외의 다른 모듈이 제공하는 API 함수를 임포트하는 경우에도 그대로 적용할 수 있음은 이 기술 분야의 숙련자라면 잘 이해할 수 있을 것이다.A second embodiment of the two embodiments will be described in detail with reference to FIG. 3 as follows. As in the first embodiment, assume that A.exe 110 imports the F () function provided by B.dll 140. Then, the address of the F () function is recorded in the IAT 130 of A.exe 110. If the address of the recorded position is nT, nT is in the executable code area 120 of A.exe 110. It is a parameter of the CALL instruction that calls the F () function. Now, to intercept a call from A.exe (110) to the F () function, first create an F2 () function with the same type as the F () function in the controller module 180. Let's call the address of F2 () function nF2. The F2 () function is an alternative to the F () function that will receive the call instead of the F () function when A.exe 110 calls the F () function. Second, all CALL instructions in the executable code area 120 of A.exe 110 are examined for their parameter values. If the parameter value matches nT, 'call dword ptr [nT]' Modify the command to 'call nF2'. The modified CALL command means that nF2 is the address of a function, which means call the function. In this case, since nF2 is the address of the F2 () function provided by the controller module 180, it means that the F2 () function is called. At this time, since the total length of the original CALL instruction is 6 bytes and the total length of the modified CALL instruction is 5 bytes, the NOP instruction is stored in the remaining 1 byte space so that 1 byte is simply skipped. If the execution code area of the A.exe 110 is changed in this manner, each time the A.exe 110 calls the F () function, the F2 () function is called before the F () function. It will be understood by those skilled in the art that the above method can be applied even when B.dll imports API functions provided by other modules.

이상 설명한 바와 같이, 본 발명은 응용프로그램의 실행 코드 영역(Code Section)을 수정하는 방식이기 때문에 기존의 시스템 API 제어 방식(IAT를 수정하는 방법, API 함수 자체를 기계어 수준에서 수정하는 방법)에 우선하여 실행 중인 응용프로그램에 대한 제어권을 확보할 수 있고, 향후에도 새로운 방식에 의해서 제어권을 선점당할 여지가 전혀 없다. 제어권 확보의 우선 순위대로 방식을 나열해 보면, 본 발명의 방식이 제어권을 가장 먼저 받고, 그 다음이 IAT를 수정하는 방식, API 함수 자체를 기계어 수준에서 재작성하는 방식 순이다. 또한, 응용프로그램의 실행 코드 영역은 기존 시스템 API 제어 방식들이 사용하지 않는 영역이기 때문에 기존 시스템 API 제어 방식과의 충돌이 없다. 응용프로그램이 시스템 API를 호출하는 과정에서 제일 먼저 호출을 가로챌 수 있기 때문에, 후 순위의 시스템 API 제어기로 제어권을 넘길 수도 있고 건너뛸 수도 있다. 이런 특징으로 인하여, 디지털 데이터 보호 시스템에서 이 방식을 사용할 때 큰 효과가 있다. 최우선 순위의 시스템 API 제어기에서 디지털 데이터가 복호화되어 응용프로그램에 바로 제공되기 때문에 기존의 디지털 데이터 보안 시스템에서 전형적인 해킹 수단이었던 데이터 가로채기 방법에 의한 해킹이 원천적으로 불가능하게 된다. 또한, 최우선 순위의 시스템 API 제어기가 하위의 제어기를 모두 건너뛰고 직접 시스템 API를 호출할 수 있기 때문에, 응용프로그램이 본래의 의도와는 다르게 조종 당하는 것을 방지하는 후킹(Hooking) 방지 기능을 추가하는데 효과가 있다.As described above, the present invention is a method of modifying an executable code section of an application program, and therefore, prior to the existing system API control method (method of modifying IAT, method of modifying API function itself at the machine language level). This gives you control over the running application, and there is no room for you to preempt control in the future. In order to control the order of priority, the method of the present invention receives the control first, then modifies the IAT, and rewrites the API function itself at the machine language level. In addition, since the execution code area of the application program is an area not used by the existing system API control methods, there is no conflict with the existing system API control methods. Since the application can intercept the call first in the process of calling the system API, it can either pass control to the next-level system API controller or skip it. Due to this feature, there is a great effect when using this method in digital data protection system. Since digital data is decoded in the highest priority system API controller and immediately provided to an application program, hacking by the data interception method, which is a typical hacking means in the existing digital data security system, is fundamentally impossible. In addition, since the highest priority system API controller can skip all of the lower controllers and directly call the system API, it is effective to add a hooking prevention function that prevents the application from being manipulated differently than the original intention. There is.

Claims (3)

컴퓨터 응용프로그램의 소스 코드 수정 없이 실시간으로 시스템 API 제어를 통하여 응용프로그램의 동작을 제어하는 방법에 있어서, 응용프로그램의 주소 공간에 로드된 PE(Portable Executable) 포맷으로 된 모듈들의 실행 코드 영역(Code Section) 안에 있는 CALL 명령들에 대하여, 제어하고자 하는 시스템 API 함수를 호출하는 CALL 명령인 경우에, 원래 호출하는 시스템 API 함수 대신에 대체 함수를 호출하도록 CALL 명령을 수정하여 시스템 API 함수로의 호출을 가로채는 방법.In the method for controlling the operation of an application through system API control in real time without modifying the source code of the computer application, an executable code area of modules in a PE (Portable Executable) format loaded in the application address space For CALL commands in C), in the case of a CALL command that calls a system API function that you want to control, modify the CALL command to call an alternative function instead of the original system API function to intercept calls to system API functions. Way. 제 1 항에 있어서, 상기 PE 포맷의 모듈은 저장 매체에 저장된 상태의 모듈과 운영체제에 의해서 로드되고 있는 상태의 모듈도 포함하는 것을 특징으로 하는 방법.The method of claim 1, wherein the PE format module includes a module in a state stored in a storage medium and a module in a state loaded by an operating system. 제 1 항에 있어서, 상기 CALL 명령은 32비트(bit) 프로세서(Processor)와 64비트 프로세서의 CALL 명령을 모두 포함하는 것을 특징으로 하는 방법.The method of claim 1, wherein the CALL instruction includes a CALL instruction of both a 32-bit processor and a 64-bit processor.
KR1020050097281A 2005-10-17 2005-10-17 The method of api hook by modifying call instructions in code sections of modules in address space of application KR20070041800A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
KR1020050097281A KR20070041800A (en) 2005-10-17 2005-10-17 The method of api hook by modifying call instructions in code sections of modules in address space of application

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
KR1020050097281A KR20070041800A (en) 2005-10-17 2005-10-17 The method of api hook by modifying call instructions in code sections of modules in address space of application

Publications (1)

Publication Number Publication Date
KR20070041800A true KR20070041800A (en) 2007-04-20

Family

ID=38176877

Family Applications (1)

Application Number Title Priority Date Filing Date
KR1020050097281A KR20070041800A (en) 2005-10-17 2005-10-17 The method of api hook by modifying call instructions in code sections of modules in address space of application

Country Status (1)

Country Link
KR (1) KR20070041800A (en)

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101470620B (en) * 2007-12-29 2013-01-16 珠海金山软件有限公司 Method and apparatus for judging PE file source code consistency
CN107818034A (en) * 2016-09-14 2018-03-20 华为技术有限公司 The method and device of the running space of process in monitoring calculation machine equipment
KR20180038262A (en) * 2016-10-06 2018-04-16 명지대학교 산학협력단 Data hidden device and method of executing program instructions in the same
KR20200037968A (en) * 2018-10-02 2020-04-10 주식회사 한글과컴퓨터 Method and appratus for providing virtualized opencl environment for stable execution

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101470620B (en) * 2007-12-29 2013-01-16 珠海金山软件有限公司 Method and apparatus for judging PE file source code consistency
CN107818034A (en) * 2016-09-14 2018-03-20 华为技术有限公司 The method and device of the running space of process in monitoring calculation machine equipment
CN107818034B (en) * 2016-09-14 2021-02-12 华为技术有限公司 Method and device for monitoring running space of process in computer equipment
KR20180038262A (en) * 2016-10-06 2018-04-16 명지대학교 산학협력단 Data hidden device and method of executing program instructions in the same
KR20200037968A (en) * 2018-10-02 2020-04-10 주식회사 한글과컴퓨터 Method and appratus for providing virtualized opencl environment for stable execution

Similar Documents

Publication Publication Date Title
JP5769891B2 (en) Dynamic execution prevention to suppress return-oriented programming
JP4006337B2 (en) How to fix executable execution using shared libraries
US6578094B1 (en) Method for preventing buffer overflow attacks
JP5571201B2 (en) Limit memory area for read instructions based on hardware mode and security flags
JP2010129080A (en) Software executing system and software executing method
US20100042980A1 (en) Cross-domain inlining in a system virtual machine
US10528729B2 (en) Methods and systems for defending against cyber-attacks
US20020194521A1 (en) Memory exchange
KR20070041800A (en) The method of api hook by modifying call instructions in code sections of modules in address space of application
US8099724B2 (en) Fast patch-based method calls
CN116150739A (en) Automatic stack overflow defense method based on dynamic protection of key address
CN112256396B (en) Memory management method and system, security processing device and data processing device
US10929528B2 (en) Systems and methods for intrinsic runtime security
US9417856B2 (en) Efficient interpreter profiling to obtain accurate call-path information
CN115510430A (en) Function pointer and data dependency identification and protection method and device thereof
US11893113B2 (en) Return-oriented programming protection
KR20070088160A (en) Method for invoking inlined method and java virtual machine using the same
JP2006048186A (en) Language processing system protecting generated code of dynamic compiler
US11340915B2 (en) Encaching and sharing transformed libraries
KR102617678B1 (en) Selective memory coalescing device and method according to a class of load instruction
KR100382355B1 (en) Method of Alternating Text Areas of the Shared Library
JP2003162411A (en) Data processor
JP2004126739A (en) Name resolution method
JPH11259308A (en) Programmable controller
KR20210144175A (en) Method and apparatus for instruction expansion for embedded device

Legal Events

Date Code Title Description
A201 Request for examination
E902 Notification of reason for refusal
E601 Decision to refuse application