如何判断二进制文件是否经过 GS 编译且没有符号?

发布于 2024-12-11 01:59:02 字数 164 浏览 0 评论 0原文

我希望能够确定二进制文件是否经过 GS 编译? /GS 是缓冲区安全检查,使用 cookie。我希望能够在没有符号的情况下以通用方式找到它。

BinScope 在尝试检查 GS 时向我提供以下信息: E_PDB_NO_DEBUG_INFO(PDB 已删除简历信息)

有什么想法吗?

I want to be able to determine if a binary is GS compiled or not? /GS being a buffer security check, using a cookie. I want to be able to find this without symbols and in a generic manner.

BinScope gives me the following when it tries to check for GS:
E_PDB_NO_DEBUG_INFO (PDB is stripped of cv info)

Any idea?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

无人接听 2024-12-18 01:59:02

如果您没有 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

If you don't have PDB, there is no good way to do it short of inspecting the binary and looking at the functions. I had thought it should be possible to check the loadconfig directory which records the location of the security cookie, but that's no good. Even if the program is compiled with /GS-, the linked CRT functions still use the 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
一个人的旅程 2024-12-18 01:59:02

如果您的二进制文件没有“加载配置”(例如 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

引用与其逆存储在一起的 cookie:

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

__security_cookie 将有很多引用,而前面的逆只有一个很少。

在 init 列表中会有一个函数用一些伪随机值初始化 cookie。

在二进制文件中搜索这些模式应该可以让您了解是否使用了 /GS。

if your binary does not have a 'load config' ( like for instance windows mobile binaries)
i think it is still quite easy to recognize the pattern:

many functions will look like this:

... [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]

then sub_1007147 looks like this:

.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

referencing the cookie which is stored together with it's inverse:

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

the __security_cookie will have lots of references while the preceeding inverse has only a few.

in the init list there will be a function to initialize the cookie with some pseudo random value.

searching the binary for these patterns should give you an idea if /GS was used.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文