1

我想確定一個二進制文件是否被GS編譯?/GS是一個緩衝區安全檢查,使用cookie。我希望能夠以通用的方式找到這個符號。如何說如果一個二進制是GS編譯或沒有符號?

BinScope給我的時候,它會檢查GS如下: E_PDB_NO_DEBUG_INFO(PDB被剝離的簡歷信息)

任何想法?

回答

1

如果你沒有PDB,沒有很好的方法來做到這一點,檢查二進制文件和看功能。我曾經認爲應該可以檢查記錄安全cookie位置的loadconfig目錄,但這並不好。即使程序與/ GS-編譯,鏈接CRT功能還是使用cookie:

>dumpbin /loadconfig test.exe 

Microsoft (R) COFF/PE Dumper Version 10.00.40219.01 
Copyright (C) Microsoft Corporation. All rights reserved. 


Dump of file test.exe 

File Type: EXECUTABLE IMAGE 

    Section contains the following load config: 

      00000048 size 
        0 time date stamp 
       0.00 Version 
        0 GlobalFlags Clear 
        0 GlobalFlags Set 
        0 Critical Section Default Timeout 
        0 Decommit Free Block Threshold 
        0 Decommit Total Free Threshold 
      00000000 Lock Prefix Table 
        0 Maximum Allocation Size 
        0 Virtual Memory Threshold 
        0 Process Heap Flags 
        0 Process Affinity Mask 
        0 CSD Version 
       0000 Reserved 
      00000000 Edit list 
    >  00408000 Security Cookie  < 
      00407840 Safe Exception Handler Table 
        3 Safe Exception Handler Count 

    Safe Exception Handler Table 

      Address 
      -------- 
      004025D0 
      00404200 
      00405160 
0

,如果你的二進制文件不具有「加載配置」(例如像Windows Mobile的二進制文件) 我認爲這還是相當容易識別的模式:

很多功能看起來就像這樣:

... [function entry] 
.text:01005188     mov  eax, ___security_cookie 
.text:0100518D     mov  [ebp+var_1C], eax 
... [function body] 
.text:010057F6     mov  ecx, [ebp+var_1C] 
.text:010057F9     call sub_1007147 
... [function exit] 

然後sub_1007147看起來是這樣的:

.text:01007147     cmp  ecx, ___security_cookie 
.text:0100714D     jnz  short loc_1007158 
.text:0100714F     test ecx, 0FFFF0000h 
.text:01007155     jnz  short loc_1007158 
.text:01007157     retn 

引用其存儲起來與它的逆餅乾:

.data:01009600 dword_1009600 dd 0FFFF44BFh 
.data:01009604 ___security_cookie dd 0BB40h 

的__security_cookie將有大量引用,而前述逆只有少數。

在init列表中會有一個函數用一些僞隨機值初始化cookie。

搜索這些模式的二進制文件應該給你一個想法,如果/ GS被使用。

相關問題