- 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:

推薦閱讀
- 基于C語言的程序設計
- 計算機應用
- 高性能混合信號ARM:ADuC7xxx原理與應用開發(fā)
- Hands-On Data Science with SQL Server 2017
- UTM(統(tǒng)一威脅管理)技術概論
- Visual C# 2008開發(fā)技術實例詳解
- 永磁同步電動機變頻調(diào)速系統(tǒng)及其控制(第2版)
- HTML5 Canvas Cookbook
- 精通數(shù)據(jù)科學:從線性回歸到深度學習
- 基于ARM9的小型機器人制作
- SQL Server數(shù)據(jù)庫應用基礎(第2版)
- 數(shù)據(jù)要素:全球經(jīng)濟社會發(fā)展的新動力
- 自適應學習:人工智能時代的教育革命
- Flash CS5二維動畫設計與制作
- Learning Couchbase