- Machine Learning for Cybersecurity Cookbook
- Emmanuel Tsukerman
- 121字
- 2021-06-24 12:29:03
How to do it...
In the following steps, we will parse the PE header of a file, and then print out notable portions of it:
- Import the PE file and use it to parse the PE header of your desired file:
import pefile
desired_file = "python-3.7.2-amd64.exe"
pe = pefile.PE(desired_file)
- List the imports of the PE file:
for entry in pe.DIRECTORY_ENTRY_IMPORT:
print(entry.dll)
for imp in entry.imports:
print("\t", hex(imp.address), imp.name)
A small portion of the output is shown here:

- List the sections of the PE file:
for section in pe.sections:
print(
section.Name,
hex(section.VirtualAddress),
hex(section.Misc_VirtualSize),
section.SizeOfRawData,
)
The output of the previous code is as follows:

- Print a full dump of the parsed information:
print(pe.dump_info())
A small portion of the output is displayed here:

推薦閱讀
- Hands-On Deep Learning with Apache Spark
- 21天學通PHP
- 走入IBM小型機世界
- 微型計算機控制技術
- INSTANT Varnish Cache How-to
- 3D Printing for Architects with MakerBot
- Machine Learning with Apache Spark Quick Start Guide
- 單片機技術一學就會
- 突破,Objective-C開發速學手冊
- 從零開始學JavaScript
- 基于RPA技術財務機器人的應用與研究
- Mastering OpenStack(Second Edition)
- 網站規劃與網頁設計
- 數據清洗
- Mastering DynamoDB