Skip to content

Commit

Permalink
Fix/corrupted file architecture key error (#2444)
Browse files Browse the repository at this point in the history
* Add try except clause
  • Loading branch information
Tamir-K authored Oct 6, 2024
1 parent 8c8b67a commit 41c5194
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@

### Bug Fixes

- extractor: fix exception when PE extractor encounters unknown architecture #2440 @Tamir-K

### capa Explorer Web

### capa Explorer IDA Pro plugin
Expand Down
8 changes: 7 additions & 1 deletion capa/features/extractors/pefile.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,13 @@ def extract_file_arch(pe, **kwargs):
elif pe.FILE_HEADER.Machine == pefile.MACHINE_TYPE["IMAGE_FILE_MACHINE_AMD64"]:
yield Arch(ARCH_AMD64), NO_ADDRESS
else:
logger.warning("unsupported architecture: %s", pefile.MACHINE_TYPE[pe.FILE_HEADER.Machine])
try:
logger.warning(
"unsupported architecture: %s",
pefile.MACHINE_TYPE[pe.FILE_HEADER.Machine],
)
except KeyError:
logger.warning("unknown architecture: %s", pe.FILE_HEADER.Machine)


def extract_file_features(pe, buf):
Expand Down

0 comments on commit 41c5194

Please sign in to comment.