日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

14.IDA-XREF(交叉引用)概述

發(fā)布時間:2024/4/11 编程问答 26 豆豆
生活随笔 收集整理的這篇文章主要介紹了 14.IDA-XREF(交叉引用)概述 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

XREF分類

CODE XREF:代碼交叉引用?
DATA XREF:數(shù)據(jù)交叉引用

XREF描述含義

  • 這是個代碼交叉引用
  • sub401000是被引用者,main+2A是引用者(引用sub401000的位置)
  • 下箭頭表示引用者的地址比sub401000高,你需要向下滾動才能到達(dá)引用者地址(main+2A),上行反之~?
    4.每個交叉引用注釋都包含一個單字符后綴(箭頭后面),用以說明交叉引用的類型,這里是↓P
  • CODE XREF

    代碼交叉引用用于表示一條指令將控制權(quán)轉(zhuǎn)交給另一條指令。在IDA中,指令轉(zhuǎn)交控制權(quán)的方式叫做流(flow)?
    IDA中有3種基本流:

    普通流?
    調(diào)用流?
    跳轉(zhuǎn)流

    示例代碼:

    int read_it; int write_it; int ref_it; void callflow() {} int main() {int *p = &ref_it;*p = read_it;write_it = *p;callflow();if (read_it == 3){write_it = 2;}else{write_it = 1;}callflow(); }
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21

    示例匯編:

    .text:00401010 ; int __cdecl main(int argc, const char **argv, const char **envp) .text:00401010 _main proc near ; CODE XREF: __tmainCRTStartup+10Ap .text:00401010 .text:00401010 p = dword ptr -4 .text:00401010 argc = dword ptr 8 .text:00401010 argv = dword ptr 0Ch .text:00401010 envp = dword ptr 10h .text:00401010 .text:00401010 push ebp .text:00401011 mov ebp, esp .text:00401013 push ecx .text:00401014 mov [ebp+p], offset int ref_it .text:0040101B mov eax, [ebp+p] .text:0040101E mov ecx, int read_it .text:00401024 mov [eax], ecx .text:00401026 mov edx, [ebp+p] .text:00401029 mov eax, [edx] .text:0040102B mov int write_it, eax .text:00401030call callflow(void) .text:00401035 cmp int read_it, 3 .text:0040103C jnz short loc_40104A .text:0040103E mov int write_it, 2 .text:00401048 jmp short loc_401054 .text:0040104A ; --------------------------------------------------------------------------- .text:0040104A .text:0040104A loc_40104A: ; CODE XREF: _main+2C↑j .text:0040104A mov int write_it, 1 .text:00401054 .text:00401054 loc_401054: ; CODE XREF: _main+38↑j .text:00401054call callflow(void) .text:00401059 xor eax, eax .text:0040105B mov esp, ebp .text:0040105D pop ebp .text:0040105E retn .text:0040105E _main endp .text:0040105E
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36

    普通流

    普通流表示由一條指令到另一條指令的順序流。這是所有非分支指令(如ADD)的默認(rèn)執(zhí)行流。

    調(diào)用流

    如果IDA認(rèn)為某個函數(shù)并不返回(在分析階段確定,注意不是運(yùn)行階段),那么,在調(diào)用該函數(shù)時,它就不會為該函數(shù)分配普通流

    .text:00401030call callflow(void) .text:00401054call callflow(void)
    • 1
    • 2
    • 1
    • 2

    指令用于調(diào)用函數(shù),如③處的 call指令,它分配到一個調(diào)用流(call flow),表示控制權(quán)被轉(zhuǎn)交給目標(biāo)函數(shù)?
    callflow函數(shù)的反匯編:

    .text:00401000 void __cdecl callflow(void) proc near ; ①CODE XREF: _main+20↓p .text:00401000 ; ①_main:loc_401054↓p .text:00401000 push ebp .text:00401001 mov ebp, esp .text:00401003 pop ebp .text:00401004 retn .text:00401004 void __cdecl callflow(void) endp
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7

    callflow所在的位置顯示了兩個交叉引用(①處),表示這個函數(shù)被調(diào)用了兩次

    由函數(shù)調(diào)用導(dǎo)致的交叉引用使用后綴↓p(看做是Procedure)。

    跳轉(zhuǎn)流

    每個無條件分支指令和條件分支指令將分配到一個跳轉(zhuǎn)流(jump flow)

    .text:00401048 jmp short loc_401054 .text:0040104A ; --------------------------------------------------------------------------- .text:0040104A
    • 1
    • 2
    • 3
    • 1
    • 2
    • 3

    無條件分支并沒有相關(guān)的普通流,因為它總會進(jìn)入分支。上處的虛線表示相鄰的兩條指令之間并不存在普通流(也就是00401048后沒有跟著順序執(zhí)行的指令)

    跳轉(zhuǎn)交叉引用使用后綴↑j(看做是Jump)。

    DATA XREF

    數(shù)據(jù)交叉引用用于跟蹤二進(jìn)制文件訪問數(shù)據(jù)的方式。數(shù)據(jù)交叉引用與IDA數(shù)據(jù)庫中任何牽涉到虛擬地址的字節(jié)有關(guān)(換言之,數(shù)據(jù)交叉引用與棧變量毫無關(guān)系)?
    最常用的3種數(shù)據(jù)交叉引用:

    address何時被讀取(讀取交叉引用)?
    address何時被寫入(寫入交叉引用)?
    address何時被引用(偏移量交叉引用)

    .data:00403378 int ref_it db ? ; ; DATA XREF: _main+4↑o .data:00403379 db ? ; .data:0040337A db ? ; .data:0040337B db ? ; .data:0040337C int write_it dd ? ; DATA XREF: _main+1B↑w .data:0040337C ; _main+2E↑w ... .data:00403380 int read_it dd ? ; DATA XREF: _main+E↑r .data:00403380 ; _main+25↑r
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8

    讀取交叉引用

    讀取交叉引用(read cross-reference)表示訪問的是某個內(nèi)存位置的內(nèi)容?
    可以看到read_it在_main+E處、_main+25被讀取,如下

    .text:0040101E mov ecx, int read_it .text:00401035 cmp int read_it, 3
    • 1
    • 2
    • 1
    • 2

    讀取交叉引用使用后綴↑r(看做是Read)。

    寫入交叉引用

    寫入交叉引用指出了修改變量內(nèi)容的程序位置?
    可以看到write_it在_main+1B、_main+2E處被寫入,如下

    .text:0040102B mov int write_it, eax .text:0040103E mov int write_it, 2
    • 1
    • 2
    • 1
    • 2

    寫入交叉引用使用后綴↑w(看做是Write)。

    偏移量交叉引用

    偏移量交叉引用表示引用的是某個位置的地址(而非內(nèi)容)?
    可以看到ref_it在_main+4處被引用

    .text:00401014 mov [ebp+p], offset int ref_it
    • 1
    • 1

    偏移量交叉引用使用后綴↑o(看做是Offset)。

    與僅源自于指令位置的讀取和寫入交叉引用不同,偏移量交叉引用可能源于指令位置或數(shù)據(jù)位置,例如虛表
    回溯偏移量交叉引用是一種有用的技術(shù),可迅速在程序的數(shù)據(jù)部分定位C++虛表。

    總結(jié)

    以上是生活随笔為你收集整理的14.IDA-XREF(交叉引用)概述的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

    如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。