JP2005032182A - Program, attack code extracting apparatus, and its method - Google Patents

Program, attack code extracting apparatus, and its method Download PDF

Info

Publication number
JP2005032182A
JP2005032182A JP2003273617A JP2003273617A JP2005032182A JP 2005032182 A JP2005032182 A JP 2005032182A JP 2003273617 A JP2003273617 A JP 2003273617A JP 2003273617 A JP2003273617 A JP 2003273617A JP 2005032182 A JP2005032182 A JP 2005032182A
Authority
JP
Japan
Prior art keywords
address
data
stack
code
input
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.)
Pending
Application number
JP2003273617A
Other languages
Japanese (ja)
Inventor
Junji Hamano
淳史 濱野
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.)
Sony Corp
Original Assignee
Sony Corp
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 Sony Corp filed Critical Sony Corp
Priority to JP2003273617A priority Critical patent/JP2005032182A/en
Publication of JP2005032182A publication Critical patent/JP2005032182A/en
Pending legal-status Critical Current

Links

Images

Landscapes

  • Storage Device Security (AREA)

Abstract

<P>PROBLEM TO BE SOLVED: To provide a program, an apparatus, and a method for extracting attack codes, which can automatically extract harmful attack codes that can be executed in computers by stack smashing attacks. <P>SOLUTION: When input of illegal data including attack codes is detected in an illegal data input detecting part 101, based on a specified pointer (i.e., a frame pointer) linked to an address on a stack in which return addresses to calling functions are stored, a return address that is rewritten by stack overflow is acquired in a beginning address specifying part 102. Based on the address, the beginning address of an attack code is specified. Thereby, without depending on a person, attack codes that are transmitted into a computer by a stack smashing attack can be automatically extracted. <P>COPYRIGHT: (C)2005,JPO&NCIPI

Description

本発明は、コンピュータに入力される不正な攻撃コードを抽出するプログラムとその抽出装置および抽出方法に係り、特に、スタックオーバーフローを利用した攻撃によって実行され得る攻撃コードを抽出するプログラムとその抽出装置および抽出方法に関するものである。   The present invention relates to a program for extracting an illegal attack code input to a computer, an extraction apparatus and an extraction method thereof, and in particular, a program for extracting an attack code that can be executed by an attack using stack overflow, an extraction apparatus for the same, and It relates to an extraction method.

現在、コンピュータのセキュリティに関する多くの問題が報告されている。最も多く報告されているものの一つに、バッファオーバーフローを利用した攻撃があり、その中でも特に、スタックのオーバーフローを利用するスタックスマッシング(stack smashing)と呼ばれる攻撃が数多く報告されている。   Currently, many problems related to computer security have been reported. One of the most reported is an attack using buffer overflow, and in particular, many attacks called stack smashing using stack overflow have been reported.

スタックオーバーフローは、次に述べるような、スタックの構造とC言語における配列の境界チェックの欠如とに起因して発生する。   Stack overflow occurs due to the structure of the stack and the lack of array boundary checking in the C language as described below.

スタックは、最後に置かれたオブジェクトが最初に取り除かれるLILO(last-in first-out)と呼ばれる性質を持つ抽象データ型である。C言語において関数の呼び出しに用いられるスタックは、一般に、スタック・ポインタ、スタック・フレーム、フレーム・ポインタから構成される。   The stack is an abstract data type having a property called LILO (last-in first-out) in which the last placed object is removed first. A stack used for calling a function in the C language is generally composed of a stack pointer, a stack frame, and a frame pointer.

スタック・ポインタは、スタックの先頭を指す。
スタック・フレームは、関数の引数や、ローカル変数、以前に積まれたスタック・フレームを復元するために必要なデータ(呼び出し元関数の命令ポインタ、呼び出し元関数のフレーム・ポインタなど)が所定の順序で格納されるメモリ領域である。
The stack pointer points to the top of the stack.
A stack frame contains function arguments, local variables, and data required to restore a previously loaded stack frame (caller function instruction pointer, caller function frame pointer, etc.) in the specified order. Is a memory area stored in

フレーム・ポインタは、スタック・フレーム内において基準となるアドレス位置を指示する。主として、ローカル変数を参照するための相対値として利用される。
すなわち、ローカル変数のサイズや引数の数が変化しても、ローカル変数が格納される先頭のアドレスは、このフレーム・ポインタによって指示される基準アドレスに対して相対的に一定の位置にある。したがって、フレーム・ポインタを取得することにより、ローカル変数へ容易にアクセスすることができる。
また、呼び出し元関数の命令ポインタやそのフレーム・ポインタなど、以前に積まれたスタック・フレームを復元するために必要なデータについても、この基準アドレスから相対的に一定の位置に格納される。したがって、フレーム・ポインタを取得することにより、これらのデータへのアクセスも容易になる。
The frame pointer indicates a reference address position in the stack frame. It is mainly used as a relative value for referring to a local variable.
That is, even if the size of the local variable and the number of arguments change, the head address where the local variable is stored is at a fixed position relative to the reference address indicated by the frame pointer. Therefore, local variables can be easily accessed by obtaining the frame pointer.
In addition, data necessary for restoring a previously stacked stack frame, such as an instruction pointer of the caller function and its frame pointer, is also stored in a relatively fixed position from this reference address. Therefore, access to these data is facilitated by obtaining the frame pointer.

関数の呼び出し時および戻り時におけるスタックの動作について、図16および図17を参照して説明する。   The stack operation at the time of function call and return will be described with reference to FIG. 16 and FIG.

図16は、C言語のソース・コードの一例を示す図である。
図16のソース・コードにおける行番号L1の関数‘function()’には、3つの整数の変数‘a’,‘b’,‘c’が引数として渡されている。また、関数‘function()’の内部では、文字型の配列‘buf’がローカル変数として定義されている(行番号L2)。この関数‘function()’がmain関数において呼び出されている(行番号L4、L5)。
FIG. 16 is a diagram illustrating an example of a C language source code.
In the function “function ()” of the line number L1 in the source code of FIG. 16, three integer variables “a”, “b”, and “c” are passed as arguments. In addition, inside the function “function ()”, a character type array “buf” is defined as a local variable (line number L2). This function 'function ()' is called in the main function (line numbers L4 and L5).

図17は、このようなソース・コードが実行された場合におけるスタックの状態の一例を図解した図である。   FIG. 17 is a diagram illustrating an example of a stack state when such source code is executed.

関数の呼び出しは、以下の手順で実行される。   The function call is executed in the following procedure.

(1)関数‘function()’の引数(‘a’〜‘c’)がスタックに積まれる。図17に示すように、‘c’、‘b’、‘a’の順でスタックに引数が積まれる。 (1) The arguments ('a' to 'c') of the function 'function ()' are stacked on the stack. As shown in FIG. 17, arguments are stacked on the stack in the order of ‘c’, ‘b’, and ‘a’.

(2)次いで、現在の命令ポインタ(実行すべき命令コードが格納されるメモリのアドレス)が戻りアドレス‘ret’としてスタックに積まれる。 (2) Next, the current instruction pointer (the address of the memory where the instruction code to be executed is stored) is loaded on the stack as the return address ‘ret’.

(3)更に、現在のフレーム・ポインタ‘FP’がスタックに積まれ、フレーム・ポインタ‘sfp’(saved frame pointer)として保存される。 (3) Further, the current frame pointer 'FP' is stacked on the stack and saved as a frame pointer 'sfp' (saved frame pointer).

(4)現在のスタック・ポインタ‘SP’が、現在のフレーム・ポインタ‘FP’にコピーされる。これにより、新しいフレーム・ポインタ‘FP’は、上述した戻りアドレス‘ret’を指す。 (4) The current stack pointer 'SP' is copied to the current frame pointer 'FP'. As a result, the new frame pointer ‘FP’ points to the return address ‘ret’ described above.

(5)最後に、ローカル変数‘buf’のメモリ領域を確保するため、スタック・ポインタ‘SP’が更に上位へ進められる。図17は、この時点におけるスタックの状態の一例を示している。 (5) Finally, in order to secure the memory area of the local variable “buf”, the stack pointer “SP” is further advanced. FIG. 17 shows an example of the state of the stack at this point.

関数の戻り時には、以下の動作が実行される。   When the function returns, the following operations are performed:

(1)現在のフレーム・ポインタ‘FP’がスタック・ポインタ‘SP’にコピーされる。これにより、新しいスタック・ポイン‘SP’は、戻りアドレス‘ret’を指す。 (1) The current frame pointer 'FP' is copied to the stack pointer 'SP'. Thus, the new stack point 'SP' points to the return address 'ret'.

(2)また、スタックに積まれていた以前のフレーム・ポインタ‘SFP’がフレーム・ポインタ‘FP’にコピーされる。これにより、フレーム・ポインタ‘FP’が呼び出し元の関数のスタック・フレームに戻る。 (2) Also, the previous frame pointer 'SFP' that was loaded on the stack is copied to the frame pointer 'FP'. As a result, the frame pointer 'FP' returns to the stack frame of the calling function.

(3)そして、スタック・ポインタSPによって指示されている戻りアドレス‘ret’がスタックから読み出され、命令ポインタにセットされる。これにより、呼び出し元の関数へ処理がジャンプする。以降、スタックに積まれていた引数(‘a’〜‘c’)が順に読み出されることによって、スタック・ポインタ‘SP’は元の状態に戻る。 (3) The return address 'ret' indicated by the stack pointer SP is read from the stack and set in the instruction pointer. As a result, the process jumps to the calling function. Thereafter, the stack pointer ‘SP’ returns to the original state by sequentially reading the arguments (‘a’ to ‘c’) stacked on the stack.

図18は、このような構造のスタックにオーバーフローが発生した場合におけるスタックの状態の一例を図解した図である。   FIG. 18 is a diagram illustrating an example of a stack state when an overflow occurs in the stack having such a structure.

ローカル変数としての配列‘buf’に、割り当てを超えたデータ(図18の例では、終端文字を含めて10個を超える文字型のデータ)が入力されると、図18の矢印に示すように、配列bufより上位のアドレスに格納されているデータが、入力データによって上書きされる。このように、割り当てを超えたデータが入力されることによって、スタック上の保持すべきデータが上書きされてしまうことを、スタックオーバーフローと呼んでいる。   When data exceeding the allocation (in the example of FIG. 18, more than 10 character-type data including the terminal character) is input to the array 'buf' as a local variable, as shown by the arrow in FIG. , Data stored at an address higher than the array buf is overwritten by the input data. In this way, when data exceeding the allocation is input, data to be held on the stack is overwritten, which is called stack overflow.

図19は、スタックオーバーフローを利用したスタックスマッシング攻撃によって、攻撃コードが実行される様子を図解した図である。   FIG. 19 is a diagram illustrating a state in which an attack code is executed by a stack smashing attack using stack overflow.

スタックスマッシング攻撃では、スタックオーバーフローを引き起こす入力データの中に、有害な攻撃コードが挿入される。すなわち、図19に示すように、スタックオーバーフローによって上書きされたメモリ領域に、攻撃コードが書き込まれる。更に、この入力データの中には、攻撃コードを指示するアドレスが含まれており、このアドレスによって、スタックに格納されている戻りアドレス‘ret’が書き換えられる。そのため、関数の戻り時において、本来実行されるべき命令コードの代わりに、攻撃コードが実行されてしまう。   In stack smashing attacks, malicious attack code is inserted into the input data that causes stack overflow. That is, as shown in FIG. 19, the attack code is written in the memory area overwritten by the stack overflow. Further, this input data includes an address indicating an attack code, and the return address ‘ret’ stored in the stack is rewritten by this address. Therefore, when the function returns, the attack code is executed instead of the instruction code that should be executed originally.

例えばUNIX(登録商標)の場合、多くのデーモンプロセスはroot権限で実行されている。そこで、例えば攻撃コードとして‘exec(/bin/sh)’を利用し、デーモンプロセスに対してスタックスマッシング攻撃を行なうことにより、攻撃者はそのホストでのroot権限を獲得できる。   For example, in the case of UNIX (registered trademark), many daemon processes are executed with root authority. Therefore, for example, by using “exec (/ bin / sh)” as an attack code and performing a stack smashing attack on the daemon process, the attacker can acquire the root authority on the host.

このようなスタックスマッシング攻撃に対抗するため、現在幾つかの技術が提案されており、これらは、大きく以下の3つに分類される。   In order to counter such a stack smashing attack, several technologies are currently proposed, and these are roughly classified into the following three types.

(1)スタック上の情報が上書きされることを事前に検出する方法
(2)スタック上の情報が上書きされたことを検出する方法
(3)メモリ上のコードの実行可否を判定する方法
(1) Method for detecting in advance that information on stack is overwritten (2) Method for detecting that information on stack has been overwritten (3) Method for determining whether or not code on memory is executable

以下では、これらの従来技術について説明する。   Below, these prior arts are demonstrated.

(1)スタック上の情報が上書きされることを事前に検出する方法 (1) Method for detecting in advance that information on the stack is overwritten

[非特許文献1]には、ソース・コードのライブラリを置き換える方法として、libsafeと呼ばれる方法が提案されている。   [Non-Patent Document 1] proposes a method called libsafe as a method for replacing a library of source code.

libsafeでは、スタックオーバーフローを引き起こす可能性のあるライブラリ関数の呼び出しを横取り(intercept)し、関数の引数がスタックのメモリ範囲内に収まるか否かを検査する。そして、正常な場合には適当なライブラリ関数を呼び出し、異常な場合にはその旨を通知するメッセージを残してプログラムを終了することにより、スタックオーバーフローを防止する。   In libsafe, a library function call that may cause a stack overflow is intercepted, and it is checked whether the argument of the function falls within the memory range of the stack. When normal, an appropriate library function is called, and when abnormal, a message notifying that is left and the program is terminated to prevent stack overflow.

C言語における標準ライブラリ(libc)の関数‘strcpy()’を例にして、libsafeの動作を説明する。
図20は、libsafeのライブラリをリンクしたあるプロセスでのメモリの状態を示す図である。
The operation of libsafe will be described by taking the function “strcpy ()” of the standard library (libc) in C language as an example.
FIG. 20 is a diagram illustrating a state of a memory in a certain process linked with a library of libsafe.

プログラムが‘strcpy()’を呼び出すと、標準ライブラリ(libc)ではなく、libsafeのライブラリに実装されている‘strcpy()’が実行される(F1)。これはライブラリのロードの順番を工夫することにより実現される。   When the program calls ‘strcpy ()’, ‘strcpy ()’ implemented in the library of libsafe is executed instead of the standard library (libc) (F <b> 1). This is achieved by devising the order of library loading.

libsafeの‘strcpy()’は、まず、コピー元の文字列(‘src’)の長さとコピー先のバッファ長の上限(すなわちスタック・フレーム長)を計算し、コピー元の文字列がコピー先のバッファ長の上限を越えないかを検査する。
上限を越えない場合、libsafeの‘strcpy()’は、標準ライブラリ(libc)の関数‘memcpy()’を呼び出してこれを実行し(F2,F3)、メイン関数に戻る(F4)。
一方、上限を越えると判定された場合、libsafeの‘strcpy()’はシステムのログ・ファイル(syslog)にメッセージを残し、プログラムを終了させる。
このように、libsafeでは、スタックオーバーフローの発生を事前に検出することにより、スタックスマッシング攻撃を防いでいる。
The libsafe 'strcp ()' first calculates the length of the copy source character string ('src') and the upper limit of the copy destination buffer length (that is, the stack frame length), and the copy source character string is the copy destination. Check whether the upper limit of the buffer length is exceeded.
If the upper limit is not exceeded, libsafe 'strcpy ()' calls the function 'memcpy ()' of the standard library (libc) and executes it (F2, F3), and returns to the main function (F4).
On the other hand, if it is determined that the upper limit is exceeded, libsafe's “strcpy ()” leaves a message in the system log file (syslog) and terminates the program.
Thus, in libsafe, stack smashing attacks are prevented by detecting the occurrence of stack overflow in advance.

(2)スタック上の情報が上書きされたことを検出する方法 (2) Method for detecting that information on the stack has been overwritten

[非特許文献2]には、コンパイラを拡張する方法として、StackGuardと呼ばれる方法が提案されている。
StackGuardでは、図21に示されるように、戻りアドレス‘ret’とローカル変数‘buf’との間に‘Canary Word’と呼ばれる値を挿入する。そして、関数戻り時にこの値をチェックし、スタックオーバーフローの上書きによって値が変更されている場合、スタックスマッシング攻撃が行なわれたものとしてプロセスを終了させる(図22)。
[Non-Patent Document 2] proposes a method called StackGuard as a method for extending a compiler.
In StackGuard, as shown in FIG. 21, a value called “Canary Word” is inserted between the return address “ret” and the local variable “buf”. Then, this value is checked when the function returns, and if the value has been changed by overwriting the stack overflow, the process is terminated assuming that a stack smashing attack has been performed (FIG. 22).

また、[特許文献1]においても、Stack Smashing Protectorと呼ばれる、上述のStackGuardと同様な技術が開示されている。[特許文献1]によれば、関数戻り時に、スタックのプレヴィアス・フレーム・ポインタ(図17におけるフレーム・ポインタ‘sfp’に相当する)と配列(図17における配列‘buf’に相当する)との間にガード変数を格納し、その有効性を確認することにより、スタックスマッシング攻撃を防止する。   [Patent Document 1] also discloses a technique called “Stack Smashing Protector” similar to the above-mentioned StackGuard. According to [Patent Document 1], when a function returns, the stack's previous frame pointer (corresponding to the frame pointer 'sfp' in FIG. 17) and the array (corresponding to the array 'buf' in FIG. 17) Prevents stack smashing attacks by storing guard variables between them and checking their effectiveness.

(3)メモリ上のコードの実行可否を判定する方法 (3) A method for determining whether or not the code on the memory can be executed

オペレーティング・システムを拡張する方法として、インターネット<URL: http://www.openwall.com/linux/>において開示されている、non−executable stackと呼ばれる方法や、インターネット<URL: http://pageexec.virtualave.net/>において開示されている、PaXと呼ばれる方法が存在する。   As a method for extending the operating system, a method called non-executable stack, disclosed in the Internet <URL: http://www.openwall.com/linux/>, or the Internet <URL: http: // pageexec There is a method called PaX, disclosed in .virtualave.net />.

non−executable stackの方法では、スタックスマッシング攻撃において攻撃コードがスタック上に置かれることに着目し、メモリ上のスタックのページにおいて、CPUによる命令の実行が許可されないように、カーネルを変更している。スタックスマッシング攻撃によりスタック上に置かれた攻撃コードが実行された場合、ページ違反(page fault)としてプロセスを停止させる。   In the non-executable stack method, focusing on the fact that attack code is placed on the stack in a stack smashing attack, the kernel is changed so that execution of instructions by the CPU is not permitted on the page of the stack on the memory. . When an attack code placed on the stack is executed by a stack smashing attack, the process is stopped as a page fault.

一方、PaXの方法では、スタックだけでなく全てのデータページにおいてCPUによる命令実行の許可/不許可をマークできるように、カーネルを変更している。   On the other hand, in the PaX method, the kernel is changed so that the instruction execution permission / non-permission of the CPU can be marked not only in the stack but in all data pages.

何れの方法においても、スタック上に置かれたコードを実行できなくすることにより、スタックスマッシング攻撃を防止している。   In either method, stack smashing attacks are prevented by making it impossible to execute code placed on the stack.

以上述べた、スタックスマッシング攻撃を防止する3つの方法とは別に、[特許文献2]においては、既知や未知のコンピュータウィルスの検索・駆除を行なう技術が開示されている。   In addition to the three methods for preventing the stack smashing attack described above, [Patent Document 2] discloses a technique for searching and removing known and unknown computer viruses.

[特許文献2]の技術では、ウィルスが存在する仮想のコンピュータ環境を作成して、感染を誘発するためのバイト列からなる複数の対象を提供し、検査対象に付着している可能性のあるウィルスを誘引して、この複数の対象にウィルスを感染させる。そして、感染を誘発させた後の複数の対象と、もともと提供された複数の対象とを比較し、これらに変化があるかどうかを調べることにより、ウィルスが含まれているか否かを決定する。また、この比較結果からウィルスに関する情報や知識を抽出し、ウィルスの駆除を行なう。更に、ウィルスによって変更されたキー情報を、このウィルスに関して抽出した情報や知識、感染したバイト列に対してウィルスが行なった修正に基づき修正する。
Arash Baratloo,他2名、 ‘Transparent Run-Time Defense Against Stack Smashing Attacks’、 In Proceedings of 2000 USENIX Annual Technical Conference、(米国)、 2000年 Crispin Cowan,他8名、 ‘Automatic Adaptive Detection and Prevention of Buffer-Overflow Attacks’、 In Proceedings of the 7th USENIX Security Symposium、(米国)、 1998年 特開2001−216161号公報 特開2002−342106号公報
In the technique of [Patent Document 2], there is a possibility that a virtual computer environment in which a virus is present is created, a plurality of objects composed of byte sequences for inducing infection are provided, and the object is attached to the inspection object. Invite the virus to infect these multiple subjects with the virus. Then, it is determined whether or not a virus is contained by comparing a plurality of subjects after inducing infection with a plurality of originally provided subjects and examining whether or not there is any change. In addition, virus information and knowledge are extracted from the comparison results to remove the virus. Further, the key information changed by the virus is corrected based on the information and knowledge extracted about the virus and the correction made by the virus on the infected byte string.
Arash Baratloo, 2 others, 'Transparent Run-Time Defense Against Stack Smashing Attacks', In Proceedings of 2000 USENIX Annual Technical Conference, (USA), 2000 Crispin Cowan, 8 others, 'Automatic Adaptive Detection and Prevention of Buffer-Overflow Attacks', In Proceedings of the 7th USENIX Security Symposium, (USA), 1998 JP 2001-216161 A JP 2002-342106 A

ところで、数多くの被害報告がなされている上述したスタックスマッシング攻撃に対処するためには、その攻撃内容を詳しく分析することが必須であり、そのためには、攻撃者が送り込んできた攻撃コードを抽出して調べなくてはならない。   By the way, in order to deal with the above-described stack smashing attack, for which many damage reports have been made, it is indispensable to analyze the details of the attack, and for that purpose, the attack code sent by the attacker is extracted. I have to investigate.

しかしながら、スタックスマッシング攻撃に対抗する上述した3つの方法は、何れもスタックオーバーフローの発生や、禁止されたアドレスの命令コードの実行を検出して、プロセスを停止または終了させるのみであり、攻撃コードを抽出することに関しては何ら手立てを与えるものではない。   However, the above three methods to counter the stack smashing attack only detect the occurrence of stack overflow or the execution of the instruction code of the prohibited address, and stop or terminate the process. There is no way to extract it.

そのため、攻撃コードがいかなるものかを知るためには、人手で攻撃内容を分析しなくてはならず、それには多大な時間とコストが要求されるという不利益がある。   Therefore, in order to know what the attack code is, it is necessary to manually analyze the attack contents, which has the disadvantage of requiring a great deal of time and cost.

また、[特許文献2]に開示される技術では、ウィルスが感染する対象のバイト列をある瞬間保持しておき、感染を誘発させた後の感染対象のバイト列とこれを比較することによりウィルス感染を判断する。
しかしながら、スタックスマッシング攻撃は動作中のプロセスに対する攻撃であり、動作中のプロセスのメモリの状態は逐一変化しているので、[特許文献2]に開示される技術のように、以前のある瞬間のバイト列と感染を誘発させた後の感染対象のバイト列との比較を行なうことは不可能である。すなわち、この方法では、スタックスマッシング攻撃を利用したコンピュータウィルスの検索・駆除、ならびに攻撃コードの抽出を行なうことはできない。
In the technique disclosed in [Patent Document 2], a byte string to be infected with a virus is held for a certain moment, and the virus string is compared with the byte string to be infected after the infection is induced. Determine infection.
However, the stack smashing attack is an attack on the running process, and the state of the memory of the running process changes one by one. Therefore, as in the technique disclosed in [Patent Document 2], a certain moment in the past. It is impossible to compare the byte sequence with the byte sequence to be infected after inducing infection. That is, with this method, it is not possible to search for and remove a computer virus using a stack smashing attack and extract an attack code.

本発明はかかる事情に鑑みてなされたものであり、その目的は、スタックのオーバーフローを利用した攻撃によりコンピュータにおいて実行され得る有害な攻撃コードを効率的に抽出することができるプログラムと、攻撃コード抽出装置および方法を提供することにある。   The present invention has been made in view of such circumstances, and an object thereof is a program capable of efficiently extracting harmful attack codes that can be executed in a computer by an attack utilizing stack overflow, and attack code extraction. It is to provide an apparatus and method.

上記の目的を達成するため、本発明の第1の観点のプログラムは、攻撃コードを含む不正データの入力によってスタックにオーバーフローを引き起こし、上記オーバーフローによって、スタックに格納される呼び出し元関数のコードの戻りアドレスを上記攻撃コードの開始アドレスに書き換えることにより、上記攻撃コードを実行させることが可能なコンピュータに、上記不正データの入力を検知する第1のステップと、上記第1のステップにおいて上記不正データの入力が検知された場合、上記不正データの入力による上記オーバーフローで書き換えられた上記戻りアドレスに基づいて、上記攻撃コードの開始アドレスを特定する第2のステップとを有する処理を実行させる。   In order to achieve the above object, the program according to the first aspect of the present invention causes an overflow in the stack due to the input of illegal data including attack code, and returns the code of the calling function stored in the stack due to the overflow. By rewriting the address to the start address of the attack code, a first step of detecting the input of the illegal data to a computer capable of executing the attack code, and in the first step, When an input is detected, a process including a second step of specifying a start address of the attack code is executed based on the return address rewritten by the overflow due to the input of the illegal data.

本発明の第1の観点によると、上記不正データの入力が検知された場合、上記不正データの入力による上記オーバーフローで書き換えられた上記戻りアドレスに基づいて、上記攻撃コードの開始アドレスが特定される。   According to the first aspect of the present invention, when the input of the illegal data is detected, the start address of the attack code is specified based on the return address rewritten by the overflow caused by the input of the illegal data. .

好適には、上記第2のステップにおいて、上記コンピュータの所定のレジスタに格納されるポインタであって、上記戻りアドレスが格納されるスタック上のアドレスに関連付けられたポインタに基づいて、上記書き換えられた戻りアドレスを取得する。上記ポインタは、例えば、フレーム・ポインタやスタック・ポインタであっても良い。   Preferably, in the second step, the pointer is stored in a predetermined register of the computer and is rewritten based on a pointer associated with an address on the stack in which the return address is stored. Get the return address. The pointer may be a frame pointer or a stack pointer, for example.

また、上記第1のステップにおいて上記不正データの入力が検知された後に新たな関数が呼び出された場合、上記第2のステップにおいて、上記コンピュータの所定のレジスタに格納されるポインタであって、呼び出し元関数のスタック・フレームにおいて基準となるアドレスを指示するポインタが格納されるスタック上のアドレスに関連付けられたポインタに基づいて、呼び出し元関数の上記基準アドレスを取得し、取得した上記基準アドレスに基づいて、上記書き換えられた戻りアドレスを取得しても良い。
上記攻撃検知後に呼び出される関数が複数の場合には、上記第2のステップにおいて、取得した上記基準アドレスに基づいて、更に上位の呼び出し元関数のスタック・フレームにおける上記基準アドレスを取得する処理を反復し、上記反復処理の結果として取得される上記基準アドレスに基づいて、上記書き換えられた戻りアドレスを取得しても良い。
これにより、上記不正データの入力検知後に関数が呼び出されることによって、上記オーバーフローを生じたスタック・フレーム上に別のスタック・フレームが積み重ねられた状態でも、上記基準アドレスを辿って上記書き換えられた戻りアドレスが取得される。
In addition, when a new function is called after the input of the illegal data is detected in the first step, a pointer stored in a predetermined register of the computer in the second step The reference address of the caller function is obtained based on the pointer associated with the address on the stack in which the pointer indicating the reference address in the stack frame of the original function is stored, and based on the obtained reference address Thus, the rewritten return address may be acquired.
When there are a plurality of functions to be called after the attack is detected, in the second step, the process of acquiring the reference address in the stack frame of a higher-level caller function is repeated based on the acquired reference address The rewritten return address may be acquired based on the reference address acquired as a result of the iterative process.
As a result, even if another stack frame is stacked on the stack frame in which the overflow has occurred by calling a function after detecting the input of the invalid data, the rewritten return is performed by following the reference address. An address is obtained.

また、本発明の第1の観点のプログラムは、上記第1のステップにおいて上記不正データの入力が検知された場合、上記不正データの入力によって上記オーバーフローが引き起こされたメモリ領域のデータを取得する第4のステップと、上記第2のステップにおいて特定された上記攻撃コードの開始アドレスと、上記第4のステップにおいて取得されたデータとに応じて、上記攻撃コードが格納されるアドレス範囲を特定する第5のステップとを有しても良い。
これにより、上記不正データの入力が検知された場合、上記オーバーフローが引き起こされたメモリ領域のデータが取得され、この取得されたデータと、上記第2のステップにおいて特定された上記攻撃コードの開始アドレスとに応じて、上記攻撃コードが格納されるアドレス範囲が特定される。
The program according to the first aspect of the present invention obtains data in a memory area where the overflow is caused by the input of the illegal data when the input of the illegal data is detected in the first step. 4, the address range for storing the attack code is determined according to the start address of the attack code specified in the second step and the data acquired in the fourth step. 5 steps may be included.
Thereby, when the input of the illegal data is detected, the data of the memory area where the overflow is caused is acquired, and the acquired data and the start address of the attack code specified in the second step are acquired. In response, the address range in which the attack code is stored is specified.

また、本発明の第1の観点のプログラムは、上記第2のステップにおいて上記攻撃コードの開始アドレスが特定された場合、少なくとも、当該特定された開始アドレスに関する情報、または、当該開始アドレスより格納される攻撃コードに関する情報を含んだ所定の攻撃通知情報を生成する第7のステップを有しても良い。   In addition, when the start address of the attack code is specified in the second step, the program according to the first aspect of the present invention is stored at least from information related to the specified start address or from the start address. There may be a seventh step of generating predetermined attack notification information including information on the attack code.

本発明の第2の観点のプログラムは、上記コンピュータに、予め設定されたメモリ領域のデータが実行すべき命令コードとして上記コンピュータに取得されたか否かを検知する第1のステップと、上記第1のステップにおいて上記命令コードの取得が検知された場合、上記コンピュータの所定のレジスタに格納される、実行すべき命令コードのアドレスを指示するポインタに基づいて、上記攻撃コードの開始アドレスを特定する第2のステップとを有する処理を実行させる。   A program according to a second aspect of the present invention includes a first step of detecting whether or not data stored in a memory area set in advance is acquired by the computer as an instruction code to be executed; When the acquisition of the instruction code is detected in the step, the attack code start address is specified based on a pointer stored in a predetermined register of the computer and indicating the instruction code address to be executed. A process having two steps is executed.

本発明の第2の観点によると、予め設定されたメモリ領域のデータが実行すべき命令コードとして上記コンピュータに取得されたことが検知された場合、上記コンピュータの所定のレジスタに格納される、実行すべき命令コードのアドレスを指示するポインタに基づいて、上記攻撃コードの開始アドレスが特定される。   According to a second aspect of the present invention, when it is detected that data in a preset memory area is acquired by the computer as an instruction code to be executed, the execution is stored in a predetermined register of the computer Based on the pointer indicating the address of the instruction code to be executed, the start address of the attack code is specified.

本発明の第3の観点の攻撃コード抽出装置は、上記コンピュータへの上記不正データの入力を検知する不正データ入力検知手段と、上記不正データ入力検知手段において上記不正データの入力が検知された場合、上記不正データの入力による上記オーバーフローで書き換えられたスタックに格納される上記戻りアドレスに基づいて、上記攻撃コードの開始アドレスを特定する開始アドレス特定手段とを有する。   An attack code extraction device according to a third aspect of the present invention includes an unauthorized data input detection unit that detects an input of the unauthorized data to the computer, and an input of the unauthorized data detected by the unauthorized data input detection unit. Start address specifying means for specifying a start address of the attack code based on the return address stored in the stack rewritten by the overflow caused by the input of the illegal data.

本発明の第3の観点によると、上記不正データ入力検知手段において上記不正データの入力が検知された場合、上記開始アドレス特定手段において、上記不正データの入力による上記オーバーフローで書き換えられたスタックに格納される上記戻りアドレスに基づいて、上記攻撃コードの開始アドレスが特定される。   According to a third aspect of the present invention, when the illegal data input detecting means detects the input of the illegal data, the start address specifying means stores it in the stack rewritten by the overflow caused by the illegal data input. The start address of the attack code is specified based on the return address.

本発明の第4の観点は、予め設定されたメモリ領域のデータが実行すべき命令コードとして上記コンピュータに取得されたか否かを検知する命令コード取得検知手段と、上記命令コード取得検知手段において上記命令コードの取得が検知された場合、上記コンピュータの所定のレジスタに格納される、実行すべき命令コードのアドレスを指示するポインタに基づいて、上記攻撃コードの開始アドレスを特定する開始アドレス特定手段とを有する。   According to a fourth aspect of the present invention, there is provided an instruction code acquisition detecting means for detecting whether or not data in a preset memory area is acquired by the computer as an instruction code to be executed; Start address specifying means for specifying a start address of the attack code based on a pointer stored in a predetermined register of the computer and indicating an address of the instruction code to be executed, when acquisition of the instruction code is detected; Have

本発明の第4の観点によると、上記命令コード取得検知手段において上記命令コードの取得が検知された場合、上記開始アドレス特定手段において、上記コンピュータの所定のレジスタに格納される、実行すべき命令コードのアドレスを指示するポインタに基づいて、上記攻撃コードの開始アドレスが特定される。   According to a fourth aspect of the present invention, an instruction to be executed is stored in a predetermined register of the computer in the start address specifying means when the instruction code acquisition detecting means detects the acquisition of the instruction code. Based on the pointer indicating the address of the code, the start address of the attack code is specified.

本発明の第5の観点は、上記コンピュータへの上記不正データの入力を検知する第1の工程と、上記第1の工程において上記不正データの入力が検知された場合、上記不正データの入力による上記オーバーフローで書き換えられたスタックに格納される上記戻りアドレスに基づいて、上記攻撃コードの開始アドレスを特定する第2の工程とを有する。   According to a fifth aspect of the present invention, there is provided a first step of detecting an input of the unauthorized data to the computer, and an input of the unauthorized data when the input of the unauthorized data is detected in the first step. And a second step of specifying a start address of the attack code based on the return address stored in the stack rewritten by the overflow.

本発明の第6の観点は、予め設定されたメモリ領域のデータが実行すべき命令コードとして上記コンピュータに取得されたか否かを検知する第1の工程と、上記命令コード取得検知手段において上記命令コードの取得が検知された場合、上記コンピュータの所定のレジスタに格納される、実行すべき命令コードのアドレスを指示するポインタに基づいて、上記攻撃コードの開始アドレスを特定する第2の工程とを有する。   According to a sixth aspect of the present invention, there is provided a first step of detecting whether or not data in a preset memory area is acquired by the computer as an instruction code to be executed, and the instruction code acquisition detecting means includes the instruction A second step of specifying a start address of the attack code based on a pointer indicating an address of an instruction code to be executed, which is stored in a predetermined register of the computer when a code acquisition is detected; Have.

本発明によれば、スタックのオーバーフローを利用した攻撃によりコンピュータにおいて実行され得る有害な攻撃コードを効率的に抽出できる。   ADVANTAGE OF THE INVENTION According to this invention, the harmful attack code | cord | chord which can be executed in a computer by the attack using a stack overflow can be extracted efficiently.

以下、本発明の5つの実施形態を述べる。   Hereinafter, five embodiments of the present invention will be described.

<第1の実施形態>
図1は、本発明の実施形態に係るコンピュータの構成の一例を示すブロック図である。
<First Embodiment>
FIG. 1 is a block diagram showing an example of the configuration of a computer according to an embodiment of the present invention.

図1に示すコンピュータは、CPU10と、記憶装置20と、入出力部30と、プログラムメモリ40と、RAM50とを有する。   The computer shown in FIG. 1 includes a CPU 10, a storage device 20, an input / output unit 30, a program memory 40, and a RAM 50.

CPU10は、プログラムメモリ40に格納される本実施形態に係るプログラムを読み出し、これに基づいて所定の処理を実行する。   The CPU 10 reads the program according to the present embodiment stored in the program memory 40 and executes a predetermined process based on the program.

ここでは例として、CPU10は、インテル社(米国)において開発されたIA−32と称されるアーキテクチャを有するものとする。IA−32アーキテクチャのプロセッサは、演算処理に用いる種々のレジスタを有しており、スタックの処理に係わるレジスタとしては、ESPレジスタ11、EBPレジスタ12、およびEIPレジスタ13を有する。(図4参照)。   Here, as an example, the CPU 10 is assumed to have an architecture called IA-32 developed by Intel Corporation (USA). The processor of the IA-32 architecture has various registers used for arithmetic processing, and has an ESP register 11, an EBP register 12, and an EIP register 13 as registers related to stack processing. (See FIG. 4).

ESPレジスタ11は、スタック・ポインタを格納する。
EBPレジスタ12は、フレーム・ポインタを格納する。このフレーム・ポインタは、呼び出し元関数の戻りアドレスが格納されているスタック上のアドレスを指示する。
EIPレジスタ13は、命令ポインタを格納する。
The ESP register 11 stores a stack pointer.
The EBP register 12 stores a frame pointer. This frame pointer points to the address on the stack where the return address of the caller function is stored.
The EIP register 13 stores an instruction pointer.

記憶装置20は、CPU10の処理過程において利用されるデータや、処理結果のデータを記憶する。   The storage device 20 stores data used in the process of the CPU 10 and processing result data.

入出力部30は、CPU10の処理過程において利用されるデータを入力する処理や、処理結果のデータを出力する処理を行なう。
入出力部30には、例えば、LAN(local area network)やインターネットなどのネットワークを介して他の機器との間でデータをやり取りするネットワーク・インターフェース装置や、磁気ディスク、光ディスク、ICカードなどの可搬性を有する記録媒体に対してデータの書き込みや読み出しを行なう装置、キーボードやマウスなどのユーザ・インターフェース装置、ディスプレイ装置などが含まれる。
The input / output unit 30 performs a process of inputting data used in the process of the CPU 10 and a process of outputting process result data.
The input / output unit 30 may be, for example, a network interface device that exchanges data with other devices via a local area network (LAN) or the Internet, a magnetic disk, an optical disk, an IC card, or the like. Examples include a device for writing and reading data on a portable recording medium, a user interface device such as a keyboard and a mouse, a display device, and the like.

プログラムメモリ40は、後述する本実施形態に係るプログラムを記憶する。   The program memory 40 stores a program according to this embodiment to be described later.

RAM50は、CPU10による処理の過程で利用するプログラム・コードやデータを一時的に記憶する。スタックを構成するデータは、このRAM50における所定のスタック領域に格納される。   The RAM 50 temporarily stores program codes and data used in the course of processing by the CPU 10. Data constituting the stack is stored in a predetermined stack area in the RAM 50.

なお、これらのユニット(CPU10、記憶装置20、入出力部30、プログラムメモリ40、RAM50)は、図1の例において、共通のバス60に接続される。各ユニットの間におけるデータの受け渡しは、CPU10の制御の基に、このバス60を介して行なわれる。   These units (CPU 10, storage device 20, input / output unit 30, program memory 40, and RAM 50) are connected to a common bus 60 in the example of FIG. Data is transferred between the units via the bus 60 under the control of the CPU 10.

図2は、本実施形態に係るプログラムの機能的な構成の一例を示すブロック図である。
本実施形態に係るプログラムは、不正データ入力検知部101と、開始アドレス特定部102と、通知情報生成部103とを有する。
FIG. 2 is a block diagram illustrating an example of a functional configuration of the program according to the present embodiment.
The program according to the present embodiment includes an illegal data input detection unit 101, a start address specifying unit 102, and a notification information generation unit 103.

[不正データ入力検知部101]
不正データ入力検知部101は、スタックにオーバーフローを引き起こす不正なデータの入力を検知する。
[Incorrect data input detection unit 101]
The illegal data input detection unit 101 detects illegal data input that causes an overflow in the stack.

例えば、不正データ入力検知部101は、新たな関数が呼び出された場合、スタック・フレーム中の所定のアドレス(フレーム・ポインタと戻りアドレスとの間や、ローカル変数とフレーム・ポインタとの間など)に、所定値の上書き検出用のデータを挿入する。この値は、例えば、図示しない乱数生成部において生成される乱数を用いて設定する。そして、呼び出し元の関数へ戻る場合に、この所定のアドレスに格納されるデータと上記所定値とを比較し、上書き検出用のデータが変化しているか否かを調べる。この結果、上書き検出用のデータが変化している場合に、スタックオーバーフローが発生したと判定する。   For example, when a new function is called, the invalid data input detection unit 101 has a predetermined address in the stack frame (between the frame pointer and the return address, or between the local variable and the frame pointer). In addition, data for overwriting detection of a predetermined value is inserted. This value is set using, for example, a random number generated by a random number generator (not shown). When returning to the calling function, the data stored at the predetermined address is compared with the predetermined value to check whether the data for overwriting detection has changed. As a result, when the data for overwriting detection has changed, it is determined that a stack overflow has occurred.

不正なデータの入力が検知されると、不正データ入力検知部101は、開始アドレス特定部102にその旨を通知する。   When the input of unauthorized data is detected, the unauthorized data input detection unit 101 notifies the start address specifying unit 102 to that effect.

[開始アドレス特定部102]
開始アドレス特定部102は、不正データ入力検知部101より不正データの入力が通知された場合、この不正データの入力により生じるスタックオーバーフローによって書き換えられた、呼び出し元関数の戻りアドレスに基づいて、入力された不正データに含まれる攻撃コードの開始アドレスを特定する。
[Start address specifying unit 102]
When the input of illegal data is notified from the illegal data input detection unit 101, the start address specifying unit 102 is input based on the return address of the caller function rewritten due to a stack overflow caused by the input of the illegal data. The start address of the attack code included in the illegal data is identified.

例えば、開始アドレス特定部102は、CPU10のEBPレジスタ12に格納されるフレーム・ポインタに基づいて、攻撃コードの開始アドレスを取得する。   For example, the start address specifying unit 102 acquires the start address of the attack code based on the frame pointer stored in the EBP register 12 of the CPU 10.

既に述べたように、EBPレジスタ12は、呼び出し元関数への戻りアドレスを指示するフレーム・ポインタを格納している。また、攻撃コードを含む不正データによてスタックオーバーフローが引き起こされる場合、この戻りアドレスは、攻撃コードへのアドレスに上書きされる。したがって、開始アドレス特定部102は、不正データの入力が検知された場合に、EBPレジスタ12のフレーム・ポインタで指示されるスタック上のアドレスの内容を参照することによって、攻撃コードの開始アドレスを取得することができる。   As already described, the EBP register 12 stores a frame pointer that indicates the return address to the caller function. In addition, when stack overflow is caused by illegal data including an attack code, the return address is overwritten on the address to the attack code. Therefore, the start address specifying unit 102 obtains the attack code start address by referring to the contents of the address on the stack indicated by the frame pointer of the EBP register 12 when the input of illegal data is detected. can do.

開始アドレス特定部102において特定された攻撃コードの開始アドレスは、通知情報生成部103に入力される。   The start address of the attack code specified by the start address specifying unit 102 is input to the notification information generating unit 103.

[通知情報生成部103]
通知情報生成部103は、開始アドレス特定部102において攻撃コードの開始アドレスが特定された場合、この特定された開始アドレスに関する情報や、この開始アドレスより格納される攻撃コードに関する情報を含んだ所定の通知情報を生成する。
[Notification information generation unit 103]
When the start address of the attack code is specified by the start address specifying unit 102, the notification information generating unit 103 is a predetermined information including information about the specified start address and information about the attack code stored from the start address. Generate notification information.

例えば、通知情報生成部103は、開始アドレス特定部102において特定された開始アドレスや攻撃コードに関する情報を含む所定のファイルを生成し、これを記憶装置20に書き込む。これにより、ユーザは、このファイルを参照することにより、攻撃コードのアドレスを知ることができる。   For example, the notification information generation unit 103 generates a predetermined file including information on the start address and attack code specified by the start address specification unit 102 and writes the file in the storage device 20. Thereby, the user can know the address of the attack code by referring to this file.

また、通知情報生成部103は、この開始アドレスや攻撃コードに関する情報をネットワーク経由で他の機器に伝送するための情報を生成しても良い。例えば、入出力部30がインターネットに接続されているのであれば、この情報をE−mailによって所定のアドレスに送信しても良い。
また、通知情報生成部103は、入出力部30がディスプレイ装置を含む場合、ディスプレイ画面上にこの開始アドレスや攻撃コードに関する情報を表示させるための情報を生成しても良い。
Further, the notification information generation unit 103 may generate information for transmitting information related to the start address and the attack code to other devices via the network. For example, if the input / output unit 30 is connected to the Internet, this information may be transmitted to a predetermined address by E-mail.
Further, when the input / output unit 30 includes a display device, the notification information generation unit 103 may generate information for displaying information on the start address and the attack code on the display screen.

次に、上述した構成を有した本実施形態のプログラムによる処理を説明する。   Next, processing by the program of the present embodiment having the above-described configuration will be described.

図3は、本実施形態に係るプログラムによる処理の流れの一例を図解したフローチャートである。   FIG. 3 is a flowchart illustrating an example of the flow of processing by the program according to the present embodiment.

ステップST10:
図2には示されていない他のプロセスによる処理が進められる。
Step ST10:
Processing by another process not shown in FIG. 2 proceeds.

ステップST20:
不正データ入力検知部101は、このプロセスの処理過程において、不正なデータの入力の有無を監視する。不正データの入力が検知されない場合は、プロセスの処理(ステップST10)を通常通り進行させ、不正データの入力が検知された場合は、開始アドレス特定部102へ不正データの入力を通知する。
Step ST20:
The illegal data input detection unit 101 monitors the presence or absence of illegal data input during the process of this process. If the input of illegal data is not detected, the process (step ST10) proceeds as usual. If the input of illegal data is detected, the start address specifying unit 102 is notified of the input of illegal data.

ステップST30:
開始アドレス特定部102は、不正データ入力検知部101より不正データの入力が通知されると、例えばEBPレジスタ12のフレーム・ポインタを参照して、スタックオーバーフローにより書き換えられた戻りアドレスを取得し、これにより、攻撃コードの開始アドレスを特定する。
Step ST30:
When the illegal data input detection unit 101 is notified of illegal data input, the start address specifying unit 102 refers to, for example, the frame pointer of the EBP register 12, and acquires the return address rewritten due to stack overflow. Thus, the start address of the attack code is specified.

図4は、不正データの入力が検出された場合におけるスタックの状態の一例を図解した図である。   FIG. 4 is a diagram illustrating an example of the state of the stack when illegal data input is detected.

図4に示すように、スタック・フレームは、その下位から上位に向かって、引数(‘a’〜‘c’)、戻りアドレス、呼び出し元関数のスタック・フレームにおけるフレーム・ポインタsfp、および、ローカル変数‘buf’を格納している。また、ESPレジスタ11のスタック・ポインタは、スタックの先頭を指しており、EBPレジスタ12のフレーム・レジスタは、スタック上に格納された呼び出し元関数への戻りアドレスを指している。   As shown in FIG. 4, the stack frame has an argument ('a' to 'c'), a return address, a frame pointer sfp in the stack frame of the caller function, and a local frame from the lower level to the higher level. The variable “buf” is stored. The stack pointer of the ESP register 11 points to the top of the stack, and the frame register of the EBP register 12 points to the return address to the caller function stored on the stack.

このような構造のスタックにおいて、ローカル変数に不正データが入力されると、図4に示すようにスタックオーバーフローが発生し、スタック領域を含むメモリ上に攻撃コードが書き込まれる。また、スタック上に格納される戻りアドレスは、不正データに含まれるデータによって、この攻撃コードを指示するアドレス‘addr’に書き換えられる。   In the stack having such a structure, when illegal data is input to the local variable, a stack overflow occurs as shown in FIG. 4, and an attack code is written on the memory including the stack area. Further, the return address stored on the stack is rewritten to an address “addr” indicating the attack code by data included in the illegal data.

開始アドレス特定部102は、図4に示すようなスタックの状態において、EBPレジスタ12に格納されるフレーム・ポインタを参照し、フレーム・ポインタによって指示されるスタック上のアドレス、すなわち攻撃コードへのアドレス‘addr’を取得する。   The start address specifying unit 102 refers to the frame pointer stored in the EBP register 12 in the state of the stack as shown in FIG. 4, and addresses on the stack indicated by the frame pointer, that is, an address to the attack code Get 'addr'.

ステップST40:
開始アドレス特定部102において攻撃コードの開始アドレスが特定されると、通知情報生成部103は、この特定された開始アドレスや攻撃コードに関する情報を含んだ所定の通知情報を生成する。例えば、特定された開始アドレスを含む情報を、記憶装置20にファイルとして格納したり、E−mailとしてインターネットのメールサーバに送信したり、ディスプレイ装置の画面上に画像として表示させる処理を行なう。
Step ST40:
When the start address of the attack code is specified by the start address specifying unit 102, the notification information generating unit 103 generates predetermined notification information including information regarding the specified start address and attack code. For example, information including the specified start address is stored in the storage device 20 as a file, transmitted as an E-mail to an Internet mail server, or displayed as an image on the screen of the display device.

以上説明したように、本実施形態に係るプログラムによれば、プロセスの処理過程において不正データの入力が検知された場合、戻りアドレスが格納されるスタック上のアドレスに関連付けられた所定のポインタ(例えばフレーム・ポインタ)に基づいて、不正データの入力によるスタックオーバーフローで書き換えられた戻りアドレスが取得され、これにより、攻撃コードの開始アドレスが特定される。
したがって、スタックスマッシング攻撃によりコンピュータに送り込まれた攻撃コードを、人手に依らず自動的に抽出することが可能になり、従来の方法で攻撃コードを調べるために費やされていた時間とコストを大幅に削減することができる。
As described above, according to the program according to the present embodiment, when an input of invalid data is detected in the process of the process, a predetermined pointer (for example, associated with an address on the stack in which the return address is stored) Based on the frame pointer, a return address rewritten by stack overflow due to input of illegal data is acquired, and thereby, the start address of the attack code is specified.
Therefore, it is possible to automatically extract the attack code sent to the computer by the stack smashing attack without depending on the manpower, greatly increasing the time and cost spent on examining the attack code by the conventional method. Can be reduced.

また、上述したプログラムによれば、新たな関数が呼び出された場合に所定の値を有する上書き検出用のデータがスタック上の所定のアドレスに格納され、呼び出し元関数へ戻る場合に当該アドレスに格納されるデータの値と上記所定値とが比較され、この比較結果に基づいて、スタックオーバーフローの発生の有無が検知されて、攻撃コードの開始アドレスが取得される。したがって、ネットワーク経由によるアクセスや、ウィルス感染したファイルとして入力される場合など、不正データがコンピュータに侵入する経路に依存することなく、不正データの侵入を検知し、その攻撃コードを抽出することができる。このことから、既知の攻撃だけでなく、侵入経路が不明な未知の攻撃についても攻撃コードの抽出を行なうことができる。   Further, according to the above-described program, when a new function is called, data for overwriting detection having a predetermined value is stored at a predetermined address on the stack, and when returning to the caller function, it is stored at the address. The data value to be compared is compared with the predetermined value, and based on the comparison result, the presence or absence of stack overflow is detected, and the start address of the attack code is obtained. Therefore, it is possible to detect the intrusion of unauthorized data and extract the attack code without depending on the route of unauthorized data entering the computer, such as when accessing via a network or when being input as a virus infected file. . Therefore, attack codes can be extracted not only for known attacks but also for unknown attacks whose intrusion route is unknown.

なお、上述した実施形態では、不正データの入力検知後に、EBPレジスタ12のフレーム・ポインタを参照することによって、スタックオーバーフローで書き換えられた戻りアドレスが取得される。これは、スタックオーバーフローを起こしたスタック・フレームがスタックの最上位にある場合に有効であるが、次に述べるように、この条件が成り立たない場合もあり得る。   In the above-described embodiment, the return address rewritten due to stack overflow is acquired by referring to the frame pointer of the EBP register 12 after detecting input of invalid data. This is useful when the stack frame that caused the stack overflow is at the top of the stack, but this condition may not hold as described below.

すなわち、不正データ入力検知部101において不正データの入力が検知された後、開始アドレス特定部102によるアドレスの特定が行なわれる前に、何らかの処理(例えば攻撃データの実行を阻止する処理など)を実行するハンドラ関数へ処理が移行すると、図5に示すように、スタックオーバーフローを起こしたスタック・フレームの上には、新たに呼び出された関数のためのスタック・フレームが積まれる。スタック・ポインタおよびフレーム・ポインタは、この新たに積まれたスタック・フレームを指す。   That is, after illegal data input is detected by the illegal data input detection unit 101, some processing (for example, processing for preventing execution of attack data) is performed before the address is specified by the start address specifying unit 102. When the processing shifts to the handler function to be performed, as shown in FIG. 5, the stack frame for the newly called function is stacked on the stack frame where the stack overflow has occurred. The stack pointer and frame pointer point to this newly stacked stack frame.

このような場合、開始アドレス特定部102は、フレーム・ポインタによって指示されるアドレスの1つ手前のアドレスを参照して、呼び出し元関数のスタック・フレームにおけるフレーム・ポインタ‘sfp’を読み出し、更に、このフレーム・ポインタ‘sfp’によって指示されるアドレスを参照して、書き換えられた戻りアドレス‘addr’を取得する。   In such a case, the start address specifying unit 102 reads the frame pointer 'sfp' in the stack frame of the caller function with reference to the address immediately before the address indicated by the frame pointer, and The rewritten return address “addr” is obtained by referring to the address indicated by the frame pointer “sfp”.

既に述べたように、EBPレジスタ12のフレーム・ポインタは、呼び出し元関数への戻りアドレス‘ret’が格納されるスタック上のアドレスを指示しているが、このアドレスの1つ手前には、図5に示すように、呼び出し元関数のスタック・フレームにおけるフレーム・ポインタ‘sfp’が格納されている。そして、そのフレーム・ポインタ‘sfp’の指示アドレスには、オーバーフローによって上書きされたスタック・フレーム上の戻りアドレスが格納されている。
したがって、開始アドレス特定部102は、EBPレジスタ12のフレーム・ポインタの指示アドレスに基づいて、フレーム・ポインタ‘sfp’を取得し、さらにその取得したフレーム・ポインタ‘sfp’の指示アドレスを参照することによって、書き換えられた戻りアドレス‘addr’を取得することができる。
As described above, the frame pointer of the EBP register 12 indicates the address on the stack where the return address 'ret' to the caller function is stored. As shown in FIG. 5, the frame pointer 'sfp' in the stack frame of the caller function is stored. Then, the return address on the stack frame overwritten by the overflow is stored in the instruction address of the frame pointer 'sfp'.
Therefore, the start address specifying unit 102 acquires the frame pointer 'sfp' based on the instruction address of the frame pointer of the EBP register 12, and refers to the instruction address of the acquired frame pointer 'sfp'. Thus, the rewritten return address “addr” can be acquired.

以上は、攻撃検知後に呼び出される関数が1つの場合の例であるが、これが複数の場合でも、上述と同様な方法によって、戻りアドレス‘addr’を取得可能である。
すなわち、開始アドレス特定部102は、スタック・フレームから取得したフレーム・ポインタ‘sfp’に基づいて、更に上位の呼び出し元関数のスタック・フレームにおけるフレーム・ポインタ‘sfp’を取得する処理を反復する。この処理を反復することにより、結果として、スタックオーバーフローにより書き換えられたスタック・フレームにおけるフレーム・ポインタ‘sfp’を取得する。そして、当該フレーム・ポインタ‘sfp’の指示アドレスから、書き換えられた戻りアドレス‘addr’を取得する。
The above is an example in which one function is called after the attack is detected, but even when there are a plurality of functions, the return address “addr” can be acquired by the same method as described above.
That is, the start address specifying unit 102 repeats the process of acquiring the frame pointer 'sfp' in the stack frame of the higher-level caller function based on the frame pointer 'sfp' acquired from the stack frame. By repeating this process, as a result, the frame pointer 'sfp' in the stack frame rewritten by the stack overflow is obtained. Then, the rewritten return address “addr” is acquired from the instruction address of the frame pointer “sfp”.

<第2の実施形態>
次に、本発明の第2の実施形態について述べる。
<Second Embodiment>
Next, a second embodiment of the present invention will be described.

上述した第1の実施形態に対する本実施形態の違いは、本実施形態において、新たな関数が呼び出される前にスタックオーバーフローの発生の有無が事前に検知される点と、スタックオーバーフローの発生が事前に検知された場合において強制的にオーバーフローが引き起こされる点にある。   The difference between this embodiment and the first embodiment described above is that, in this embodiment, the presence or absence of stack overflow is detected in advance before a new function is called, and the occurrence of stack overflow is detected in advance. In the case where it is detected, an overflow is forcibly caused.

図6は、本発明の第2の実施形態に係るプログラムの機能的な構成の一例を示すブロック図である。   FIG. 6 is a block diagram showing an example of a functional configuration of a program according to the second embodiment of the present invention.

図6に示すプログラムは、不正データ入力検知部101Aと、強制オーバーフロー部104と、開始アドレス特定部102と、通知情報生成部103とを有する。ただし、図2と図6の同一符号は、同一の構成要素を示す。
以下では、図2に示すプログラムと比較して異なる構成である、不正データ入力検知部101Aおよび強制オーバーフロー部104について説明する。
The program illustrated in FIG. 6 includes an illegal data input detection unit 101A, a forced overflow unit 104, a start address specifying unit 102, and a notification information generation unit 103. However, the same reference numerals in FIG. 2 and FIG. 6 indicate the same components.
Hereinafter, the illegal data input detection unit 101A and the forced overflow unit 104, which are different from the program illustrated in FIG. 2, will be described.

[不正データ入力検知部101A]
不正データ入力検知部101Aは、新たな関数が呼び出される前に、オーバーフローの発生の有無を予測する。
[Incorrect data input detection unit 101A]
The illegal data input detection unit 101A predicts whether or not an overflow has occurred before a new function is called.

例えば、不正データ入力検知部101Aは、新たに呼び出すべき関数に引数として渡されるデータのサイズと、この関数において引数に割り当てられているデータサイズとを比較し、この比較結果に基づいて、この関数が呼び出された場合におけるスタックオーバーフローの発生の有無を事前に検知する。この引数のチェックは、例えば、‘strcpy()’などの境界チェックを欠いた関数について行なう。   For example, the illegal data input detection unit 101A compares the size of data passed as an argument to a function to be newly called with the data size assigned to the argument in this function, and based on the comparison result, Detects in advance whether or not a stack overflow occurs when is called. This argument check is performed on a function lacking a boundary check such as 'strcpy ()'.

スタックオーバーフローの発生が事前に検知されると、不正データ入力検知部101Aは、強制オーバーフロー部104にその旨を通知する。   When the occurrence of the stack overflow is detected in advance, the illegal data input detection unit 101A notifies the forced overflow unit 104 to that effect.

[強制オーバーフロー部104]
強制オーバーフロー部104は、不正データ入力検知部101Aよりスタックオーバーフローの発生が事前に通知された場合、オーバーフローの発生が検知された関数を呼び出して、強制的にオーバーフローを発生させる。
[Forced overflow part 104]
When the occurrence of stack overflow is notified in advance from the illegal data input detection unit 101A, the forced overflow unit 104 calls a function in which the occurrence of overflow has been detected to forcibly generate an overflow.

次に、上述した構成を有する図6に示すプログラムの処理について、図7のフローチャートを参照して説明する。   Next, the processing of the program shown in FIG. 6 having the above-described configuration will be described with reference to the flowchart of FIG.

ステップST10:
図3と同様に、他のプロセスによる処理が進められる。
Step ST10:
Similar to FIG. 3, processing by other processes proceeds.

ステップST20A:
不正データ入力検知部101Aは、このプロセスの処理過程において、不正なデータの入力の有無を監視する。すなわち、スタックオーバーフローを引き起こす可能性のある関数の引数をチェックし、スタックオーバーフローの発生の有無を事前に検知する。スタックオーバーフローの発生が検知されない場合は、プロセスの処理(ステップST10)を通常通り進行させ、スタックオーバーフローの発生が事前に検知された場合は、強制オーバーフロー部104へその旨を通知する。
Step ST20A:
The unauthorized data input detection unit 101A monitors whether or not unauthorized data is input during the process of this process. That is, the function argument that may cause a stack overflow is checked, and whether or not a stack overflow has occurred is detected in advance. If the occurrence of the stack overflow is not detected, the process (step ST10) proceeds as usual, and if the occurrence of the stack overflow is detected in advance, the fact is notified to the forced overflow unit 104.

ステップST50:
不正データ入力検知部101Aにおいてスタックオーバーフローの発生が事前に検知されると、強制オーバーフロー部104は、この関数を呼び出して、オーバーフローを強制的に発生させる。
Step ST50:
When the occurrence of stack overflow is detected in advance in the illegal data input detection unit 101A, the forced overflow unit 104 calls this function to forcibly generate overflow.

ステップST30、ST40:
強制オーバーフロー部104によるスタックオーバーフローが発生すると、開始アドレス特定部102は、既に述べたものと同様の処理により、攻撃コードの開始アドレスを特定する。そして、通知情報生成部103は、この特定された開始アドレスや攻撃コードに関する情報を含んだ所定の通知情報を生成する。
Steps ST30 and ST40:
When a stack overflow occurs by the forced overflow unit 104, the start address specifying unit 102 specifies the start address of the attack code by the same process as described above. Then, the notification information generation unit 103 generates predetermined notification information including information regarding the specified start address and attack code.

以上説明したように、図6に示すプログラムによれば、不正データの入力検知後にスタックオーバーフローを強制的に引き起こす点が異なるものの、それ以降における攻撃コードの開始アドレスの特定処理については、図2に示すプログラムと同様である。したがって、スタックスマッシング攻撃の攻撃コードを自動的に抽出することが可能になり、時間とコストの削減を図ることができる。   As described above, the program shown in FIG. 6 differs in that the stack overflow is forcibly caused after detection of illegal data input, but the attack code start address specifying process thereafter is shown in FIG. It is the same as the program shown. Therefore, it is possible to automatically extract the attack code of the stack smashing attack, and it is possible to reduce time and cost.

また、上述したプログラムによれば、プログラム上で呼び出される関数の引数をチェックすることによりスタックオーバーフローの発生の有無が検知されて、攻撃コードが取得されるため、図2に示すプログラムと同様に、不正データがコンピュータに侵入する経路に依存することなく、攻撃コードを抽出することができる。   Further, according to the above-described program, the presence or absence of stack overflow is detected by checking the argument of the function called on the program, and the attack code is acquired. Therefore, like the program shown in FIG. The attack code can be extracted without depending on the path of unauthorized data entering the computer.

<第3の実施形態>
次に、本発明の第3の実施形態について述べる。
<Third Embodiment>
Next, a third embodiment of the present invention will be described.

上述した第1の実施形態に対する本実施形態の違いは、第1の実施形態において攻撃コードの開始アドレスが特定されるところを、本実施形態においては、更に攻撃コードが格納されるアドレス範囲が特定される点にある。   The difference between this embodiment and the first embodiment described above is that the start address of the attack code is specified in the first embodiment, and in this embodiment, the address range in which the attack code is further stored is specified. Is in the point to be.

図8は、本発明の第3の実施形態に係るプログラムの機能的な構成の一例を示すブロック図である。   FIG. 8 is a block diagram illustrating an example of a functional configuration of a program according to the third embodiment of the present invention.

図8に示すプログラムは、不正データ入力検知部101と、開始アドレス特定部102と、データ取得部105と、アドレス範囲特定部106と、通知情報生成部103とを有する。ただし、図2と図8の同一符号は、同一の構成要素を示す。
以下では、図2に示すプログラムと比較して異なる構成である、データ取得部105およびアドレス範囲特定部106について説明する。
The program shown in FIG. 8 includes an illegal data input detection unit 101, a start address specification unit 102, a data acquisition unit 105, an address range specification unit 106, and a notification information generation unit 103. However, the same reference numerals in FIG. 2 and FIG. 8 indicate the same components.
Hereinafter, the data acquisition unit 105 and the address range specifying unit 106, which are different from the program shown in FIG. 2, will be described.

[データ取得部105]
データ取得部105は、不正データ入力検知部101において不正データの入力が検知された場合、この不正データの入力によってオーバーフローが引き起こされたメモリ領域のデータを取得する。
[Data acquisition unit 105]
When the illegal data input detection unit 101 detects the input of illegal data, the data acquisition unit 105 acquires the data in the memory area in which overflow has been caused by the input of the illegal data.

[アドレス範囲特定部106]
アドレス範囲特定部106は、特定された攻撃コードの開始アドレスと、データ取得部105において取得されたデータとに応じて、攻撃コードが格納されるアドレス範囲を特定する。
[Address range specifying unit 106]
The address range specifying unit 106 specifies an address range in which the attack code is stored according to the start address of the specified attack code and the data acquired by the data acquisition unit 105.

例えば、アドレス範囲特定部106は、データ取得部105において取得されたデータと、文字列の終端を示す終端文字(ヌル文字)とを、開始アドレス特定部102において特定された攻撃コードの開始アドレスから順に比較し、終端文字と一致するデータが格納されるアドレスを検索する。   For example, the address range specifying unit 106 uses the data acquired by the data acquisition unit 105 and the end character (null character) indicating the end of the character string from the attack code start address specified by the start address specifying unit 102. By comparing in order, an address where data matching the terminal character is stored is searched.

図9は、スタックスマッシング攻撃によってメモリに書き込まれた攻撃コードの一例を図解した図である。
図9に示すように、バッファオーバーフロー攻撃は、しばしば文字列のコピーを利用して行なわれる。文字列は終端文字で終端されているため、攻撃を受けたメモリ領域において終端文字を検索することにより、攻撃コードの終端のアドレスを特定することができる。
アドレス範囲特定部106は、このようにして特定された攻撃コードの終端アドレスと、開始アドレス特定部102において特定された攻撃コードの開始アドレスとに基づいて、攻撃コードが格納されるメモリ上のアドレス範囲を特定する。
FIG. 9 is a diagram illustrating an example of an attack code written in a memory by a stack smashing attack.
As shown in FIG. 9, a buffer overflow attack is often performed using a copy of a character string. Since the character string is terminated with a termination character, the end address of the attack code can be specified by searching for the termination character in the memory area under attack.
The address range specifying unit 106 addresses the address on the memory where the attack code is stored based on the end address of the attack code specified in this way and the start address of the attack code specified by the start address specifying unit 102. Identify the range.

次に、上述した構成を有する図8に示すプログラムの処理について、図10のフローチャートを参照して説明する。   Next, the processing of the program shown in FIG. 8 having the above-described configuration will be described with reference to the flowchart of FIG.

ステップST10,ST20:
不正データ入力検知部101は、通常プロセス(ステップST10)の処理過程において、不正なデータの入力の有無を監視する(ステップST20)。
不正データの入力が検知されない場合、不正データ入力検知部101は、プロセスの処理(ステップST10)を通常通り進行させる。
不正データの入力が検知された場合、不正データ入力検知部101は、開始アドレス特定部102へ不正データの入力を通知する。
Steps ST10 and ST20:
The unauthorized data input detection unit 101 monitors whether or not unauthorized data is input during the process of the normal process (step ST10) (step ST20).
If the input of unauthorized data is not detected, the unauthorized data input detection unit 101 proceeds with the process (step ST10) as usual.
When the input of illegal data is detected, the illegal data input detection unit 101 notifies the start address specifying unit 102 of the input of illegal data.

ステップST30:
不正データの入力が通知されると、開始アドレス特定部102は、既に述べたものと同様の処理により、攻撃コードが格納される開始アドレスを特定する。
Step ST30:
When the input of illegal data is notified, the start address specifying unit 102 specifies the start address where the attack code is stored by the same process as described above.

ステップST60:
また、データ取得部105は、不正データの入力によりスタックオーバーフローが引き起こされたメモリ領域のデータを取得する。
Step ST60:
Further, the data acquisition unit 105 acquires data in a memory area in which a stack overflow is caused by input of illegal data.

ステップST70:
アドレス範囲特定部106は、データ取得部105において取得されたデータと、文字列の終端を示す終端文字とを、開始アドレス特定部102において特定された攻撃コードの開始アドレスから順に比較し、終端文字と一致するデータが格納されるアドレスを検索する。このようにして検索したアドレスを、攻撃コードの終端アドレスとして特定することにより、攻撃コードが格納されるアドレス範囲を特定する。
Step ST70:
The address range specifying unit 106 compares the data acquired by the data acquisition unit 105 with the end character indicating the end of the character string in order from the start address of the attack code specified by the start address specifying unit 102, and the end character Search for the address where the data that matches is stored. By specifying the searched address as the end address of the attack code, the address range in which the attack code is stored is specified.

ステップST40:
通知情報生成部103は、アドレス範囲特定部106において特定された攻撃コードのアドレス範囲に関する情報や、そのアドレス範囲に含まれる攻撃コードに関する情報を含んだ所定の通知情報を生成する。例えば、データ取得部105において取得されたデータの中から、アドレス範囲特定部106において特定されたアドレス範囲のデータを抽出し、これを攻撃コードとして通知する情報を生成しても良い。
Step ST40:
The notification information generation unit 103 generates predetermined notification information including information related to the address range of the attack code specified by the address range specifying unit 106 and information related to the attack code included in the address range. For example, the data of the address range specified by the address range specifying unit 106 may be extracted from the data acquired by the data acquisition unit 105, and information for notifying this as an attack code may be generated.

以上説明したように、図8に示すプログラムによれば、攻撃コードの開始アドレスのみならず、攻撃コードの終端アドレスも特定することにより、攻撃コードのアドレス範囲を特定することが可能になる。このため、図2に示すプログラムに比べて、攻撃コードに関するさらに詳しい情報を自動的に抽出することが可能になり、解析に要する時間とコストをより効果的に削減することができる。   As described above, according to the program shown in FIG. 8, it is possible to specify the address range of the attack code by specifying not only the start address of the attack code but also the end address of the attack code. Therefore, compared to the program shown in FIG. 2, more detailed information regarding the attack code can be automatically extracted, and the time and cost required for analysis can be reduced more effectively.

また、不正データの侵入経路に依存することなく、不正データの侵入を検知し、その攻撃コードを抽出することができる点は図2に示すプログラムと同じでありであり、これと同様な効果を奏することができる。   Moreover, the point that it is possible to detect the intrusion of illegal data and extract the attack code without depending on the intrusion route of illegal data is the same as the program shown in FIG. Can play.

<第4の実施形態>
次に、本発明の第4の実施形態について述べる。
<Fourth Embodiment>
Next, a fourth embodiment of the present invention will be described.

上述した第3の実施形態に対する本実施形態の違いは、第3の実施形態において、攻撃を受けたメモリ領域から終端文字などの所定のデータと一致するデータを検索することにより攻撃コードの終端アドレスが特定されるのに対し、本実施形態においては、プロセスへの入力データの記録結果に基づいて、攻撃コードの終端アドレスが特定される点にある。   The difference of this embodiment from the third embodiment described above is that the end address of the attack code in the third embodiment is searched by searching for data matching the predetermined data such as the end character in the memory area that has been attacked. In the present embodiment, the end address of the attack code is specified based on the result of recording the input data to the process.

図11は、本発明の第4の実施形態に係るプログラムの機能的な構成の一例を示すブロック図である。   FIG. 11 is a block diagram showing an example of a functional configuration of a program according to the fourth embodiment of the present invention.

図11に示すプログラムは、不正データ入力検知部101と、開始アドレス特定部102と、アドレス範囲特定部106Aと、データ取得部105と、通知情報生成部103と、入力データベース107とを有する。ただし、図8と図11の同一符号は、同一の構成要素を示す。
以下では、図8に示すプログラムと比較して異なる構成である、アドレス範囲特定部106Aおよび入力データベース107について説明する。
The program shown in FIG. 11 includes an illegal data input detection unit 101, a start address specification unit 102, an address range specification unit 106A, a data acquisition unit 105, a notification information generation unit 103, and an input database 107. However, the same reference numerals in FIG. 8 and FIG. 11 indicate the same components.
Hereinafter, the address range specifying unit 106A and the input database 107, which are different from the program shown in FIG. 8, will be described.

[入力データベース107]
入力データデータベース107は、プロセスの実行に伴って入力されるデータを記録するデータベースである。
[Input database 107]
The input data database 107 is a database that records data input along with the execution of a process.

例えば、入力データベース107は、データの入力を伴う所定のライブラリ関数がプロセスによって呼び出されるたびに、ヒープ領域に対するメモリの割り当てを行い、プロセスに入力されるデータのコピーを、このヒープ領域に記憶する。   For example, the input database 107 allocates memory to the heap area each time a predetermined library function that involves data input is called by the process, and stores a copy of the data input to the process in the heap area.

図12は、入力データベース107による入力データの記録方法の一例を図解した図である。
入力データベース107は、プロセスに対する入力データのコピーを、例えば図12に示すような、リスト状の構造でヒープ領域に記録する。すなわち、それぞれ入力データが格納されるメモリ領域の先頭部分にアドレスを付加し、この付加アドレスによって、次に入力されるデータのメモリ領域の先頭アドレスを指示する。
入力データベース107は、新たなデータがプロセスに入力されると、図12に示すようなリストの先頭に、この入力データのコピーを記録する。
FIG. 12 is a diagram illustrating an example of a method for recording input data by the input database 107.
The input database 107 records a copy of input data for the process in a heap area in a list-like structure as shown in FIG. 12, for example. That is, an address is added to the head portion of the memory area where the input data is stored, and the head address of the memory area of the next input data is indicated by this additional address.
When new data is input to the process, the input database 107 records a copy of this input data at the top of the list as shown in FIG.

[アドレス範囲特定部106A]
アドレス範囲特定部106Aは、データ取得部105において取得された攻撃後のメモリ領域のデータと、入力データベース107において記録された入力データとを、開始アドレス特定部102で特定された攻撃コードの開始アドレスから順に比較し、記録された入力データと一致するデータが格納されるアドレスを検索する。
例えば、アドレス範囲特定部106Aは、入力データベース107に記録される直近の入力データから順にデータ取得部105の取得データとの比較を行い、入力データと一致する取得データの終端のアドレスから、攻撃コードの終端のアドレスを特定する。
[Address range specifying unit 106A]
The address range specifying unit 106A uses the data in the post-attack memory area acquired by the data acquisition unit 105 and the input data recorded in the input database 107 as the start address of the attack code specified by the start address specifying unit 102. Are compared in order, and an address where data that matches the recorded input data is stored is searched.
For example, the address range specifying unit 106A compares the acquired data of the data acquisition unit 105 in order from the latest input data recorded in the input database 107, and determines the attack code from the end address of the acquired data that matches the input data. Specify the end address of.

上述した構成を有する図11に示すプログラムの処理は、ステップST70において、入力データベース107に記録される入力データとデータ取得部105の取得データとの比較により、攻撃コードの終端のアドレスが特定される点を除いて、図10のフローチャートに示す処理と同じである。   In the processing of the program shown in FIG. 11 having the above-described configuration, the end address of the attack code is specified by comparing the input data recorded in the input database 107 with the acquired data of the data acquiring unit 105 in step ST70. Except for this point, the processing is the same as that shown in the flowchart of FIG.

以上説明したように、図11に示すプログラムにおいても、図8に示すプログラムと同様に、攻撃コードのアドレス範囲を特定可能であり、これと同様な効果を奏することができる。
更に、図11に示すプログラムによれば、プロセスの入力データに基づいて攻撃コードの検索を行なうので、終端文字を含まない攻撃コードについても、そのアドレス範囲を正確に特定することができる。
As described above, also in the program shown in FIG. 11, the address range of the attack code can be specified similarly to the program shown in FIG. 8, and the same effect can be obtained.
Furthermore, according to the program shown in FIG. 11, the attack code is searched based on the input data of the process, so that the address range of the attack code not including the terminal character can be specified accurately.

<第5の実施形態>
次に、本発明の第5の実施形態について述べる。
<Fifth Embodiment>
Next, a fifth embodiment of the present invention will be described.

第5の実施形態では、上述した第1〜第4の実施形態とは異なり、予め設定されたメモリ領域のデータ(例えばスタック領域のデータ)が実行すべき命令コードとしてCPUにフェッチされた場合に、この命令コードのアドレスを指示する命令ポインタに基づいて、攻撃コードのアドレスが取得される。   In the fifth embodiment, unlike the first to fourth embodiments described above, when data in a preset memory area (for example, data in a stack area) is fetched by the CPU as an instruction code to be executed. The address of the attack code is acquired based on the instruction pointer indicating the address of the instruction code.

図13は、本発明の第5の実施形態に係るプログラムの機能的な構成の一例を示すブロック図である。   FIG. 13 is a block diagram illustrating an example of a functional configuration of a program according to the fifth embodiment of the present invention.

図13に示すプログラムは、命令コード取得検知部108と、開始アドレス特定部102Aと、アドレス範囲特定部106と、データ取得部105Aと、通知情報生成部103とを有する。ただし、図8と図13の同一符号は、同一の構成要素を示す。
以下では、図8に示すプログラムと比較して異なる構成である、命令コード取得検知部108、開始アドレス特定部102A、およびデータ取得部105Aについて説明する。
The program shown in FIG. 13 includes an instruction code acquisition detecting unit 108, a start address specifying unit 102A, an address range specifying unit 106, a data acquiring unit 105A, and a notification information generating unit 103. However, the same reference numerals in FIG. 8 and FIG. 13 indicate the same components.
Hereinafter, the instruction code acquisition detection unit 108, the start address specifying unit 102A, and the data acquisition unit 105A, which are different from the program illustrated in FIG. 8, will be described.

[命令コード取得検知部108]
命令コード取得検知部108は、予め命令の実行を禁止する領域として設定されたメモリ領域のデータが、実行すべき命令コードとしてCPU10にフェッチされたか否かを検知する。そして、この実行不可のメモリ領域から命令フェッチが行なわれた場合、命令コード取得検知部108は、この命令コードを実行しようとしたプロセスを強制終了させる。例えば、命令コード取得検知部108は、オペレーティング・システムに対して、このプロセスの強制終了を指示する。
[Instruction code acquisition detection unit 108]
The instruction code acquisition detection unit 108 detects whether or not data in a memory area set as an area in which execution of instructions is prohibited is fetched by the CPU 10 as an instruction code to be executed. When an instruction fetch is performed from this non-executable memory area, the instruction code acquisition detection unit 108 forcibly terminates the process that tried to execute this instruction code. For example, the instruction code acquisition detection unit 108 instructs the operating system to forcibly terminate this process.

[開始アドレス特定部102A]
開始アドレス特定部102Aは、命令コード取得検知部108において、禁止されたメモリ領域における命令フェッチが検知された場合、EIPレジスタ13に格納される命令ポインタに基づいて、攻撃コードの開始アドレスを特定する。
[Start address specifying unit 102A]
The start address specifying unit 102A specifies the start address of the attack code based on the instruction pointer stored in the EIP register 13 when the instruction code acquisition detecting unit 108 detects an instruction fetch in the prohibited memory area. .

図14は、メモリ上に書き込まれた攻撃コードの開始アドレスがCPUによってフェッチされた状態を図解した図である。
図14に示すように、予め設定された実行不可のメモリ領域に攻撃コードの開始アドレスが含まれている場合、命令コード取得検知部108は、このアドレスがEIPレジスタ13に格納されたところで、プロセスを強制終了させる。したがって、開始アドレス特定部102Aは、命令コード取得検知部108において禁止された命令フェッチが検知されたときのEIPレジスタ13の命令ポインタを参照することにより、攻撃コードの開始アドレスを特定することができる。
FIG. 14 is a diagram illustrating a state where the start address of the attack code written in the memory is fetched by the CPU.
As shown in FIG. 14, when the start address of the attack code is included in a preset non-executable memory area, the instruction code acquisition detection unit 108 executes the process when the address is stored in the EIP register 13. Is forcibly terminated. Therefore, the start address specifying unit 102A can specify the attack code start address by referring to the instruction pointer of the EIP register 13 when the instruction fetch prohibited by the instruction code acquisition detecting unit 108 is detected. .

[データ取得部105A]
命令コード取得検知部108の指示に応じてプロセスが強制終了した場合、この強制終了したプロセスに対応するメモリ領域のデータを取得する。
[Data acquisition unit 105A]
When a process is forcibly terminated in accordance with an instruction from the instruction code acquisition detection unit 108, data in a memory area corresponding to the forcibly terminated process is acquired.

例えば、オペレーティング・システムは、命令コード取得検知部108の指示に応じてプロセスを強制終了させる場合、そのプロセスのメモリイメージであるコアダンプ(core dump)ファイルを生成する。データ取得部105Aは、強制終了したプロセスのコアダンプファイルを取得し、コアダンプファイルのフォーマットと、オペレーティング・システムによって設定されているスタック領域のメモリ割り当てとに従って、そのプロセスのスタックだったメモリ領域を割り出す。そして、割り出したメモリ領域を、アドレス範囲特定部106を実現するプロセスのメモリ領域にマップし、攻撃を受けたプロセスの終了時におけるスタックの状態を復元する。   For example, when the operating system forcibly terminates a process according to an instruction from the instruction code acquisition detection unit 108, the operating system generates a core dump file that is a memory image of the process. The data acquisition unit 105A acquires the core dump file of the process that has been forcibly terminated, and determines the memory area that was the stack of the process according to the format of the core dump file and the memory allocation of the stack area set by the operating system. Then, the determined memory area is mapped to the memory area of the process realizing the address range specifying unit 106, and the stack state at the end of the attacked process is restored.

次に、上述した構成を有する図13に示すプログラムの処理について、図15のフローチャートを参照して説明する。   Next, the processing of the program shown in FIG. 13 having the above-described configuration will be described with reference to the flowchart of FIG.

ステップST10,ST80:
命令コード取得検知部108は、通常プロセス(ステップST10)の処理過程において、禁止されたメモリ領域からの命令フェッチの有無を監視する(ステップST80)。
禁止されたメモリ領域からの命令フェッチが検知されない場合、命令コード取得検知部108は、プロセスの処理(ステップST10)を通常通り進行させる。
禁止されたメモリ領域からの命令フェッチが検知された場合、命令コード取得検知部108は、開始アドレス特定部102Aへこの違反の発生を通知するとともに、禁止された命令コードを実行させようとしたプロセスの強制終了をオペレーティング・システムに指示する。この指示に応じて、オペレーティング・システムは、当該プロセスを強制終了させ、そのコアダンプファイルを生成する。
Steps ST10 and ST80:
The instruction code acquisition detection unit 108 monitors the presence / absence of instruction fetch from the prohibited memory area in the process of the normal process (step ST10) (step ST80).
If instruction fetch from the prohibited memory area is not detected, the instruction code acquisition detection unit 108 proceeds with the process (step ST10) as usual.
When instruction fetch from the prohibited memory area is detected, the instruction code acquisition detecting unit 108 notifies the start address specifying unit 102A of the occurrence of this violation and attempts to execute the prohibited instruction code. Tells the operating system to kill In response to this instruction, the operating system forcibly terminates the process and generates the core dump file.

ステップST30A:
命令フェッチ違反の発生が通知されると、開始アドレス特定部102Aは、EIPレジスタ13に格納される命令ポインタに基づいて、攻撃コードの開始アドレスを特定する。
Step ST30A:
When the occurrence of the instruction fetch violation is notified, the start address specifying unit 102A specifies the start address of the attack code based on the instruction pointer stored in the EIP register 13.

ステップST60A:
また、データ取得部105Aは、スタックオーバーフローが生じたプロセスのコアダンプファイルに基づいて、そのプロセスの終了時におけるスタック領域のデータを取得する。
Step ST60A:
Further, the data acquisition unit 105A acquires data in the stack area at the end of the process based on the core dump file of the process in which the stack overflow has occurred.

ステップST70,ST40:
アドレス範囲特定部106、通知情報生成部103の処理については、図8に示すプログラムと同様である。
すなわち、アドレス範囲特定部106は、データ取得部105Aにおいて取得されたデータと、文字列の終端を示す終端文字とを、開始アドレス特定部102Aにおいて特定された攻撃コードの開始アドレスから順に比較し、終端文字と一致するデータが格納されるアドレスを検索することにより、攻撃コードが格納されるアドレス範囲を特定する。通知情報生成部103は、アドレス範囲特定部106において特定された攻撃コードのアドレス範囲に関する情報や、当該アドレス範囲に含まれる攻撃コードに関する情報を含んだ所定の通知情報を生成する。
Steps ST70 and ST40:
The processing of the address range specifying unit 106 and the notification information generating unit 103 is the same as the program shown in FIG.
That is, the address range specifying unit 106 compares the data acquired by the data acquisition unit 105A with the terminal character indicating the end of the character string in order from the start address of the attack code specified by the start address specifying unit 102A. The address range where the attack code is stored is specified by searching the address where the data matching the terminal character is stored. The notification information generation unit 103 generates predetermined notification information including information related to the address range of the attack code specified by the address range specifying unit 106 and information related to the attack code included in the address range.

以上説明したように、図13に示すプログラムにおいても、図2に示すプログラムと同様に、攻撃コードの開始アドレスを自動的に特定することができる。
また、図13に示すプログラムによれば、禁止されたメモリ領域から命令フェッチが行なわれるか否かによって不正データの入力が検知されるため、既に述べた実施形態と同様に、不正データの侵入経路に依存することなく、不正データの侵入を検知し、その攻撃コードを抽出することができる。
また、攻撃コードのアドレス範囲を自動的に抽出できる点については、図8に示すプログラムと同じであり、同様な効果を奏することができる。
As described above, in the program shown in FIG. 13, the start address of the attack code can be automatically specified as in the program shown in FIG.
Further, according to the program shown in FIG. 13, since illegal data input is detected depending on whether or not an instruction is fetched from a prohibited memory area, the illegal data intrusion route is the same as in the above-described embodiment. It is possible to detect the intrusion of illegal data and extract the attack code without depending on.
Further, the point that the address range of the attack code can be automatically extracted is the same as the program shown in FIG. 8, and the same effect can be obtained.

なお、本発明は上述した実施形態に限定されない。
例えば、本発明のプログラムは、上述した実施形態のようにROM40に予め書き込まれたものでも良いし、記憶装置20から読み出したものでも良い。あるいは、入出力部30において光ディスクなどの記録媒体から読み出したものや、ネットワークを介して他の機器から入力したものでも良い。あるいは、上述のような幾つかの方法によって取得されたプログラムの部分データを組み合わせたものでも良い。
In addition, this invention is not limited to embodiment mentioned above.
For example, the program of the present invention may be previously written in the ROM 40 as in the above-described embodiment, or may be read from the storage device 20. Or what was read from recording media, such as an optical disk, in the input-output part 30, or what was input from the other apparatus via the network may be used. Or the partial data of the program acquired by the several methods as mentioned above may be combined.

また、本発明は、上述した実施形態のように、プログラムによって実現することも可能であるが、その一部または全部の処理を、専用のハードウェアによって実行させることも可能である。すなわち、図2、図6、図8、図11、図13に示すブロック図において、機能ブロックの一部または全部をハードウェアの回路に置き換えることも可能である。その場合の回路は、CPUと同一の半導体チップ上に形成しても良いし、別のチップ上に形成しても良い。   Further, the present invention can be realized by a program as in the above-described embodiment, but part or all of the processing can be executed by dedicated hardware. That is, in the block diagrams shown in FIGS. 2, 6, 8, 11, and 13, some or all of the functional blocks can be replaced with hardware circuits. The circuit in that case may be formed on the same semiconductor chip as the CPU, or may be formed on another chip.

また、本明細書における「不正データの入力」とは、コンピュータに不正データが入力されることを広く意味する。
例えば、入力命令の実行によりスタック上のローカル変数領域に不正データが入力される場合に加えて、入出力部30においてネットワークや記録媒体などから不正データが入力される場合や、記憶装置20やRAM50に既に格納された不正データがCPU10によって処理される場合なども、「不正データの入力」に含まれる。
したがって、不正データ入力検知部における不正データの入力検知方法は、上述した実施形態に限定されない。すなわち不正データ入力検知部は、例えば、不正な入力データに含まれる特定のデータ・パターンや、ファイル名、データの送信元のネットワーク・アドレスなど、不正データの入力を特徴付けるさまざまな情報に基づいて、これを検知しても良い。
Further, “input of illegal data” in this specification widely means that illegal data is input to a computer.
For example, in addition to the case where illegal data is input to the local variable area on the stack by execution of the input instruction, when illegal data is input from the network or recording medium in the input / output unit 30, the storage device 20 or the RAM 50 The case where illegal data already stored in the CPU 10 is processed by the CPU 10 is also included in “input of illegal data”.
Therefore, the illegal data input detection method in the illegal data input detection unit is not limited to the above-described embodiment. That is, the illegal data input detection unit, for example, based on various information characterizing the input of illegal data, such as a specific data pattern included in the illegal input data, a file name, a network address of the data transmission source, This may be detected.

本発明の実施形態に係るコンピュータの構成の一例を示すブロック図である。It is a block diagram which shows an example of a structure of the computer which concerns on embodiment of this invention. 本発明の第1の実施形態に係るプログラムの機能的な構成の一例を示すブロック図である。It is a block diagram which shows an example of a functional structure of the program which concerns on the 1st Embodiment of this invention. 図2に示すプログラムにおける処理の流れの一例を図解したフローチャートである。3 is a flowchart illustrating an example of a process flow in the program shown in FIG. 2. 図2に示すプログラムにおいて不正データの入力が検出された場合におけるスタックの状態の一例を図解した図である。FIG. 3 is a diagram illustrating an example of a state of a stack when illegal data input is detected in the program shown in FIG. 2. スタックオーバーフローを起こしたスタック・フレーム上に、新たに呼び出された関数のためのスタック・フレームが積まれる様子を図解した図である。FIG. 10 is a diagram illustrating a state in which a stack frame for a newly called function is stacked on a stack frame in which a stack overflow has occurred. 本発明の第2の実施形態に係るプログラムの機能的な構成の一例を示すブロック図である。It is a block diagram which shows an example of a functional structure of the program which concerns on the 2nd Embodiment of this invention. 図6に示すプログラムにおける処理の流れの一例を図解したフローチャートである。7 is a flowchart illustrating an example of a processing flow in the program shown in FIG. 6. 本発明の第3の実施形態に係るプログラムの機能的な構成の一例を示すブロック図である。It is a block diagram which shows an example of a functional structure of the program which concerns on the 3rd Embodiment of this invention. スタックスマッシング攻撃によってメモリに書き込まれた攻撃コードの一例を図解した図である。It is the figure which illustrated an example of the attack code written in the memory by the stack smashing attack. 図8に示すプログラムにおける処理の流れの一例を図解したフローチャートである。It is the flowchart which illustrated an example of the flow of the process in the program shown in FIG. 本発明の第4の実施形態に係るプログラムの機能的な構成の一例を示すブロック図である。It is a block diagram which shows an example of a functional structure of the program which concerns on the 4th Embodiment of this invention. 入力データベースによる入力データの記録方法の一例を図解した図である。It is the figure which illustrated an example of the recording method of the input data by an input database. 本発明の第5の実施形態に係るプログラムの機能的な構成の一例を示すブロック図である。It is a block diagram which shows an example of a functional structure of the program which concerns on the 5th Embodiment of this invention. メモリ上に書き込まれた攻撃コードの開始アドレスがCPUによってフェッチされた状態を図解した図である。It is the figure which illustrated the state where the start address of the attack code written on the memory was fetched by CPU. 図13に示すプログラムにおける処理の流れの一例を図解したフローチャートである。14 is a flowchart illustrating an example of a process flow in the program shown in FIG. 13. C言語のソース・コードの一例を示す図である。It is a figure which shows an example of the source code of C language. 図16に示すソース・コードが実行された場合におけるスタックの状態の一例を図解した図である。FIG. 17 is a diagram illustrating an example of a stack state when the source code shown in FIG. 16 is executed. スタックオーバーフローが発生した場合におけるスタックの状態の一例を図解した図である。It is the figure which illustrated an example of the state of a stack when stack overflow occurred. スタックスマッシング攻撃によって攻撃コードが実行される様子を図解した図である。It is the figure which illustrated a mode that the attack code was executed by the stack smashing attack. 非特許文献1の方法によるスタックスマッシング攻撃の防御方法を説明するための図である。It is a figure for demonstrating the defense method of the stack smashing attack by the method of a nonpatent literature 1. FIG. 非特許文献2の方法によるスタックスマッシング攻撃の防御方法を説明するための第1の図である。It is the 1st figure for demonstrating the defense method of the stack smashing attack by the method of a nonpatent literature 2. FIG. 非特許文献2の方法によるスタックスマッシング攻撃の防御方法を説明するための第2の図である。It is the 2nd figure for demonstrating the defense method of the stack smashing attack by the method of a nonpatent literature 2. FIG.

符号の説明Explanation of symbols

10…CPU、11〜13…レジスタ、20…記憶装置、30…入出力部、40…プログラムメモリ、50…RAM、101,101A…不正データ入力検知部、102,102A…開始アドレス特定部、103…通知情報生成部、104…強制オーバーフロー部、105,105A…データ取得部、106,106A…アドレス範囲特定部、107…入力データベース
DESCRIPTION OF SYMBOLS 10 ... CPU, 11-13 ... Register, 20 ... Storage device, 30 ... Input / output unit, 40 ... Program memory, 50 ... RAM, 101, 101A ... Invalid data input detection unit, 102,102A ... Start address specifying unit, 103 ... Notification information generation unit 104 ... Forced overflow unit 105,105A ... Data acquisition unit 106,106A ... Address range identification unit 107 ... Input database

Claims (16)

攻撃コードを含む不正データの入力によってスタックにオーバーフローを引き起こし、上記オーバーフローによって、スタックに格納される呼び出し元関数のコードの戻りアドレスを上記攻撃コードの開始アドレスに書き換えることにより、上記攻撃コードを実行させることが可能なコンピュータに、
上記不正データの入力を検知する第1のステップと、
上記第1のステップにおいて上記不正データの入力が検知された場合、上記不正データの入力による上記オーバーフローで書き換えられた上記戻りアドレスに基づいて、上記攻撃コードの開始アドレスを特定する第2のステップと、
を有する処理を実行させるプログラム。
The attack code is executed by rewriting the return address of the code of the caller function stored in the stack to the start address of the attack code due to overflow of the stack due to input of invalid data including the attack code. To a computer that can
A first step of detecting input of the unauthorized data;
A second step of specifying a start address of the attack code based on the return address rewritten by the overflow caused by the input of the illegal data when the input of the illegal data is detected in the first step; ,
A program for executing a process having
上記第2のステップにおいて、上記コンピュータの所定のレジスタに格納されるポインタであって、上記戻りアドレスが格納されるスタック上のアドレスに関連付けられたポインタに基づいて、上記書き換えられた戻りアドレスを取得する、
請求項1に記載のプログラム。
In the second step, the rewritten return address is obtained based on a pointer stored in a predetermined register of the computer and associated with an address on the stack in which the return address is stored. To
The program according to claim 1.
上記第1のステップにおいて上記不正データの入力が検知された後に新たな関数が呼び出された場合、
上記第2のステップにおいて、上記コンピュータの所定のレジスタに格納されるポインタであって、呼び出し元関数のスタック・フレームにおいて基準となるアドレスを指示するポインタが格納されたスタック上のアドレスに関連付けられたポインタに基づいて、呼び出し元関数の上記基準アドレスを取得し、取得した上記基準アドレスに基づいて、上記書き換えられた戻りアドレスを取得する、
請求項1に記載のプログラム。
When a new function is called after the input of the illegal data is detected in the first step,
In the second step, a pointer that is stored in a predetermined register of the computer and that indicates a reference address in the stack frame of the caller function is associated with an address on the stack that stores the pointer. Acquiring the reference address of the caller function based on the pointer, and acquiring the rewritten return address based on the acquired reference address;
The program according to claim 1.
上記第1のステップにおいて上記攻撃が検知された後、新たに複数の関数が呼び出された場合、
上記第2のステップにおいて、取得した上記基準アドレスに基づいて、更に上位の呼び出し元関数のスタック・フレームにおける上記基準アドレスを取得する処理を反復し、上記反復処理の結果として取得される上記基準アドレスに基づいて、上記書き換えられた戻りアドレスを取得する、
請求項3に記載のプログラム。
When a plurality of functions are newly called after the attack is detected in the first step,
In the second step, based on the acquired reference address, the process of acquiring the reference address in the stack frame of a higher-level caller function is repeated, and the reference address acquired as a result of the iterative process To obtain the rewritten return address based on
The program according to claim 3.
上記第1のステップにおいて、新たな関数が呼び出された場合に所定値のデータをスタック上の所定のアドレスに格納し、呼び出し元関数へ戻る場合に当該アドレスに格納されるデータの値と上記所定値とを比較し、当該比較結果に基づいて、上記オーバーフローの発生の有無を検知する、
請求項1に記載のプログラム。
In the first step, when a new function is called, a predetermined value of data is stored at a predetermined address on the stack, and when returning to the caller function, the value of the data stored at the address and the predetermined value are stored. Comparing the value and detecting the occurrence of the overflow based on the comparison result,
The program according to claim 1.
上記第1のステップにおいて、新たに呼び出すべき関数に引数として渡されるデータのサイズと、上記関数において上記引数に割り当てられているデータサイズとを比較し、当該比較結果に基づいて、上記関数が呼び出された場合における上記オーバーフローの発生の有無を事前に検知し、
上記第1のステップにおいて上記オーバーフローの発生が事前に検知された場合、上記新たな関数を呼び出して、上記オーバーフローを発生させる第3のステップを有する、
請求項1に記載のプログラム。
In the first step, the size of data passed as an argument to the function to be newly called is compared with the data size assigned to the argument in the function, and the function is called based on the comparison result. In the case of occurrence of the above overflow,
When the occurrence of the overflow is detected in advance in the first step, the method includes a third step of calling the new function to generate the overflow.
The program according to claim 1.
上記第1のステップにおいて上記不正データの入力が検知された場合、上記不正データの入力によって上記オーバーフローが引き起こされたメモリ領域のデータを取得する第4のステップと、
上記第2のステップにおいて特定された上記攻撃コードの開始アドレスと、上記第4のステップにおいて取得されたデータとに応じて、上記攻撃コードが格納されるアドレス範囲を特定する第5のステップと、を有する、
請求項1に記載のプログラム。
A fourth step of acquiring data in the memory area where the overflow is caused by the input of the illegal data when the input of the illegal data is detected in the first step;
A fifth step of specifying an address range in which the attack code is stored according to the start address of the attack code specified in the second step and the data acquired in the fourth step; Having
The program according to claim 1.
上記第5のステップにおいて、上記第4のステップで取得されたデータと所定のデータとを、上記第2のステップで特定された攻撃コードの開始アドレスから順に比較し、上記所定のデータと一致するデータが格納されるアドレスを検索する、
請求項7に記載のプログラム。
In the fifth step, the data acquired in the fourth step and the predetermined data are compared in order from the start address of the attack code specified in the second step, and coincide with the predetermined data. Search for the address where the data is stored,
The program according to claim 7.
プロセスの実行に伴って入力されるデータを記録する第6のステップを有し、
上記第5のステップにおいて、上記第4のステップで取得されたデータと上記第6のステップで記録された入力データとを、上記第2のステップで特定された攻撃コードの開始アドレスから順に比較し、上記入力データと一致するデータが格納されるアドレスを検索する、
請求項7に記載のプログラム。
A sixth step of recording data input as the process is performed;
In the fifth step, the data acquired in the fourth step and the input data recorded in the sixth step are compared in order from the start address of the attack code specified in the second step. Search for an address where data matching the input data is stored,
The program according to claim 7.
上記第2のステップにおいて上記攻撃コードの開始アドレスが特定された場合、少なくとも、当該特定された開始アドレスに関する情報、または当該開始アドレスより格納される攻撃コードに関する情報を含んだ所定の通知情報を生成する第7のステップを有する、
請求項1に記載のプログラム。
When the attack code start address is specified in the second step, at least information related to the specified start address or predetermined notification information including information related to the attack code stored from the start address is generated Having a seventh step,
The program according to claim 1.
攻撃コードを含む不正データの入力によってスタックにオーバーフローを引き起こし、上記オーバーフローによってスタックに格納される呼び出し元関数のコードの戻りアドレスを上記攻撃コードの開始アドレスに書き換えることにより、上記攻撃コードを実行させることが可能なコンピュータに、
予め設定されたメモリ領域のデータが実行すべき命令コードとして上記コンピュータに取得されたか否かを検知する第1のステップと、
上記第1のステップにおいて上記命令コードの取得が検知された場合、上記コンピュータの所定のレジスタに格納される、実行すべき命令コードのアドレスを指示するポインタに基づいて、上記攻撃コードの開始アドレスを特定する第2のステップと、
を有する処理を実行させるプログラム。
The attack code is executed by rewriting the return address of the code of the caller function stored in the stack by the overflow to the start address of the attack code. To a computer that can
A first step of detecting whether data in a preset memory area is acquired by the computer as an instruction code to be executed;
When the acquisition of the instruction code is detected in the first step, the start address of the attack code is set based on a pointer stored in a predetermined register of the computer and indicating the address of the instruction code to be executed. A second step of identifying;
A program for executing a process having
攻撃コードを含む不正データがコンピュータに入力されてスタックにオーバーフローが引き起こされ、上記オーバーフローによってスタックに格納される呼び出し元関数のコードの戻りアドレスが上記攻撃コードの開始アドレスに書き換えられることにより、上記コンピュータにおいて実行され得る上記攻撃コードを抽出する攻撃コード抽出装置であって、
上記不正データの入力を検知する不正データ入力検知手段と、
上記不正データ入力検知手段において上記不正データの入力が検知された場合、上記不正データの入力による上記オーバーフローで書き換えられたスタックに格納される上記戻りアドレスに基づいて、上記攻撃コードの開始アドレスを特定する開始アドレス特定手段と、
を有する攻撃コード抽出装置。
When illegal data including attack code is input to the computer and the stack is overflowed, the return address of the caller function code stored in the stack is rewritten to the start address of the attack code. An attack code extraction device for extracting the attack code that can be executed in
Unauthorized data input detection means for detecting the input of the unauthorized data;
When the illegal data input detecting means detects the illegal data input, the start address of the attack code is specified based on the return address stored in the stack rewritten by the overflow caused by the illegal data input. A starting address specifying means to perform,
An attack code extraction apparatus having
上記不正データ入力検知手段において上記不正データの入力が検知された場合、上記不正データの入力によって上記オーバーフローが引き起こされたメモリ領域のデータを取得するデータ取得手段と、
上記アドレス特定手段において特定された上記攻撃コードの開始アドレスと、上記データ取得手段において取得されたデータとに応じて、上記攻撃コードが格納されるアドレス範囲を特定するアドレス範囲特定手段と、を有する、
請求項12に記載の攻撃コード抽出装置。
A data acquisition means for acquiring data in the memory area where the overflow is caused by the input of the illegal data when the illegal data input detection means detects the input of the illegal data;
Address range specifying means for specifying an address range in which the attack code is stored according to the start address of the attack code specified by the address specifying means and the data acquired by the data acquisition means ,
The attack code extraction device according to claim 12.
攻撃コードを含む不正データがコンピュータに入力されてスタックにオーバーフローが引き起こされ、上記オーバーフローによってスタックに格納される呼び出し元関数のコードの戻りアドレスが上記攻撃コードの開始アドレスに書き換えられることにより、上記コンピュータにおいて実行され得る上記攻撃コードを抽出する攻撃コード抽出装置であって、
予め設定されたメモリ領域のデータが実行すべき命令コードとして上記コンピュータに取得されたか否かを検知する命令コード取得検知手段と、
上記命令コード取得検知手段において上記命令コードの取得が検知された場合、上記コンピュータの所定のレジスタに格納される、実行すべき命令コードのアドレスを指示するポインタに基づいて、上記攻撃コードの開始アドレスを特定する開始アドレス特定手段と、
を有する攻撃コード抽出装置。
When illegal data including attack code is input to the computer and the stack is overflowed, the return address of the caller function code stored in the stack is rewritten to the start address of the attack code. An attack code extraction device for extracting the attack code that can be executed in
Instruction code acquisition detecting means for detecting whether or not data in a preset memory area is acquired by the computer as an instruction code to be executed;
When acquisition of the instruction code is detected by the instruction code acquisition detection means, the attack code start address is stored in a predetermined register of the computer and points to the instruction code address to be executed. A start address specifying means for specifying
An attack code extraction apparatus having
攻撃コードを含む不正データがコンピュータに入力されてスタックにオーバーフローが引き起こされ、上記オーバーフローによってスタックに格納される呼び出し元関数のコードの戻りアドレスが上記攻撃コードの開始アドレスに書き換えられることにより、上記コンピュータにおいて実行され得る上記攻撃コードを抽出する攻撃コード抽出方法であって、
上記不正データの入力を検知する第1の工程と、
上記第1の工程において上記不正データの入力が検知された場合、上記不正データの入力による上記オーバーフローで書き換えられたスタックに格納される上記戻りアドレスに基づいて、上記攻撃コードの開始アドレスを特定する第2の工程と、
を有する攻撃コード抽出方法。
When illegal data including attack code is input to the computer and the stack is overflowed, the return address of the caller function code stored in the stack is rewritten to the start address of the attack code. An attack code extraction method for extracting the attack code that can be executed in
A first step of detecting input of the unauthorized data;
When an input of the illegal data is detected in the first step, a start address of the attack code is specified based on the return address stored in the stack rewritten by the overflow caused by the input of the illegal data A second step;
An attack code extraction method comprising:
攻撃コードを含む不正データがコンピュータに入力されてスタックにオーバーフローが引き起こされ、上記オーバーフローによってスタックに格納される呼び出し元関数のコードの戻りアドレスが上記攻撃コードの開始アドレスに書き換えられることにより、上記コンピュータにおいて実行され得る上記攻撃コードを抽出する攻撃コード抽出方法であって、
予め設定されたメモリ領域のデータが実行すべき命令コードとして上記コンピュータに取得されたか否かを検知する第1の工程と、
上記命令コード取得検知手段において上記命令コードの取得が検知された場合、上記コンピュータの所定のレジスタに格納される、実行すべき命令コードのアドレスを指示するポインタに基づいて、上記攻撃コードの開始アドレスを特定する第2の工程と、
を有する攻撃コード抽出方法。
When illegal data including attack code is input to the computer and the stack is overflowed, the return address of the caller function code stored in the stack is rewritten to the start address of the attack code. An attack code extraction method for extracting the attack code that can be executed in
A first step of detecting whether data in a preset memory area is acquired by the computer as an instruction code to be executed;
When acquisition of the instruction code is detected by the instruction code acquisition detection means, the attack code start address is stored in a predetermined register of the computer and points to the instruction code address to be executed. A second step of identifying
An attack code extraction method comprising:
JP2003273617A 2003-07-11 2003-07-11 Program, attack code extracting apparatus, and its method Pending JP2005032182A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP2003273617A JP2005032182A (en) 2003-07-11 2003-07-11 Program, attack code extracting apparatus, and its method

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP2003273617A JP2005032182A (en) 2003-07-11 2003-07-11 Program, attack code extracting apparatus, and its method

Publications (1)

Publication Number Publication Date
JP2005032182A true JP2005032182A (en) 2005-02-03

Family

ID=34210803

Family Applications (1)

Application Number Title Priority Date Filing Date
JP2003273617A Pending JP2005032182A (en) 2003-07-11 2003-07-11 Program, attack code extracting apparatus, and its method

Country Status (1)

Country Link
JP (1) JP2005032182A (en)

Cited By (3)

* 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
JP2017514260A (en) * 2014-07-31 2017-06-01 エヌイーシー ラボラトリーズ アメリカ インクNEC Laboratories America, Inc. Transparent detection and extraction of return-oriented programming attacks
CN111209042A (en) * 2020-01-06 2020-05-29 北京字节跳动网络技术有限公司 Method, device, medium and electronic equipment for establishing function stack

Cited By (4)

* 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
JP2017514260A (en) * 2014-07-31 2017-06-01 エヌイーシー ラボラトリーズ アメリカ インクNEC Laboratories America, Inc. Transparent detection and extraction of return-oriented programming attacks
CN111209042A (en) * 2020-01-06 2020-05-29 北京字节跳动网络技术有限公司 Method, device, medium and electronic equipment for establishing function stack
CN111209042B (en) * 2020-01-06 2022-08-26 北京字节跳动网络技术有限公司 Method, device, medium and electronic equipment for establishing function stack

Similar Documents

Publication Publication Date Title
JP4741782B2 (en) Computer immune system and method for detecting undesirable codes in a computer system
Kang et al. Renovo: A hidden code extractor for packed executables
Liang et al. Fast and automated generation of attack signatures: A basis for building self-protecting servers
Carmony et al. Extract Me If You Can: Abusing PDF Parsers in Malware Detectors.
US7103913B2 (en) Method and apparatus for determination of the non-replicative behavior of a malicious program
US20240012907A1 (en) Cloud based just in time memory analysis for malware detection
US7779472B1 (en) Application behavior based malware detection
EP0636977B1 (en) Method and apparatus for detection of computer viruses
JP4518564B2 (en) Method for preventing unauthorized code execution, program for preventing unauthorized code execution, and recording medium for program for preventing unauthorized code execution
US7631356B2 (en) System and method for foreign code detection
US7934261B1 (en) On-demand cleanup system
US20050262567A1 (en) Systems and methods for computer security
KR20180032566A (en) Systems and methods for tracking malicious behavior across multiple software entities
US9038161B2 (en) Exploit nonspecific host intrusion prevention/detection methods and systems and smart filters therefor
US7251735B2 (en) Buffer overflow protection and prevention
WO2019133637A1 (en) Detection of exploitative program code
KR101064164B1 (en) Kernel integrity inspection and the recovery method on linux kernel based smart platform
US8938807B1 (en) Malware removal without virus pattern
US7350235B2 (en) Detection of decryption to identify encrypted virus
CN112463287A (en) Method and system for processing access request based on instrumentation
JP4643201B2 (en) Buffer overflow vulnerability analysis method, data processing device, analysis information providing device, analysis information extraction processing program, and analysis information provision processing program
JP2005032182A (en) Program, attack code extracting apparatus, and its method
EP2720170A1 (en) Automated protection against computer exploits
JP2007219786A (en) System for preventing information leakage by unknown malware
EP3293660A1 (en) System and method of detecting malicious code in files