From 780b145b595bfb1916b0ee3febcfdf72928b4c9c Mon Sep 17 00:00:00 2001 From: William Ballenthin Date: Tue, 7 Jul 2020 13:39:15 -0600 Subject: [PATCH 1/2] pep8 --- capa/features/extractors/ida/__init__.py | 1 - capa/features/extractors/ida/basicblock.py | 1 - capa/features/extractors/ida/file.py | 1 - capa/features/extractors/ida/function.py | 1 - capa/features/extractors/ida/insn.py | 1 - capa/ida/ida_capa_explorer.py | 3 +-- scripts/testbed/{__init__.py => utils.py} | 0 7 files changed, 1 insertion(+), 7 deletions(-) rename scripts/testbed/{__init__.py => utils.py} (100%) diff --git a/capa/features/extractors/ida/__init__.py b/capa/features/extractors/ida/__init__.py index c994faad..b40310d9 100644 --- a/capa/features/extractors/ida/__init__.py +++ b/capa/features/extractors/ida/__init__.py @@ -7,7 +7,6 @@ import capa.features.extractors.ida.file import capa.features.extractors.ida.insn import capa.features.extractors.ida.function import capa.features.extractors.ida.basicblock - from capa.features.extractors import FeatureExtractor diff --git a/capa/features/extractors/ida/basicblock.py b/capa/features/extractors/ida/basicblock.py index 00ff9859..c9eb601e 100644 --- a/capa/features/extractors/ida/basicblock.py +++ b/capa/features/extractors/ida/basicblock.py @@ -5,7 +5,6 @@ import struct import idaapi import capa.features.extractors.ida.helpers - from capa.features import Characteristic from capa.features.basicblock import BasicBlock from capa.features.extractors.ida import helpers diff --git a/capa/features/extractors/ida/file.py b/capa/features/extractors/ida/file.py index a227c82e..650ec775 100644 --- a/capa/features/extractors/ida/file.py +++ b/capa/features/extractors/ida/file.py @@ -7,7 +7,6 @@ import idautils import capa.features.extractors.helpers import capa.features.extractors.strings import capa.features.extractors.ida.helpers - from capa.features import String, Characteristic from capa.features.file import Export, Import, Section diff --git a/capa/features/extractors/ida/function.py b/capa/features/extractors/ida/function.py index fd5d91b1..31d12920 100644 --- a/capa/features/extractors/ida/function.py +++ b/capa/features/extractors/ida/function.py @@ -2,7 +2,6 @@ import idaapi import idautils import capa.features.extractors.ida.helpers - from capa.features import Characteristic from capa.features.extractors import loops diff --git a/capa/features/extractors/ida/insn.py b/capa/features/extractors/ida/insn.py index f6fa2dac..ba237766 100644 --- a/capa/features/extractors/ida/insn.py +++ b/capa/features/extractors/ida/insn.py @@ -4,7 +4,6 @@ import idautils import capa.features.extractors.helpers import capa.features.extractors.ida.helpers - from capa.features import MAX_BYTES_FEATURE_SIZE, Bytes, String, Characteristic from capa.features.insn import Number, Offset, Mnemonic diff --git a/capa/ida/ida_capa_explorer.py b/capa/ida/ida_capa_explorer.py index c5468b31..ad1c7a7f 100644 --- a/capa/ida/ida_capa_explorer.py +++ b/capa/ida/ida_capa_explorer.py @@ -1,16 +1,15 @@ import os import logging import collections -from PyQt5 import QtGui, QtCore, QtWidgets import idaapi +from PyQt5 import QtGui, QtCore, QtWidgets import capa.main import capa.rules import capa.ida.helpers import capa.render.utils as rutils import capa.features.extractors.ida - from capa.ida.explorer.view import CapaExplorerQtreeView from capa.ida.explorer.model import CapaExplorerDataModel from capa.ida.explorer.proxy import CapaExplorerSortFilterProxyModel diff --git a/scripts/testbed/__init__.py b/scripts/testbed/utils.py similarity index 100% rename from scripts/testbed/__init__.py rename to scripts/testbed/utils.py From e0ad071dd46a795eedac9e3ff497d0f619143e0b Mon Sep 17 00:00:00 2001 From: William Ballenthin Date: Tue, 7 Jul 2020 13:39:50 -0600 Subject: [PATCH 2/2] testbed: fix imports now that its standalone scripts closes #125 --- scripts/testbed/run_rule_on_testbed.py | 5 ++++- scripts/testbed/start_ida_dump_fnames.py | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/scripts/testbed/run_rule_on_testbed.py b/scripts/testbed/run_rule_on_testbed.py index aa78a830..61b10305 100644 --- a/scripts/testbed/run_rule_on_testbed.py +++ b/scripts/testbed/run_rule_on_testbed.py @@ -18,9 +18,12 @@ import argparse import capa.main import capa.rules import capa.features.freeze -from scripts.testbed import FNAMES_EXTENSION, FREEZE_EXTENSION +from utils import FNAMES_EXTENSION, FREEZE_EXTENSION from start_ida_export_fimages import export_fimages +# enable import of code in the same directory +sys.path.append(os.path.dirname(__file__)) + logger = logging.getLogger(__name__) # sorry globals... diff --git a/scripts/testbed/start_ida_dump_fnames.py b/scripts/testbed/start_ida_dump_fnames.py index b701d509..bea8c892 100644 --- a/scripts/testbed/start_ida_dump_fnames.py +++ b/scripts/testbed/start_ida_dump_fnames.py @@ -17,7 +17,10 @@ import subprocess import argparse -from scripts.testbed import FNAMES_EXTENSION +from utils import FNAMES_EXTENSION + +# enable import of code in the same directory +sys.path.append(os.path.dirname(__file__)) IDA32_PATH = "C:\\Program Files\\IDA Pro 7.3\\ida.exe" IDA64_PATH = "C:\\Program Files\\IDA Pro 7.3\\ida64.exe"