From 7d4888bb777246cc43b6d8a92bc991e6d7d2adf5 Mon Sep 17 00:00:00 2001 From: "Daniel Plohmann (jupiter)" Date: Fri, 6 Nov 2020 10:09:06 +0100 Subject: [PATCH] addressing the comments in the PR discussion --- capa/features/extractors/smda/basicblock.py | 15 ++++----------- capa/features/extractors/smda/function.py | 15 +-------------- capa/features/extractors/smda/insn.py | 15 --------------- 3 files changed, 5 insertions(+), 40 deletions(-) diff --git a/capa/features/extractors/smda/basicblock.py b/capa/features/extractors/smda/basicblock.py index 4d130505..07477139 100644 --- a/capa/features/extractors/smda/basicblock.py +++ b/capa/features/extractors/smda/basicblock.py @@ -69,19 +69,12 @@ def is_mov_imm_to_stack(smda_ins): def is_printable_ascii(chars): - if sys.version_info[0] >= 3: - return all(c < 127 and chr(c) in string.printable for c in chars) - else: - return all(ord(c) < 127 and c in string.printable for c in chars) + return all(c < 127 and chr(c) in string.printable for c in chars) def is_printable_utf16le(chars): - if sys.version_info[0] >= 3: - if all(c == 0x00 for c in chars[1::2]): - return is_printable_ascii(chars[::2]) - else: - if all(c == "\x00" for c in chars[1::2]): - return is_printable_ascii(chars[::2]) + if all(c == 0x00 for c in chars[1::2]): + return is_printable_ascii(chars[::2]) def get_printable_len(instr): @@ -110,7 +103,7 @@ def get_printable_len(instr): if is_printable_ascii(chars): return instr.imm_size if is_printable_utf16le(chars): - return instr.imm_size / 2 + return instr.imm_size // 2 return 0 diff --git a/capa/features/extractors/smda/function.py b/capa/features/extractors/smda/function.py index e8f3729c..e1765e67 100644 --- a/capa/features/extractors/smda/function.py +++ b/capa/features/extractors/smda/function.py @@ -2,19 +2,6 @@ from capa.features import Characteristic from capa.features.extractors import loops -def interface_extract_function_XXX(f): - """ - parse features from the given function. - - args: - f (viv_utils.Function): the function to process. - - yields: - (Feature, int): the feature and the address at which its found. - """ - yield NotImplementedError("feature"), NotImplementedError("virtual address") - - def extract_function_calls_to(f): for inref in f.inrefs: yield Characteristic("calls to"), inref @@ -38,7 +25,7 @@ def extract_features(f): extract features from the given function. args: - f (viv_utils.Function): the function from which to extract features + f (smda.common.SmdaFunction): the function from which to extract features yields: Feature, set[VA]: the features and their location found in this function. diff --git a/capa/features/extractors/smda/insn.py b/capa/features/extractors/smda/insn.py index af29bbbc..8fa4e221 100644 --- a/capa/features/extractors/smda/insn.py +++ b/capa/features/extractors/smda/insn.py @@ -33,21 +33,6 @@ def get_arch(smda_report): raise NotImplementedError -def interface_extract_instruction_XXX(f, bb, insn): - """ - parse features from the given instruction. - - args: - f (smda.common.SmdaFunction): the function to process. - bb (smda.common.SmdaBasicBlock): the basic block to process. - insn (smda.common.SmdaInstruction): the instruction to process. - - yields: - (Feature, int): the feature and the address at which its found. - """ - yield NotImplementedError("feature"), NotImplementedError("virtual address") - - def extract_insn_api_features(f, bb, insn): """parse API features from the given instruction.""" if insn.offset in f.apirefs: