Skip to content

Commit e29e85c

Browse files
authored
Merge pull request #77 from MobSF/fix_76
Threadpool, SDK bump, handle asterik in host
2 parents 511429c + b169ea4 commit e29e85c

File tree

2 files changed

+36
-23
lines changed

2 files changed

+36
-23
lines changed

mobsfscan/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
__title__ = 'mobsfscan'
77
__authors__ = 'Ajin Abraham'
88
__copyright__ = f'Copyright {datetime.now().year} Ajin Abraham, OpenSecurity'
9-
__version__ = '0.3.5'
9+
__version__ = '0.3.6'
1010
__version_info__ = tuple(int(i) for i in __version__.split('.'))
1111
__all__ = [
1212
'__title__',

mobsfscan/manifest.py

Lines changed: 35 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77

88
import requests
99

10+
from concurrent.futures import ThreadPoolExecutor
11+
1012
from mobsfscan.logger import init_logger
1113
from mobsfscan.manifest_metadata import metadata
1214

@@ -47,6 +49,7 @@
4749
'31': '12',
4850
'32': '12L',
4951
'33': '13',
52+
'34': '14',
5053
}
5154

5255

@@ -307,11 +310,33 @@ def browsable_activity_check(self, app):
307310
for act in activities:
308311
self.check_in_intents(act)
309312

313+
def check_url(self, w_url):
314+
"""Check URL."""
315+
rcode = 0
316+
iden = 'sha256_cert_fingerprints'
317+
rule = 'android_manifest_well_known_assetlinks'
318+
status = True
319+
try:
320+
r = requests.get(
321+
w_url,
322+
allow_redirects=True,
323+
timeout=5)
324+
if not (str(r.status_code).startswith('2')
325+
and iden in str(r.json())):
326+
status = False
327+
rcode = r.status_code
328+
except Exception:
329+
status = False
330+
if not status:
331+
add_finding(
332+
self.findings,
333+
self.xml_path,
334+
rule,
335+
(w_url, rcode))
336+
310337
def assetlinks_check(self, intent):
311338
"""Well known assetlink check."""
312-
iden = 'sha256_cert_fingerprints'
313339
well_known_path = '/.well-known/assetlinks.json'
314-
rule = 'android_manifest_well_known_assetlinks'
315340
well_knowns = set()
316341

317342
applink_data = intent.get('data')
@@ -325,31 +350,19 @@ def assetlinks_check(self, intent):
325350
scheme = applink.get('@android:scheme')
326351
# Collect possible well-known paths
327352
if scheme and scheme in ('http', 'https') and host:
353+
host = host.replace('*.', '')
328354
if port:
329355
c_url = f'{scheme}://{host}:{port}{well_known_path}'
330356
else:
331357
c_url = f'{scheme}://{host}{well_known_path}'
332358
well_knowns.add(c_url)
333-
for w_url in well_knowns:
334-
try:
335-
status = True
336-
r = requests.get(
337-
w_url,
338-
allow_redirects=True,
339-
timeout=5)
340-
if not (str(r.status_code).startswith('2')
341-
and iden in str(r.json())):
342-
status = False
343-
rcode = r.status_code
344-
except Exception:
345-
status = False
346-
rcode = 0
347-
if not status:
348-
add_finding(
349-
self.findings,
350-
self.xml_path,
351-
rule,
352-
(w_url, rcode))
359+
with ThreadPoolExecutor() as executor:
360+
futures = []
361+
for w_url in well_knowns:
362+
futures.append(
363+
executor.submit(self.check_url, w_url))
364+
for future in futures:
365+
future.result()
353366

354367

355368
class TaskHijackingChecks:

0 commit comments

Comments
 (0)