如何通过调试器工具找到未知 exe 的命令行/参数?
假设我有一个已编译的exe,并且我想找到exe的参数或命令行参数,我该如何使用调试器来做到这一点?我认为这个主题属于逆向工程的范畴,但我似乎找不到如何实现这个技巧的指南。
我能得到的最接近的是在 exe 上使用调试器,并在 CreateProcess 上设置断点。但是,如何在调试器中找到 CreateProcess 函数呢?
Suppose I have a compiled exe, and I want to find the parameter or command line argument of the exe, how do I do it using a debugger? I think this topic enters into category of reverse engineering, but I can't seem to find a guide of how to achieve this trick.
The closest that I could get is to use a debugger on the exe, and set breakpoints on CreateProcess. However, how do I find the CreateProcess function inside the debugger?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用一些命令行参数运行 exe,例如“target.exe -whateverabc”
然后,当调试器加载 exe 时,在内存中搜索 -whateverabc 并在该内存位置和可能的重复项上设置读取断点。希望当断点触发时,您将进入检查该 exe 中的命令行参数的函数内。
要在 CreateProcess 上设置断点,您可以在某些调试器中键入“bpx CreateProcess”。
或者编写一个小应用程序,在 kernel32.dll 上使用 LoadLibrary 或包含您的函数的 dll,然后使用函数名称的 GetProcAddress 来获取其地址。然后在该地址上设置执行断点;
Run the exe with some command line parameter, like "target.exe -whateverabc"
Then when your debugger loads the exe, search the memory for -whateverabc and set a read breakpoint on that memory location and possible duplicates. Hopefully when the breakpoint triggers you'll be inside the function that checks the command line parameters in that exe.
To set a breakpoint on CreateProcess you can type 'bpx CreateProcess" in some debuggers.
Or write a small app that uses LoadLibrary on kernel32.dll or w/e dll that contains your function and then GetProcAddress w/ the name of the function to get its address. Then you set a breakpoint on execution on that address;
某些调试器允许您在调试对象的上下文中调用任意函数,因此如果您的调试器支持该功能,则可以调用 GetCommandLine() 函数。
另一种选择是采用半文档化的 TEB 和 PEB 结构。您需要转到 fs:30h (PEB),然后 ProcessParameters,并检查其中的 CommandLine 字段。
Some debuggers allow you to call an arbitrary function in the context of debuggee, so if yours supports that, you can call the GetCommandLine() function.
Another option is to go via semi-documented TEB and PEB structures. You would need to go to fs:30h (PEB), then ProcessParameters, and examine the CommandLine field there.