WO2012023809A2 - 훅 재진입 방지 장치 및 그 방법을 컴퓨터에서 실행시키기 위한 프로그램을 기록한 기록매체 - Google Patents

훅 재진입 방지 장치 및 그 방법을 컴퓨터에서 실행시키기 위한 프로그램을 기록한 기록매체 Download PDF

Info

Publication number
WO2012023809A2
WO2012023809A2 PCT/KR2011/006062 KR2011006062W WO2012023809A2 WO 2012023809 A2 WO2012023809 A2 WO 2012023809A2 KR 2011006062 W KR2011006062 W KR 2011006062W WO 2012023809 A2 WO2012023809 A2 WO 2012023809A2
Authority
WO
WIPO (PCT)
Prior art keywords
hook
function
thread
layer
called
Prior art date
Application number
PCT/KR2011/006062
Other languages
English (en)
French (fr)
Other versions
WO2012023809A3 (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 US13/818,054 priority Critical patent/US9098356B2/en
Priority to JP2013524794A priority patent/JP5579934B2/ja
Priority to EP20110818409 priority patent/EP2608021A4/en
Publication of WO2012023809A2 publication Critical patent/WO2012023809A2/ko
Publication of WO2012023809A3 publication Critical patent/WO2012023809A3/ko

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/448Execution paradigms, e.g. implementations of programming paradigms
    • G06F9/4482Procedural
    • G06F9/4484Executing subprograms
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/30Monitoring
    • G06F11/3089Monitoring arrangements determined by the means or processing involved in sensing the monitored data, e.g. interfaces, connectors, sensors, probes, agents
    • 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/46Multiprogramming arrangements
    • G06F9/54Interprogram communication
    • G06F9/541Interprogram communication via adapters, e.g. between incompatible applications
    • 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/46Multiprogramming arrangements
    • G06F9/54Interprogram communication
    • G06F9/545Interprogram communication where tasks reside in different layers, e.g. user- and kernel-space
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/30Monitoring
    • G06F11/3003Monitoring arrangements specially adapted to the computing system or computing system component being monitored
    • G06F11/3017Monitoring arrangements specially adapted to the computing system or computing system component being monitored where the computing system is implementing multitasking
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/30Monitoring
    • G06F11/3003Monitoring arrangements specially adapted to the computing system or computing system component being monitored
    • G06F11/302Monitoring arrangements specially adapted to the computing system or computing system component being monitored where the computing system component is a software system
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2209/00Indexing scheme relating to G06F9/00
    • G06F2209/54Indexing scheme relating to G06F9/54
    • G06F2209/542Intercept

Definitions

  • the present invention relates to an apparatus for preventing hook re-entry and a recording medium for recording a program for executing the method in a computer. More specifically, the apparatus and apparatus for preventing recursive entry of a hook during a function call during API hooking A recording medium having recorded thereon a program for executing the method on a computer.
  • API hooks are a generic term for a technique that bypasses the flow of a function's call to a different location through specific manipulations for a general API call process.
  • 1 and 2 illustrate a basic call structure and an API filtering process by hooks, respectively.
  • the hook function B intervenes in the calling process of the target function C by the original function A.
  • FIG. The hook layer introduced to complete this hook technique should not be affected by the hook.
  • the ideal structure of the hook layer as shown in FIG. 3 should be able to support the hook and replace / filter processing for multiple functions, and the hook layer itself should not be affected by the hook.
  • the hook layer must not use the hook target API or know the address where the hook target API source function can be called, so that the hook API or the source API can be selectively called if necessary. If the hook layer does not use the hook target API, the behavior inside the hook layer is independent of the API hook. However, it is not easy to prevent the hook layer from using the hook target API. In other words, in order for the hook layer not to use the hook target API, it is possible only if there is no direct association between the hook target API and the run time binary for the subordinate source function. Therefore, this method is not suitable for the implementation of the hook layer because it is necessary to implement an emulator supporting program operation on this OS platform or to emulate a hook API.
  • the hook layer manages the address where the hook target API source function can be called.
  • the hook layer is additionally used to prevent the hook layer from being affected by the hook.
  • the programming method of implementing the hook layer in the form of managing the address where the hook target API source function can be called differs depending on the API hook technique.
  • a hook exception is executed at runtime module units such as * .exe or * .dll belonging to the hook layer, and the hook is executed for the modules belonging to the hook layer and lower layers. There is a way not. The requirement for this approach is how accurately the runtime module belonging to the hook layer can be identified.
  • the present invention has been made in an effort to provide an apparatus capable of preventing reentry of a hook due to a call back of an original function of a lower function during dynamic API hooking.
  • Another object of the present invention is to provide a computer-readable recording medium having recorded thereon a program for executing on a computer a method for preventing hook re-entry due to a call back of an original function of a sub-function during dynamic API hooking. have.
  • a preferred embodiment of the hook reentry prevention device for preventing the reentry of the hook defined by the recursive execution of the hook, which is code for executing hooking during dynamic API hooking.
  • An apparatus comprising: a state information management module for setting or releasing a state information flag indicating whether a hook function is called at the time of starting the dynamic API hooking; And a reentry prevention module configured to execute a program originally requested to be executed by determining that the hook function is made during the execution of the hook when the state information flag is set when the hook function is called.
  • the recording medium in order to achieve the above another technical problem, the method for preventing the reentry of the hook, which is defined as the recursive execution of the hook, which is a code for executing the hooking during the dynamic API hooking.
  • a computer-readable recording medium having recorded thereon a program comprising: (a) a hook function that is called at the start of the dynamic API hooking by a source function or a sub-function executed during the execution of the hook; Checking a value of a state information flag set in function information corresponding to the function; And (b) determine that the call of the hook function is made by the original function if the status information flag value is not set, and set the value of the status information flag, and set the value of the hook if the status information flag value is set. It is determined that the call of the function was made during the execution of the hook to cause the program to execute the original execution request; has a program for executing the hook re-entry prevention method having a computer.
  • the hook layer can be safely isolated from the hook by functioning as an entry / exit layer independent of the hook layer.
  • hooking API it is possible to prevent hook reentry due to recall of original function of sub-function during execution of hook routine in hook layer.
  • by taking a structure that determines whether the hook is re-entry at the starting point of entering the hook layer in the application program it is possible to reduce the burden of writing a separate code for preventing hook re-entry when writing the program.
  • 1 and 2 are diagrams illustrating an API filtering process using a basic call structure and a hook, respectively.
  • FIG. 4 is a view showing the configuration of a preferred embodiment of the hook re-entry prevention device according to the invention
  • FIG. 5 is a diagram illustrating an API call branching process by the re-entry prevention module 330 according to the value of the status information flag.
  • FIG. 6 is a view illustrating a hook re-entry prevention process by the re-entry prevention module 330
  • FIG. 7 and 8 illustrate a call stack and a call stack according to the present invention in an API hooking scheme without considering hook reentry, respectively.
  • FIG. 9 is a flow chart showing the implementation of the preferred embodiment for the hook re-entry prevention method according to the invention.
  • FIG. 10 is a view showing a process performed when there is no thread generated inside the hook layer in the hook re-entry prevention apparatus and method according to the present invention.
  • FIG. 11 is a view showing a process performed when there is a thread generated inside the hook layer in the hook re-entry prevention device and method according to the present invention.
  • FIG. 12 is a view illustrating a hook reentry prevention process according to another embodiment of the apparatus and method for preventing the reentrant hook according to the present invention.
  • FIG. 4 is a view showing the configuration of a preferred embodiment of the hook re-entry prevention device according to the present invention.
  • a preferred embodiment 400 of a hook reentry prevention device includes a state information management module 410 and a reentry prevention module 420.
  • the state information management module 410 determines the call point of the hook function based on the value of the state information flag at the time of the call of the hook function driven according to the original function call of the application. At this time, there is a need to set the minimum unit that can identify whether the original function call is made from the inside of the hook layer or from the outside of the hook layer.
  • a thread is used as an identification unit, and the reason is as follows. All functions belong to one thread at the time of operation, and functions on a thread at any point in time exist in either the inside or outside of the hook layer, and occur when they have two states or do not correspond to both states at the same time. I never do that.
  • the value of the state information flag is set in the function information corresponding to the hook function and stored in the memory 330.
  • the value of the status information flag is global data variable that can be identified by thread, thread local storage (TLS) that enables information management by thread, static data variable that can manage information by thread, and information management by thread. Set to other possible data objects (e.g.
  • the state information management module 410 sets or releases the state information flag value in the memory 430 in which the corresponding value is stored, and the reentry prevention module 420 sets the state information from the memory 430 in which the corresponding value is stored. Read the flag value.
  • the status information flag should have at least Boolean form to identify the entry / exit information.
  • the status information management module 410 determines that the hook function is called from the outside of the hook layer and sets the value of the status information flag. On the contrary, if the value of the status information flag is set in the function information corresponding to the hook function, the status information management module 410 determines that the hook function is called from inside the hook layer. In addition, the status information management module 410 releases the value of the status information flag set in the function information corresponding to the hook function when the result value of the execution of the last lower function on the hook routine is returned to the system layer.
  • the reentry prevention module 420 selectively performs the execution of the hook routine and the detachment of the hook layer based on the value of the status information flag corresponding to the hook function recorded in the memory 430 when the hook function is recalled.
  • 5 illustrates an API call branching process by the re-entry prevention module 420 according to the value of the status information flag.
  • the reentry prevention module 420 includes a hook function, which is a starting point for entering the hook layer 520 from the application 510, and calls the original API of the lower layer from the hook layer 520. The location exiting to the layer 530 becomes a departure point. At this time, the entry point for the hook layer 520 coincides with the call point for the hook function.
  • the structure of calling the original function explicitly in the programming stage to implement the breakpoint is handled together at the entry point in the present invention due to the problem of being implemented for all modules as mentioned above.
  • the preferred embodiment 400 of the hook re-entry prevention device according to the present invention described above is provided with a plurality of components corresponding to the execution unit.
  • the state information management module 410 and the re-entry prevention module 420 may be integrated into one module.
  • the hook re-entry prevention device according to the present invention is located between the system layer and the hook layer to take a hook routine on the hook layer or return a value to the system layer depending on whether the status information flag is set.
  • FIG. 6 illustrates a hook reentry prevention process by the reentry prevention module 420.
  • the hook routine of the hook layer 630 itself ie, sub-functions H0, H1, H2, VC, etc.
  • the state information management module 410 sets the state information flag value of the function information corresponding to the hook function H0, and then when the hook function H0 is called as the sub-function VC calls the original function H again.
  • the re-entry prevention module 420 checks the status information flag value of the hook function H0 and returns the value to the system layer 620.
  • the system layer 620 returns a value to the sub function VC, so that the next sub function H3 is executed according to the planned hook routine after the VC is called.
  • 8 shows a call stack when performing the hook re-entry prevention procedure according to the present invention.
  • FIG. 9 is a flowchart illustrating a preferred embodiment of the hook re-entry prevention method according to the present invention.
  • the hook re-entry prevention apparatus 400 may function information corresponding to the hook function.
  • the value of the state information flag set in step S10 is checked (S910). If the status information flag value is not set, the hook re-entry prevention device 400 determines that the hook function is called from outside the hook layer, and sets the value of the status information flag (S920). In this case, sub-functions according to the hook routine are executed sequentially (S930).
  • the hook re-entry prevention device 400 determines that the hook function is called from inside the hook layer, and returns the value to the system layer 620 (S940). Therefore, in this case, the system layer 620 returns a value to the sub function VC, and then the next sub function is executed according to the hook routine (S930). Next, the hook re-entry prevention device 400 returns a result value to the system layer 620 when a result value by execution of the last lower function on the hook routine is input (S950).
  • the embodiment of the hook re-entry prevention device and method according to the present invention as described above, by setting the status information flag value of the function information corresponding to the hook function at the first entry into the hook layer from the outside, Accordingly, when the hook function is recalled from the outside of the hook layer, reentry can be prevented based on the state information flag value of the function information corresponding to the hook function.
  • the embodiment of the hook re-entry prevention device and method according to the present invention as described above has a problem that the re-entry prevention function is not performed when the hook function is recalled by a thread generated inside the hook layer. Therefore, in order to provide a reentry prevention function for a thread created inside the hook layer, a configuration for monitoring thread creation and setting an identification flag for the created thread should be additionally provided.
  • FIG. 10 is a diagram illustrating an execution process when a thread generated inside a hook layer does not exist in the hook reentry prevention apparatus and method according to the present invention.
  • the embodiment shown in FIG. 10 includes an additional log function for recording the operation status of the hook function in a file during execution of a hook function that monitors file input / output and encrypts generated file data.
  • the hook reentry prevention device 1020 may determine the value of the state information flag corresponding to the data write function that is the original function ( Or the value of the status information flag corresponding to the hook function) (S1005).
  • the data encryption function is called in accordance with the hook routine set in the hook layer 1030 (S1010), and the data is encrypted by the encryption function (S1015).
  • the hook reentry prevention device 1020 receives encrypted data from the hook layer 1030 (S1020), and transmits the encrypted data to the system layer 1040 (S1025). Subsequently, the system layer 1040 writes data to the memory (S1030).
  • the log data for the data write operation is generated by the log function according to the hook routine set in the hook layer 1030 (S1035), and the data write function for writing the generated log data into the memory is recalled (S1040). .
  • the hook function is also recalled by the recall of the data write function, and the hook reentry prevention device 1020 checks the value of the status information flag corresponding to the data write function (or the value of the status information flag corresponding to the hook function). (S1045). Since the value of the status information flag corresponding to the data write function (or the value of the status information flag corresponding to the hook function) has been set in step S1005, the hook re-entry prevention device 1020 blocks entering the hook routine and prevents the system from entering the hook routine.
  • the log data is transmitted to the layer 1040 (S1050). Subsequently, the system layer 840 writes log data to the memory (S1055). By re-entry by the log function by the above operation, the log data can be stored in plain text without being encrypted.
  • FIG. 11 is a diagram illustrating an execution process when a thread generated inside a hook layer is present in the apparatus and method for preventing a reentry of a hook according to the present invention.
  • the embodiment shown in FIG. 11 includes an additional log function for recording an operation state of a hook function in a file during execution of a hook function that monitors file input / output and encrypts generated file data, and the log function internally.
  • Worker Thread LogThread causes I / O inside the hook layer.
  • a worker thread logthread is generated in the hook layer 1130 (S1100).
  • the hook reentry prevention device 1120 may determine the value of the status information flag corresponding to the data write function that is the original function (or the hook function). The value of the corresponding status information flag) is set (S1110).
  • the encryption function of the data is called according to the hook routine set in the hook layer 1130 (S1115), and the data is encrypted by the encryption function (S1120).
  • the hook re-entry prevention device 1120 transmits the encrypted data to the system layer 1140 (S1130). Subsequently, the system layer 1140 writes data in the memory (S1135).
  • a log function called according to a hook routine set in the hook layer 1130 generates log data about a data write operation (S1140).
  • the log function transmits log data to a worker thread logthread in the hook layer 1130 (S1145).
  • the worker thread logthread reads a data write function to write log data generated in the hook layer 1130 to the memory (S1150).
  • the hook function is also recalled by the recall of the data write function, but the hook reentry prevention device 1120 is reentrant because the recall of the data write function (or hook function) is not entered from the outside of the hook layer 1130. It will not be recognized.
  • the hook re-entry prevention device 1120 calls an encryption function (S1155), and the called encryption function performs encryption on log data (S1160).
  • the hook reentry prevention device 1120 transmits the received encrypted log data to the system layer 1140 (S1170). Subsequently, the system layer 1140 writes data in the memory (S1175).
  • an embodiment of an apparatus and method for preventing a hook reentrancy according to the present invention is a hook when an original function (or a hook function) is recalled by a thread created inside the hook layer. There is a problem that does not prevent reentry. To solve this problem, an additional component for detecting thread creation is needed.
  • FIG. 12 is a view illustrating a hook reentry prevention process according to another embodiment of the apparatus and method for preventing the reentrant hook according to the present invention.
  • the apparatus for performing the hook re-entry prevention process shown in FIG. 12 includes a thread generation detecting module in addition to the components of the embodiment shown in FIG. 3.
  • the hook re-entry prevention device 1220 initializes the state of the hook layer (S1200), and creates a worker thread in the hook layer 1230 (S1205).
  • the hook reentry prevention device 1220 monitors the parent thread generating the worker thread and determines whether the state of the parent thread is inside or outside the hook layer 1230 (S1210).
  • the hook re-entry prevention device 1220 inherits the setting information of the parent thread to the hook layer setting information of the child thread generated when the state of the parent is inside the hook layer 1230 (S1215). This operation is performed by the thread generation detection module.
  • the thread generation detection module sets the state information of the parent thread to "entry" at the time the thread is created in the hook layer 1230 or traces the stack information of the parent thread at the time of thread creation so that a specific thread is connected to the hook layer ( It is detected whether it is generated inside or outside 1230.
  • the thread creation detection module must monitor thread creation APIs (eg, CreateThread, _beginthread, _beginthreadex, etc. on Win32 systems) to monitor the creation of threads.
  • the hook reentry prevention device 1220 may determine the value of the status information flag corresponding to the data write function that is the original function (or the hook function). The value of the corresponding status information flag) is set (S1225).
  • the data encryption function is called in accordance with the hook routine set in the hook layer 1230 (S1230), and the data is encrypted by the encryption function (S1235).
  • the hook reentry prevention device 1220 receives encrypted data from the hook layer 1230 (S1240), and transmits the encrypted data to the system layer 1240 (S1245). Subsequently, the system layer 1040 writes data to the memory (S1250).
  • a log function called according to a hook routine set in the hook layer 1230 generates log data for a data write operation (S1255).
  • the log function transmits log data to a worker thread logthread in the hook layer 1230 (S1260).
  • the worker thread logthread function calls a data write function to write log data generated in the hook layer 1230 to the memory (S1265).
  • the hook function is also recalled by the data write function recall, and the hook reentry prevention device 1220 checks the hook layer setting information of the worker thread logthread function (S1270).
  • the hook reentry prevention device 1220 blocks entry to the hook routine and transmits log data to the system layer 1240 (S1275). . Subsequently, the system layer 1240 writes log data in the memory (S1280). By re-entry by the log function by the above operation, the log data can be stored in plain text without being encrypted.
  • the invention can also be embodied as computer readable code on a computer readable recording medium.
  • the computer-readable recording medium includes all kinds of recording devices in which data that can be read by a computer system is stored. Examples of computer-readable recording media include ROM, RAM, CD-ROM, magnetic tape, floppy disk, optical data storage, and the like, and may also be implemented in the form of a carrier wave (for example, transmission over the Internet). Include.
  • the computer readable recording medium can also be distributed over network coupled computer systems so that the computer readable code is stored and executed in a distributed fashion.

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Software Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Computing Systems (AREA)
  • Quality & Reliability (AREA)
  • Mathematical Physics (AREA)
  • Debugging And Monitoring (AREA)
  • Stored Programmes (AREA)
  • Storage Device Security (AREA)

Abstract

훅 재진입 방지 장치 및 그 방법을 컴퓨터에서 실행시키기 위한 프로그램을 기록한 기록매체가 개시된다. 상태정보 관리 모듈은 훅 함수의 호출여부를 나타내는 상태정보 플래그를 설정하거나 해제한다. 재진입 방지 모듈은 훅 함수의 호출시 상태정보 플래그가 설정되어 있으면 훅 함수의 호출이 훅 레이어의 내부로부터 이루어진 것으로 판단하여 시스템 레이어로 값을 반환한다. 본 발명에 따르면, 훅 레이어와는 독립적인 진입/이탈 레이어로 기능함으로써 훅 레이어를 훅으로부터 안전하게 격리시킬 수 있게 되어 동적 API 후킹 시 훅 레이어 내의 훅 루틴의 수행과정에서 하위 함수의 원본 함수 재호출에 따른 훅 재진입을 방지할 있다.

Description

훅 재진입 방지 장치 및 그 방법을 컴퓨터에서 실행시키기 위한 프로그램을 기록한 기록매체
본 발명은 훅 재진입 방지 장치 및 그 방법을 컴퓨터에서 실행시키기 위한 프로그램을 기록한 기록매체에 관한 것으로, 보다 상세하게는, API 후킹시 함수의 호출 과정에서 훅의 재귀적인 진입을 방지하기 위한 장치 및 그 방법을 컴퓨터에서 실행시키기 위한 프로그램을 기록한 기록매체에 관한 것이다.
API 훅(hook)은 일반적인 API 호출 과정에 대해 특정한 조작을 통하여 다른 위치로 함수의 호출 흐름을 우회시키는 기법을 통칭한다. 도 1 및 도 2에는 기본적인 호출 구조와 훅에 의한 API 필터링 과정이 각각 도시되어 있다. 도 2에 도시된 바와 같이 훅 함수 B는 원본 함수 A에 의한 목표 함수 C의 호출 과정에 개입한다. 이러한 훅 기법을 완성하기 위해 도입되는 훅 레이어는 훅의 영향을 받지 않아야 한다.
도 3에 도시된 바와 같은 훅 레이어의 이상적인 구조는 다수 함수에 대해서 훅 및 대체/필터링 처리를 가능하도록 지원할 수 있어야 하며, 훅 레이어 자체는 훅의 영향을 받지 않아야 한다. 이러한 구조를 지원하기 위해 훅 레이어는 훅 대상 API를 사용하지 않거나 훅 대상 API 원본 함수를 호출할 수 있는 주소를 명확히 알고 있어 필요시 훅 API 또는 원본 API를 선택적으로 호출할 수 있어야 한다. 훅 레이어가 훅 대상 API를 사용하지 않는 경우에 훅 레이어 내부에서의 동작은 API 훅과 무관하게 된다. 그러나 훅 레이어가 훅 대상 API를 사용하지 않도록 하는 것은 용이하지 않다. 즉 훅 레이어가 훅 대상 API를 사용하지 않기 위해서는 현실적으로 훅 대상 API와 하위 원본 함수에 대한 런타임 바이너리(run time binary)의 직접적인 연관이 없는 경우에만 가능하다. 따라서 이 기종 OS 플랫폼에서의 프로그램 동작을 지원하는 에뮬레이터를 구현하거나, 훅 API를 에뮬레이션해주는 형태로의 구현이 필요하기 때문에 이러한 방식은 훅 레이어의 구현에 적합하지 않다.
상술한 이유로 인해 기존에는 훅 레이어가 훅 대상 API 원본 함수를 호출할 수 있는 주소를 관리하도록 구현하고 있으며, 이에 더해 보조적인 방법들을 추가적으로 사용하여 훅 레이어가 훅의 영향을 받지 않도록 하고 있다. 이때 훅 대상 API 원본 함수를 호출할 수 있는 주소를 관리하는 형태로 훅 레이어를 구현하는 프로그래밍 방식은 API 훅의 기법에 따라 차이가 있다. 먼저, IAT 훅 등 API 호출자가 호출하는 함수 주소를 수정하는 경우에 훅 레이어에 속하는 *.exe, *.dll 등 런타임 모듈 단위로 훅 예외를 실행하여 훅 레이어 및 하위 레이어에 속하는 모듈에 대해서는 훅을 하지 않는 방식이 있다. 이러한 방식에 있어서 요구되는 조건은 얼마나 정확하게 훅 레이어에 속한 런타임 모듈을 식별할 수 있는가이다. 다음으로 훅 레이어에 속하는 모든 런타임 모듈이 훅 대상 API의 원본 함수를 호출할 수 있는 주소를 알고, 프로그램 단계에서 적절한 주소를 호출하도록 하여 훅 레이어를 구성하는 방식이 있다. 이 방식에서는 훅 레이어에 속한 모든 런타임 모듈에서 훅이 이루어지고 있는 API의 정확한 목록과 주소를 알고 있어야 한다.
그러나 현실적으로 이상적인 훅 레이어를 구성하기 위해 필요한 조건을 총족시킬 수 있는 관리/프로그래밍의 작성이 용이하지 않다는 문제가 있다. 일예로 모듈별 예외 처리를 하는 경우에 기능 확장에 따라 훅 레이어에 속한 런타임 모듈이 고정적이지 않을 가능성이 높다. 이러한 이유로 훅 레이어의 형상 관리 및 업데이트 관리의 문제가 부각될 수 밖에 없다. 또한 OS의 형태, 주요 및 하위 버전 구성에 따른 예외 모듈의 정보가 추가될 여지가 있으므로, OS의 패치에 대한 검증이 매우 중요하게 된다. 한편 원본 API의 주소를 직접 호출하는 방식의 경우에 훅 레이어 내의 제3자 모듈과 같이 소스의 수정이 불가능한 모듈에 대한 지원이 곤란하다는 문제가 있으며, 특히 훅 대상 API의 개수가 많아질 수록 프로그램이 난해해진다는 문제가 있다.
이상과 같은 문제점을 해결하기 위해 기존에는 개발자의 판단에 따라 파일 이미지의 경로, 파일이미지의 패턴, 전자 서명의 발급자의 패턴 등을 이용하여 예외 처리를 하고 있다. 이 경우 정확한 목록 관리에 대한 부담은 줄어드나, 신규 모듈의 추가 및 제3자 모듈, 훅 레이어의 하부 레이어 모듈에 대한 목록 관리에 대한 부담은 여전히 남아 있게 된다.
본 발명이 이루고자 하는 기술적 과제는, 동적 API 후킹시 하위 함수의 원본 함수 재호출에 의한 훅 재진입을 방지할 수 있는 장치를 제공하는 데 있다.
본 발명이 이루고자 하는 다른 기술적 과제는, 동적 API 후킹시 하위 함수의 원본 함수 재호출에 의한 훅 재진입을 방지하기 위한 방법을 컴퓨터에서 실행시키기 위한 프로그램을 기록한 컴퓨터로 읽을 수 있는 기록매체를 제공하는 데 있다.
상기의 기술적 과제를 달성하기 위한, 본 발명에 따른 훅 재진입 방지 장치에 대한 바람직한 실시예는, 동적 API 후킹 시 후킹을 실행하기 위한 코드인 훅의 재귀적 실행으로 정의되는 훅의 재진입을 방지하기 위한 장치에 있어서, 상기 동적 API 후킹의 개시 시점에 호출되는 훅 함수의 호출여부를 나타내는 상태정보 플래그를 설정하거나 해제하는 상태정보 관리 모듈; 및 상기 훅 함수의 호출 시 상기 상태정보 플래그가 설정되어 있으면, 상기 훅 함수의 호출이 상기 훅의 실행과정에서 이루어진 것으로 판단하여 원래 실행이 요청된 프로그램을 실행하도록 하는 재진입 방지 모듈:을 구비한다.
상기의 다른 기술적 과제를 달성하기 위한, 본 발명에 따른 기록매체는, 동적 API 후킹 시 후킹을 실행하기 위한 코드인 훅의 재귀적 실행으로 정의되는 훅의 재진입을 방지하기 위한 방법을 컴퓨터에서 실행시키기 위한 프로그램을 기록한 컴퓨터로 읽을 수 있는 기록매체에 있어서, (a) 원본 함수 또는 상기 훅의 수행과정에서 실행되는 하위 함수에 의해 상기 동적 API 후킹의 개시 시점에 호출되는 훅 함수가 호출되면, 상기 훅 함수에 대응하는 함수 정보에 설정되어 있는 상태정보 플래그의 값을 확인하는 단계; 및 (b) 상기 상태정보 플래그 값이 설정되어 있지 않으면 상기 훅 함수의 호출이 상기 원본 함수에 의해 이루어진 것으로 판단하여 상기 상태정보 플래그의 값을 설정하고, 상기 상태정보 플래그 값이 설정되어 있으면 상기 훅 함수의 호출이 상기 훅의 실행과정에서 이루어진 것으로 판단하여 원래 실행이 요청된 프로그램을 실행하도록 하는 단계;를 가지는 훅 재진입 방지 방법을 컴퓨터에서 실행시키기 위한 프로그램을 보유한다.
본 발명에 따른 훅 재진입 방지 장치 및 그 방법을 컴퓨터에서 실행시키기 위한 프로그램을 기록한 기록매체에 의하면, 훅 레이어와는 독립적인 진입/이탈 레이어로 기능함으로써 훅 레이어를 훅으로부터 안전하게 격리시킬 수 있게 되어 동적 API 후킹 시 훅 레이어 내의 훅 루틴의 수행과정에서 하위 함수의 원본 함수 재호출에 따른 훅 재진입을 방지할 있다. 또한 응용 프로그램에서 훅 레이어로 진입하는 시작점에서 훅의 재진입 여부를 판단하는 구조를 취함으로써, 프로그램 작성시 훅 재진입 방지를 위한 별도의 코드를 작성하는 부담을 줄일 수 있다.
도 1 및 도 2는 각각 기본적인 호출 구조와 훅에 의한 API 필터링 과정을 도시한 도면,
도 3은 훅 레이어의 이상적인 구조를 도시한 도면,
도 4는 본 발명에 따른 훅 재진입 방지 장치에 대한 바람직한 실시예의 구성을 도시한 도면,
도 5는 상태정보 플래그의 값에 따른 재진입 방지 모듈(330)에 의한 API 호출 분기 과정을 도시한 도면,
도 6은 재진입 방지 모듈(330)에 의한 훅 재진입 방지 과정을 도시한 도면,
도 7 및 도 8은 각각 훅 재진입을 고려하지 않는 API 후킹 기법에서의 콜 스택 및 본 발명에 따른 콜 스택을 도시한 도면,
도 9는 본 발명에 따른 훅 재진입 방지 방법에 대한 바람직한 실시예의 수행과정을 도시한 흐름도,
도 10은 본 발명에 따른 훅 재진입 방지 장치 및 방법에서 훅 레이어 내부에서 생성되는 스레드가 존재하지 않는 경우의 수행과정을 도시한 도면,
도 11은 본 발명에 따른 훅 재진입 방지 장치 및 방법에서 훅 레이어 내부에서 생성되는 스레드가 존재하는 경우의 수행과정을 도시한 도면, 그리고,
도 12는 본 발명에 따른 훅 재진입 방지 장치 및 방법의 다른 실시예에 의한 훅 재진입 방지과정을 도시한 도면이다.
이하에서 첨부된 도면들을 참조하여 본 발명에 따른 훅 재진입 방지 장치 및 그 방법을 컴퓨터에서 실행시키기 위한 프로그램을 기록한 기록매체의 바람직한 실시예에 대해 상세하게 설명한다.
도 4는 본 발명에 따른 훅 재진입 방지 장치에 대한 바람직한 실시예의 구성을 도시한 도면이다.
도 4를 참조하면, 본 발명에 따른 훅 재진입 방지 장치에 대한 바람직한 실시예(400)는 상태정보 관리 모듈(410) 및 재진입 방지 모듈(420)을 구비한다.
상태정보 관리 모듈(410)은 어플리케이션의 원본 함수 호출에 따라 구동되는 훅 함수의 호출 시점에 상태정보 플래그의 값을 기초로 훅 함수의 호출 지점을 판단한다. 이때 원본 함수의 호출이 훅 레이어의 내부로부터 이루어진 것인지 아니면 훅 레이어의 외부로부터 이루어진 것인지를 식별할 수 있는 최소 단위를 설정할 필요성이 존재한다. 본 발명에서는 식별단위로 스레드(thread)를 사용하며, 그 이유는 다음과 같다. 모든 함수는 동작 시점에 하나의 스레드에 속하고, 임의 시점의 스레드 상의 함수는 훅 레이어의 내부와 외부 중 하나에 존재하며, 동시에 두 개의 상태를 가지거나 두 개의 상태에 모두 해당되지 않는 경우는 발생하지 않는다. 또한 훅 레이어의 내부에서 생성되는 스레드를 제외하면, 훅 레이어에 진입한 이후에 실행되는 모든 함수는 스레드 단위로 훅 레이어어 진입한 함수의 하위 함수이다. 이와 같은 상태정보 플래그의 값은 훅 함수에 대응하는 함수 정보에 설정되며, 메모리(330)에 저장된다. 이때 상태정보 플래그의 값은 스레드(thread) 별로 식별 가능한 전역 데이터 변수, 스레드 별로 정보관리가 가능한 스레드 지역 저장소(Thread Local Storage : TLS), 스레드 별로 정보관리가 가능한 정적 데이터 변수, 스레드 별로 정보관리가 가능한 기타 데이터 객체(예를 들면, Worker thread, Singleton obect 등) 등에 설정된다. 그리고 상태 정보 관리 모듈(410)은 해당 값이 저장되어 있는 메모리(430)에 상태정보 플래그 값을 설정하거나 해제하고, 재진입 방지 모듈(420)은 해당 값이 저장되어 있는 메모리(430)로부터 상태정보 플래그 값을 독출한다. 이를 위해 상태정보 플래그는 진입/퇴출 정보를 식별하기 위해 적어도 Boolean의 형태를 가져야 한다.
만약 훅 함수에 대응하는 함수 정보에 상태정보 플래그의 값이 설정되어 있지 않으면, 상태정보 관리 모듈(410)은 훅 함수가 훅 레이어의 외부로부터 호출된 것으로 판단하고 상태정보 플래그의 값을 설정한다. 이와 달리 훅 함수에 대응하는 함수 정보에 상태정보 플래그의 값이 설정되어 있으면, 상태정보 관리 모듈(410)은 훅 함수가 훅 레이어의 내부로부터 호출된 것으로 판단한다. 아울러 상태정보 관리 모듈(410)은 훅 루틴 상의 마지막 하위 함수의 실행에 의한 결과값이 시스템 레이어로 반환되면 훅 함수에 대응하는 함수 정보에 설정되어 있는 상태정보 플래그의 값을 해제한다.
재진입 방지 모듈(420)은 훅 함수의 재호출시 메모리(430)에 기록되어 있는 훅 함수에 대응하는 상태정보 플래그의 값을 기초로 훅 루틴의 실행과 훅 레이어의 이탈을 선택적으로 수행한다. 도 5에는 상태정보 플래그의 값에 따른 재진입 방지 모듈(420)에 의한 API 호출 분기 과정이 도시되어 있다. 도 5를 참조하면, 재진입 방지 모듈(420)은 어플리케이션(510)에서 훅 레이어(520)로 진입하는 시작점인 훅 함수가 진입점이며, 훅 레이어(520)에서 하위 레이어의 원본 API를 호출하여 시스템 레이어(530)로 나가는 위치가 이탈점이 된다. 이때 훅 레이어(520)에 대한 진입점은 훅 함수에 대한 호출점과 일치한다. 이탈점의 구현을 위해 프로그래밍 단계에서 명시적으로 원본 함수를 호출하는 구조는 앞서 언급한 바와 같이 모든 모듈에 대해서 구현되어야 하는 문제로 인해 본 발명에서는 진입점에서 함께 처리한다.
이상에서 설명한 본 발명에 따른 훅 재진입 방지 장치에 대한 바람직한 실시예(400)는 실행 단위에 대응하는 복수의 구성요소를 구비한다. 그러나 구현 형태에 따라 상태정보 관리 모듈(410) 및 재진입 방지 모듈(420)은 하나의 모듈로 통합될 수 있다. 이때 본 발명에 따른 훅 재진입 방지 장치는 시스템 레이어와 훅 레이어 사이에 위치하여 상태정보 플래그의 설정여부에 따라 훅 레이어 상의 훅 루틴을 수행하도록 하거나 시스템 레이어로 값을 반환하는 필터의 형태를 취한다.
도 6에는 재진입 방지 모듈(420)에 의한 훅 재진입 방지 과정이 도시되어 있다. 도 6을 참조하면, 호출자인 어플리케이션(610)이 시스템 레이어(620) 상의 원본 함수 H를 호출하면, 동적 API 후킹에 의해 훅 레이어(630) 자체의 훅 루틴(즉, 하위 함수인 H0, H1, H2, VC 등)이 수행된다. 이 과정에서 만약 하위 함수 VC가 원본 함수 H를 재차 호출하면, 훅 재진입을 고려하지 않는 API 후킹 기법에서는 도 7에 도시된 바와 같은 콜 스택에서 알 수 있듯이 H0, H1, H2, VC 등이 다시 실행되는 문제가 발생하게 된다. 이와 달리 본 발명에서는 상태정보 관리 모듈(410)이 훅 함수인 H0에 대응하는 함수 정보의 상태정보 플래그 값을 설정하고, 이후 하위 함수 VC가 원본 함수 H를 재차 호출함에 따라 훅 함수 H0가 호출되면 재진입 방지 모듈(420)은 훅 함수 H0의 상태정보 플래그 값을 확인한 후 시스템 레이어(620)로 값을 반환한다. 그리고 시스템 레이어(620)는 하위 함수 VC로 값을 반환하며, 따라서 VC가 호출된 이후에 계획되어 있는 훅 루틴에 따라 다음 하위 함수인 H3이 실행된다. 도 8에는 이와 같은 본 발명에 따른 훅 재진입 방지 절차의 수행시 콜 스택이 도시되어 있다.
도 9는 본 발명에 따른 훅 재진입 방지 방법에 대한 바람직한 실시예의 수행과정을 도시한 흐름도이다.
도 9를 참조하면, 어플리케이션(610)이 원본 함수를 호출함에 따라 구동되거나 하위 함수에 의한 호출에 의해 훅 함수가 호출되면(S900), 훅 재진입 방지 장치(400)는 훅 함수에 대응하는 함수 정보에 설정되어 있는 상태정보 플래그의 값을 확인한다(S910). 만약 상태정보 플래그 값이 설정되어 있지 않으면, 훅 재진입 방지 장치(400)는 훅 함수가 훅 레이어의 외부로부터 호출된 것으로 판단하고, 상태정보 플래그의 값을 설정한다(S920). 이 경우에는 훅 루틴에 따른 하위 함수들이 순차적으로 실행된다(S930). 이와 달리 상태정보 플래그 값이 설정되어 있으면, 훅 재진입 방지 장치(400)는 훅 함수가 훅 레이어의 내부로부터 호출된 것으로 판단하고, 시스템 레이어(620)로 값을 반환한다(S940). 따라서 이 경우에는 시스템 레이어(620)가 하위 함수 VC로 값을 반환하게 되며, 이어서 훅 루틴에 따라 다음 하위 함수가 실행된다(S930). 다음으로 훅 재진입 방지 장치(400)는 훅 루틴 상의 마지막 하위 함수의 실행에 의한 결과값이 입력되면(S950), 시스템 레이어(620)로 결과값을 반환한다(S960).
한편 상술한 바와 같은 본 발명에 따른 훅 재진입 방지 장치 및 방법에 대한 실시예는 외부로부터의 훅 레이어로의 최초 진입시 훅 함수에 대응하는 함수 정보의 상태정보 플래그값을 설정함으로써, 훅 루틴의 수행에 따라 훅 레이어의 외부로부터 훅 함수가 재호출되는 경우에 훅 함수에 대응하는 함수 정보의 상태정보 플래그값을 기초로 재진입을 방지할 수 있다. 그러나 상술한 바와 같은 본 발명에 따른 훅 재진입 방지 장치 및 방법에 대한 실시예는 훅 레이어 내부에서 생성된 스레드에 의해 훅 함수가 재호출되면 재진입방지 기능이 수행되지 않는 문제가 있다. 따라서 훅 레이어의 내부에서 생성되는 스레드에 대해서도 재진입 방지 기능을 제공하기 위해서는 스레드의 생성을 감시하고, 생성된 스레드에 대한 식별 플래그를 설정하는 구성을 추가적으로 구비하여야 한다.
도 10은 본 발명에 따른 훅 재진입 방지 장치 및 방법에서 훅 레이어 내부에서 생성되는 스레드가 존재하지 않는 경우의 수행과정을 도시한 도면이다. 도 10에 도시된 실시예는 파일 입출력을 감시하고 생성되는 파일 데이터를 암호화하는 훅 함수의 실행과정에서 훅 함수의 동작상황을 파일에 기록하기 위한 부가적인 로그 함수를 포함한다.
도 10을 참조하면, 어플리케이션(1010)이 데이터 쓰기 함수를 호출함에 따라 훅 함수가 호출되면(S1000), 훅 재진입 방지 장치(1020)는 원본 함수인 데이터 쓰기 함수에 대응하는 상태정보 플래그의 값(또는 훅 함수에 대응하는 상태정보 플래그의 값)을 설정한다(S1005). 다음으로 훅 레이어(1030) 내에 설정된 훅 루틴에 따라 데이터의 암호화 함수가 호출되고(S1010), 암호화 함수에 의해 데이터가 암호화된다(S1015). 그리고 훅 재진입 방지 장치(1020)는 훅 레이어(1030)로부터 암호화된 데이터를 수신하고(S1020), 암호화된 데이터를 시스템 레이어(1040)로 전달한다(S1025). 이어서 시스템 레이어(1040)는 메모리에 데이터를 기록한다(S1030). 한편 훅 레이어(1030) 내에 설정된 훅 루틴에 따라 로그 함수에 의해 데이터의 쓰기 동작에 대한 로그 데이터가 생성되고(S1035), 생성된 로그 데이터를 메모리에 쓰기 위한 데이터 쓰기 함수가 재호출된다(S1040). 이러한 데이터 쓰기 함수의 재호출에 의해 훅 함수 역시 재호출되며, 훅 재진입 방지 장치(1020)는 데이터 쓰기 함수에 대응하는 상태정보 플래그의 값(또는 훅 함수에 대응하는 상태정보 플래그의 값)을 확인한다(S1045). 앞서 S1005단계에서 데이터 쓰기 함수에 대응하는 상태정보 플래그의 값(또는 훅 함수에 대응하는 상태정보 플래그의 값)이 설정된 바 있으므로, 훅 재진입 방지 장치(1020)는 훅 루틴으로 진입하는 것을 차단하고 시스템 레이어(1040)로 로그 데이터를 전달한다(S1050). 이어서 시스템 레이어(840)는 메모리에 로그 데이터를 기록한다(S1055). 이상과 같은 동작에 의해 로그 함수에 의한 재진입이 방지됨으로써, 로그 데이터가 암호화되지 않고 평문으로 저장될 수 있다.
도 11은 본 발명에 따른 훅 재진입 방지 장치 및 방법에서 훅 레이어 내부에서 생성되는 스레드가 존재하는 경우의 수행과정을 도시한 도면이다. 도 11에 도시된 실시예는 파일 입출력을 감시하고 생성되는 파일 데이터를 암호화하는 훅 함수의 실행과정에서 훅 함수의 동작상황을 파일에 기록하기 위한 부가적인 로그 함수를 포함하며, 로그 함수는 내부적으로 Worker Thread LogThread에 로그 데이터를 전송한다. 이때 Worker Thread LogThread는 훅 레이어 내부에서의 입출력을 야기한다.
도 11을 참조하면, 먼저 훅 레이어(1130) 내부에서 Worker Thread LogThread가 생성된다(S1100). 다음으로 어플리케이션(1110)이 데이터 쓰기 함수를 호출함에 따라 훅 함수가 호출되면(S1105), 훅 재진입 방지 장치(1120)는 원본 함수인 데이터 쓰기 함수에 대응하는 상태정보 플래그의 값(또는 훅 함수에 대응하는 상태정보 플래그의 값)을 설정한다(S1110). 다음으로 훅 레이어(1130) 내에 설정된 훅 루틴에 따라 데이터의 암호화 함수가 호출되고(S1115), 암호화 함수에 의해 데이터가 암호화된다(S1120). 그리고 훅 레이어(1130)로부터 암호화된 데이터가 수신되면(S1125), 훅 재진입 방지 장치(1120)는 암호화된 데이터를 시스템 레이어(1140)로 전달한다(S1130). 이어서 시스템 레이어(1140)는 메모리에 데이터를 기록한다(S1135).
한편 훅 레이어(1130) 내에 설정된 훅 루틴에 따라 호출된 로그 함수가 데이터의 쓰기 동작에 대한 로그 데이터를 생성한다(S1140). 그리고 로그 함수는 훅 레이어(1130) 내에서 Worker Thread LogThread에 로그 데이터를 전송한다(S1145). 다음으로 Worker Thread LogThread는 훅 레이어(1130) 내에서 생성된 로그 데이터를 메모리에 쓰기 위해 데이터 쓰기 함수를 호출한다(S1150). 이러한 데이터 쓰기 함수의 재호출에 의해 훅 함수 역시 재호출되나, 훅 재진입 방지 장치(1120)는 데이터 쓰기 함수(또는 훅 함수)의 재호출이 훅 레이어(1130)의 외부로부터 진입이 아니기 때문에 재진입으로 인식하지 못하게 된다. 따라서 훅 재진입 방지 장치(1120)는 암호화 함수를 호출하며(S1155), 호출된 암호화 함수는 로그 데이터에 대한 암호화를 수행한다(S1160). 그리고 훅 레이어(1130)로부터 암호화된 로그 데이터를 수신하면(S1165), 훅 재진입 방지 장치(1120)는 수신된 암호화된 로그 데이터를 시스템 레이어(1140)로 전달한다(S1170). 이어서 시스템 레이어(1140)는 메모리에 데이터를 기록한다(S1175).
도 10 및 도 11을 참조하여 설명한 바와 같이 본 발명에 따른 훅 재진입 방지 장치 및 방법에 대한 실시예는 훅 레이어의 내부에서 생성된 스레드에 의해 원본 함수(또는 훅 함수)가 재호출되는 경우에 훅 재진입을 방지하지 못하는 문제가 있다. 이와 같은 문제를 해결하기 위해서는 스레드의 생성을 감지하는 구성요소가 추가적으로 필요하다.
도 12는 본 발명에 따른 훅 재진입 방지 장치 및 방법의 다른 실시예에 의한 훅 재진입 방지과정을 도시한 도면이다. 도 12에 도시된 훅 재진입 방지과정을 수행하는 장치는 도 3에 도시된 실시예의 구성요소에 더해 스레드 생성 감지 모듈을 구비한다.
도 12를 참조하면, 먼저 훅 재진입 방지 장치(1220)는 훅 레이어의 상태를 초기화하고(S1200), 훅 레이어(1230) 내부에서 Worker Thread가 생성된다(S1205). 그리고 훅 재진입 방지 장치(1220)는 Worker Thread를 생성하는 Parent Thread를 감시하여 Parent Thread의 상태가 훅 레이어(1230)의 내부인지 아니면 외부인지를 파악한다(S1210). 그리고 훅 재진입 방지 장치(1220)는 Parent Thead의 상태가 훅 레이어(1230)의 내부인 경우에 생성되는 Child Thread의 훅 레이어 설정정보에 Parent Thread의 설정정보를 상속한다(S1215). 이와 같은 동작은 스레드 생성 감지 모듈에 의해 수행된다. 이때 스레드 생성 감지 모듈은 훅 레이어(1230) 내부에서 스레드가 생성되는 시점에 Parent Thread의 상태정보를 "진입"으로 설정하거나 스레드의 생성 시점에 Parent Thread의 스택정보를 추적하여 특정한 스레드가 훅 레이어(1230)의 내부에서 생성되었는지 아니면 외부에서 생성되었는지를 감지한다. 또한 스레드 생성 감지 모듈은 스레드의 생성을 파악하기 위해 스레드 생성 API(예를 들어, Win32 시스템에서는 CreateThread, _beginthread, _beginthreadex 등)를 감시하여야 하며, 나아가 모든 스레드의 생성여부를 감시할 수 있어야 한다.
다음으로 어플리케이션(1210)이 데이터 쓰기 함수를 호출함에 따라 훅 함수가 호출되면(S1220), 훅 재진입 방지 장치(1220)는 원본 함수인 데이터 쓰기 함수에 대응하는 상태정보 플래그의 값(또는 훅 함수에 대응하는 상태정보 플래그의 값)을 설정한다(S1225). 다음으로 훅 레이어(1230) 내에 설정된 훅 루틴에 따라 데이터의 암호화 함수가 호출되고(S1230), 암호화 함수에 의해 데이터가 암호화된다(S1235). 그리고 훅 재진입 방지 장치(1220)는 훅 레이어(1230)로부터 암호화된 데이터를 수신하고(S1240), 암호화된 데이터를 시스템 레이어(1240)로 전달한다(S1245). 이어서 시스템 레이어(1040)는 메모리에 데이터를 기록한다(S1250).
한편 훅 레이어(1230) 내에 설정된 훅 루틴에 따라 호출된 로그 함수가 데이터의 쓰기 동작에 대한 로그 데이터를 생성한다(S1255). 그리고 로그 함수는 훅 레이어(1230) 내에서 Worker Thread LogThread에 로그 데이터를 전송한다(S1260). 다음으로 Worker Thread LogThread 함수는 훅 레이어(1230) 내에서 생성된 로그 데이터를 메모리에 쓰기 위해 데이터 쓰기 함수를 호출한다(S1265). 이때 데이터 쓰기 함수의 재호출에 의해 훅 함수 역시 재호출되며, 훅 재진입 방지 장치(1220)는 Worker Thread LogThread 함수의 훅 레이어 설정정보를 확인한다(S1270). 앞서 S1215단계에서 Worker Thread LogThread 함수의 설정정보가 "진입"으로 설정된 바 있으므로, 훅 재진입 방지 장치(1220)는 훅 루틴으로 진입하는 것을 차단하고 시스템 레이어(1240)로 로그 데이터를 전달한다(S1275). 이어서 시스템 레이어(1240)는 메모리에 로그 데이터를 기록한다(S1280). 이상과 같은 동작에 의해 로그 함수에 의한 재진입이 방지됨으로써, 로그 데이터가 암호화되지 않고 평문으로 저장될 수 있다.
본 발명은 또한 컴퓨터로 읽을 수 있는 기록매체에 컴퓨터가 읽을 수 있는 코드로서 구현하는 것이 가능하다. 컴퓨터가 읽을 수 있는 기록매체는 컴퓨터 시스템에 의하여 읽혀질 수 있는 데이터가 저장되는 모든 종류의 기록장치를 포함한다. 컴퓨터가 읽을 수 있는 기록매체의 예로는 ROM, RAM, CD-ROM, 자기 테이프, 플로피디스크, 광데이터 저장장치 등이 있으며, 또한 캐리어 웨이브(예를 들어 인터넷을 통한 전송)의 형태로 구현되는 것도 포함한다. 또한 컴퓨터가 읽을 수 있는 기록매체는 네트워크로 연결된 컴퓨터 시스템에 분산되어 분산방식으로 컴퓨터가 읽을 수 있는 코드가 저장되고 실행될 수 있다.
이상에서 본 발명의 바람직한 실시예에 대해 도시하고 설명하였으나, 본 발명은 상술한 특정의 바람직한 실시예에 한정되지 아니하며, 청구범위에서 청구하는 본 발명의 요지를 벗어남이 없이 당해 발명이 속하는 기술분야에서 통상의 지식을 가진 자라면 누구든지 다양한 변형 실시가 가능한 것은 물론이고, 그와 같은 변경은 청구범위 기재의 범위 내에 있게 된다.

Claims (6)

  1. 동적 API 후킹 시 후킹을 실행하기 위한 코드인 훅의 재귀적 실행으로 정의되는 훅의 재진입을 방지하기 위한 장치에 있어서,
    상기 동적 API 후킹의 개시 시점에 호출되는 훅 함수의 호출여부를 나타내는 상태정보 플래그를 설정하거나 해제하는 상태정보 관리 모듈; 및
    상기 훅 함수의 호출 시 상기 상태정보 플래그가 설정되어 있으면, 상기 훅 함수의 호출이 상기 훅의 실행과정에서 이루어진 것으로 판단하여 원래 실행이 요청된 프로그램을 실행하도록 하는 재진입 방지 모듈:을 포함하는 것을 특징으로 하는 훅 재진입 방지 장치.
  2. 제 1항에 있어서,
    상기 상태정보 플래그는 상기 훅 함수에 대응하여 스레드 별로 식별 가능한 전역 데이터 변수, 스레드 지역 저장소, 정적 데이터 변수 또는 데이터 객체에 기록되는 것을 특징으로 하는 훅 재진입 방지 장치.
  3. 제 1항 또는 제 2항에 있어서,
    상기 훅의 실행과정에서 스레드가 생성되는 시점에 생성된 스레드의 상태정보를 설정하는 스레드 생성 감지 모듈을 더 포함하고,
    상기 재진입 방지 모듈은 상기 스레드 생성 감지 모듈에 의해 상태정보가 설정되어 있는 스레드에 의해 상기 훅 함수가 호출되면, 상기 훅 함수의 호출이 상기 훅의 실행과정에서 이루어진 것으로 판단하는 것을 특징으로 하는 훅 재진입 방지 장치.
  4. 동적 API 후킹 시 후킹을 실행하기 위한 코드인 훅의 재귀적 실행으로 정의되는 훅의 재진입을 방지하기 위한 방법을 컴퓨터에서 실행시키기 위한 프로그램을 기록한 컴퓨터로 읽을 수 있는 기록매체에 있어서,
    (a) 원본 함수 또는 상기 훅의 수행과정에서 실행되는 하위 함수에 의해 상기 동적 API 후킹의 개시 시점에 호출되는 훅 함수가 호출되면, 상기 훅 함수에 대응하는 함수 정보에 설정되어 있는 상태정보 플래그의 값을 확인하는 단계; 및
    (b) 상기 상태정보 플래그 값이 설정되어 있지 않으면 상기 훅 함수의 호출이 상기 원본 함수에 의해 이루어진 것으로 판단하여 상기 상태정보 플래그의 값을 설정하고, 상기 상태정보 플래그 값이 설정되어 있으면 상기 훅 함수의 호출이 상기 훅의 실행과정에서 이루어진 것으로 판단하여 원래 실행이 요청된 프로그램을 실행하도록 하는 단계;를 포함하는 것을 특징으로 하는 기록매체.
  5. 제 4항에 있어서,
    상기 상태정보 플래그는 상기 훅 함수에 대응하여 스레드 별로 식별 가능한 전역 데이터 변수, 스레드 지역 저장소, 정적 데이터 변수 또는 데이터 객체에 기록되는 것을 특징으로 하는 기록매체.
  6. 제 4항 또는 제 5항에 있어서,
    상기 훅의 실행과정에서 스레드의 상태정보를 설정하는 단계를 더 포함하고,
    상기 (b)단계에서, 상기 상태정보가 설정되어 있는 스레드에 의해 상기 훅 함수가 호출되면, 상기 훅 함수의 호출이 상기 훅의 실행과정에서 이루어진 것으로 판단하는 것을 특징으로 하는 기록매체.
PCT/KR2011/006062 2010-08-20 2011-08-18 훅 재진입 방지 장치 및 그 방법을 컴퓨터에서 실행시키기 위한 프로그램을 기록한 기록매체 WO2012023809A2 (ko)

Priority Applications (3)

Application Number Priority Date Filing Date Title
US13/818,054 US9098356B2 (en) 2010-08-20 2011-08-18 Hook re-entry prevention device and recording medium, in which program for executing method thereof in computer is recorded thereon
JP2013524794A JP5579934B2 (ja) 2010-08-20 2011-08-18 フック再進入防止装置及びその方法をコンピュータで実行させるためのプログラムを記録した記録媒体
EP20110818409 EP2608021A4 (en) 2010-08-20 2011-08-18 DEVICE FOR PREVENTING A RECONNECTING AND RECORDING MEDIUM WITH A PROGRAM RECORDED THEREFOR FOR PERFORMING A CORRESPONDING METHOD ON A COMPUTER

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
KR20100080926A KR101052586B1 (ko) 2010-08-20 2010-08-20 훅 재진입 방지 장치 및 그 방법을 컴퓨터에서 실행시키기 위한 프로그램을 기록한 기록매체
KR10-2010-0080926 2010-08-20

Publications (2)

Publication Number Publication Date
WO2012023809A2 true WO2012023809A2 (ko) 2012-02-23
WO2012023809A3 WO2012023809A3 (ko) 2012-05-10

Family

ID=44924192

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/KR2011/006062 WO2012023809A2 (ko) 2010-08-20 2011-08-18 훅 재진입 방지 장치 및 그 방법을 컴퓨터에서 실행시키기 위한 프로그램을 기록한 기록매체

Country Status (5)

Country Link
US (1) US9098356B2 (ko)
EP (1) EP2608021A4 (ko)
JP (1) JP5579934B2 (ko)
KR (1) KR101052586B1 (ko)
WO (1) WO2012023809A2 (ko)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20220363277A1 (en) * 2021-05-13 2022-11-17 Dana Belgium N.V. Driveline component control and fault diagnostics

Family Cites Families (17)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US9048A (en) * 1852-06-22 Heat-radiator
JPH06332720A (ja) * 1993-05-20 1994-12-02 Hitachi Ltd シグナル制御方法
US6148325A (en) * 1994-06-30 2000-11-14 Microsoft Corporation Method and system for protecting shared code and data in a multitasking operating system
US5974549A (en) * 1997-03-27 1999-10-26 Soliton Ltd. Security monitor
IL132916A (en) * 1999-11-14 2004-02-08 Mcafee Inc Method and system for intercepting an application program interface
GB0011020D0 (en) 2000-05-09 2000-06-28 Ibm Intercepting system API calls
US6874149B1 (en) * 2000-06-28 2005-03-29 Microsoft Corporation Hooking of replacement and augmented API functions
US7426737B2 (en) * 2004-01-26 2008-09-16 Lucent Technologies Inc. Method and apparatus for operating an open API network having a proxy
US7607173B1 (en) * 2005-10-31 2009-10-20 Symantec Corporation Method and apparatus for preventing rootkit installation
US20070261044A1 (en) 2006-05-04 2007-11-08 Jonathan Clark Chained Hook Function Serving Multiple Versions Of Identically Named Dynamically Loaded Libraries
US20080016339A1 (en) 2006-06-29 2008-01-17 Jayant Shukla Application Sandbox to Detect, Remove, and Prevent Malware
US20080059676A1 (en) * 2006-08-31 2008-03-06 Charles Jens Archer Efficient deferred interrupt handling in a parallel computing environment
KR100843701B1 (ko) * 2006-11-07 2008-07-04 소프트캠프(주) 콜 스택에 기록된 정보를 이용한 에이피아이 확인방법
US8793662B2 (en) 2008-03-25 2014-07-29 Microsoft Corporation Runtime code hooking for print driver and functionality testing
US8307246B2 (en) 2008-10-29 2012-11-06 Aternity Information Systems Ltd. Real time monitoring of computer for determining speed of various processes
JP5404030B2 (ja) * 2008-12-26 2014-01-29 デジタルア−ツ株式会社 電子ファイル送信方法
CA2790838A1 (en) 2010-04-21 2011-10-27 Nestec S.A. Coffee extract comprising a multivalent ion

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
None
See also references of EP2608021A4

Also Published As

Publication number Publication date
US20130160033A1 (en) 2013-06-20
US9098356B2 (en) 2015-08-04
JP5579934B2 (ja) 2014-08-27
KR101052586B1 (ko) 2011-07-29
EP2608021A2 (en) 2013-06-26
JP2013534346A (ja) 2013-09-02
WO2012023809A3 (ko) 2012-05-10
EP2608021A4 (en) 2014-03-19

Similar Documents

Publication Publication Date Title
US10387649B2 (en) Detecting malware when executing in a system
US10083294B2 (en) Systems and methods for detecting return-oriented programming (ROP) exploits
US10331881B2 (en) User-mode component injection techniques
JP6706273B2 (ja) インタープリタ仮想マシンを用いた挙動マルウェア検出
JP2018041438A (ja) ファイル中の悪意のあるコードの検出システム及び方法
US20150020198A1 (en) Methods of detection of software exploitation
CN111858004A (zh) 基于tee扩展的计算机安全世界实时应用动态加载方法及系统
WO2011159005A1 (ko) 응용 모듈 삽입 장치, 응용 모듈 삽입 기능을 구비한 컴퓨팅 장치 및 응용 모듈 삽입 방법을 실행하기 위한 프로그램을 기록한 기록매체
JP2017033552A (ja) ユーザモードコンポーネントインジェクションとアトミックなフック
WO2012023809A2 (ko) 훅 재진입 방지 장치 및 그 방법을 컴퓨터에서 실행시키기 위한 프로그램을 기록한 기록매체
EP3223185B1 (en) System and method dynamic code patching techniques from user-mode process address space
KR20110057297A (ko) 악성 봇 동적 분석 시스템 및 방법
WO2019235664A1 (ko) 프로그램 보호를 위한 디버거 차단 방법 및 시스템
US20220398317A1 (en) Information processing apparatus, information processing method, and recording medium
US9619306B2 (en) Information processing device, control method thereof, and recording medium
CN113157299B (zh) 一种资源配置方法及系统
US20220398120A1 (en) Information processing apparatus, information processing method, and recording medium
WO2019231000A1 (ko) 프로그램 보호를 위한 자바 디버거 차단 방법 및 시스템
US11709937B2 (en) Inactivating basic blocks of program code to prevent code reuse attacks
WO2019235663A1 (ko) 네이티브 라이브러리를 보호하는 방법 및 시스템
CN114168944A (zh) 一种处理读写操作的方法和系统
CN117556423A (zh) 业务资源管理方法、设备及可读存储介质
CN116108433A (zh) 基于Linux的进程监视防护方法、系统、设备及储存介质
CN116501529A (zh) 故障处理方法、装置、存储介质及电子设备

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: 11818409

Country of ref document: EP

Kind code of ref document: A2

ENP Entry into the national phase

Ref document number: 2013524794

Country of ref document: JP

Kind code of ref document: A

NENP Non-entry into the national phase

Ref country code: DE

WWE Wipo information: entry into national phase

Ref document number: 13818054

Country of ref document: US

REEP Request for entry into the european phase

Ref document number: 2011818409

Country of ref document: EP

WWE Wipo information: entry into national phase

Ref document number: 2011818409

Country of ref document: EP