Skip to content

Commit

Permalink
Merge pull request #902 from onekey-sec/update_flake_lock_action
Browse files Browse the repository at this point in the history
Update flake.lock
  • Loading branch information
vlaci authored Aug 7, 2024
2 parents 5e775ac + dfe312d commit b7390b6
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 48 deletions.
6 changes: 3 additions & 3 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

77 changes: 42 additions & 35 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ python-magic = "^0.4.27"
pyperscan = "^0.3.0"
lark = "^1.1.8"
lz4 = "^4.3.2"
lief = "^0.14.1"
lief = "^0.15.1"
cryptography = ">=41.0,<44.0"
treelib = "^1.7.0"
unblob-native = "^0.1.1"
Expand Down
18 changes: 9 additions & 9 deletions unblob/handlers/executable/elf.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
)
from unblob.models import HexString, StructHandler, ValidChunk

lief.logging.set_level(lief.logging.LOGGING_LEVEL.ERROR)
lief.logging.set_level(lief.logging.LEVEL.ERROR)

logger = get_logger()

Expand All @@ -44,7 +44,7 @@ def extract(self, inpath: Path, outdir: Path):
return

is_kernel = (
elf.header.file_type == lief.ELF.E_TYPE.EXECUTABLE
elf.header.file_type == lief.ELF.Header.FILE_TYPE.EXEC
and elf.has_section(KERNEL_INIT_DATA_SECTION)
)
if is_kernel:
Expand Down Expand Up @@ -76,10 +76,10 @@ def extract_initramfs(elf, file: File, outdir):
if not init_data.size:
return

is_64bit = elf.header.identity_class == lief.ELF.ELF_CLASS.CLASS64
is_64bit = elf.header.identity_class == lief.ELF.Header.CLASS.ELF64
endian = (
Endian.LITTLE
if elf.header.identity_data == lief.ELF.ELF_DATA.LSB
if elf.header.identity_data == lief.ELF.Header.ELF_DATA.LSB
else Endian.BIG
)

Expand Down Expand Up @@ -140,9 +140,9 @@ class _ELFBase(StructHandler):
def is_valid_header(self, header) -> bool:
# check that header fields have valid values
try:
lief.ELF.E_TYPE(header.e_type)
lief.ELF.Header.FILE_TYPE(header.e_type)
lief.ELF.ARCH(header.e_machine)
lief.ELF.VERSION(header.e_version)
lief.ELF.Header.VERSION(header.e_version)
except RuntimeError:
return False
return True
Expand All @@ -166,8 +166,8 @@ def get_last_section_end(

try:
if (
lief.ELF.SECTION_TYPES(section_header.sh_type)
== lief.ELF.SECTION_TYPES.NOBITS
lief.ELF.Section.TYPE(section_header.sh_type)
== lief.ELF.Section.TYPE.NOBITS
):
continue
except RuntimeError:
Expand Down Expand Up @@ -261,7 +261,7 @@ def calculate_chunk(self, file: File, start_offset: int) -> Optional[ElfChunk]:
end_offset = self.get_end_offset(file, start_offset, header, endian)

# kernel modules are always relocatable
if header.e_type == lief.ELF.E_TYPE.RELOCATABLE.value:
if header.e_type == lief.ELF.Header.FILE_TYPE.REL.value:
end_offset = self.get_signed_kernel_module_end_offset(file, end_offset)

# do a special extraction of ELF files with ElfChunk
Expand Down

0 comments on commit b7390b6

Please sign in to comment.