Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PE header data is returned partially with pefile 2024.8.26 #430

Open
platomav opened this issue Oct 7, 2024 · 0 comments
Open

PE header data is returned partially with pefile 2024.8.26 #430

platomav opened this issue Oct 7, 2024 · 0 comments

Comments

@platomav
Copy link

platomav commented Oct 7, 2024

Hello,

The latest pefile release, 2024.8.26, appears to incorrectly get the full data of the PE header in some cases. This can cause various issues later down the line, especially when attempting to "get_data()" and/or calculate hashes based on the size/end of the PE header.

I have attached below a sample PE binary, alongside its header data, which triggers the issue:

a8346d8cfa1c3241fa006216d22a679d6bf2d10bac33993cb728650ba6e2b4c6.zip

At pefile 2023.2.7, the header data size is 0x280. However, at 2024.8.26, the header data size is 0x270 instead. The missing data is 16 (0x10) bytes of (what appears to be) 0x00 padding at the end of the PE header:

Screenshot 2024-10-07 145212

After a few hours of debugging between 2023.2.7 and 2024.8.26, the issue seems to originate from this call:

pefile/pefile.py

Line 3322 in 4b3b1e2

self.adjust_PointerToRawData(s.PointerToRawData)

Applying git blame on this call, the following commit by @erocarrera comes up:

Improve and document handling of PointerToRawData values (4934b7d)

I have confirmed that adding back those 0x10-sized null bytes at the end of the header data, does produce the same end-user results as pefile 2023.2.7.

@platomav platomav changed the title PE header data is returned partially when using pefile 2024.8.26 vs 2023.2.7 PE header data is returned partially with pefile 2024.8.26 Oct 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant