-
Notifications
You must be signed in to change notification settings - Fork 567
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
smda: fix negative number extraction #851
Conversation
Add fixtures to validate the following number features: - number(0x0): to check feature extraction for null number - number(0xFFFFFFFF): to check feature extraction for -1 number - number(0xFFFFFFF0): to check feature extraction for negative number (-0x10 in this case)
SmdaInstruction operands are python `str` objects. SMDA number operands are signed integers. This commit adds a converter to the SMDA number extractor. The goal is to convert any signed number to the two’s complement representation with the correct bitness.
@@ -86,7 +86,7 @@ def main(argv=None): | |||
argv = sys.argv[1:] | |||
|
|||
parser = argparse.ArgumentParser(description="Show the features that capa extracts from the given sample") | |||
capa.main.install_common_args(parser, wanted={"format", "sample", "signatures"}) | |||
capa.main.install_common_args(parser, wanted={"format", "sample", "signatures", "backend"}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice catch, thanks
("mimikatz", "function=0x401000", capa.features.insn.Number(0x0), True), | ||
# insn/number: stack adjustments | ||
("mimikatz", "function=0x40105D", capa.features.insn.Number(0xC), False), | ||
("mimikatz", "function=0x40105D", capa.features.insn.Number(0x10), False), | ||
# insn/number: bitness flavors | ||
("mimikatz", "function=0x40105D", capa.features.insn.Number(0xFF), True), | ||
("mimikatz", "function=0x40105D", capa.features.insn.Number(0xFF, bitness=BITNESS_X32), True), | ||
("mimikatz", "function=0x40105D", capa.features.insn.Number(0xFF, bitness=BITNESS_X64), False), | ||
# insn/number: negative | ||
("mimikatz", "function=0x401553", capa.features.insn.Number(0xFFFFFFFF), True), | ||
("mimikatz", "function=0x43e543", capa.features.insn.Number(0xFFFFFFF0), True), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks for adding tests! this makes me confident that the fixes work as intended
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thank you!
SMDA extractor is extracting negative Number features as described in #430.
This is not compliant with the rule format described in capa documentation:
This PR adds the following fixtures:
The function
extract_insn_number_features
now converts the parsed smda number operands in its two's complement representation.I also edited the
show-features.py
script to be able to compare the feature extraction of smda and vivisect. I think that it could be useful and it does not seem to cause any issue.The documentation is not updated since I am just fixing a simple issue.
closes #430
Checklist