mirror of
https://github.com/MobSF/Mobile-Security-Framework-MobSF.git
synced 2026-10-12 02:06:59 +00:00
Hotfix: Docker error fixes
This commit is contained in:
@@ -25,6 +25,7 @@ from mobsf.DynamicAnalyzer.tools.webproxy import (
|
||||
stop_httptools,
|
||||
)
|
||||
from mobsf.MobSF.utils import (
|
||||
get_android_dm_exception_msg,
|
||||
get_config_loc,
|
||||
get_device,
|
||||
get_proxy_ip,
|
||||
@@ -65,21 +66,17 @@ def dynamic_analysis(request, api=False):
|
||||
try:
|
||||
identifier = get_device()
|
||||
except Exception:
|
||||
msg = ('Is Android VM running? MobSF cannot'
|
||||
' find android instance identifier.'
|
||||
' Please run an android instance and refresh'
|
||||
' this page. If this error persists,'
|
||||
' set ANALYZER_IDENTIFIER in '
|
||||
f'{get_config_loc()}')
|
||||
return print_n_send_error_response(request, msg, api)
|
||||
return print_n_send_error_response(
|
||||
request, get_android_dm_exception_msg(), api)
|
||||
try:
|
||||
if identifier:
|
||||
env = Environment(identifier)
|
||||
env.connect()
|
||||
device_packages = env.get_device_packages()
|
||||
pkg_file = Path(settings.DWD_DIR) / 'packages.json'
|
||||
with pkg_file.open('w', encoding='utf-8') as target:
|
||||
dump(device_packages, target)
|
||||
if device_packages:
|
||||
pkg_file = Path(settings.DWD_DIR) / 'packages.json'
|
||||
with pkg_file.open('w', encoding='utf-8') as target:
|
||||
dump(device_packages, target)
|
||||
and_ver = env.get_android_version()
|
||||
and_sdk = env.get_android_sdk()
|
||||
except Exception:
|
||||
@@ -134,13 +131,8 @@ def dynamic_analyzer(request, checksum, api=False):
|
||||
except Exception:
|
||||
pass
|
||||
if not identifier:
|
||||
msg = ('Is the android instance running? MobSF cannot'
|
||||
' find android instance identifier. '
|
||||
'Please run an android instance and refresh'
|
||||
' this page. If this error persists,'
|
||||
' set ANALYZER_IDENTIFIER in '
|
||||
f'{get_config_loc()}')
|
||||
return print_n_send_error_response(request, msg, api)
|
||||
return print_n_send_error_response(
|
||||
request, get_android_dm_exception_msg(), api)
|
||||
|
||||
# Get activities from the static analyzer results
|
||||
try:
|
||||
|
||||
@@ -430,7 +430,9 @@ class Environment:
|
||||
'list',
|
||||
'packages',
|
||||
'-f',
|
||||
'-3'], True)
|
||||
'-3'], True, True)
|
||||
if not out:
|
||||
return device_packages
|
||||
for pkg_str in out.decode('utf-8').rstrip().split():
|
||||
path_pkg = pkg_str.split('package:', 1)[1].strip()
|
||||
parts = path_pkg.split('.apk=', 1)
|
||||
|
||||
+12
-4
@@ -333,10 +333,7 @@ def get_device():
|
||||
if len(out) > 2:
|
||||
dev_id = out[1].decode('utf-8').split('\t')[0]
|
||||
return dev_id
|
||||
logger.error('Is the Android VM running?\n'
|
||||
'MobSF cannot identify device id.\n'
|
||||
'Please set ''ANALYZER_IDENTIFIER in '
|
||||
'%s', get_config_loc())
|
||||
logger.error(get_android_dm_exception_msg())
|
||||
|
||||
|
||||
def get_adb():
|
||||
@@ -637,3 +634,14 @@ def android_component(data):
|
||||
elif 'Broadcast Receiver' in data:
|
||||
cmp = 'receiver_'
|
||||
return cmp
|
||||
|
||||
|
||||
def get_android_dm_exception_msg():
|
||||
return (
|
||||
'Is your Android VM/emulator running? MobSF cannot'
|
||||
' find the android device identifier.'
|
||||
' Please run an android instance and refresh'
|
||||
' this page. If this error persists,'
|
||||
' set ANALYZER_IDENTIFIER in '
|
||||
f'{get_config_loc()} or via environment variable'
|
||||
' MOBSF_ANALYZER_IDENTIFIER')
|
||||
|
||||
@@ -70,7 +70,7 @@ textarea:focus {
|
||||
</div>
|
||||
<!-- /.card-header -->
|
||||
<div class="card-body">
|
||||
<p> MobSF cannot find android instance identifier. Make sure that an android instance is running and refresh this page.</p><p> If this error persists, Please set <i>ANALYZER_IDENTIFIER</i> in <strong>{{ settings_loc }}</strong> or via environment variable <strong>ANALYZER_IDENTIFIER</strong>.
|
||||
<p> MobSF cannot find android instance identifier. Make sure that an android instance is running and refresh this page.</p><p> If this error persists, Please set <i>ANALYZER_IDENTIFIER</i> in <strong>{{ settings_loc }}</strong> or via environment variable <strong>MOBSF_ANALYZER_IDENTIFIER</strong>.
|
||||
</p>
|
||||
</div>
|
||||
<!-- /.card-body -->
|
||||
|
||||
Reference in New Issue
Block a user