Skip to content

Should we add more ways to parse raw files and sections? #426

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

Open
NikolajSchlej opened this issue Apr 30, 2025 · 1 comment
Open

Should we add more ways to parse raw files and sections? #426

NikolajSchlej opened this issue Apr 30, 2025 · 1 comment

Comments

@NikolajSchlej
Copy link
Collaborator

Both @platomav (in a recent discussion in #270) and @Ykidia (in his recent PR #423) expressed the need to parse contents of raw files and raw sections.

The problem with this approach for a generic tool like this one is that such parsing can only be done by trying multiple parsers in a row, and choosing something that generated less parsing errors.

Another possible issue is on trying to rebuild such a raw file (when we get to that point again), given that there are basically not spec-compliant ways to rebuild such a file.

I'm notionally OK with adding more parsers for the sake of increasing usability as a reverse-engineering tool, and we already got way off the original plan to only parse/edit UEFI PI images, so the only issue I currently have is "adding new code needs to be justified, and we will have to support that added code forever into the future".

CC @vit9696 for his opinion.

@platomav
Copy link

platomav commented May 2, 2025

In my opinion, it is important to be able to detect Volumes, Files and/or Sections within non-expected areas (raw, padding, non-UEFI) because it's not rare for vendors to place things there. This is very useful when doing research or reverse engineering.

One important topic is that of re-building that you mentioned. The way I see it, we should not have to worry about that. At least not before a builder has been written for the expected/canonical UEFI structure. I suggest to "simply" not allow editing of FV/FILE/SECTION which were found in non-standard/expected areas (with some parser note/warning indicating that of course).

Regarding methodology, and based on what I've observed from another project which added such parsing (Chipsec), the method which works is to attempt FV first, otherwise fallback to Files, otherwise fallback to Sections. Yes, the last 2 don't have strong methods to verify, so it would be expected to get errors from such brute-force parsers. As an extra (more brute-forcy) option, there could be a way to also allow checking for FV + Files + Sections without stopping at first match. This may be useful for (even weirder) cases where an FV is included as part of the data of a PE/TE Section. These do sound (and may look) ugly, so maybe it could be optional instead of always being attempted.

This type of topic has been discussed at the Chipsec project, where I had also provided various samples which can be used for testing and/or proof that these brute-force parsing modes are needed:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants