use pathlib.Path() in binja and ida extractors

This commit is contained in:
Yacine Elhamer
2023-07-20 21:42:14 +01:00
parent d99b16ed5e
commit 482e0d386b
2 changed files with 4 additions and 4 deletions

View File

@@ -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
@@ -34,8 +35,7 @@ class BinjaFeatureExtractor(StaticFeatureExtractor):
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)

View File

@@ -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
@@ -34,8 +35,7 @@ class IdaFeatureExtractor(StaticFeatureExtractor):
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())