Skip to content

Commit

Permalink
lief fixes
Browse files Browse the repository at this point in the history
Signed-off-by: Prabhu Subramanian <[email protected]>
  • Loading branch information
prabhu committed Feb 7, 2024
1 parent 6a461fc commit b770291
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions blint/binary.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@
import lief
from lief import DEX, ELF, PE, MachO

from blint.logger import LOG
from blint.logger import DEBUG, LOG
from blint.utils import calculate_entropy, check_secret, decode_base64

MIN_ENTROPY = 0.39
MIN_LENGTH = 80

lief.logging.disable()
# Enable lief logging in debug mode
if LOG.level != DEBUG:
lief.logging.disable()

ADDRESS_FMT = "0x{:<10x}"

Expand Down Expand Up @@ -54,7 +56,7 @@ def parse_notes(parsed_obj):
ndk_build_number = ""
abi = ""
version_str = ""
if isinstance(note_details, lief.ELF.AndroidNote):
if isinstance(note_details, lief.ELF.AndroidIdent):
sdk_version = note_details.sdk_version
ndk_version = note_details.ndk_version
ndk_build_number = note_details.ndk_build_number
Expand All @@ -71,7 +73,7 @@ def parse_notes(parsed_obj):
metadata["notes"].append(
{
"index": idx,
"description": str(description_str),
"description": description_str,
"type": type_str,
"details": note_details_str,
"sdk_version": sdk_version,
Expand Down Expand Up @@ -715,7 +717,7 @@ def parse(exe_file):
header = parsed_obj.header
optional_header = parsed_obj.optional_header
metadata["used_bytes_in_the_last_page"] = (
dos_header.used_bytes_in_the_last_page
dos_header.used_bytes_in_last_page
)
metadata["file_size_in_pages"] = dos_header.file_size_in_pages
metadata["num_relocation"] = dos_header.numberof_relocation
Expand Down Expand Up @@ -1073,15 +1075,15 @@ def parse(exe_file):
code_signature = parsed_obj.code_signature
metadata["code_signature"] = {
"available": True if code_signature.size else False,
"data": str(bytes(code_signature.data).hex()),
"data": str(code_signature.data.hex()),
"data_size": str(code_signature.data_size),
"size": str(code_signature.size),
}
if (
not parsed_obj.has_code_signature
and parsed_obj.has_code_signature_dir
):
code_signature = parsed_obj.has_code_signature_dir
code_signature = parsed_obj.code_signature_dir
metadata["code_signature"] = {
"available": True if code_signature.size else False,
"data": str(bytes(code_signature.data).hex()),
Expand Down

0 comments on commit b770291

Please sign in to comment.