

在PE文件中简单注入代码,实现在启动前弹窗 - zz89
source link: https://www.cnblogs.com/zz89/p/16760396.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

获得的新知识:
1、kernel32.dll,user32.dll,ntdll.dll等一些dll在同一个PC环境下的映射到虚拟内存基址是一样的。
2、在win8以上系统上,更改PE文件的入口点要大于SizeOfHeaders(在可选文件头中),否则会报错无法运行。

1、实现原理
PE可选文件头有一个AddressOfEntryPoint,更改这个值指向自己代码,执行完自己代码再跳转到原来入口点。
2、实验过程
1、字节的代码
shellcode: 6A 00 6A 00 6A 00 E8 __ __ __ __ E9 __ __ __ ___
调用messagebox过程,压栈调用

这里用了IAT表,为了简单起见直接使用user32.dll中messagebox的地址
e8指令是call指令,后面要补充相对messagbox的地址,e9是jmp指令,要补充相对入口点地址。

将代码注入这个程序
用x32dbg查messagebox地址是0x76D160660。程序入口点为0x00401140。shellcode入口点设置为0x00401030



用wenhex写入shellcode

再把程序入口点修改了

最后,完美运行

Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK