Skip to content

Commit

Permalink
elf: detect Android OS via note
Browse files Browse the repository at this point in the history
closes #1705
  • Loading branch information
williballenthin committed Aug 14, 2023
1 parent ec93ca5 commit 8003547
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions capa/features/extractors/elf.py
Expand Up @@ -54,6 +54,7 @@ class OS(str, Enum):
CLOUD = "cloud"
SYLLABLE = "syllable"
NACL = "nacl"
ANDROID = "android"


# via readelf: https://github.com/bminor/binutils-gdb/blob/c0e94211e1ac05049a4ce7c192c9d14d1764eb3e/binutils/readelf.c#L19635-L19658
Expand Down Expand Up @@ -764,6 +765,11 @@ def guess_os_from_ph_notes(elf: ELF) -> Optional[OS]:
elif note.name == "FreeBSD":
logger.debug("note owner: %s", "FREEBSD")
return OS.FREEBSD
elif note.name == "Android":
logger.debug("note owner: %s", "Android")
# see the following for parsing the structure:
# https://android.googlesource.com/platform/ndk/+/master/parse_elfnote.py
return OS.ANDROID
elif note.name == "GNU":
abi_tag = note.abi_tag
if abi_tag:
Expand Down

0 comments on commit 8003547

Please sign in to comment.