Skip to content

Commit

Permalink
Handle aapt/aapt2 search in windows
Browse files Browse the repository at this point in the history
  • Loading branch information
ajinabraham committed Nov 29, 2024
1 parent 772c6c9 commit f8fa4a0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
7 changes: 5 additions & 2 deletions mobsf/StaticAnalyzer/views/android/aapt.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import re
import logging
import subprocess
from platform import system
from pathlib import Path

from django.conf import settings
Expand Down Expand Up @@ -37,15 +38,17 @@ def __init__(self, apk_path):
and Path(settings.AAPT2_BINARY).exists()):
self.aapt2_path = settings.AAPT2_BINARY
else:
self.aapt2_path = find_aapt('aapt2')
aapt2 = 'aapt2.exe' if system() == 'Windows' else 'aapt2'
self.aapt2_path = find_aapt(aapt2)

# Check for custom AAPT path in settings
if (getattr(settings, 'AAPT_BINARY', '')
and len(settings.AAPT_BINARY) > 0
and Path(settings.AAPT_BINARY).exists()):
self.aapt_path = settings.AAPT_BINARY
else:
self.aapt_path = find_aapt('aapt')
aapt = 'aapt.exe' if system() == 'Windows' else 'aapt'
self.aapt_path = find_aapt(aapt)

# Ensure both aapt and aapt2 are found
if not (self.aapt2_path and self.aapt_path):
Expand Down
4 changes: 4 additions & 0 deletions mobsf/StaticAnalyzer/views/android/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ def aapt_parse(app_dict):
if not app_dict.get('files'):
app_dict['files'] = aapt_obj.get_apk_files()
app_dict['apk_strings'] = aapt_obj.get_apk_strings()
except FileNotFoundError:
msg = 'aapt and aapt2 not found, skipping APK feature extraction'
logger.warning(msg)
append_scan_status(checksum, msg)
except Exception as exp:
msg = 'Failed to extract APK features using aapt/aapt2'
logger.warning(msg)
Expand Down

0 comments on commit f8fa4a0

Please sign in to comment.