调试版本如何使逆向工程变得容易?
这里的一些答案指出调试信息将使对软件进行逆向工程变得更容易。当我使用 Visual C++ 并分发带有调试信息但没有其他文件 (.pdb) 的可执行文件时,它会包含任何有趣的内容吗?
我用十六进制编辑器查看了可执行文件,没有发现任何类似符号名称的东西,现在我假设 .exe 文件只是链接到 .pdb 文件中的信息,对吗?
你知道它是否包含
- 变量名吗?
- 函数/成员名称?
- 行号?
- 有什么有趣的吗?
Some answer here stated that debug info would make it easier to reverse engineer the software. When I use Visual C++ and distribute an executable with debugging information but without other files (.pdb), will it contain any interesting things?
I looked to the executable with a hex editor and found nothing like symbol names, for now I assume the .exe file just links to information in the .pdb files, right?
Do you know whether it contains
- variable names?
- function/member names?
- line numbers?
- anything interesting?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
调试构建往往会生成可以轻松与高级语言结构关联的输出。只需查看机器代码,您就可以识别变量、测试、循环等。您不会获得变量的名称,但这通常是逆向工程时最不重要的考虑因素之一。
优化代码,OTOH,重新排列指令,展开循环,重用多个变量的槽,在函数之间共享代码块,内联小函数等等,使得辨别原始意图变得更加困难。即使您拥有代码,它也使调试变得更加困难,因为当前行标记通常非常具有误导性,并且变量往往会消失或显示随机垃圾。
不过,这一切并不意味着逆向工程成为不可能。只是需要做更多的工作来弄清楚其含义。
Debug builds tend to generate output that can easily be correlated with high-level language constructs. You can identify variables, tests, loops, etc., just by looking at the machine code. You won't get names of variables, but that's usually among the least important considerations when reverse-engineering.
Optimised code, OTOH, rearranges instructions, unfolds loops, reuses slots for multiple variables, shares blocks of code between functions, inlines small functions and so on, making it quite a bit more difficult to discern the original intent. It also makes it more difficult to debug, even if you own the code, since the current line marker is often very misleading, and variables tend to disappear or show random crap.
None of this makes reverse-engineering impossible, though. It's just more work to tease out the meaning.
使用调试信息构建不是“调试构建”。
“调试构建”是定义 _DEBUG 符号时的构建。如果是这样,就有很多可用于逆向工程的字符串(断言等)。
因此,您可以使用.pbd中的调试信息进行Release构建,并且反编译程序将与没有调试信息一样困难。
Build with debugging information isn't "debug build".
"Debug build" is such build when _DEBUG symbol is defined. If so, there are lots of strings useful for reverse-engineer (asserts, etc).
So you can make Release build with debugging information in .pbd, and to decompile the program will be as hard as without debugging information.
可执行文件不应包含变量名或行号。它可能包含导出的任何此类名称的函数/成员名称(更可能是 lib/dll 而不是 exe)。
代码的结构将“更接近”类似于原始源代码 - 代码不太可能被内联、语句重新排序、循环展开等。
The executable should not contain variable names or line numbers. It may contain function/member names, for any such names that are exported (more likely for a lib/dll than an exe).
The structure of the code will "more closely" resemble the original source code - it's unlikely that code will have been inlined, had statements re-ordered, had loops unrolled, etc.
优化使代码更难理解(并且在使用符号和源代码调试自己的代码时也更难将源代码和程序集关联起来)。
调试版本不包含行号、函数名称,也不包含行号,这些属于 PDB。但是,每次使用 assert()该代码将包含一个包含文件名和行号的字符串。
Optimizations make code harder to understand (and also make it harder to correlate between the source and the assembly when debugging your own code with symbols and sources).
A debug build does not include line numbers, function names, nor line numbers, these belong to the PDB. However, every time you use assert() the code will include a string that contains file names and line numbers.
很久以前,调试信息被附加到可执行文件中(以所谓的 CodeView 格式)。如今,它大多单独出现在 PDB 文件中。 exe 本身确实只包含 PDB 的链接。
PDB 通常有两种类型:私有和公共(也称为剥离)。公共(例如,由微软提供的)通常只有函数和全局变量的名称。私有的(例如,当您使用调试信息构建应用程序时生成的)还可以包括类型信息(结构、枚举、类、变量类型)函数原型、局部变量名称和类型以及行号信息。
如果要检查 PDB,请检查 Visual Studio 安装中“DIA SDK”文件夹中的 DIA2Dump。
Long time ago the debug information was attached to the executable (in so-called CodeView format). These days it mostly comes separately in PDB files. The exe itself indeed only includes a link to the PDB.
PDBs usually come in two flavors: private and public (aka stripped). Public (e.g. those provided by Microsoft) usually have only names of the functions and global variables. Private ones (e.g. the ones produced when you build your app with debug info) can additionally include type information (structures, enums, classes, types of variables) function prototypes, local variable names and types and line number info.
If you want to examine your PDBs, check DIA2Dump in the "DIA SDK" folder in your Visual Studio installation.