代码:
print hex(pe.OPTIONAL_HEADER.AddressOfEntryPoint)
实验二
代码:
import os, string, shutil,re
import pefile ##记得import pefile
PEfile_Path = r"C:\temp\test.exe"
pe = pefile.PE(PEfile_Path)
print PEfile_Path
for section in pe.sections:
print section
代码:
实验二结果
C:\temp\test.exe
[IMAGE_SECTION_HEADER]
Name: .text
Misc: 0x418
Misc_PhysicalAddress: 0x418
Misc_VirtualSize: 0x418
VirtualAddress: 0x220
SizeOfRawData: 0x420
PointerToRawData: 0x420
PointerToRelocations: 0x0
PointerToLinenumbers: 0x0
NumberOfRelocations: 0x0
NumberOfLinenumbers: 0x0
Characteristics: 0x60000020
[IMAGE_SECTION_HEADER]
Name: .rsrc
Misc: 0x128
Misc_PhysicalAddress: 0x128
Misc_VirtualSize: 0x128
VirtualAddress: 0x640
SizeOfRawData: 0x130
PointerToRawData: 0x840
PointerToRelocations: 0x0
PointerToLinenumbers: 0x0
NumberOfRelocations: 0x0
NumberOfLinenumbers: 0x0
Characteristics: 0x40000040
可以看出此文件有2个节.text 和 .rsrc,并且给出了节的相关信息。当然如果你需要获得某一节的具体的某个信息如Characteristics,可以采用