[go: up one dir, main page]

JP4927231B1 - Program, information device, and unauthorized access detection method - Google Patents

Program, information device, and unauthorized access detection method Download PDF

Info

Publication number
JP4927231B1
JP4927231B1 JP2011281931A JP2011281931A JP4927231B1 JP 4927231 B1 JP4927231 B1 JP 4927231B1 JP 2011281931 A JP2011281931 A JP 2011281931A JP 2011281931 A JP2011281931 A JP 2011281931A JP 4927231 B1 JP4927231 B1 JP 4927231B1
Authority
JP
Japan
Prior art keywords
function
address
address range
unauthorized access
return
Prior art date
Legal status (The legal status 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 status listed.)
Active
Application number
JP2011281931A
Other languages
Japanese (ja)
Other versions
JP2013131157A (en
Inventor
哲也 永田
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Fourteenforty Research Institute
Original Assignee
Fourteenforty Research Institute
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 Fourteenforty Research Institute filed Critical Fourteenforty Research Institute
Priority to JP2011281931A priority Critical patent/JP4927231B1/en
Application granted granted Critical
Publication of JP4927231B1 publication Critical patent/JP4927231B1/en
Publication of JP2013131157A publication Critical patent/JP2013131157A/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Landscapes

  • Storage Device Security (AREA)

Abstract

【課題】不正アクセスの検出精度を高める。
【解決手段】所定の関数の呼び出しを検出し、関数の検出が行われた際に、スタック領域に格納されているリターンアドレスを取得し、検出された関数が、メモリ上の指定されたアドレス範囲の領域に実行可能属性を付与する関数であり、リターンアドレスの指し示す先の1つ前の命令が関数の呼び出し命令でない場合に、当該アドレス範囲をアドレス範囲記憶部に記憶し、検出された関数のリターンアドレスがアドレス範囲記憶部に記憶されているアドレス範囲内である場合に、不正アクセスが行われていると判定する。
【選択図】図1
An object of the present invention is to increase detection accuracy of unauthorized access.
When a call to a predetermined function is detected and a function is detected, a return address stored in a stack area is obtained, and the detected function is in a specified address range on a memory. If the previous instruction pointed to by the return address is not a function call instruction, the address range is stored in the address range storage unit, and the detected function When the return address is within the address range stored in the address range storage unit, it is determined that unauthorized access has been performed.
[Selection] Figure 1

Description

本発明は、プログラム、情報機器、及び不正アクセス検出方法に関する。   The present invention relates to a program, an information device, and an unauthorized access detection method.

近年、不正なプログラムコードがコンピュータにおいて実行されることにより、個人情報や機密情報が流出する事件が後をたたず、社会問題となっている。このような不正なプログラムコードの実行、すなわち、不正アクセスを行うためのプログラム等は、マルウェアとも呼ばれ、ソフトウェアの脆弱性を利用するものが多い。例えば、ソフトウェアの脆弱性としては、バッファオーバーフローが良く知られている。バッファオーバーフローとは、例えば、プログラムで用いられる変数に、当該変数のために確保された領域より大きいサイズの文字列等が入力されることにより、他の領域に文字列等が書き込まれてしまうことである。   In recent years, cases in which personal information and confidential information are leaked due to execution of illegal program codes in a computer have become a social problem. Such execution of unauthorized program code, that is, a program for performing unauthorized access is also called malware, and often uses software vulnerabilities. For example, buffer overflow is well known as a software vulnerability. For example, buffer overflow means that a character string or the like that is larger than the area reserved for the variable is input to a variable used in the program, and the character string or the like is written to another area. It is.

プログラムで関数が呼び出される際には、当該関数の呼び出し元へと戻ることを可能とするために、戻り先のアドレス(リターンアドレス)がスタックへと格納される。マルウェアは、例えば、関数の脆弱性を利用することにより、関数の実行時にバッファオーバーフローを発生させ、リターンアドレスを不正なアドレスへと書き換える。この不正なアドレスは、例えば、プログラムコードが格納されるメモリ領域ではなく、データ領域を指しており、このデータ領域には不正なプログラムコードが格納されている。また、不正なアドレスは、例えば、不正アクセスのために使用される別の関数の開始アドレスである場合もある。この状態で関数の実行が終了すると、プログラムの実行は、当該関数の呼び出し元ではなく、不正なアドレスへと遷移することとなる。これにより、この不正なアドレスに格納されているプログラムコードが実行され、不正アクセスが行われることとなる。   When a function is called by a program, a return address (return address) is stored in the stack so that the function can be returned to the caller of the function. For example, by using the vulnerability of the function, the malware causes a buffer overflow when the function is executed, and rewrites the return address to an invalid address. The illegal address indicates, for example, a data area, not a memory area where the program code is stored, and the illegal program code is stored in the data area. The illegal address may be, for example, the start address of another function used for illegal access. When the execution of the function is completed in this state, the execution of the program is not the caller of the function, but transits to an illegal address. As a result, the program code stored at the unauthorized address is executed and unauthorized access is performed.

このような不正アクセスを検出するための様々な手法が提案されている。例えば、特許文献1に開示されている手法では、プログラムコードは、プログラムコードのためのメモリ領域、または、書き込み不可能な属性となっているデータ領域の何れかに格納されるという特性が利用されている。具体的には、例えば、リターンアドレスの指し示す先が、プログラムコードを格納するためのメモリ領域でなければ不正アクセスであると判断される。また、例えば、リターンアドレスの指し示す先の属性が、書込み可能となっていれば不正アクセスであると判断される。   Various methods for detecting such unauthorized access have been proposed. For example, the technique disclosed in Patent Document 1 uses the characteristic that the program code is stored in either a memory area for the program code or a data area having a non-writable attribute. ing. Specifically, for example, if the destination indicated by the return address is not a memory area for storing the program code, it is determined that the access is unauthorized. Further, for example, if the destination attribute indicated by the return address is writable, it is determined that the access is unauthorized.

また、例えば、特許文献2には、Return−to−LibcやROP(Return Oriented Programming)と呼ばれる攻撃手法による不正アクセスを検出するための手法が開示されている。例えば、リターンアドレスの指し示す先が関数の開始アドレスであるか、リターンアドレスの指し示す先の1つ前の命令が関数の呼び出し命令(call命令)でなければ不正アクセスであると判断される。   Further, for example, Patent Document 2 discloses a technique for detecting unauthorized access by an attack technique called Return-to-Libc or ROP (Return Oriented Programming). For example, if the destination indicated by the return address is the start address of the function, or if the instruction immediately before the destination indicated by the return address is a function call instruction (call instruction), it is determined that the access is illegal.

特開2009−199529号公報JP 2009-199529 A 特開2010−257275号公報JP 2010-257275 A

しかしながら、例えば、正常なプログラムの中には、メモリ上のデータ領域に別のプログラムコードを展開したうえで、当該データ領域に実行属性を付与し、当該プログラムコードを実行するものがある。この場合、当該データ領域には実行属性とともに書き込み属性も付与されているため、特許文献1に開示されている手法を適用すると、不正アクセスであると誤って検出されることとなる。また、正常なプログラムの中には、call命令を用いずに関数呼び出しを行うものもある。そのため、このようなプログラムに特許文献2に開示されている手法を適用すると、不正アクセスであると誤って検出されることとなる。
そこで、本発明は、不正アクセスの検出精度を高めることを目的とする。
However, for example, in some normal programs, another program code is developed in a data area on a memory, an execution attribute is given to the data area, and the program code is executed. In this case, since the write attribute is given to the data area in addition to the execution attribute, if the technique disclosed in Patent Document 1 is applied, it is erroneously detected as unauthorized access. Some normal programs make function calls without using the call instruction. Therefore, if the technique disclosed in Patent Document 2 is applied to such a program, it is erroneously detected as unauthorized access.
Therefore, an object of the present invention is to improve the detection accuracy of unauthorized access.

本発明の一側面に係るプログラムは、コンピュータを、所定の関数の呼び出しを検出する呼び出し検出部と、関数の検出が行われた際に、スタック領域に格納されているリターンアドレスを取得するリターンアドレス取得部と、検出された関数が、メモリ上の指定されたアドレス範囲の領域に実行可能属性を付与する関数であり、リターンアドレスの指し示す先の1つ前の命令が関数の呼び出し命令でない場合に、当該アドレス範囲をアドレス範囲記憶部に記憶する属性変更検出部と、検出された関数のリターンアドレスがアドレス範囲記憶部に記憶されているアドレス範囲内である場合に、不正アクセスが行われていると判定する不正アクセス検出部と、して機能させるためのものである。   A program according to an aspect of the present invention includes a call detection unit that detects a call to a predetermined function, and a return address that acquires a return address stored in the stack area when the function is detected. The acquisition unit and the detected function are functions that give an executable attribute to an area in a specified address range on the memory, and the previous instruction pointed to by the return address is not a function call instruction The attribute change detection unit that stores the address range in the address range storage unit, and the unauthorized access is performed when the return address of the detected function is within the address range stored in the address range storage unit It is intended to function as an unauthorized access detector that determines that

さらに、リターンアドレス取得部は、関数の検出が行われた際に、スタック領域に格納されている複数のリターンアドレスを順次取得し、属性変更検出部は、順次取得されるリターンアドレスのそれぞれについて、検出された関数が、メモリ上の指定されたアドレス範囲の領域に実行可能属性を付与する関数であり、リターンアドレスの指し示す先の1つ前の命令が関数の呼び出し命令でない場合に、当該アドレス範囲をアドレス範囲記憶部に記憶し、不正アクセス検出部は、順次取得されるリターンアドレスのそれぞれについて、リターンアドレスがアドレス範囲記憶部に記憶されているアドレス範囲内である場合に、不正アクセスが行われていると判定することとしてもよい。   Furthermore, when the function is detected, the return address acquisition unit sequentially acquires a plurality of return addresses stored in the stack area, and the attribute change detection unit, for each of the sequentially acquired return addresses, If the detected function is a function that adds an executable attribute to the area of the specified address range on the memory, and the previous instruction pointed to by the return address is not a function call instruction, the address range Is stored in the address range storage unit, and the unauthorized access detection unit performs unauthorized access when the return address is within the address range stored in the address range storage unit for each of the sequentially acquired return addresses. It is good also as determining with having.

また、本発明の一側面に係る情報機器は、所定の関数の呼び出しを検出する呼び出し検出部と、関数の検出が行われた際に、スタック領域に格納されているリターンアドレスを取得するリターンアドレス取得部と、検出された関数が、メモリ上の指定されたアドレス範囲の領域に実行可能属性を付与する関数である場合に、当該アドレス範囲をアドレス範囲記憶部に記憶する属性変更検出部と、検出された関数のリターンアドレスがアドレス範囲記憶部に記憶されているアドレス範囲内である場合に、不正アクセスが行われていると判定する不正アクセス検出部と、を備える。   An information device according to an aspect of the present invention includes a call detection unit that detects a call to a predetermined function, and a return address that acquires a return address stored in the stack area when the function is detected. An acquisition unit and an attribute change detection unit that stores the address range in an address range storage unit when the detected function is a function that assigns an executable attribute to a specified address range area on the memory; And an unauthorized access detection unit that determines that unauthorized access is being performed when the return address of the detected function is within the address range stored in the address range storage unit.

また、本発明の一側面に係る不正アクセス検出方法では、コンピュータが、所定の関数の呼び出しを検出し、関数の検出が行われた際に、スタック領域に格納されているリターンアドレスを取得し、検出された関数が、メモリ上の指定されたアドレス範囲の領域に実行可能属性を付与する関数である場合に、当該アドレス範囲をアドレス範囲記憶部に記憶し、検出された関数のリターンアドレスがアドレス範囲記憶部に記憶されているアドレス範囲内である場合に、不正アクセスが行われていると判定する。   In the unauthorized access detection method according to one aspect of the present invention, the computer detects a call to a predetermined function, and when the function is detected, obtains a return address stored in the stack area, When the detected function is a function that adds an executable attribute to the specified address range area on the memory, the address range is stored in the address range storage unit, and the return address of the detected function is the address If it is within the address range stored in the range storage unit, it is determined that unauthorized access has been performed.

なお、本発明において、「部」とは、単に物理的手段を意味するものではなく、その「部」が有する機能をソフトウェアによって実現する場合も含む。また、1つの「部」や装置が有する機能が2つ以上の物理的手段や装置により実現されても、2つ以上の「部」や装置の機能が1つの物理的手段や装置により実現されてもよい。   In the present invention, the “part” does not simply mean a physical means, but includes a case where the function of the “part” is realized by software. Also, even if the functions of one “unit” or device are realized by two or more physical means or devices, the functions of two or more “units” or devices are realized by one physical means or device. May be.

本発明によれば、不正アクセスの検出精度を高めることができる。   According to the present invention, it is possible to improve the accuracy of detecting unauthorized access.

本発明の一実施形態である情報機器のハードウェア構成の一例を示す図である。It is a figure which shows an example of the hardware constitutions of the information equipment which is one Embodiment of this invention. 情報機器において実現される機能部の構成例を示す図である。It is a figure which shows the structural example of the function part implement | achieved in information equipment. スタック領域の構造の一例を示す図である。It is a figure which shows an example of the structure of a stack area | region. 脆弱性のあるプログラムが実行されている際のメモリマップの一例を示す図である。It is a figure which shows an example of the memory map at the time of the program with a vulnerability being executed. バッファオーバーフローの脆弱性により、スタック領域に上書きされた攻撃コードの一例を示す図である。It is a figure which shows an example of the attack code overwritten on the stack area | region by the vulnerability of the buffer overflow. 攻撃コードの動作の一例を示す図である。It is a figure which shows an example of operation | movement of an attack code | cord | chord. 攻撃コードの動作の一例を示す図である。It is a figure which shows an example of operation | movement of an attack code | cord | chord. 攻撃コードの動作の一例を示す図である。It is a figure which shows an example of operation | movement of an attack code | cord | chord. 不正アクセスの検出処理の一例を示すフローチャートである。It is a flowchart which shows an example of the detection process of an unauthorized access.

以下、図面を参照して本発明の一実施形態について説明する。
==構成==
Hereinafter, an embodiment of the present invention will be described with reference to the drawings.
== Configuration ==

まず、本発明の一実施形態である情報機器の構成について説明する。図1は、本発明の一実施形態である情報機器のハードウェア構成の一例を示す図である。図1に示すように、情報機器10は、プロセッサ20、メモリ22、記憶装置24、入力インタフェース(I/F)26、データインタフェース(I/F)28、通信インタフェース(I/F)30、及び表示装置32を含んで構成されている。情報機器10は、例えば、パーソナルコンピュータや携帯情報端末等の情報処理装置である。   First, the configuration of an information device that is an embodiment of the present invention will be described. FIG. 1 is a diagram illustrating an example of a hardware configuration of an information device that is an embodiment of the present invention. As shown in FIG. 1, the information device 10 includes a processor 20, a memory 22, a storage device 24, an input interface (I / F) 26, a data interface (I / F) 28, a communication interface (I / F) 30, and The display device 32 is included. The information device 10 is an information processing apparatus such as a personal computer or a portable information terminal.

プロセッサ20は、メモリ22に記憶されているプログラムを実行することにより情報機器10における様々な処理の実行を制御する。なお、図1には示していないが、プロセッサ20は、命令やアドレスを記憶するための各種レジスタを備えている。本実施形態では、プロセッサ20の構成は、インテル(登録商標)社が開発した32ビットマイクロプロセッサのアーキテクチャであるIA−32を前提として説明する。なお、プロセッサ20の構成はこれに限られず、任意の構成を採用することができる。   The processor 20 controls the execution of various processes in the information device 10 by executing a program stored in the memory 22. Although not shown in FIG. 1, the processor 20 includes various registers for storing instructions and addresses. In this embodiment, the configuration of the processor 20 will be described on the assumption of IA-32, which is a 32-bit microprocessor architecture developed by Intel (registered trademark). The configuration of the processor 20 is not limited to this, and an arbitrary configuration can be adopted.

メモリ22は、例えばRAM(Random Access Memory)等の記憶領域であり、プロセッサ20によって実行されるプログラムのプログラムコードや、プログラムの実行時に必要となるデータを一時的に記憶する。例えば、メモリ22の記憶領域には、プログラムの実行時に必要となるスタック領域が確保される。   The memory 22 is a storage area such as a RAM (Random Access Memory), for example, and temporarily stores a program code of a program executed by the processor 20 and data necessary for executing the program. For example, in the storage area of the memory 22, a stack area necessary for executing a program is secured.

記憶装置24は、例えばハードディスクやフラッシュメモリ等の記憶領域であり、オペレーティングシステムをはじめとした各種プログラムや、各種データ等が記憶される。記憶装置24に記憶されているプログラムやデータは、必要に応じてメモリ22にロードされ、プロセッサ20により参照される。   The storage device 24 is a storage area such as a hard disk or a flash memory, and stores various programs including an operating system, various data, and the like. Programs and data stored in the storage device 24 are loaded into the memory 22 as necessary, and are referenced by the processor 20.

入力I/F26は、ユーザからの入力を受け付けるためのデバイスであり、例えば、キーボードやマウス、タッチパネル、各種センサ等である。入力I/F26は、例えば、USB(Universal Serial Bus)等のインタフェースを介して情報機器10の外部に設けられていてもよい。   The input I / F 26 is a device for receiving input from the user, and is, for example, a keyboard, a mouse, a touch panel, various sensors, or the like. The input I / F 26 may be provided outside the information device 10 via an interface such as USB (Universal Serial Bus), for example.

データI/F28は、情報機器10の外部からデータを入力するためのデバイスであり、例えば、各種記憶媒体に記憶されているデータを読み取るためのドライブ装置等である。データI/F28は、USB等のインタフェースを介して情報機器10の外部に設けられていてもよい。   The data I / F 28 is a device for inputting data from the outside of the information device 10, and is, for example, a drive device for reading data stored in various storage media. The data I / F 28 may be provided outside the information device 10 via an interface such as a USB.

通信I/F30は、情報機器10の外部の装置との間でデータ通信を行うためのデバイスであり、例えば、有線または無線によりデータ通信を行うことができる。通信I/F30は、USB等のインタフェースを介して情報機器10の外部に設けられていてもよい。   The communication I / F 30 is a device for performing data communication with an external device of the information device 10, and can perform data communication by wire or wireless, for example. The communication I / F 30 may be provided outside the information device 10 via an interface such as a USB.

表示装置32は、各種情報を表示するためのデバイスであり、例えば、液晶ディスプレイや有機EL(Electro−Luminescense)ディスプレイ等である。表示装置32は、ディスプレイケーブル等を介して情報機器10の外部に設けられていてもよい。   The display device 32 is a device for displaying various information, and is, for example, a liquid crystal display or an organic EL (Electro-Luminescence) display. The display device 32 may be provided outside the information device 10 via a display cable or the like.

図2は、情報機器10において実現される機能部の構成例を示す図である。図2に示される機能部は、例えば、メモリ22上の記憶領域を用いたり、メモリ22に記憶されているプログラムをプロセッサ20が実行したりすることにより実現することができる。   FIG. 2 is a diagram illustrating a configuration example of a functional unit realized in the information device 10. 2 can be realized, for example, by using a storage area on the memory 22 or by the processor 20 executing a program stored in the memory 22.

図2に示すように、情報機器10は、呼び出し検出部40、リターンアドレス取得部42、属性変更検出部44、アドレス範囲記憶部46、及び不正アクセス検出部48を含んで構成することができる。   As shown in FIG. 2, the information device 10 can include a call detection unit 40, a return address acquisition unit 42, an attribute change detection unit 44, an address range storage unit 46, and an unauthorized access detection unit 48.

呼び出し検出部40は、情報機器10において、所定のAPI(Application Program Interface)関数の呼び出しを検出することができる。呼び出し検出部40による関数の呼び出し検出は、例えば、任意の手法によるフックを用いることにより行うことができる。本実施形態では、Windows(登録商標)におけるAPI関数である、VirtualProtectおよびWinExecをフックする場合を一例として説明する。なお、本実施形態では、検出する関数の一例としてVirtualProtectおよびWinExecを示すが、関数はこれに限られず、不正アクセスに用いられる可能性のある任意の関数を検出対象とすることができる。また、例えば、UNIX(登録商標)等の他の環境においても同様に、フックによりAPI関数の呼び出しを検出することができる。   The call detection unit 40 can detect a call of a predetermined API (Application Program Interface) function in the information device 10. The function call detection by the call detection unit 40 can be performed, for example, by using a hook by an arbitrary method. In the present embodiment, a case of hooking VirtualProtect and WinExec, which are API functions in Windows (registered trademark), will be described as an example. In this embodiment, VirtualProtect and WinExec are shown as examples of functions to be detected. However, the functions are not limited to this, and any function that may be used for unauthorized access can be detected. Similarly, for example, in other environments such as UNIX (registered trademark), it is possible to detect an API function call by a hook.

リターンアドレス取得部42は、呼び出し検出部40により所定のAPI関数の呼び出しが検出された際に、スタック領域に格納されているリターンアドレスを取得する。図3に、スタック領域の構造の一例を示す。図3に示すように、スタック領域には、関数ごとに、スタックフレームという領域が確保されている。そして、図3に示すように、スタック領域におけるポインタとして、スタックポインタ(esp:Extended Stack Pointer)およびベースポインタ(ebp:Extended Base Pointer)が設けられている。スタックポインタは、スタックの一番上の場所を示すものであり、その値はスタックポインタレジスタに格納されている。また、ベースポインタは、実行中の関数のスタックフレームの底(ベース)の場所を示すものであり、その値はベースポインタレジスタに格納されている。   The return address acquisition unit 42 acquires the return address stored in the stack area when a call to a predetermined API function is detected by the call detection unit 40. FIG. 3 shows an example of the structure of the stack area. As shown in FIG. 3, in the stack area, an area called a stack frame is secured for each function. As shown in FIG. 3, a stack pointer (esp: Extended Stack Pointer) and a base pointer (ebp: Extended Base Pointer) are provided as pointers in the stack area. The stack pointer indicates the top position of the stack, and its value is stored in the stack pointer register. The base pointer indicates the location of the bottom (base) of the stack frame of the function being executed, and its value is stored in the base pointer register.

そして、ベースポインタが指し示す場所には、呼び出し元の関数のスタックフレームにおけるベースのアドレス(ebp Backup)が格納され、その下にはリターンアドレスが格納されている。したがって、リターンアドレス取得部42は、ベースのアドレスを辿ることにより、スタック領域に格納されている複数のリターンアドレスを順次取得することができる。このようにベースのアドレスを辿ることにより複数のリターンアドレスを順次取得する処理は、バックトレースと呼ばれる。   Then, the base address (ebp Backup) in the stack frame of the caller function is stored at the location pointed to by the base pointer, and the return address is stored below it. Therefore, the return address acquisition unit 42 can sequentially acquire a plurality of return addresses stored in the stack area by tracing the base address. The process of sequentially acquiring a plurality of return addresses by tracing the base address in this way is called backtrace.

ただし、アプリケーションの中にはこの規定に従わない関数が存在し、ebp Backupには不正な値が格納されている可能性がある。そのため、リターンアドレス取得部42は、ebp Backupに格納されたアドレスがスタック領域の範囲外であるか、それが格納されているアドレスよりも小さいアドレスであるときは不正な値であると判断し、バックトレースを終了する。   However, there is a function that does not follow this rule in the application, and there is a possibility that an invalid value is stored in ebp Backup. Therefore, the return address acquisition unit 42 determines that the address stored in the ebp backup is out of the stack area or is an incorrect value when the address is smaller than the stored address. End backtrace.

属性変更検出部44は、呼び出し検出部40により検出された関数が、メモリ上の指定されたアドレス範囲の領域に実行可能属性を付与する関数である場合に、当該アドレス範囲を、メモリ22上で確保された領域であるアドレス範囲記憶部46に記憶する。本実施形態では、属性変更検出部44は、呼び出し検出部40によってVirtualProtectの呼び出しが検出され、当該関数により、指定されたアドレス範囲の領域に実行属性が付与される場合には、当該アドレス範囲をアドレス範囲記憶部46に記憶する。VirtualProtectは、属性変更の対象領域の先頭のアドレス(第1引数)、対象領域のサイズ(第2引数)、変更後の属性(第3引数)、変更前の属性の保存先(第4引数)の4つの引数を取る。そのため、属性変更検出部44は、VirtualProtectの呼び出しが検出された際には、第3引数により、実行可能属性を付与するものであるかを判断し、第1引数及び第2引数により、属性変更のアドレス範囲を取得することができる。なお、アドレス範囲記憶部46に記憶されるアドレス範囲の情報の形式は任意である。例えば、アドレス範囲の開始アドレスと最終アドレスが記憶されることとしてもよいし、アドレス範囲の開始アドレスとアドレス範囲のサイズが記憶されることとしてもよい。   If the function detected by the call detection unit 40 is a function that assigns an executable attribute to the designated address range area on the memory, the attribute change detection unit 44 stores the address range on the memory 22. The data is stored in the address range storage unit 46 that is a reserved area. In the present embodiment, the attribute change detection unit 44 detects the call of VirtualProtect by the call detection unit 40, and if the function assigns an execution attribute to the specified address range area, Store in the address range storage unit 46. VirtualProtect is the start address (first argument) of the attribute change target area, the size of the target area (second argument), the attribute after change (third argument), and the storage destination of the attribute before change (fourth argument). Takes four arguments. Therefore, when the call to VirtualProtect is detected, the attribute change detection unit 44 determines whether the executable attribute is to be given by the third argument, and changes the attribute by the first argument and the second argument. Address range can be obtained. The format of the address range information stored in the address range storage unit 46 is arbitrary. For example, the start address and end address of the address range may be stored, or the start address of the address range and the size of the address range may be stored.

また、属性変更検出部44は、リターンアドレス取得部42により取得されたリターンアドレスを考慮することができる。具体的には、属性変更検出部44は、VirtualProtectにより、指定されたアドレス範囲の領域に実行属性が付与される場合であって、取得されたリターンアドレスの指し示す先の1つ前の命令がcall命令(呼び出し命令)でない場合に、当該アドレス範囲をアドレス範囲記憶部46に記憶することができる。リターンアドレス取得部42により複数のリターンアドレスが順次取得される場合、属性変更検出部44は、各リターンアドレスについて当該判定を行うことができる。   Further, the attribute change detection unit 44 can consider the return address acquired by the return address acquisition unit 42. Specifically, the attribute change detection unit 44 is a case where an execution attribute is given to the area of the designated address range by VirtualProtect, and the previous instruction to which the acquired return address indicates is called When the instruction is not an instruction (call instruction), the address range can be stored in the address range storage unit 46. When a plurality of return addresses are sequentially acquired by the return address acquisition unit 42, the attribute change detection unit 44 can make the determination for each return address.

不正アクセス検出部48は、リターンアドレス取得部42により取得されたリターンアドレスが、アドレス範囲記憶部46に記憶されているアドレス範囲内である場合に、不正アクセスが行われていると判定する。本実施形態では、不正アクセス検出部48は、例えば、呼び出し検出部40によってWinExecの呼び出しが検出され、リターンアドレス取得部42により取得されたリターンアドレスが、アドレス範囲記憶部46に記憶されているアドレス範囲内である場合に、不正アクセスが行われていると判定する。リターンアドレス取得部42により複数のリターンアドレスが順次取得される場合、不正アクセス検出部48は、各リターンアドレスについて当該判定を行うことができる。   The unauthorized access detection unit 48 determines that unauthorized access has been performed when the return address acquired by the return address acquisition unit 42 is within the address range stored in the address range storage unit 46. In the present embodiment, the unauthorized access detection unit 48 detects, for example, a call to WinExec by the call detection unit 40 and the return address acquired by the return address acquisition unit 42 is stored in the address range storage unit 46. If it is within the range, it is determined that unauthorized access is being performed. When a plurality of return addresses are sequentially acquired by the return address acquisition unit 42, the unauthorized access detection unit 48 can make the determination for each return address.

==不正アクセスの検出処理==
次に、情報機器10における不正アクセスの検出処理について説明する。図4は、脆弱性のあるプログラムが実行されている際のメモリマップの一例を示す図である。図4に示す例では、0x65300000〜0x6547FFFF番地までの1.5MBの領域にプログラムコードが配置され、0x65480000〜0x654FFFF番地までの0.5MBの領域に静的データが配置されている。このプログラムには、バッファオーバーフローを引き起こす可能性のある、脆弱性のある関数が含まれている。なお、図4に示すように、プログラム領域の0x65401122番地には0x54が格納され、0x65401123番地には0xC3が格納されている。IA−32において、0x54はpush esp命令、0xC3はret命令である。push esp命令は、スタックポインタレジスタに記憶されている値をスタック領域にプッシュするための命令である。また、ret命令は、呼び出された関数から呼び出し元の関数へと制御を戻すための命令である。本実施形態では、これらのpush esp命令およびret命令は、不正アクセスを行うための攻撃コードによって利用されることとなる。
== Unauthorized access detection processing ==
Next, unauthorized access detection processing in the information device 10 will be described. FIG. 4 is a diagram illustrating an example of a memory map when a vulnerable program is executed. In the example shown in FIG. 4, the program code is arranged in the 1.5 MB area from 0x65300000 to 0x6547FFFF, and the static data is arranged in the 0.5 MB area from 0x654480000 to 0x654FFFF. The program contains a vulnerable function that can cause a buffer overflow. As shown in FIG. 4, 0x54 is stored at address 0x650401122 in the program area, and 0xC3 is stored at address 0x650401123. In IA-32, 0x54 is a push esp instruction, and 0xC3 is a ret instruction. The push esp instruction is an instruction for pushing the value stored in the stack pointer register to the stack area. The ret instruction is an instruction for returning control from the called function to the calling function. In the present embodiment, these push esp instruction and ret instruction are used by an attack code for performing unauthorized access.

図5は、図4に示したプログラムにおけるバッファオーバーフローの脆弱性により、スタック領域に上書きされた攻撃コードの一例を示す図である。図5の例では、スタック領域は4バイト(ダブルワード)幅で構成されており、攻撃コードは16進数で示されている。図5に示す例では、攻撃コードはブロックA〜ブロックCの3つのブロックにより構成されている。   FIG. 5 is a diagram showing an example of attack code overwritten in the stack area due to a buffer overflow vulnerability in the program shown in FIG. In the example of FIG. 5, the stack area has a 4-byte (double word) width, and the attack code is indicated in hexadecimal. In the example shown in FIG. 5, the attack code is composed of three blocks, block A to block C.

ブロックAは、VirtualProtect関数を呼び出すことにより、データ領域に実行属性を付与するためのROP(Return Oriented Programmin)のプログラムコードである。ブロックAのスタック領域の右側には、各ダブルワードの意味が示されている。先頭のダブルワードは、本来であれば、呼び出し元の関数へと戻るためのリターンアドレスが格納される領域であるが、VirtualProtect関数のアドレスに上書きされている。なお、VirtualProtect関数のアドレスはWindows(登録商標)のバージョンや実行環境により異なるが、図5の例では、0x7C801AD0としている。そして、図5に示すように、ブロックAには、ret命令のドレス(0x65401123)、VirtualProtect関数の引数、push esp命令のアドレス(0x65401122)が格納されている。   Block A is a ROP (Return Oriented Program) program code for assigning an execution attribute to a data area by calling a VirtualProtect function. On the right side of the stack area of block A, the meaning of each double word is shown. The leading double word is an area where the return address for returning to the calling function is stored, but is overwritten with the address of the VirtualProtect function. Note that the address of the VirtualProtect function differs depending on the version of Windows (registered trademark) and the execution environment, but in the example of FIG. 5, it is set to 0x7C801AD0. As shown in FIG. 5, in the block A, the address of the ret instruction (0x650401123), the argument of the VirtualProtect function, and the address of the push esp instruction (0x650401122) are stored.

ブロックBは、VirtualProtect関数により実行属性が付与されたデータ領域に攻撃コード本体をコピーするプログラムコードである。ブロックBのスタック領域の右側には、当該プログラムコードのアセンブリ言語表記が示されている。このブロックBのプログラムコードは、プロセッサ20がこのスタック領域を参照することにより実行される。   Block B is a program code for copying the attack code body to the data area to which the execution attribute is given by the VirtualProtect function. On the right side of the stack area of block B, an assembly language notation of the program code is shown. The program code of block B is executed by the processor 20 referring to this stack area.

ブロックCは、ブロックBのプログラムコードによってデータ領域にコピーされる攻撃コード本体である。ブロックCのスタック領域の右側には、当該プログラムコードのアセンブリ言語表記が示されている。このブロックCのプログラムコードは、プロセッサ20がコピー先のデータ領域を参照することにより実行される。なお、図5に示す例では、説明を簡単にするために、攻撃コード本体では、WinExec(”calc”,1)が実行され、電卓アプリケーションが起動されるのみとなっている。実際に用いられる攻撃コードでは、不正アクセスを行うための任意のアプリケーションや関数が起動される。   Block C is an attack code body that is copied to the data area by the program code of block B. On the right side of the stack area of block C, an assembly language notation of the program code is shown. The program code of the block C is executed by the processor 20 referring to the copy destination data area. In the example shown in FIG. 5, in order to simplify the description, WinExec (“calc”, 1) is executed in the attack code body, and the calculator application is only activated. In the attack code actually used, an arbitrary application or function for performing unauthorized access is activated.

図6〜図8を参照して、図5に示した攻撃コードの動作について説明する。図6〜図8において、espはスタックポインタ、eip(Extended Instruction Pointer)は命令ポインタを示している。命令ポインタは、プロセッサ20が次に実行する命令のアドレスを保持するものであり、その値は命令ポインタレジスタに格納されている。図6〜図8に示す例では、状態S1から状態S9までの状態変化が示されている。   The operation of the attack code shown in FIG. 5 will be described with reference to FIGS. 6 to 8, esp is a stack pointer, and eip (Extended Instruction Pointer) is an instruction pointer. The instruction pointer holds the address of the instruction to be executed next by the processor 20, and its value is stored in the instruction pointer register. In the example shown in FIGS. 6 to 8, state changes from state S1 to state S9 are shown.

図6に示す状態S1は、図4に示した脆弱性のある関数の実行によりスタック領域が上書きされ、当該関数から呼び出し元の関数へとリターンする直前の状態を示している。このとき、espは攻撃コードの先頭を示している。そして、eipは脆弱性のある関数から呼び出し元の関数に制御を戻すためのret命令(リターン命令)の位置を指している。プロセッサ20は、eipに従ってret命令を実行し、espが指していた場所の内容、すなわち、VirtualProtect関数のアドレス0x7C801AD0をeipに設定し、espを1ダブルワード(4バイト)増加させる。これにより、状態S2へと遷移する。すなわち、脆弱性のある関数の呼び出し元ではなく、VirtualProtect関数へ遷移することとなる。   A state S1 shown in FIG. 6 shows a state immediately before the stack area is overwritten by the execution of the vulnerable function shown in FIG. 4 and the function returns to the calling function. At this time, esp indicates the head of the attack code. Eip indicates the position of a ret instruction (return instruction) for returning control from the vulnerable function to the calling function. The processor 20 executes the ret instruction according to eip, sets the contents of the location pointed to by esp, that is, the address 0x7C801AD0 of the VirtualProtect function to eip, and increases esp by 1 double word (4 bytes). Thereby, it changes to state S2. That is, a transition is made to the VirtualProtect function instead of the caller of the vulnerable function.

状態S2では、プロセッサ20は、eipに従ってVirtualProtec関数を実行する。このとき、VirtualProtect関数は、espが指す場所の次のダブルワードから順に4つのダブルワードを引数として受け取る。第1引数0x65480000は、属性変更の対象領域の先頭アドレスであり、第2引数0x00001000は対象領域のサイズである。図4を参照すると、このアドレス範囲は、静的変数1のアドレス範囲となっている。第3引数0x00000040は、変更後の属性が「読み出し、書き込み、実行」の全属性であることを示している。第4引数0x65481000は、変更前の属性の保存先であり、図4を参照すると、静的変数2の領域が変更前の属性の保存先として設定されていることがわかる。これにより、静的変数1の4096バイトの領域に、「読み出し、書き込み、実行」の属性が付与される。   In the state S2, the processor 20 executes the VirtualProtec function according to eip. At this time, the VirtualProtect function receives four double words as arguments in order from the next double word at the location pointed to by esp. The first argument 0x654800000 is the start address of the target area for attribute change, and the second argument 0x00001000 is the size of the target area. Referring to FIG. 4, this address range is the address range of static variable 1. The third argument 0x00000040 indicates that the changed attributes are all “read, write, execute” attributes. The fourth argument 0x654481000 is the storage destination of the attribute before the change. Referring to FIG. 4, it can be seen that the area of the static variable 2 is set as the storage destination of the attribute before the change. As a result, the attribute “read, write, execute” is given to the 4096-byte area of the static variable 1.

状態S3は、VirtualProtect関数からリターンする直前の状態を示している。このとき、eipはret 16命令の位置を指している。Windows(登録商標)のAPIの場合、関数からリターンする際にはespは引数領域の次のアドレスまで移動される。したがって、プロセッサ20は、VirtualProtect関数のret 16命令を実行すると、espが指していたアドレスの値0x65401123をリターンアドレスとしてeipに設定し、espを5ダブルワード(20バイト)分増加させる。これにより、図7に示す状態S4へと遷移する。   A state S3 indicates a state immediately before returning from the VirtualProtect function. At this time, eip points to the position of the ret 16 instruction. In the case of the API of Windows (registered trademark), when returning from the function, esp is moved to the next address in the argument area. Accordingly, when executing the ret 16 instruction of the VirtualProtect function, the processor 20 sets the value 0x650401123 of the address pointed to by esp as eip as the return address, and increases esp by 5 double words (20 bytes). Thereby, the state transits to the state S4 shown in FIG.

状態S4において、eipが指す0x65401123番地には、ret命令が格納されている。そのため、プロセッサ20は、eipに従ってret命令を実行し、espが指している場所に格納されている0x65401122をeipに設定し、espを1ダブルワード(4バイト)増加させる。図4を参照すると、0x65401122番地には、0x54(push esp命令)が格納されていることがわかる。これにより、状態S5へと遷移する。   In state S4, a ret instruction is stored at address 0x650401123 pointed to by eip. Therefore, the processor 20 executes the ret instruction according to ei, sets 0x650401122 stored in the location pointed to by esp to eip, and increases esp by 1 double word (4 bytes). Referring to FIG. 4, it can be seen that 0x54 (push esp instruction) is stored at address 0x650401122. Thereby, it changes to state S5.

状態S5では、プロセッサ20は、eipに従ってpush esp命令を実行する。プロセッサ20は、push esp命令を実行すると、espを1ダブルワード(4バイト)減少させ、espが指す場所に元のespの値(図7の例ではesp+4)を格納する。また、プロセッサ20は、eipを1命令分先へ進める。これにより、状態S6へと遷移する。   In state S5, the processor 20 executes a push esp instruction according to eip. When executing the push esp instruction, the processor 20 decreases esp by 1 double word (4 bytes), and stores the original esp value (esp + 4 in the example of FIG. 7) at the location pointed to by esp. Further, the processor 20 advances the eip one instruction ahead. Thereby, it changes to state S6.

状態S6では、プロセッサ20は、eipに従ってret命令を実行する。そして、プロセッサ20は、espが指す場所に格納されている値(esp+4)をeipにセットし、espを1ダブルワード(4バイト)増加させる。これにより、図8に示す状態S7へと遷移する。   In state S6, the processor 20 executes a ret instruction according to eip. Then, the processor 20 sets the value (esp + 4) stored in the location pointed to by esp to eip, and increases esp by 1 double word (4 bytes). Thereby, the state transits to the state S7 shown in FIG.

状態S7では、espとeipはともに、図5に示したスタック領域上のブロックBの先頭を指している。プロセッサ20は、eipに従って、ブロックBのプログラムコードをスタック領域から順次読み出して実行していく。これにより、データ領域上の静的変数1の領域に攻撃コード本体がコピーされる。これにより、状態S8へと遷移する。   In the state S7, both esp and eip point to the head of the block B on the stack area shown in FIG. The processor 20 sequentially reads and executes the program code of the block B from the stack area in accordance with eip. As a result, the attack code body is copied to the area of static variable 1 on the data area. Thereby, it changes to state S8.

状態S8では、eipはブロックBのプログラムコードの最後の命令を指している。プロセッサ20は、eipに従って、静的変数1のアドレスをeipに設定するjmp命令を実行する。これにより、状態S9へと遷移する。   In state S8, eip points to the last instruction in the program code of block B. The processor 20 executes a jmp instruction for setting the address of the static variable 1 to “ip” according to “eip”. Thereby, it changes to state S9.

状態S9では、eipは、データ領域上の静的変数1の領域の先頭を指している。前述したように、静的変数1の領域には、攻撃コード本体が格納されている。したがって、プロセッサ20は、eipに従って、攻撃コード本体のプログラムコードを静的変数1の領域から順次読み出して実行していく。これにより、プロセッサ20は、WinExec関数により電卓アプリケーションを起動する。前述したように、ここでは電卓アプリケーションが起動されることとしたが、攻撃コード本体のプログラムコードを変更することにより、任意の処理の実行が可能となる。   In state S9, eip points to the beginning of the area of static variable 1 on the data area. As described above, the attack code body is stored in the area of the static variable 1. Therefore, the processor 20 sequentially reads and executes the program code of the attack code body from the area of the static variable 1 in accordance with the eip. As a result, the processor 20 activates the calculator application by the WinExec function. As described above, the calculator application is activated here, but any processing can be executed by changing the program code of the attack code body.

ここで、状態S9において、WinExec関数が呼び出されたとき、リターンアドレスが指している領域である静的変数1の領域には実行属性が付与されており、通常のプログラムコードのためのメモリ領域と同様に見える。そのため、リターンアドレスの指し示す先がプログラムコードを格納するためのメモリ領域であるかどうか判断することにより不正アクセスを検出するという一般的な手法では、図4〜図8に示したような不正アクセスを検出することができない。また、リターンアドレスの指し示す先の属性が書込み可能であるかどうか判断することにより不正アクセスを検出するという一般的な手法を用いれば、当該不正アクセスの検出は可能になるものの、この手法では、前述したように誤検出の可能性がある。   Here, when the WinExec function is called in the state S9, an execution attribute is given to the area of the static variable 1, which is the area pointed to by the return address, and a memory area for normal program code and Looks similar. Therefore, in a general method of detecting unauthorized access by determining whether the destination indicated by the return address is a memory area for storing program code, unauthorized access as shown in FIGS. It cannot be detected. In addition, if a general method of detecting unauthorized access by determining whether or not the destination attribute indicated by the return address is writable, the unauthorized access can be detected. There is a possibility of false detection.

また、状態S9において、WinExec関数が呼び出されたとき、リターンアドレスの指し示す先が関数の先頭である可能性は低い。そのため、リターンアドレスの指し示す先が関数の開始アドレスであるかどうか判断することにより不正アクセスを検出するという一般的な手法では、当該不正アクセスを検出することができない。さらに、正常なプログラムの中には、call命令を用いずに関数呼び出しを行うものもあるため、リターンアドレスの指し示す先の1つ前の命令がcall命令かどうか判断することにより不正アクセスを検出するという一般的な手法では誤検出の可能性がある。   In the state S9, when the WinExec function is called, there is a low possibility that the destination indicated by the return address is the head of the function. For this reason, it is impossible to detect the unauthorized access by a general method of detecting unauthorized access by determining whether the destination indicated by the return address is the start address of the function. Further, since some normal programs call a function without using a call instruction, an unauthorized access is detected by determining whether the instruction immediately before the return address is a call instruction. There is a possibility of false detection in the general method.

一方、本実施形態における検出手法を用いることにより、上述したような誤検出をすることなく、不正アクセスを検出することが可能となる。以下に本実施形態における検出の手順について説明する。   On the other hand, by using the detection method in the present embodiment, it is possible to detect unauthorized access without performing the erroneous detection as described above. The detection procedure in this embodiment will be described below.

図9は、本実施形態における不正アクセスの検出処理の一例を示すフローチャートである。図9に示す処理は、呼び出し検出部40が、所定のAPI関数の呼び出しを検出することにより開始される。リターンアドレス取得部42は、呼び出し検出部40によりAPI関数の呼び出しが検出されると、図9に示すバックトレースのループ処理において、スタック領域を参照してリターンアドレスを順次取得する(S901)。そして、順次取得されるリターンアドレスのそれぞれについて、バックトレースのループ内の処理が実行される。   FIG. 9 is a flowchart showing an example of unauthorized access detection processing in the present embodiment. The process illustrated in FIG. 9 is started when the call detection unit 40 detects a call to a predetermined API function. When the API function call is detected by the call detection unit 40, the return address acquisition unit 42 sequentially acquires return addresses with reference to the stack area in the backtrace loop process shown in FIG. 9 (S901). Then, the processing in the backtrace loop is executed for each return address acquired sequentially.

属性変更検出部44は、呼び出し検出部40により検出されたAPI関数が、例えばVirtualProtect等のメモリ属性変更関数であるかどうか判断する(S902)。メモリ属性変更関数である場合(S902:YES)、属性変更検出部44は、さらに、変更後の属性が実行属性を含むものであるかどうか判断する(S903)。変更後の属性が実行属性を含むものである場合(S903:YES)、属性変更検出部44は、さらに、リターンアドレス取得部42により取得されたリターンアドレスによって示されるリターン先の1つ前の命令がcall命令であるかどうか判断する(S904)。そして、call命令であれば(S904:YES)、属性変更検出部44は、属性変更の対象となっている領域のアドレス範囲をアドレス範囲記憶部46に記憶する(S905)。すなわち、属性変更検出部44は、呼び出し検出部40により検出されたAPI関数の呼び出しは攻撃コードによるものである可能性が高いとして、属性変更の対象となっている領域のアドレス範囲をアドレス範囲記憶部46に記憶する。   The attribute change detection unit 44 determines whether the API function detected by the call detection unit 40 is a memory attribute change function such as VirtualProtect (S902). If it is a memory attribute change function (S902: YES), the attribute change detection unit 44 further determines whether or not the changed attribute includes an execution attribute (S903). When the changed attribute includes an execution attribute (S903: YES), the attribute change detection unit 44 further sets the instruction immediately before the return destination indicated by the return address acquired by the return address acquisition unit 42 to call. It is determined whether it is an instruction (S904). If it is a call instruction (S904: YES), the attribute change detection unit 44 stores the address range of the area subject to attribute change in the address range storage unit 46 (S905). That is, the attribute change detection unit 44 stores the address range of the area whose attribute is to be changed as the API function call detected by the call detection unit 40 is likely to be caused by an attack code. Store in the unit 46.

呼び出し検出部40により検出されたAPI関数がメモリ属性変更関数でない場合(S902:NO)、不正アクセス検出部48は、リターンアドレス取得部42により取得されたリターンアドレスが、アドレス範囲記憶部46に記憶されているアドレス範囲内に含まれるかどうか判断する(S906)。また、変更後の属性に実行属性が含まれない場合(S903:NO)、リターンアドレスによって示されるリターン先の1つ前の命令がcall命令である場合(S904:NO)、もしくは、アドレス範囲を保存した場合(S905)においても、当該判定処理(S906)に遷移する。   If the API function detected by the call detection unit 40 is not a memory attribute change function (S902: NO), the unauthorized access detection unit 48 stores the return address acquired by the return address acquisition unit 42 in the address range storage unit 46. It is determined whether it is included within the address range that has been set (S906). If the changed attribute does not include an execution attribute (S903: NO), the instruction immediately preceding the return destination indicated by the return address is a call instruction (S904: NO), or the address range is changed. Also when it preserve | saves (S905), it changes to the said determination process (S906).

そして、リターンアドレスがアドレス範囲内に含まれる場合(S906:YES)、不正アクセス検出部48は、攻撃コードによる不正アクセスが行われていると判定する(S907)。この場合、不正アクセス検出部48は、例えば、不正アクセスの判定結果を示す情報を出力し(S908)、実行中のプログラムを強制終了させる。   If the return address is included in the address range (S906: YES), the unauthorized access detection unit 48 determines that unauthorized access using the attack code is being performed (S907). In this case, for example, the unauthorized access detection unit 48 outputs information indicating the unauthorized access determination result (S908), and forcibly terminates the program being executed.

一方、リターンアドレスがアドレス範囲内に含まれない場合(S906:NO)、不正アクセス検出部48は、必要に応じて、他の一般的な手法による不正アクセスの検出処理を実行する(S909)。   On the other hand, if the return address is not included in the address range (S906: NO), the unauthorized access detection unit 48 executes unauthorized access detection processing by another general method as necessary (S909).

そして、リターンアドレス取得部42により順次取得される複数のリターンアドレスについて上述の処理が実行された後、呼び出し検出部40は、検出されたAPI関数の本体を実行する(S910)。   Then, after the above-described processing is executed for a plurality of return addresses sequentially acquired by the return address acquisition unit 42, the call detection unit 40 executes the main body of the detected API function (S910).

図9に示した処理により、図5に示した攻撃コードによる不正アクセスを検出する場合を説明する。まず、図6に示す状態S2において、呼び出し検出部40が、VirtualProtect関数の呼び出しを検出すると、図9に示す処理が開始される。そして、リターンアドレス取得部42は、スタック領域を参照し、リターンアドレス0x65401123を取得する(S901)。図6の状態S2において実行されるVirtualProtect関数は、メモリ属性変更関数であり(S902:YES)、図4に示したデータ領域における静的変数1の領域に実行属性を付与するものである(S903:YES)。また、図4に示すように、取得されたリターンアドレス0x65401123の指し示す先の1つ前の命令はcall命令ではない(S904:NO)。したがって、属性変更検出部44は、VirtualProtect関数により実行属性が付与される領域のアドレス範囲0x65480000〜0x65480FFFをアドレス範囲記憶部46に記憶する(S905)。   The case where the unauthorized access by the attack code shown in FIG. 5 is detected by the process shown in FIG. 9 will be described. First, in the state S2 shown in FIG. 6, when the call detection unit 40 detects a call to the VirtualProtect function, the process shown in FIG. 9 is started. Then, the return address acquisition unit 42 refers to the stack area and acquires the return address 0x650401123 (S901). The VirtualProtect function executed in the state S2 in FIG. 6 is a memory attribute change function (S902: YES), and assigns an execution attribute to the area of the static variable 1 in the data area shown in FIG. 4 (S903). : YES) Also, as shown in FIG. 4, the previous instruction pointed to by the acquired return address 0x650401123 is not a call instruction (S904: NO). Therefore, the attribute change detection unit 44 stores the address range 0x654480000 to 0x65480FFF of the area to which the execution attribute is given by the VirtualProtect function in the address range storage unit 46 (S905).

そして、リターンアドレス0x65401123は保存されたアドレス範囲0x65480000〜0x65480FFFに含まれないため(S906:NO)、不正アクセス検出部48は、他の一般的な手法による不正アクセスの検出処理を実行する(S909)。そして、リターンアドレス取得部42は次のリターンアドレスの取得を試みるが、スタックに格納されていたベースアドレスはバッファオーバーフローにより別の値に上書きされているため不正なアドレスであると判定される。そのため、ここでバックトレース処理のループが終了し、呼び出し検出部40は、API関数の本体、すなわち、VirtualProtect関数を呼び出して属性変更処理を実行する(S910)。これにより、データ領域における静的変数1の領域に実行属性が付与される。   Since the return address 0x65401123 is not included in the stored address range 0x6548000-0x65480FFF (S906: NO), the unauthorized access detection unit 48 executes unauthorized access detection processing by another general method (S909). . Then, the return address acquisition unit 42 attempts to acquire the next return address, but the base address stored in the stack is overwritten with another value due to buffer overflow, and thus is determined to be an illegal address. Therefore, the loop of the back trace process ends here, and the call detection unit 40 calls the main body of the API function, that is, the VirtualProtect function, and executes the attribute change process (S910). As a result, the execution attribute is given to the area of the static variable 1 in the data area.

その後、図8に示す状態S9に遷移するまでの間にはAPI関数の呼び出しは行われないため、図9に示す処理は実行されない。そして、図8に示す状態S9において、呼び出し検出部40が、WinExec関数の呼び出しを検出すると、図9に示す処理が開始される。WinExec関数の呼び出しが行われたとき、スタック領域には、WinExec関数を呼び出すcall命令の次の命令のアドレスがリターンアドレスとして格納されている。リターンアドレス取得部42は、スタック領域を参照し、このリターンアドレスを取得する(S901)。WinExec関数は、メモリ属性変更関数ではないため(S902:NO)、不正アクセス検出部48は、リターンアドレスが、保存されたアドレス範囲0x65480000〜0x65480FFFに含まれるかどうか判定する(S906)。   Thereafter, the API function is not called until the transition to the state S9 shown in FIG. 8, so the processing shown in FIG. 9 is not executed. Then, in the state S9 shown in FIG. 8, when the call detection unit 40 detects a call to the WinExec function, the process shown in FIG. 9 is started. When the WinExec function is called, the address of the instruction next to the call instruction that calls the WinExec function is stored as a return address in the stack area. The return address acquisition unit 42 refers to the stack area and acquires this return address (S901). Since the WinExec function is not a memory attribute change function (S902: NO), the unauthorized access detection unit 48 determines whether the return address is included in the stored address range 0x655480000 to 0x65480FFF (S906).

ここで、WinExec関数を呼び出すcall命令は、属性変更が行われた静的変数1の領域にあるため、リターンアドレスも当該領域内にある。つまり、リターンアドレスは、保存されたアドレス範囲0x65480000〜0x65480FFFに含まれている(S906:YES)。そのため、不正アクセス検出部48は、攻撃コードによる不正アクセスが行われていると判定する(S907)。そして、不正アクセス検出部48は、不正アクセスの判定結果を出力し(S908)、処理を強制終了させる。これにより、WinExec関数の本体は実行されず、不正アクセスを防止することが可能となる。   Here, since the call instruction for calling the WinExec function is in the area of the static variable 1 in which the attribute change is performed, the return address is also in the area. That is, the return address is included in the stored address range 0x654480000 to 0x65480FFF (S906: YES). Therefore, the unauthorized access detection unit 48 determines that unauthorized access using an attack code has been performed (S907). Then, the unauthorized access detection unit 48 outputs the unauthorized access determination result (S908) and forcibly terminates the process. Thus, the main body of the WinExec function is not executed, and unauthorized access can be prevented.

本実施形態によれば、呼び出し検出部40により検出された関数が、メモリ上の指定されたアドレス範囲の領域に実行可能属性を付与する関数(例えばVirtualProtect)であり、リターンアドレスの指し示す先の1つ前の命令が関数の呼び出し命令でない場合に、当該アドレス範囲がアドレス範囲記憶部46に記憶される。そして、リターンアドレスがアドレス範囲記憶部46に記憶されているアドレス範囲内である場合に、不正アクセスが行われていると判定される。   According to the present embodiment, the function detected by the call detection unit 40 is a function (for example, VirtualProtect) that assigns an executable attribute to an area in a specified address range on the memory, and the destination address indicated by the return address is 1 When the previous instruction is not a function call instruction, the address range is stored in the address range storage unit 46. When the return address is within the address range stored in the address range storage unit 46, it is determined that unauthorized access is being performed.

したがって、リターンアドレスの指し示す先がプログラムコードを格納するためのメモリ領域と同様に見える場合であっても、不正アクセスを検出することができる。さらに、リターンアドレスの指し示す先の属性が書込み可能であっても、その領域に実行属性を付与した関数の各リターンアドレスの指し示す先の1つ前の命令が関数の呼び出し命令であれば不正アクセスとして誤検出されることはない。そのため、メモリ上のデータ領域に別のプログラムコードを展開する正常なプログラムによる処理を不正アクセスとして誤検出することを防ぐことができる。このように、本実施形態によれば、不正アクセスの検出精度を高めることが可能となる。   Therefore, even if the destination indicated by the return address looks similar to the memory area for storing the program code, unauthorized access can be detected. Furthermore, even if the destination attribute pointed to by the return address is writable, if the previous instruction pointed to by the return address of the function to which the execution attribute is assigned to the area is a function call instruction, illegal access is assumed. There is no false detection. For this reason, it is possible to prevent erroneous detection of processing by a normal program that develops another program code in the data area on the memory as unauthorized access. Thus, according to the present embodiment, it is possible to improve the detection accuracy of unauthorized access.

また、本実施形態によれば、リターンアドレスの指し示す先が関数の先頭でない場合であっても、不正アクセスを検出することができる。さらに、本実施形態では、単に、リターンアドレスの指し示す先の1つ前の命令がcall命令でない場合に不正アクセスが行われていると判定するのではない。そのため、call命令を用いずに関数呼び出しを行う正常なプログラムによる処理を不正アクセスとして誤検出することを防ぐことができる。したがって、本実施形態によれば、不正アクセスの検出精度を高めることが可能となる。   Further, according to the present embodiment, unauthorized access can be detected even when the destination indicated by the return address is not the beginning of the function. Furthermore, in the present embodiment, it is not simply determined that an unauthorized access has been performed when the instruction immediately preceding the return address is not a call instruction. For this reason, it is possible to prevent erroneous detection of processing by a normal program that calls a function without using a call instruction as unauthorized access. Therefore, according to the present embodiment, it is possible to improve the detection accuracy of unauthorized access.

また、本実施形態によれば、リターンアドレス取得部42は、バックトレースにより、スタック領域に格納されている複数のリターンアドレスを順次取得することができる。そして、順次取得されるリターンアドレスのそれぞれについて、図9に示したように、属性変更検出部44による処理と、不正アクセス検出部48による処理とが実行される。したがって、複数の関数が階層的に呼び出される構成となっている場合においても同様に、不正アクセスを検出することが可能となる。   Further, according to the present embodiment, the return address acquisition unit 42 can sequentially acquire a plurality of return addresses stored in the stack area by backtrace. Then, as shown in FIG. 9, the process by the attribute change detection unit 44 and the process by the unauthorized access detection unit 48 are executed for each return address acquired sequentially. Accordingly, even when a plurality of functions are called hierarchically, it is possible to detect unauthorized access in the same manner.

なお、本実施形態は、本発明の理解を容易にするためのものであり、本発明を限定して解釈するためのものではない。本発明は、その趣旨を逸脱することなく、変更/改良され得るととともに、本発明にはその等価物も含まれる。   Note that this embodiment is intended to facilitate understanding of the present invention and is not intended to limit the present invention. The present invention can be changed / improved without departing from the spirit thereof, and the present invention includes equivalents thereof.

10 情報機器
20 プロセッサ
22 メモリ
24 記憶装置
26 入力インタフェース
28 データインタフェース
30 通信インタフェース
32 表示装置
40 呼び出し検出部
42 リターンアドレス取得部
44 属性変更検出部
46 アドレス範囲記憶部
48 不正アクセス検出部
DESCRIPTION OF SYMBOLS 10 Information apparatus 20 Processor 22 Memory 24 Storage device 26 Input interface 28 Data interface 30 Communication interface 32 Display device 40 Call detection part 42 Return address acquisition part 44 Attribute change detection part 46 Address range storage part 48 Unauthorized access detection part

Claims (4)

コンピュータを、
所定の関数の呼び出しを検出する呼び出し検出部と、
前記関数の検出が行われた際に、スタック領域に格納されているリターンアドレスを取得するリターンアドレス取得部と、
前記検出された関数が、メモリ上の指定されたアドレス範囲の領域に実行可能属性を付与する関数であり、前記リターンアドレスの指し示す先の1つ前の命令が関数の呼び出し命令でない場合に、当該アドレス範囲をアドレス範囲記憶部に記憶する属性変更検出部と、
前記リターンアドレスが前記アドレス範囲記憶部に記憶されている前記アドレス範囲内である場合に、不正アクセスが行われていると判定する不正アクセス検出部と、
して機能させるためのプログラム。
Computer
A call detection unit for detecting a call to a predetermined function;
A return address acquisition unit for acquiring a return address stored in the stack area when the function is detected;
When the detected function is a function that assigns an executable attribute to an area in a specified address range on the memory, and the previous instruction pointed to by the return address is not a function call instruction, An attribute change detection unit for storing the address range in the address range storage unit;
An unauthorized access detection unit that determines that unauthorized access is performed when the return address is within the address range stored in the address range storage unit;
Program to make it function.
請求項1に記載のプログラムであって、
前記リターンアドレス取得部は、前記関数の検出が行われた際に、前記スタック領域に格納されている複数のリターンアドレスを順次取得し、
前記属性変更検出部は、前記順次取得されるリターンアドレスのそれぞれについて、前記検出された関数が、メモリ上の指定されたアドレス範囲の領域に実行可能属性を付与する関数であり、前記リターンアドレスの指し示す先の1つ前の命令が関数の呼び出し命令でない場合に、当該アドレス範囲を前記アドレス範囲記憶部に記憶し、
前記不正アクセス検出部は、前記順次取得されるリターンアドレスのそれぞれについて、前記リターンアドレスが前記アドレス範囲記憶部に記憶されている前記アドレス範囲内である場合に、不正アクセスが行われていると判定する、
プログラム。
The program according to claim 1,
The return address acquisition unit sequentially acquires a plurality of return addresses stored in the stack area when the function is detected,
The attribute change detection unit is a function in which, for each of the sequentially acquired return addresses, the detected function is a function that assigns an executable attribute to an area in a specified address range on the memory. If the previous instruction to be pointed to is not a function call instruction, the address range is stored in the address range storage unit,
The unauthorized access detection unit determines that unauthorized access has been performed for each of the sequentially acquired return addresses when the return address is within the address range stored in the address range storage unit. To
program.
所定の関数の呼び出しを検出する呼び出し検出部と、
前記関数の検出が行われた際に、スタック領域に格納されているリターンアドレスを取得するリターンアドレス取得部と、
前記検出された関数が、メモリ上の指定されたアドレス範囲の領域に実行可能属性を付与する関数であり、前記リターンアドレスの指し示す先の1つ前の命令が関数の呼び出し命令でない場合に、当該アドレス範囲をアドレス範囲記憶部に記憶する属性変更検出部と、
前記リターンアドレスが前記アドレス範囲記憶部に記憶されている前記アドレス範囲内である場合に、不正アクセスが行われていると判定する不正アクセス検出部と、
を備える情報機器。
A call detection unit for detecting a call to a predetermined function;
A return address acquisition unit for acquiring a return address stored in the stack area when the function is detected;
When the detected function is a function that assigns an executable attribute to an area in a specified address range on the memory, and the previous instruction pointed to by the return address is not a function call instruction, An attribute change detection unit for storing the address range in the address range storage unit;
An unauthorized access detection unit that determines that unauthorized access is performed when the return address is within the address range stored in the address range storage unit;
Information equipment equipped with.
コンピュータが、
所定の関数の呼び出しを検出し、
前記関数の検出が行われた際に、スタック領域に格納されているリターンアドレスを取得し、
前記検出された関数が、メモリ上の指定されたアドレス範囲の領域に実行可能属性を付与する関数であり、前記リターンアドレスの指し示す先の1つ前の命令が関数の呼び出し命令でない場合に、当該アドレス範囲をアドレス範囲記憶部に記憶し、
前記リターンアドレスが前記アドレス範囲記憶部に記憶されている前記アドレス範囲内である場合に、不正アクセスが行われていると判定する、
不正アクセス検出法方法。
Computer
Detect calls to a given function,
When the function is detected, the return address stored in the stack area is acquired,
When the detected function is a function that assigns an executable attribute to an area in a specified address range on the memory, and the previous instruction pointed to by the return address is not a function call instruction, Store the address range in the address range storage unit,
When the return address is within the address range stored in the address range storage unit, it is determined that unauthorized access has been performed.
Unauthorized access detection method.
JP2011281931A 2011-12-22 2011-12-22 Program, information device, and unauthorized access detection method Active JP4927231B1 (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP2011281931A JP4927231B1 (en) 2011-12-22 2011-12-22 Program, information device, and unauthorized access detection method

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP2011281931A JP4927231B1 (en) 2011-12-22 2011-12-22 Program, information device, and unauthorized access detection method

Publications (2)

Publication Number Publication Date
JP4927231B1 true JP4927231B1 (en) 2012-05-09
JP2013131157A JP2013131157A (en) 2013-07-04

Family

ID=46261511

Family Applications (1)

Application Number Title Priority Date Filing Date
JP2011281931A Active JP4927231B1 (en) 2011-12-22 2011-12-22 Program, information device, and unauthorized access detection method

Country Status (1)

Country Link
JP (1) JP4927231B1 (en)

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP5265061B1 (en) * 2012-05-11 2013-08-14 アンラブ,インコーポレイテッド Malicious file inspection apparatus and method
JP2015535997A (en) * 2012-09-28 2015-12-17 ヒューレット−パッカード デベロップメント カンパニー エル.ピー.Hewlett‐Packard Development Company, L.P. Application security inspection
CN111523115A (en) * 2019-02-02 2020-08-11 阿里巴巴集团控股有限公司 Information determination method, function calling method and electronic equipment
CN112100570A (en) * 2020-08-20 2020-12-18 北京智游网安科技有限公司 The processing method, intelligent terminal, and storage medium for the specified function to be hooked
CN112395603A (en) * 2019-08-15 2021-02-23 奇安信安全技术(珠海)有限公司 Vulnerability attack identification method and device based on instruction execution sequence characteristics and computer equipment

Families Citing this family (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20160300056A1 (en) * 2013-09-24 2016-10-13 Att Consulting Co., Ltd. Processor, Processing Device, and Method for Creating Program
JP6163678B2 (en) * 2013-12-26 2017-07-19 マカフィー, インコーポレイテッド General unpacking of program binaries
EP3087475A4 (en) 2013-12-26 2017-07-19 McAfee, Inc. Generic unpacking of program binaries
KR101445634B1 (en) * 2014-01-27 2014-10-06 주식회사 이글루시큐리티 Device and Method for detecting vulnerability attack in any program

Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2005157502A (en) * 2003-11-20 2005-06-16 Sony Corp Information processor and information processing method and computer program

Patent Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2005157502A (en) * 2003-11-20 2005-06-16 Sony Corp Information processor and information processing method and computer program

Cited By (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP5265061B1 (en) * 2012-05-11 2013-08-14 アンラブ,インコーポレイテッド Malicious file inspection apparatus and method
JP2015535997A (en) * 2012-09-28 2015-12-17 ヒューレット−パッカード デベロップメント カンパニー エル.ピー.Hewlett‐Packard Development Company, L.P. Application security inspection
US9438617B2 (en) 2012-09-28 2016-09-06 Hewlett Packard Enterprise Development Lp Application security testing
CN111523115A (en) * 2019-02-02 2020-08-11 阿里巴巴集团控股有限公司 Information determination method, function calling method and electronic equipment
CN111523115B (en) * 2019-02-02 2023-05-26 斑马智行网络(香港)有限公司 Information determining method, function calling method and electronic device
CN112395603A (en) * 2019-08-15 2021-02-23 奇安信安全技术(珠海)有限公司 Vulnerability attack identification method and device based on instruction execution sequence characteristics and computer equipment
CN112395603B (en) * 2019-08-15 2023-09-05 奇安信安全技术(珠海)有限公司 Vulnerability attack identification method, device and computer equipment based on instruction execution sequence characteristics
CN112100570A (en) * 2020-08-20 2020-12-18 北京智游网安科技有限公司 The processing method, intelligent terminal, and storage medium for the specified function to be hooked

Also Published As

Publication number Publication date
JP2013131157A (en) 2013-07-04

Similar Documents

Publication Publication Date Title
JP4927231B1 (en) Program, information device, and unauthorized access detection method
CA2856268C (en) Methods of detection of software exploitation
JP4572259B1 (en) Information device, program, and illegal program code execution prevention method
KR102383900B1 (en) Region identifying operation for identifying region of a memory attribute unit corresponding to a target memory address
CN103984538B (en) Application scenario identification method, power consumption management method, devices and terminal equipment
US7836430B2 (en) Reversing execution of instructions in a debugger
US7322029B2 (en) Method and system for recovering program code in a computer system
US8327100B2 (en) Execute only access rights on a Von Neuman architectures
JP6984710B2 (en) Computer equipment and memory management method
JP6189039B2 (en) Data processing apparatus and method using secure domain and low secure domain
US10691791B2 (en) Automatic unpacking of executables
Tang et al. Exploring control flow guard in windows 10
US9116621B1 (en) System and method of transfer of control between memory locations
CN107480476A (en) A kind of Android local layer compiling of instruction based on ELF infection virtualizes shell adding method
US10261895B2 (en) System and method for transferring execution of a computer program
EP2615551B1 (en) Abnormality inspection device, central processing unit, and abnormality inspection method
US8769498B2 (en) Warning of register and storage area assignment errors
KR102066580B1 (en) Program for injecting watermark into captured data and screen leak realisation service providing method
KR20170060815A (en) A Electronic Device And Method For Protecting The Kernel Space of the Memory
CN105988811B (en) Method and device for obtaining kernel control flow chart of operating system
CN108345789B (en) Method and device for recording memory fetch operation information
KR20140111942A (en) Electronic device, method and computer readable recording medium for stack analysis for dynamic librarie attack prevention
CN117725577A (en) A method and device for breaking through malware protection through memory management unit
JP2022048593A (en) Audit device, audit method, audit program. and audit system
JP5045934B2 (en) Information processing apparatus, emulation method and emulation program in information processing apparatus

Legal Events

Date Code Title Description
TRDD Decision of grant or rejection written
A975 Report on accelerated examination

Free format text: JAPANESE INTERMEDIATE CODE: A971005

Effective date: 20120125

A01 Written decision to grant a patent or to grant a registration (utility model)

Free format text: JAPANESE INTERMEDIATE CODE: A01

Effective date: 20120127

A01 Written decision to grant a patent or to grant a registration (utility model)

Free format text: JAPANESE INTERMEDIATE CODE: A01

A61 First payment of annual fees (during grant procedure)

Free format text: JAPANESE INTERMEDIATE CODE: A61

Effective date: 20120208

FPAY Renewal fee payment (event date is renewal date of database)

Free format text: PAYMENT UNTIL: 20150217

Year of fee payment: 3

R150 Certificate of patent or registration of utility model

Free format text: JAPANESE INTERMEDIATE CODE: R150

Ref document number: 4927231

Country of ref document: JP

Free format text: JAPANESE INTERMEDIATE CODE: R150

S531 Written request for registration of change of domicile

Free format text: JAPANESE INTERMEDIATE CODE: R313531

FPAY Renewal fee payment (event date is renewal date of database)

Free format text: PAYMENT UNTIL: 20150217

Year of fee payment: 3

R350 Written notification of registration of transfer

Free format text: JAPANESE INTERMEDIATE CODE: R350

S533 Written request for registration of change of name

Free format text: JAPANESE INTERMEDIATE CODE: R313533

R350 Written notification of registration of transfer

Free format text: JAPANESE INTERMEDIATE CODE: R350

R250 Receipt of annual fees

Free format text: JAPANESE INTERMEDIATE CODE: R250

S531 Written request for registration of change of domicile

Free format text: JAPANESE INTERMEDIATE CODE: R313531

S533 Written request for registration of change of name

Free format text: JAPANESE INTERMEDIATE CODE: R313533

R350 Written notification of registration of transfer

Free format text: JAPANESE INTERMEDIATE CODE: R350

R250 Receipt of annual fees

Free format text: JAPANESE INTERMEDIATE CODE: R250

R250 Receipt of annual fees

Free format text: JAPANESE INTERMEDIATE CODE: R250

R250 Receipt of annual fees

Free format text: JAPANESE INTERMEDIATE CODE: R250