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

Feature/lief15 #111

Merged
merged 17 commits into from
Jul 28, 2024
Merged

Feature/lief15 #111

merged 17 commits into from
Jul 28, 2024

Conversation

prabhu
Copy link
Member

@prabhu prabhu commented Jul 27, 2024

Updated to lief 0.15.1

https://lief.re/doc/stable/changelog.html

By parsing .rdata and .text section, we can identify more capabilities. Example below is a go binary bundled inside a PE binary. Samples here.

2024-07-27_19-29-17

prabhu added 3 commits July 27, 2024 12:41
Signed-off-by: Prabhu Subramanian <prabhu@appthreat.com>
Signed-off-by: Prabhu Subramanian <prabhu@appthreat.com>
Signed-off-by: Prabhu Subramanian <prabhu@appthreat.com>
@prabhu prabhu requested a review from cerrussell July 27, 2024 13:35
Signed-off-by: Prabhu Subramanian <prabhu@appthreat.com>
@prabhu prabhu requested a review from timmyteo July 27, 2024 15:35
prabhu added 5 commits July 27, 2024 17:04
Signed-off-by: Prabhu Subramanian <prabhu@appthreat.com>
Signed-off-by: Prabhu Subramanian <prabhu@appthreat.com>
Signed-off-by: Prabhu Subramanian <prabhu@appthreat.com>
Signed-off-by: Prabhu Subramanian <prabhu@appthreat.com>
Signed-off-by: Prabhu Subramanian <prabhu@appthreat.com>
timmyteo
timmyteo previously approved these changes Jul 27, 2024
Copy link
Collaborator

@timmyteo timmyteo left a comment

Choose a reason for hiding this comment

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

@prabhu testing results are as expected testing against various rust, dotnet, and go binaries. No issues to report. Nice work!

Signed-off-by: Prabhu Subramanian <prabhu@appthreat.com>
prabhu added 2 commits July 27, 2024 18:30
Signed-off-by: Prabhu Subramanian <prabhu@appthreat.com>
Signed-off-by: Prabhu Subramanian <prabhu@appthreat.com>
@prabhu
Copy link
Member Author

prabhu commented Jul 27, 2024

Thanks @timmyteo. Could you do retest once more, since pushed some commits since your review.

@@ -451,7 +452,7 @@ def process_pe_resources(parsed_obj):
"has_manifest": rm.has_manifest,
"has_string_table": rm.has_string_table,
"has_version": rm.has_version,
"manifest": (rm.manifest.replace("\\xef\\xbb\\xbf", "") if rm.has_manifest else None),
"manifest": (rm.manifest.replace("\\xef\\xbb\\xbf", "").removeprefix("\ufeff") if rm.has_manifest else None),
Copy link
Member Author

Choose a reason for hiding this comment

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

This removes the byte order mark

blint/binary.py Outdated
"verification_flags": str(parsed_obj.verify_signature()).replace(
"VERIFICATION_FLAGS.", ""
),
"verification_flags": str(parsed_obj.verify_signature()).split(".")[-1],
Copy link
Member Author

Choose a reason for hiding this comment

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

Simplifies the flag by only containing the last part.

@@ -561,11 +560,7 @@ def parse_pe_symbols(symbols):
if not symbol:
continue
try:
if symbol.section_number <= 0:
section_nb_str = str(lief.PE.SYMBOL_SECTION_NUMBER(symbol.section_number)).rsplit(
Copy link
Member Author

Choose a reason for hiding this comment

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

This was always erroring out for me so removed it.

@@ -1113,6 +1106,12 @@ def add_pe_metadata(exe_file: str, metadata: dict, parsed_obj: lief.PE.Binary):
if e["name"] == "ntoskrnl.exe":
metadata["is_driver"] = True
break
rdata_section = parsed_obj.get_section(".rdata")
Copy link
Member Author

Choose a reason for hiding this comment

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

With this, we are able to catch more bundled .go and .dll files.

prabhu added 3 commits July 27, 2024 19:04
Signed-off-by: Prabhu Subramanian <prabhu@appthreat.com>
Signed-off-by: Prabhu Subramanian <prabhu@appthreat.com>
Signed-off-by: Prabhu Subramanian <prabhu@appthreat.com>
@prabhu prabhu marked this pull request as draft July 27, 2024 20:11
prabhu added 2 commits July 28, 2024 10:02
Signed-off-by: Prabhu Subramanian <prabhu@appthreat.com>
Signed-off-by: Prabhu Subramanian <prabhu@appthreat.com>
@prabhu prabhu marked this pull request as ready for review July 28, 2024 10:46
@prabhu
Copy link
Member Author

prabhu commented Jul 28, 2024

Noticed that cdxgen sbom is missing evidence with research profile. This needs to be investigated separately.

cc: @aryan-rajoria

@prabhu prabhu merged commit acb6699 into main Jul 28, 2024
31 checks passed
@prabhu prabhu deleted the feature/lief15 branch July 28, 2024 10:56
@timmyteo
Copy link
Collaborator

@prabhu I retested against the main branch, which now has this feature branch merged. No issues to report and test cases passed as expected.

@prabhu
Copy link
Member Author

prabhu commented Jul 28, 2024

Thank you so much!

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.

2 participants