Skip to content

Commit

Permalink
use pathlib.Path() in binja and ida extractors
Browse files Browse the repository at this point in the history
  • Loading branch information
yelhamer committed Jul 20, 2023
1 parent d99b16e commit 482e0d3
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions capa/features/extractors/binja/extractor.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
# is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and limitations under the License.
from typing import List, Tuple, Iterator
from pathlib import Path

import binaryninja as binja

Expand Down Expand Up @@ -34,8 +35,7 @@ def __init__(self, bv: binja.BinaryView):
self.global_features.extend(capa.features.extractors.binja.file.extract_file_format(self.bv))
self.global_features.extend(capa.features.extractors.binja.global_.extract_os(self.bv))
self.global_features.extend(capa.features.extractors.binja.global_.extract_arch(self.bv))
with open(self.bv.name, "rb") as f:
self.sample_hashes = SampleHashes.from_sample(f.read())
self.sample_hashes = SampleHashes.from_sample(Path(self.bv.name).read_bytes())

def get_base_address(self):
return AbsoluteVirtualAddress(self.bv.start)
Expand Down
4 changes: 2 additions & 2 deletions capa/features/extractors/ida/extractor.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
# is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and limitations under the License.
from typing import List, Tuple, Iterator
from pathlib import Path

import idaapi

Expand Down Expand Up @@ -34,8 +35,7 @@ def __init__(self):
self.global_features.extend(capa.features.extractors.ida.file.extract_file_format())
self.global_features.extend(capa.features.extractors.ida.global_.extract_os())
self.global_features.extend(capa.features.extractors.ida.global_.extract_arch())
with open(idaapi.get_input_file_path(), "rb") as f:
self.sample_hashes = SampleHashes.from_sample(f.read())
self.sample_hashes = SampleHashes.from_sample(Path(idaapi.get_input_file_path()).read_bytes())

def get_base_address(self):
return AbsoluteVirtualAddress(idaapi.get_imagebase())
Expand Down

0 comments on commit 482e0d3

Please sign in to comment.