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

add alternative backend provided by lancelot #234

Closed
wants to merge 53 commits into from

Conversation

williballenthin
Copy link
Collaborator

@williballenthin williballenthin commented Aug 13, 2020

lancelot is a disassembler and code analysis framework for x86/x64 PE files. this PR adds a backend to capa that's based on lancelot. key reasons to consider merging the PR are performance and py3 support. the major reason not to merge is that lancelot is quite experimental.

i've been slowly working on lancelot for the past few years, and its gone through transformations from Go to Clojure to (now) Rust with Python bindings. it uses Zydis to disassemble bytes to instructions and has routines to extract control flow and call graphs from these instructions. it also contains algorithms that attempt to identify function start addresses, such as through call target analysis, entry points, pattern matching, etc.

file features are provided by pefile as lancelot doesn't attempt to replicate this parsing logic.

it was pretty straightforward to develop this backend. a major lesson i learned is exactly what features an analysis system must provide in order to be integrated with capa. to summarize:

  • enumerate functions
  • enumerate basic blocks
  • enumerate instructions
  • extract mnemonics
  • extract operand "targets" when referencing memory (e.g. call targets)
  • extract operand immediates
  • read from loaded PE addresses

overall, it took maybe 16 hours to build out this backend. i think we can take its structure as a template for integrating with other systems, such as miasm or maybe ghidra.

image

image

TODO:

  • add shellcode workspace support

@williballenthin williballenthin added the dont merge Indicate a PR that is still being worked on label Aug 13, 2020
@williballenthin
Copy link
Collaborator Author

testing updates backported and proposed in #236

@williballenthin
Copy link
Collaborator Author

i've fixed the test handling so that appropriate tests run under py2 and py3:

image

@williballenthin
Copy link
Collaborator Author

and with that, gh actions now run tests for both py2.7 (vivisect) and py3.8 (lancelot):

image

@williballenthin
Copy link
Collaborator Author

closing due to lack of attention. can re-open in the future.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dont merge Indicate a PR that is still being worked on
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant