Skip to content

Add/Extend ELF/PE permissive parsing mode to better handle packed, broken, or malware samples#479

Merged
m4b merged 42 commits intom4b:masterfrom
chf0x:next
Sep 21, 2025
Merged

Add/Extend ELF/PE permissive parsing mode to better handle packed, broken, or malware samples#479
m4b merged 42 commits intom4b:masterfrom
chf0x:next

Conversation

@chf0x
Copy link
Copy Markdown
Contributor

@chf0x chf0x commented Jul 14, 2025

@m4b I’ve been using Goblin to work with malware, and over time I’ve encountered a number of cases where parsing fails. In the strstab issue, you mentioned that you might be open to adding a permissive mode to address such pain points. I’d like to reopen this pull request with the changes I’ve made over time to enable parsing of broken binaries.

There are still a few places where the permissive flag is missing, for example, in strtab. I’d be happy to add those if you think this is worth merging into the main project.

I also probably would need to update tests.

Thank you!

Paul Hordiienko and others added 20 commits April 24, 2025 16:01
- Resolved conflict in src/pe/load_config.rs by keeping the debug log statement
- Brings in latest changes from master including:
  * TLS raw data parser fix
  * LoadConfig cb size fix
  * ELF dynamic string fixes
  * Note type_to_str support for coredump constants
  * PE offset computation fixes
  * Documentation updates
@chf0x chf0x closed this Jul 14, 2025
@chf0x chf0x changed the title Next Add/Extend ELF/PE permissive parsing mode to better handle packed, broken, or malware samples Aug 15, 2025
@chf0x chf0x reopened this Aug 15, 2025
Copy link
Copy Markdown
Contributor

@kkent030315 kkent030315 left a comment

Choose a reason for hiding this comment

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

Thank you for the PR! I reviewed it partly. I'll do more review at the rest of time.

Comment thread src/pe/load_config.rs Outdated
Comment thread src/pe/mod.rs Outdated
Comment thread src/pe/relocation.rs Outdated
Comment thread src/pe/relocation.rs
Comment thread src/pe/relocation.rs Outdated
Comment thread src/pe/section_table.rs
Comment thread src/pe/utils.rs Outdated
Comment thread src/pe/debug.rs Outdated
Comment thread src/pe/header.rs Outdated
@chf0x
Copy link
Copy Markdown
Contributor Author

chf0x commented Aug 16, 2025

Thank you for the review! I’ll work on the fixes on Monday

Comment thread src/pe/clr.rs Outdated
Copy link
Copy Markdown
Contributor

@kkent030315 kkent030315 left a comment

Choose a reason for hiding this comment

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

Thanks, the diff look very clean now; With those changes it would be the cleanest I think.

Comment thread src/pe/header.rs Outdated
Comment thread src/pe/header.rs Outdated
Comment thread src/mach/exports.rs
Comment thread src/pe/debug.rs Outdated
Comment thread src/pe/import.rs Outdated
Comment thread src/pe/import.rs Outdated
Comment thread src/pe/load_config.rs Outdated
Comment thread src/pe/mod.rs Outdated
Comment thread src/pe/mod.rs Outdated
Comment thread src/lib.rs
@kkent030315
Copy link
Copy Markdown
Contributor

@chf0x by the way what IDE are you on? If you're under VSCode or Zed you might install rust-analyzer extension (if you don't have one yet). It looks like you're having slightly different formatting rule so. :)

Copy link
Copy Markdown
Contributor

@kkent030315 kkent030315 left a comment

Choose a reason for hiding this comment

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

Thanks very much, the patch looks very clean!

Copy link
Copy Markdown
Owner

@m4b m4b left a comment

Choose a reason for hiding this comment

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

ok the major thing is the non-exhaustive which I realized must be removed to make this backwards compat, moving the (pub(crate)) helper trait into options for now, and some other minor nits, mostly reducing the api surface from pub to pub(crate).

thanks for your patience, this should be the last review :)

Comment thread src/elf/mod.rs Outdated
Comment thread src/elf/sym.rs Outdated
Comment thread src/elf/sym.rs
Comment thread src/error.rs Outdated
Comment thread src/pe/header.rs Outdated
Comment thread src/pe/import.rs Outdated
Comment thread src/options.rs Outdated
Comment thread src/options.rs
Comment thread src/options.rs Outdated
Comment thread src/elf/mod.rs Outdated
@chf0x
Copy link
Copy Markdown
Contributor Author

chf0x commented Sep 1, 2025

Thank you for the review. I’ll make the changes. I’ve recently started a new job, so my time is a bit limited, but I’ll return to this asap

@m4b
Copy link
Copy Markdown
Owner

m4b commented Sep 8, 2025

Ok congrats on the new job! I hope we didn't scare you off with too much review, definitely would like to see this landed at some point, it's a great improvement to goblin. Thanks for your time!

…reduce public API, and lazily format error messages
@chf0x
Copy link
Copy Markdown
Contributor Author

chf0x commented Sep 20, 2025

Hi team, apologies for the delay. It’s been a busy few weeks, but I believe I’ve addressed all the requested changes. Could you please review? Thank you!

Copy link
Copy Markdown
Contributor

@kkent030315 kkent030315 left a comment

Choose a reason for hiding this comment

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

LGTM. With the permissive trait the codebase looks very clean now! (maybe you can fold them down the comments in options.rs?)

Copy link
Copy Markdown
Owner

@m4b m4b left a comment

Choose a reason for hiding this comment

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

So I'd prefer the pub(crate) and non_exhaustive to go in with this patch, but if you don't feel like it, i'll wait until tomorrow, and then merge and force push the changes since thy're important before a point release.

regardless thank you so much for your work on this, this is really great stuff! thank you for pulling through to the final stage :)

Comment thread src/error.rs Outdated
Comment thread src/options.rs
Comment thread src/pe/header.rs Outdated
Self::parse_with_opts(bytes, &crate::pe::options::ParseOptions::default())
}

pub fn parse_with_opts(
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

this is still pub :)

Comment thread src/pe/mod.rs
…RichHeader::parse_with_opts pub(crate), and remove unnecessary comment
@chf0x
Copy link
Copy Markdown
Contributor Author

chf0x commented Sep 21, 2025

Awesome news, thanks for reviewing @m4b @kkent030315 ! The last requested changes are now in

@m4b m4b merged commit 69dba8b into m4b:master Sep 21, 2025
5 checks passed
@m4b
Copy link
Copy Markdown
Owner

m4b commented Sep 21, 2025

thanks for getting this across the finish line @chf0x ! great stuff!

@m4b
Copy link
Copy Markdown
Owner

m4b commented Sep 21, 2025

NB: backwards compatible

@chf0x chf0x deleted the next branch September 21, 2025 19:16
@m4b
Copy link
Copy Markdown
Owner

m4b commented Oct 6, 2025

NB: non-breaking, in 0.10.2

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.

3 participants