From 70e243d6617ac443cda1b46c43c7992a22fdf477 Mon Sep 17 00:00:00 2001 From: Ajin Abraham Date: Sun, 10 Nov 2024 00:44:20 -0800 Subject: [PATCH] 4.1.8 (#2448) * APKID QA. * Bash and Batch file script QA. * Android Report template optimizations on how exported components are displayed. * Clickable Android Activities, Services, Providers and Recievers. * Updated Android version support to 11.0 for Android Studio AVD. * Created helper scripts for AVDs `scripts/start_avd.sh` and `scripts/start_avd.ps1`. --- mobsf/MalwareAnalyzer/views/android/apkid.py | 7 +- mobsf/MobSF/init.py | 2 +- mobsf/MobSF/tools_download.py | 5 +- mobsf/MobSF/utils.py | 5 + .../views/android/static_analyzer.py | 2 + mobsf/templates/base/list_href.html | 8 + .../android/dynamic_analysis.html | 4 +- .../android_binary_analysis.html | 89 ++------- .../android_source_analysis.html | 179 ++++++------------ pyproject.toml | 2 +- run.sh | 64 +++---- scripts/clean.bat | 70 +++---- scripts/clean.sh | 72 +++---- scripts/start_avd.ps1 | 55 ++++++ scripts/start_avd.sh | 142 ++++++++++++++ setup.bat | 158 ++++++++-------- setup.sh | 58 +++--- 17 files changed, 501 insertions(+), 421 deletions(-) create mode 100644 mobsf/templates/base/list_href.html create mode 100644 scripts/start_avd.ps1 create mode 100755 scripts/start_avd.sh diff --git a/mobsf/MalwareAnalyzer/views/android/apkid.py b/mobsf/MalwareAnalyzer/views/android/apkid.py index 14f2b823..375e73a1 100644 --- a/mobsf/MalwareAnalyzer/views/android/apkid.py +++ b/mobsf/MalwareAnalyzer/views/android/apkid.py @@ -1,6 +1,6 @@ # -*- coding: utf_8 -*- import logging -import os +from pathlib import Path from django.conf import settings @@ -24,9 +24,6 @@ def apkid_analysis(checksum, apk_file): logger.error(msg) append_scan_status(checksum, msg, repr(exp)) return {} - if not os.path.exists(apk_file): - logger.error('APKiD - APK not found') - return {} apkid_ver = apkid.__version__ from apkid.apkid import Scanner, Options @@ -87,5 +84,7 @@ def apkid_analysis(checksum, apk_file): filename = item['filename'] if '!' in filename: filename = filename.split('!', 1)[1] + else: + filename = Path(filename).name sanitized[filename] = item['matches'] return sanitized diff --git a/mobsf/MobSF/init.py b/mobsf/MobSF/init.py index 0214c642..e393f4d4 100644 --- a/mobsf/MobSF/init.py +++ b/mobsf/MobSF/init.py @@ -18,7 +18,7 @@ from mobsf.install.windows.setup import windows_config_local logger = logging.getLogger(__name__) -VERSION = '4.1.7' +VERSION = '4.1.8' BANNER = r""" __ __ _ ____ _____ _ _ _ | \/ | ___ | |__/ ___|| ___|_ _| || | / | diff --git a/mobsf/MobSF/tools_download.py b/mobsf/MobSF/tools_download.py index a763a5e0..20399446 100644 --- a/mobsf/MobSF/tools_download.py +++ b/mobsf/MobSF/tools_download.py @@ -14,7 +14,8 @@ from urllib.request import ( logging.basicConfig( level=logging.INFO, - format='%(asctime)s - %(levelname)s - %(message)s') + format='[%(levelname)s] %(asctime)-15s - %(message)s', + datefmt='%d/%b/%Y %H:%M:%S') logger = logging.getLogger(__name__) @@ -41,7 +42,7 @@ def download_file(url, file_path): # Print progress if file_size > 0: done = int(50 * downloaded / file_size) - fmt = (f'\r[{"#" * done}{"-" * (50-done)}] ' + fmt = (f'\r[{"#" * done}{"-" * (50 - done)}] ' f'{downloaded * 100 / file_size:.2f}%') sys.stdout.write(fmt) sys.stdout.flush() diff --git a/mobsf/MobSF/utils.py b/mobsf/MobSF/utils.py index 0b9fbebc..46ce6fbd 100755 --- a/mobsf/MobSF/utils.py +++ b/mobsf/MobSF/utils.py @@ -752,6 +752,11 @@ def replace(value, arg): return value.replace(what, to) +def pathify(value): + """Convert to path.""" + return value.replace('.', '/') + + def relative_path(value): """Show relative path to two parents.""" sep = None diff --git a/mobsf/StaticAnalyzer/views/android/static_analyzer.py b/mobsf/StaticAnalyzer/views/android/static_analyzer.py index 91300c57..a778aca1 100755 --- a/mobsf/StaticAnalyzer/views/android/static_analyzer.py +++ b/mobsf/StaticAnalyzer/views/android/static_analyzer.py @@ -28,6 +28,7 @@ from mobsf.MobSF.utils import ( is_file_exists, is_md5, key, + pathify, print_n_send_error_response, relative_path, ) @@ -107,6 +108,7 @@ logger = logging.getLogger(__name__) register.filter('key', key) register.filter('android_component', android_component) register.filter('relative_path', relative_path) +register.filter('pathify', pathify) @login_required diff --git a/mobsf/templates/base/list_href.html b/mobsf/templates/base/list_href.html new file mode 100644 index 00000000..bebee287 --- /dev/null +++ b/mobsf/templates/base/list_href.html @@ -0,0 +1,8 @@ +{% if list|length != 0 %} +
+ {% if list|length < limit %}Showing{% else %}Show{% endif %} all {{ list | length }} {{ type }} + {% for val in list %} + {{ val }}
+ {% endfor %} +
+{% endif %} \ No newline at end of file diff --git a/mobsf/templates/dynamic_analysis/android/dynamic_analysis.html b/mobsf/templates/dynamic_analysis/android/dynamic_analysis.html index 16cd4e5b..5336c33d 100644 --- a/mobsf/templates/dynamic_analysis/android/dynamic_analysis.html +++ b/mobsf/templates/dynamic_analysis/android/dynamic_analysis.html @@ -89,13 +89,13 @@ textarea:focus {

MobSF Dynamic Analyzer Supports

• Genymotion Android VM version 4.1 - 11.0 (arm64, x86, upto API 30)
- • Android Emulator AVD (non production) version 5.0 - 9.0 (arm, arm64, x86, and x86_64 upto API 28)
+ • Android Emulator AVD (non production) version 5.0 - 11.0 (arm, arm64, x86, and x86_64 upto API 30)
• Corellium Android VM (userdebug builds) version 7.1.2 - 11.0 (arm64 upto API 30)

{% if android_version %} Android version >= 9.0 recommended
- Detected Android Version: {{android_version}}, SDK: {{ android_sdk }}
+ Detected Android Version: {{android_version}}, SDK: API level {{ android_sdk }}
{% if android_sdk|floatformat > android_supported|floatformat %}