-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfeature_extractor_dex.py
22 lines (20 loc) · 1.06 KB
/
feature_extractor_dex.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
from apk import APK
from dex_extractor import extract_url, extract_api_call, extract_methode_path
from apis_manager import is_suspicious_methode, is_restricted, get_required_permissions
from utils import execute_baksmali_jar, get_smali_files, get_smali_lines, clean_baksmali_output_dir
def extract_dex_features(apk: 'APK', in_memory=False):
clean_baksmali_output_dir()
execute_baksmali_jar(apk.get_path())
for smali_file in get_smali_files():
for smali_line in get_smali_lines(smali_file):
api_call = extract_api_call(smali_line)
if api_call:
if is_restricted(api_call, in_memory=in_memory):
apk.add_restricted_api(api_call)
apk.add_used_permissions(get_required_permissions(api_call, in_memory=in_memory))
if is_suspicious_methode(extract_methode_path(api_call), in_memory=in_memory):
apk.add_suspicious_api(api_call)
else:
url = extract_url(smali_line)
if url:
apk.add_url(url)