=========### Python plugin for Interactive Disassembler IDAPython is an IDA plugin which makes it possible to write scriptsfor IDA in the Python programming language. IDAPython provides fullaccess to both the IDA API and any installed Python module. Check the scripts in the examples directory to get an quick glimpse. Availability------------ Latest stable versions of IDAPython are available from https://github.com/idapython/src Resources--------- The full function cross-reference is readable online at http://www.hex-rays.com/idapro/idapython_docs/ Mailing list for the project is hosted by Google Groups at http://groups.google.com/group/idapython Installation from binaries-------------------------- 1. Install 2.7 from http://www.python.org/2. Copy the whole "python" directory to %IDADIR% - 2.1 또는 2.2 시도 2.1 github idapython/src 에는 plugin 폴더가 없음 - linux 기준 makefile을 통해 생성?
2.2 idapython/bin에는 이미 컴파일 된 바이너리가 있음
- 근데 6.9버전꺼 까지만 있음
3. Copy the contents of the "plugins" directory to the %IDADIR%\plugins\4. Copy "python.cfg" to %IDADIR%\cfg Usage----- - Run script: File / Script file (Alt-F7) - Execute Python statement(s) (Ctrl-F3) - Run previously executed script again: View / Recent Scripts (Alt+F9) * Batch mode execution: Start IDA with the following command line options: -A -OIDAPython:yourscript.py file_to_work_onor-Syourscript.pyor-S"yourscript.py arg1 arg2 arg3" (Please see http://www.hexblog.com/?p=128) If you want fully unattended execution mode, make sure your scriptexits with a qexit() call. By default scripts run after the database is opened. Extended optionformat is: -OIDAPython:[N;]script.py Where N can be: 0: run script after opening database (default) 1: run script when UI is ready 2: run script immediately on plugin load (shortly after IDA starts and before processor modules and loaders) * User init file You can place your custom settings to a file called 'idapythonrc.py'that should be placed to $/.idapro/ or %AppData%\Hex-Rays\IDA Pro The user init file is read and executed at the end of the init process. Please note that IDAPython can be configured with "python.cfg" file. * Invoking Python from IDC The IDAPython plugin exposes a new IDC function "RunPythonStatement(string idc_code)" that allows executionof Python code from IDC * Invoking IDC from Python It is possible to use the idc.Eval() to evaluate IDC expressions from Python * Making Python the default language By default, IDA will use IDC to evaluate expressions. It is possible to change the default language to usePython instead of IDC. In order to do that, please use the following IDC code: RunPlugin("python", 3) To disable Python language and revert back to IDC:RunPlugin("python", 4)
크게 세 가지로 구분할 수 있는데 CFG 전체를 대표하는 graph, 각 basic block을 나타내는 node, basic block들 간의 관계를 나타내는 edge이다.
그림 1은 GDL문법의 일부를 나타내었는데, IDA Pro에서 CFG를 그리기 위해 필요한 문법만 정리하여 놓은것이다.
먼저 graph는 graph_attribute, graph, node, edge 등을 포함한다. graph안에 graph가 재귀적으로 존재할 수 있지만 IDA Pro를 이용해 만든 GDL문법에 서 하위 graph는 포함되지 않는다.
node는 node_attribute를 포함하는데, 이 속성들 중에서도 title 속성에는 노드의 식별자를 기록하고, label속성을 이용하여 모든 바이너리 명령어를 기록한다.
edge는 edge_attribute를 포함하는데, 여러 속성들 중에서도 "sourcename"과 "targetname" 속성이 중요하다. "sourcename"과 "targetname"에는 node의 title에 있는 식별번호가 기록되며, 이는 "sourcename"에서 "targetname"으로 방향성이 있는 간선을 뜻한다.
정리하면, graph 안에 node와 edge들이 있으며 graph, node, edge 각각의 속성을 통해 CFG를 표현한다
4. Extract signature from ida pro db (idb2pat)
This script allows you to easily generate function patterns from an existing IDB database that can then be turned into FLIRT
[Reference]
Running scripts from the command line with idascript http://www.hexblog.com/?p=128
FLARE IDA Pro Script Series: Generating FLAIR function patterns using IDAPython https://www.fireeye.com/blog/threat-research/2015/01/flare_ida_pro_script.html