当前位置:网站首页>逆向调试入门-PE中的VA与RVA换算04/07
逆向调试入门-PE中的VA与RVA换算04/07
2022-06-30 12:36:00 【51CTO】
区块特点:
1、内存页的属性
2、节的偏移地址
3、节的尺寸
4、不进行映射的节
节事实上就是相同属性数据的组合。

文件与内存映射的关系
公式为
RVA是相对虚拟地址(RelativeVirtualAddress)的缩写。RVA是当PE文件被装载到内存中后,某个数据位置相对于文件头的偏移量。
参考文章:
在实际情况下,我们常常会遇到将代码段中访问的RVA转换成PA,在这种情况下需要读取⽂件头来做相应的转换。

转换过程
转换的⼀般步骤为:
1、将exe⽂件映射⼊内存中,读取Dos MZ Header,在这个结构中,我们能够通过e_lfanew来获取NT⽂件头相对于Dos⽂件头的偏移。

MZ头部

DOS头部相对于PE头部的偏移
2、获取到了NT⽂件头的地址,NT⽂件头中包含了两个⽂件头,⼀个是FILE⽂件头,⼀个是Optional可选⽂件头,在FILE⽂件头中我们可以读取到段的数量,在转换RVA地址的时候,我们只需要得到这个数量。

段的数量为8
3、将NT⽂件头之后紧跟着的就是SECTION TABLE,这是段描述头,在这个段描述头中,我们⼏乎可以获取到全部的段的资料。
VritualAddress: 这个是⼀个RVA地址,代表的意义是告诉PE加载器该段存在于RVA地址为VritualAddress处

VA为1000H
PointerToRawData: 这是⼀个物理偏移地址,告诉PE加载器将物理⽂件偏移PointerToRawData处的数据映射⼊VritualAddress处
VirtualSize: 该段的⼤⼩
SizeOfRawData: 该段的物理⼤⼩。由于存在对齐问题,所以该⼤⼩为不⼩于VirtualSize⼤⼩的对齐⼤⼩的整数倍。
4.通过遍历SECTION TABLE,判断要转换的RVA地址是否处于所有段的RVA地址范围内。该段的RVA范围为: VritualAddress + SizeOfRawData,当然更精确点是VirtualAddress + VirtualSize。
5.假如存在于地址范围内,那么我们可以通过要转换的RVA地址减去该段的VirtualAddress算出相对于该段的偏移量
6.将偏移量加上PointerToRawData,即可算出物理地址。
算法比较复杂。
我们使用OD工具分析。

我们看下地址00400200

果然这地址为code的代码块。
边栏推荐
- 【C】深入理解指针、回调函数(介绍模拟qsort)
- Analysis of smart jiangcai login in Jiangxi University of Finance and Economics
- Machine learning notes - Introduction to autocorrelation and partial autocorrelation
- Ffmpeg miscellaneous
- [surprised] the download speed of Xunlei is not as fast as that of the virtual machine
- Definition of variables and assignment of variables in MySQL
- Resource realization applet opening traffic main tutorial
- Unity脚本程序的开发
- 【OpenGL】OpenGL Examples
- Postman automatically generates curl code snippets
猜你喜欢
随机推荐
FlinkSQL自定义UDATF实现TopN
PG基础篇--逻辑结构管理(表继承、分区表)
Goods and services - platform properties
Three ways for flinksql to customize udaf
[yitianxue awk] regular matching
黑马笔记---集合(Collection的常用方法与遍历方式)
全面解析免费及收费SSH工具的基本特性和总结
Unity的脚本的基础语法(2)-Unity中记录时间
[qnx hypervisor 2.2 user manual]6.2.3 communication between guest and external
Unity脚本程序的开发
Exploring the source code of Boca Cross Chain Communication: Elements
zabbix-server启动失败处理方式
排查问题的方法论(适用于任何多方合作中产生的问题排查)
IDEA 2021.3 执行 golang 报错:RNING: undefined behavior version of Delve is too old for Go version 1.18
App wechat payment unicloud version of uniapp payment (with source code)
Ffmpeg miscellaneous
Tronapi- wavefield interface - source code without encryption - can be opened in two places - interface document attached - encapsulation based on thinkphp5 - detailed guidance of the author - 21:59:3
Machine learning notes - Introduction to autocorrelation and partial autocorrelation
Resource realization applet opening traffic main tutorial
uniapp支付之APP微信支付unicloud版(附源码)








