From 900821425d32e239dd23563fa13efa0eeaa197dc Mon Sep 17 00:00:00 2001 From: Ajin Abraham Date: Sun, 24 Nov 2024 14:03:57 -0800 Subject: [PATCH] Optimizing downloads --- mobsf/MobSF/views/home.py | 12 ++---------- .../static_analysis/android_binary_analysis.html | 4 ++-- .../static_analysis/android_source_analysis.html | 1 + .../static_analysis/ios_binary_analysis.html | 2 +- .../static_analysis/ios_source_analysis.html | 1 + .../static_analysis/windows_binary_analysis.html | 1 + 6 files changed, 8 insertions(+), 13 deletions(-) diff --git a/mobsf/MobSF/views/home.py b/mobsf/MobSF/views/home.py index cf37275ce..7760e60b1 100755 --- a/mobsf/MobSF/views/home.py +++ b/mobsf/MobSF/views/home.py @@ -480,15 +480,13 @@ def download(request): @login_required def generate_download(request): - """Generate downloads for uploaded binaries/source.""" + """Generate downloads for smali/java zip.""" try: - binary = ('apk', 'ipa', 'jar', 'aar', 'so', 'dylib', 'a') - source = ('smali', 'java') logger.info('Generating Downloads') md5 = request.GET['hash'] file_type = request.GET['file_type'] if (not is_md5(md5) - or file_type not in binary + source): + or file_type not in ('smali', 'java')): msg = 'Invalid download type or hash' logger.exception(msg) return print_n_send_error_response(request, msg) @@ -509,12 +507,6 @@ def generate_download(request): shutil.make_archive( dwd_file.as_posix(), 'zip', directory.as_posix()) file_name = f'{md5}-smali.zip' - elif file_type in binary: - # Binaries - file_name = f'{md5}.{file_type}' - src = app_dir / file_name - dst = dwd_dir / file_name - shutil.copy2(src.as_posix(), dst.as_posix()) return redirect(f'/download/{file_name}') except Exception: msg = 'Generating Downloads' diff --git a/mobsf/templates/static_analysis/android_binary_analysis.html b/mobsf/templates/static_analysis/android_binary_analysis.html index aab82d7b4..647ba7847 100755 --- a/mobsf/templates/static_analysis/android_binary_analysis.html +++ b/mobsf/templates/static_analysis/android_binary_analysis.html @@ -622,7 +622,7 @@

{{exported_count.exported_providers}} / {{ providers | length }}

Rescan {% if app_type in 'so' %} - Download {{ app_type | upper}} + Download {{ app_type | upper}} {% endif %} {% if app_type not in 'so' %} Manage Suppressions @@ -659,7 +659,7 @@

{{exported_count.exported_providers}} / {{ providers | length }}

{% if app_type not in 'jar,aar' %} Download Smali Code {% endif %} - Download {{ app_type | upper}} + Download {{ app_type | upper}}

diff --git a/mobsf/templates/static_analysis/android_source_analysis.html b/mobsf/templates/static_analysis/android_source_analysis.html index 93519c2c1..e7c0ff0ba 100755 --- a/mobsf/templates/static_analysis/android_source_analysis.html +++ b/mobsf/templates/static_analysis/android_source_analysis.html @@ -502,6 +502,7 @@

{{exported_count.exported_providers}} / {{ providers | length }}

View AndroidManifest.xml View Source + Download ZIP

diff --git a/mobsf/templates/static_analysis/ios_binary_analysis.html b/mobsf/templates/static_analysis/ios_binary_analysis.html index 44b551cd1..2e02963f4 100755 --- a/mobsf/templates/static_analysis/ios_binary_analysis.html +++ b/mobsf/templates/static_analysis/ios_binary_analysis.html @@ -470,7 +470,7 @@
{% if app_type not in 'Dylib,A' %} View Class Dump {% endif %} - Download {% if app_type in 'Dylib' %}DYLIB{% elif app_type in 'A' %}A{% else %}IPA{% endif %} + Download {% if app_type in 'Dylib' %}DYLIB{% elif app_type in 'A' %}A{% else %}IPA{% endif %}

diff --git a/mobsf/templates/static_analysis/ios_source_analysis.html b/mobsf/templates/static_analysis/ios_source_analysis.html index dc2204f88..ba87d34ce 100755 --- a/mobsf/templates/static_analysis/ios_source_analysis.html +++ b/mobsf/templates/static_analysis/ios_source_analysis.html @@ -370,6 +370,7 @@
Manage Suppressions View Info.plist + Download ZIP

diff --git a/mobsf/templates/static_analysis/windows_binary_analysis.html b/mobsf/templates/static_analysis/windows_binary_analysis.html index c24fe5c37..d5caf235e 100644 --- a/mobsf/templates/static_analysis/windows_binary_analysis.html +++ b/mobsf/templates/static_analysis/windows_binary_analysis.html @@ -214,6 +214,7 @@
Rescan View Strings + Download APPX