Windows API (3) GetModuleHandle 逆向

示例代码如下(C++),有一些无效的内容,比如string什么的,无视即可

1
2
3
4
5
6
7
8
9
10
11
12
13
#include<iostream>
#include<windows.h>
#include<winternl.h>
#include<string>
#include<libloaderapi.h>
#include<winuser.h>
using namespace std;

int main() {
HANDLE a = GetModuleHandleA(NULL);
cout << a << endl;
return 0;
}

这里需要关闭随机基址

编译出来之后x86dbg打开,用API断点插件(https://www.52pojie.cn/thread-1384349-1-1.html)直接断在GetModuleHandle

跟跳

第一句是mov edi,edi,查了一下知识点比较多,之后单独开一篇

push保存现场

获取参数1(参数1是module名,这里是NULL表示exe程序自身)

sub扩展局部空间

test重置flag

je跟跳

出乎笔者意料之外,核心内容只有两行

查fs表30偏移

ring0下偏移30存放的指向是PEB的指针

peb+8偏移是ImageBaseAddress,也就是基址

返回eax

至于什么是PEB我觉得可以单开一篇文章,因为网上能找到的讲PEB的文章实在是太少了

能查到的文章基本全是一模一样的互相抄,找了半天最初来源居然是夜影爷爷写的23333,有点戏剧性

  • Copyright: Copyright is owned by the author. For commercial reprints, please contact the author for authorization. For non-commercial reprints, please indicate the source.

扫一扫,分享到微信

微信分享二维码
  • Copyrights © 2019-2024 kier Val
  • Visitors: | Views: