# pe病毒 **Repository Path**: hj_research/pe-virus ## Basic Information - **Project Name**: pe病毒 - **Description**: 一个简单的pe病毒编写 - **Primary Language**: Assembly - **License**: Not specified - **Default Branch**: main - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2023-04-04 - **Last Updated**: 2023-04-04 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README ##pe病毒,hook窗口函数为例 ![image-20211214171833907](https://gitee.com/tomhuang1/fengshen-battle-gallery/raw/master/picture/image-20211214171833907.png) #### 用函数名称找到入口地址 (1)首先得到导出表的地址。定位到PE头,从PE文件头中找到数据目录表,表项的第一个双字值就是导出表的起始RVA (2)从导出表的NumberOfNames字段得到已命名函数的总数,并以这个数字作为循环的次数来构造一个循环 (3)从AddressOfNames字段指向的函数名称地址表的第一项开始,在循环中将每一项定义的函数名与要查找的函数名相比较,如果没有任何一个函数名是符合的,表示文件中没有指定名称的函数 (4)如果某一项定义的函数名与要查找的函数名符合,那么记下这个函数名在字符串地址表中的索引值,然后在AddressOfNameOrdinals指向的数组中以同样的索引值取出数组项的值,暂且假定这个值为x。 (5)最后,以x值作为索引值,在AddressOfFunctions字段指向的函数入口地址表中获取的RVA就是函数入口地址RVA,将此RVA加上动态链接库的基地址得到函数入口地址VA #### 代码重定位 ![image-20211214184836172](https://gitee.com/tomhuang1/fengshen-battle-gallery/raw/master/picture/image-20211214184836172.png) ![image-20211214184846839](https://gitee.com/tomhuang1/fengshen-battle-gallery/raw/master/picture/image-20211214184846839.png) ![image-20211214184857294](https://gitee.com/tomhuang1/fengshen-battle-gallery/raw/master/picture/image-20211214184857294.png) 解决之道: ![image-20211214185333286](https://gitee.com/tomhuang1/fengshen-battle-gallery/raw/master/picture/image-20211214185333286.png) ![image-20211214185341624](https://gitee.com/tomhuang1/fengshen-battle-gallery/raw/master/picture/image-20211214185341624.png) https://www.zhihu.com/question/492983429/answer/2264063636