Skip to content

Commit 20d4269

Browse files
committed
Fix some hardcode issue
1 parent 4512294 commit 20d4269

File tree

4 files changed

+21
-11
lines changed

4 files changed

+21
-11
lines changed

capa/features/common.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -439,9 +439,10 @@ def get_value_str(self):
439439
ARCH_I386 = "i386"
440440
ARCH_AMD64 = "amd64"
441441
ARCH_AARCH64 = "aarch64"
442+
ARCH_ARM = "arm"
442443
# dotnet
443444
ARCH_ANY = "any"
444-
VALID_ARCH = (ARCH_I386, ARCH_AMD64, ARCH_AARCH64, ARCH_ANY)
445+
VALID_ARCH = (ARCH_I386, ARCH_AMD64, ARCH_AARCH64, ARCH_ARM, ARCH_ANY)
445446

446447

447448
class Arch(Feature):

capa/features/extractors/frida/extractor.py

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,18 @@
33

44

55
from capa.features.extractors.frida.models import FridaReport, Call
6-
from capa.features.common import Feature, String, OS, Arch, Format, FORMAT_APK
6+
from capa.features.common import (
7+
Feature,
8+
String,
9+
OS,
10+
Arch,
11+
Format,
12+
OS_ANDROID,
13+
ARCH_AARCH64,
14+
ARCH_AMD64,
15+
ARCH_I386,
16+
FORMAT_APK
17+
)
718
from capa.features.insn import API, Number
819
from capa.features.address import (
920
NO_ADDRESS,
@@ -20,9 +31,7 @@
2031
ProcessHandle,
2132
DynamicFeatureExtractor,
2233
)
23-
import logging
2434

25-
logger = logging.getLogger(__name__)
2635

2736
class FridaExtractor(DynamicFeatureExtractor):
2837
"""
@@ -45,17 +54,17 @@ def get_base_address(self) -> Union[_NoAddress, None]:
4554

4655
def extract_global_features(self) -> Iterator[tuple[Feature, Address]]:
4756
"""Basic global features"""
48-
yield OS("android"), NO_ADDRESS # OS: Frida doesn't provide OS info
57+
yield OS(OS_ANDROID), NO_ADDRESS
4958

5059
if self.report.processes:
5160
process = self.report.processes[0]
5261

5362
if process.arch:
5463
arch_mapping = {
55-
"arm64": "aarch64",
56-
"arm": "arm",
57-
"x64": "amd64",
58-
"ia32": "i386"
64+
"arm64": ARCH_AARCH64,
65+
"arm": ARCH_ARM,
66+
"x64": ARCH_AMD64,
67+
"ia32": ARCH_I386
5968
}
6069
capa_arch = arch_mapping.get(process.arch, process.arch)
6170
yield Arch(capa_arch), NO_ADDRESS

scripts/frida/java_monitor.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,8 @@ Java.perform(function() {
168168
File.delete.implementation = function() {
169169
var path = this.getAbsolutePath();
170170
var result = this.delete();
171-
recordApiCall("java.io.File.delete", []);
171+
var args = [];
172+
recordApiCall("java.io.File.delete", args);
172173
debugLog("java.io.File.delete", {"path": path}, result);
173174
return result;
174175
};

scripts/frida/test_rules/file_collction.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# TODO: Review them together next week. I think they need some changes.
21
rule:
32
meta:
43
name: file collection

0 commit comments

Comments
 (0)