IDA Python(~ Appcall 編 ~)
0x1 はじめに
IDAPython - くじらとたぬき ではIDA Pythonを用いていくつか例を記述してみた.
今回はAppcall を用いた例について, 覚書を記しておく.
0x2 Appcall とは
Appcall is a mechanism to call functions inside the debugged program from the debugger or your script as if it were a built-in function. Such a mechanism can be used for debugging, fuzzing and testing applications. Appcall mechanism highly depends on the type information of the function to be called. For that reason it is necessary to have a correct function prototype before doing an Appcall, otherwise different or incorrect results may be returned
関数をスクリプトでいい感じに実行できるという機能.
ファジングとか難読化の解析などが想定される.
地味に解析やってるときに便利そう.(IDAでデバッグするかどうかは別として...)
0x3 実行例
シンプルな以下のプログラムを作成する.
その1(MessageBoxA)
Script command(Shift F2)から以下のコードを入力.
Appcall.MessageBoxA(0, "hoge", "hogehoge", 0)
MessageBoxが実行されるのを確認.
その2(add_func 関数を呼び出す)
同様に以下のコードを入力. (※ add_func関数はsub_F75E8Cに相当する)
proto = "int sub_F75E8C(int a, int b);" func = Appcall.proto(0xF75E8C, proto); ret = func(Appcall.int64(2), Appcall.int64(3)); print(ret)
add_func 関数が実行されるのを確認.
0x4 所感
使いどころはいろいろありそう.
0x5 参考
https://hex-rays.com/products/ida/support/tutorials/debugging_appcall.pdf