diff --git a/mobsf/MobSF/utils.py b/mobsf/MobSF/utils.py index dcc7bd96c9..ba88e8a89a 100755 --- a/mobsf/MobSF/utils.py +++ b/mobsf/MobSF/utils.py @@ -763,13 +763,14 @@ def replace(value, arg): def relative_path(value): """Show relative path to two parents.""" + sep = None if '/' in value: sep = '/' elif '\\\\' in value: sep = '\\\\' elif '\\' in value: sep = '\\' - if value.count(sep) < 2: + if not sep or value.count(sep) < 2: return value path = Path(value) return path.relative_to(path.parent.parent).as_posix() diff --git a/mobsf/StaticAnalyzer/views/common/shared_func.py b/mobsf/StaticAnalyzer/views/common/shared_func.py index fd86eac656..fba6c7fe6b 100755 --- a/mobsf/StaticAnalyzer/views/common/shared_func.py +++ b/mobsf/StaticAnalyzer/views/common/shared_func.py @@ -382,8 +382,10 @@ def scan_library(request, checksum): if not is_safe_path(lib_dir.as_posix(), sfile.as_posix()): msg = 'Path Traversal Detected!' return print_n_send_error_response(request, msg) - ext = sfile.suffix + if not ext and 'Frameworks' in relative_path: + # Force Dylib on Frameworks + ext = '.dylib' if not sfile.exists(): msg = 'Library File not found' return print_n_send_error_response(request, msg) diff --git a/mobsf/StaticAnalyzer/views/ios/static_analyzer.py b/mobsf/StaticAnalyzer/views/ios/static_analyzer.py index bf513c4997..8cc547646c 100755 --- a/mobsf/StaticAnalyzer/views/ios/static_analyzer.py +++ b/mobsf/StaticAnalyzer/views/ios/static_analyzer.py @@ -95,6 +95,9 @@ def static_analyzer_ios(request, checksum, api=False): api) file_type = robj[0].SCAN_TYPE filename = robj[0].FILE_NAME + if file_type == 'dylib' and not Path(filename).suffix: + # Force dylib extension on Frameworks + filename = f'{filename}.dylib' allowed_exts = ('ios', '.ipa', '.zip', '.dylib', '.a') allowed_typ = [i.replace('.', '') for i in allowed_exts] if (not filename.lower().endswith(allowed_exts) diff --git a/mobsf/templates/pdf/ios_report.html b/mobsf/templates/pdf/ios_report.html index c0aca19435..ce8f4219da 100644 --- a/mobsf/templates/pdf/ios_report.html +++ b/mobsf/templates/pdf/ios_report.html @@ -516,14 +516,14 @@

IPA BINARY ANALYSIS

{% endif %} - - {% if dylib_analysis and app_type not in 'A' %} -

DYNAMIC LIBRARY BINARY ANALYSIS

+ {% if app_type not in 'A' %} + {% if dylib_analysis or framework_analysis %} +

DYNAMIC LIBRARY & FRAMEWORK BINARY ANALYSIS

- + @@ -568,28 +568,7 @@

DYNAMIC LIBRARY BINARY ANALYSIS


{{dy.symbol.description}} {% endfor %} - -
NODYLIBDYLIB/FRAMEWORK NX STACK CANARY ARC
- {% endif %} - - {% if framework_analysis and app_type not in 'A' %} -

FRAMEWORK BINARY ANALYSIS

- - - - - - - - - - - - - - - - {% for frm in framework_analysis %} + {% for frm in framework_analysis %} @@ -623,10 +602,10 @@

FRAMEWORK BINARY ANALYSIS


{{frm.symbol.description}} {% endfor %} - -
NOFRAMEWORKNXSTACK CANARYARCRPATHCODE SIGNATUREENCRYPTEDSYMBOLS STRIPPED
{{ forloop.counter }} {{frm.name}}
- {% endif %} - + + + {% endif %} + {% endif %} {% if app_type in 'A' %}

STATIC LIBRARY BINARY ANALYSIS

diff --git a/mobsf/templates/static_analysis/ios_binary_analysis.html b/mobsf/templates/static_analysis/ios_binary_analysis.html index 15299baed6..a4a8755c5c 100755 --- a/mobsf/templates/static_analysis/ios_binary_analysis.html +++ b/mobsf/templates/static_analysis/ios_binary_analysis.html @@ -119,13 +119,7 @@ - {% endif %} @@ -925,7 +919,7 @@
{{ binary_analysis.summary.suppressed }}

- DYNAMIC LIBRARY BINARY ANALYSIS + DYNAMIC LIBRARY & FRAMEWORK BINARY ANALYSIS

@@ -933,7 +927,7 @@
{{ binary_analysis.summary.suppressed }}
{% if app_type not in 'Dylib' %} - + {% endif %} @@ -945,8 +939,8 @@
{{ binary_analysis.summary.suppressed }}
- {% if not dylib_analysis %} - No Dylibs found. + {% if not dylib_analysis and not framework_analysis %} + No Dylibs/Frameworks found. {% endif %} {% for dy in dylib_analysis %} @@ -986,51 +980,12 @@
{{ binary_analysis.summary.suppressed }}

{{dy.symbol.description}} {% endfor %} - -
NODYLIBDYLIB/FRAMEWORKNX STACK CANARY
-
- -
-
- - - - - - - -
-
-
-
-
-
-

- FRAMEWORK BINARY ANALYSIS -

-
- - - - - - - - - - - - - - - - {% if not framework_analysis %} - No Frameworks found. - {% endif %} {% for frm in framework_analysis %} - +
NOFRAMEWORKNXSTACK CANARYARCRPATHCODE SIGNATUREENCRYPTEDSYMBOLS STRIPPED
{{ forloop.counter }}{{frm.name}}{{frm.name | relative_path}}
+ Analyze +
{{frm.nx.has_nx}}
{{frm.nx.severity}} @@ -1072,7 +1027,7 @@
{{ binary_analysis.summary.suppressed }}
- + {% endif %} {% if app_type in 'A' %}