ida入门教程

410 阅读3分钟

ELF

image.png

ELF64:Executable and Linkable Format

DWARF

image.png

DWARF 第一版发布于 1992 年, 主要是为UNIX下的调试器提供必要的调试信息,例如PC地址对应的文件名及行号等信息,以方便源码级调试, 其包含足够的信息以供调试器完成特定的一些功能, 例如显示当前栈帧(Stack Frame)下的局部变量, 尝试修改一些变量, 直接跳到函数末尾等。

有足够的可扩展性,可为多种语言提供调试信息: 如: Ada, CC++ , Fortran, Java, Objective CGoPython, Haskell ... , 除了编译/调试器外,还可用于从运行时地址还原源码对应的符号|行号的工具(如: atos)

ida的自动分析过程和阶段

ida分析so的过程是异步的,

自动分析会先后有多个阶段,其中阶段的名称是2个字母的缩写,可以在左下角看到

具体阶段和含义是:

  • FL:<address> execution FLow is being traced
  • PR:<address> a function (=PRocedure?) is being created
  • TL:<address> a function TaiL is being created
  • SP:<address> the Stack Pointer is being traced
  • AC:<address> the Address is being analyzed
  • LL:<number> a signature file is being loaded
  • L1:<address> the first pass (Level 1) of FLIRT
  • L2:<address> the second pass (Level 2) of FLIRT
  • L3:<address> the third pass (Level 3) of FLIRT
  • TP:<address> TPpe information is being applied
  • FI:<address> the FInal pass of autoanalysis
  • WF:<address> Weak execution Flow is being traced
  • AU: idle Autoanalysis is finished

image.png

一般我们没有必要等待全部分析完毕,除非我们观察到的地址ida没有分析到

快捷键

使用tab键在text view和Pseudo之间快速切换

查找引用

image.png

快捷键为X,在结果列表中列出来调用这个函数的所有地方,offset可以认为是函数内的某一行

image.png

ida的引用列表还展示了前后关系

Imports窗口是导入表(so调用到外面的函数)

image.png

Exports窗口是导出表(so中能让外部调用的函数)

image.png

ida 会智能还原出pseudo code(伪代码)

image.png

导入jni头文件更加智能还原代码

image.png

报错

Error G:\sdk\ndk\23.1.7779620\toolchains\llvm\prebuilt\windows-x86_64\sysroot\usr\include\jni.h:26: Can't open include file 'stdarg.h'
Total 1 errors

意思是找不到stdarg.h这个头文件,这个文件在

     G:\sdk\ndk\23.1.7779620\toolchains\llvm\prebuilt\windows-x86_64\lib64\clang\12.0.8\include\stdarg.h

stdarg.h和jni.h不在同一个目录,可以设置下头文件目录

Options/Compiler中设置include directories,两个路径间用”;”分隔。

image.png

又提示

Error G:\sdk\ndk\23.1.7779620\toolchains\llvm\prebuilt\windows-x86_64\lib64\clang\12.0.8\include\stdint.h:20: Syntax error near: <END>
  included from G:\sdk\ndk\23.1.7779620\toolchains\llvm\prebuilt\windows-x86_64\sysroot\usr\include\jni.h:27
Total 1 errors

G:\sdk\ndk\23.1.7779620\sources\cxx-stl\llvm-libc++\include\stdint.h

image.png

感觉像是识别不了语法导致的,我们不编译,将jni.h复制出来,单独注释掉这2个行,在让ida加载就正常了

// #include <stdarg.h>
// #include <stdint.h>

动态调试

www.52pojie.cn/thread-7426…

线性视图

image.png

  • library function为库函数
  • data为数据
  • regular function为规则函数
  • unexplored为未查过的
  • instruction为指令
  • external symbol为外部符号。