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

Improve PE size / overlay start calculations #254

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

recvfrom
Copy link

Implements fixes for #253

Make it so that the following are handled better:

  • EXEs with Authenticode signatures
  • EXEs with a COFF symbol table / string table
  • EXEs with section headers but no data after

I can contribute tests and/or test binaries too - what's the preferred way of doing this, given that the test data appears encrypted?

Make it so that the following are handled better:
 - EXEs with Authenticode signatures being treated as overlay data
 - EXEs with a COFF symbol table / string table
 - EXEs with section headers but no data after
@erocarrera
Copy link
Owner

Hi,
If the test binaries are in VirusTotal, just give me the hashes and I'll get them from there. Otherwise you can send the binaries directly to me and I'll bundle them into the tests.

# For the Security / Certificate Table, the VirtualAddress is
# a file offset instead of an RVA
largest_offset_and_size = update_if_sum_is_larger_and_within_file(
(directory.VirtualAddress, directory.Size))
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The first item in the tuple given to update_if_sum_is_larger_and_within_file() should be a file offset, not a virtual address.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment above the call is meant to clarify this - for IMAGE_DIRECTORY_ENTRY_SECURITY, a file offset is stored in the VirtualAddress field instead of an actual Relative Virtual Address like in the other DIRECTORY_ENTRYs. For reference, see: https://docs.microsoft.com/en-us/windows/desktop/debug/pe-format#the-attribute-certificate-table-image-only .

@recvfrom
Copy link
Author

Here are two examples for each case:

EXEs with Authenticode signatures

  • 00048c246c8db3c309b759631057f1a5704296803a2ba23e0d9530d14986a130
  • 001a26ff51bf6babf6325983f512cf8d84cadee1ca36f166a41702d94c1b0841

EXEs with a COFF symbol table / string table

  • 01794f55fab26842c12e2a67fc218ad9c1a9201ccf0bf2fbd9f5815d6f20182f
  • 03d896e59d78d4338cae141ea52447190fe9ebd6362acd16d4cd2954039ed5d7

EXEs with section headers but no data after

  • 76c13fe37652df8ce2fde315b6eae4d2e0ec7f9424b4a0d6fc661354a7679da0
  • 39d41e1814a82488f14acfb06e96920ca5a633dc90acb31b21ab98b3cebdef5b

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

Successfully merging this pull request may close these issues.

None yet

2 participants