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

IDA plugin: ELF file format error #911

Closed
mr-tz opened this issue Mar 17, 2022 · 5 comments
Closed

IDA plugin: ELF file format error #911

mr-tz opened this issue Mar 17, 2022 · 5 comments
Labels
bug Something isn't working ida-explorer Related to IDA Pro plugin

Comments

@mr-tz
Copy link
Collaborator

mr-tz commented Mar 17, 2022

CC: @mike-hunhoff

Are ELF files properly enabled in the IDA plugin?

ERROR:capa.ida.plugin.form:Failed to extract capabilities from database (error: ('file format: %s', 'ELF for Intel 386 (Executable)'))
INFO:capa.ida.plugin.form:Analysis failed.
@mr-tz mr-tz added bug Something isn't working ida-explorer Related to IDA Pro plugin labels Mar 17, 2022
@mr-tz
Copy link
Collaborator Author

mr-tz commented Mar 21, 2022

related: #910

@mike-hunhoff
Copy link
Collaborator

@mr-tz looks like a bug introduced here:

def extract_file_format():
format_name = ida_loader.get_file_type_name()
if "PE" in format_name:
yield Format(FORMAT_PE), 0x0
elif "ELF64" in format_name:
yield Format(FORMAT_ELF), 0x0
elif "ELF32" in format_name:
yield Format(FORMAT_ELF), 0x0
else:
raise NotImplementedError("file format: %s", format_name)

I'll take a closer look and push out a fix. Thanks for reporting!

@williballenthin
Copy link
Collaborator

im not quite sure how to enumerate all of the formats, though I think this is the source of the format above:

image

image

so maybe we can get away with checking for format_name.startswith("ELF for")

@mike-hunhoff
Copy link
Collaborator

mike-hunhoff commented Mar 21, 2022

we use the following for other file format checks:

capa/capa/ida/helpers.py

Lines 24 to 30 in 1b2f0fc

# file type as returned by idainfo.file_type
SUPPORTED_FILE_TYPES = (
idaapi.f_PE,
idaapi.f_ELF,
idaapi.f_BIN,
# idaapi.f_MACHO,
)

capa/capa/ida/helpers.py

Lines 50 to 62 in 1b2f0fc

def is_supported_file_type():
file_info = idaapi.get_inf_structure()
if file_info.filetype not in SUPPORTED_FILE_TYPES:
logger.error("-" * 80)
logger.error(" Input file does not appear to be a supported file type.")
logger.error(" ")
logger.error(
" capa currently only supports analyzing PE, ELF, or binary files containing x86 (32- and 64-bit) shellcode."
)
logger.error(" If you don't know the input file type, you can try using the `file` utility to guess it.")
logger.error("-" * 80)
return False
return True

I believe the above works for all cases

@mike-hunhoff
Copy link
Collaborator

let me see if I can grab the MD5 from @mr-tz to double-check.

mike-hunhoff pushed a commit that referenced this issue Mar 21, 2022
mike-hunhoff added a commit that referenced this issue Mar 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working ida-explorer Related to IDA Pro plugin
Projects
None yet
Development

No branches or pull requests

3 participants