16
16
from quark .logo import logo
17
17
from quark .utils .colors import yellow
18
18
from quark .utils .graph import select_label_menu , show_comparison_graph
19
- from quark .utils .pprint import print_info , print_success , print_warning
19
+ from quark .utils .pprint import (
20
+ print_error ,
21
+ print_info ,
22
+ print_success ,
23
+ print_warning ,
24
+ )
20
25
from quark .utils .weight import Weight
26
+ from quark .utils .tools import find_rizin_instance , get_rizin_version
21
27
22
28
logo ()
23
29
125
131
"--multi-process" ,
126
132
"num_of_process" ,
127
133
type = click .IntRange (min = 1 ),
128
- help = "Allow analyzing APK with N processes, where N doesn't exceeds" +
129
- " the number of usable CPUs - 1 to avoid memory exhaustion." ,
134
+ help = "Allow analyzing APK with N processes, where N doesn't exceeds"
135
+ + " the number of usable CPUs - 1 to avoid memory exhaustion." ,
130
136
required = False ,
131
137
default = 1 ,
132
138
)
139
+ @click .option (
140
+ "--rizin-path" ,
141
+ "rizin_path" ,
142
+ type = click .Path (exists = True , file_okay = True , dir_okay = False ),
143
+ help = "Specify a Rizin executable for Quark to perform analyses." ,
144
+ )
145
+ @click .option (
146
+ "--disable-rizin-installation" ,
147
+ "disable_rizin_installation" ,
148
+ default = False ,
149
+ is_flag = True ,
150
+ help = "Don't install Rizin automatically when no Rizin instance with"
151
+ + " a compatible version is found."
152
+ )
133
153
def entry_point (
134
154
summary ,
135
155
detail ,
@@ -145,12 +165,39 @@ def entry_point(
145
165
comparison ,
146
166
core_library ,
147
167
num_of_process ,
168
+ rizin_path ,
169
+ disable_rizin_installation ,
148
170
):
149
171
"""Quark is an Obfuscation-Neglect Android Malware Scoring System"""
150
172
# Load rules
151
173
rule_buffer_list = []
152
174
rule_filter = summary or detail
153
175
176
+ # Check Rizin version
177
+ if core_library .lower () == "rizin" :
178
+ if not rizin_path :
179
+ if disable_rizin_installation :
180
+ print_info ("Disable automatic Rizin installation." )
181
+
182
+ rizin_path = find_rizin_instance (
183
+ disable_rizin_installation = disable_rizin_installation
184
+ )
185
+
186
+ if not rizin_path :
187
+ print_error (
188
+ "No valid Rizin executable found. Please specify the path to the Rizin executable by using option --rizin-path."
189
+ )
190
+ return
191
+ else :
192
+ version = get_rizin_version (rizin_path )
193
+ if rizin_path .startswith (config .HOME_DIR ):
194
+ print_info (f"Use the Rizin executable (version { version } ) installed in the Quark directory." )
195
+ else :
196
+ print_info (f"Use the Rizin executable (version { version } ) installed in the system PATH." )
197
+
198
+ else :
199
+ print_info (f"Use the user-specified Rizin executable." )
200
+
154
201
# Determine the location of rules
155
202
if rule_filter and rule_filter .endswith ("json" ):
156
203
if not os .path .isfile (rule_filter ):
@@ -205,9 +252,14 @@ def entry_point(
205
252
malware_confidences = {}
206
253
for apk_ in apk :
207
254
data = (
208
- ParallelQuark (apk_ , core_library , num_of_process )
255
+ ParallelQuark (
256
+ apk_ ,
257
+ core_library ,
258
+ num_of_process ,
259
+ rizin_path ,
260
+ )
209
261
if num_of_process > 1
210
- else Quark (apk_ , core_library )
262
+ else Quark (apk_ , core_library , rizin_path )
211
263
)
212
264
all_labels = {}
213
265
# dictionary containing
@@ -262,9 +314,9 @@ def entry_point(
262
314
263
315
# Load APK
264
316
data = (
265
- ParallelQuark (apk [0 ], core_library , num_of_process )
317
+ ParallelQuark (apk [0 ], core_library , num_of_process , rizin_path )
266
318
if num_of_process > 1
267
- else Quark (apk [0 ], core_library )
319
+ else Quark (apk [0 ], core_library , rizin_path )
268
320
)
269
321
270
322
if label :
0 commit comments