7
7
8
8
import requests
9
9
10
+ from concurrent .futures import ThreadPoolExecutor
11
+
10
12
from mobsfscan .logger import init_logger
11
13
from mobsfscan .manifest_metadata import metadata
12
14
47
49
'31' : '12' ,
48
50
'32' : '12L' ,
49
51
'33' : '13' ,
52
+ '34' : '14' ,
50
53
}
51
54
52
55
@@ -307,11 +310,33 @@ def browsable_activity_check(self, app):
307
310
for act in activities :
308
311
self .check_in_intents (act )
309
312
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
+
310
337
def assetlinks_check (self , intent ):
311
338
"""Well known assetlink check."""
312
- iden = 'sha256_cert_fingerprints'
313
339
well_known_path = '/.well-known/assetlinks.json'
314
- rule = 'android_manifest_well_known_assetlinks'
315
340
well_knowns = set ()
316
341
317
342
applink_data = intent .get ('data' )
@@ -325,31 +350,19 @@ def assetlinks_check(self, intent):
325
350
scheme = applink .get ('@android:scheme' )
326
351
# Collect possible well-known paths
327
352
if scheme and scheme in ('http' , 'https' ) and host :
353
+ host = host .replace ('*.' , '' )
328
354
if port :
329
355
c_url = f'{ scheme } ://{ host } :{ port } { well_known_path } '
330
356
else :
331
357
c_url = f'{ scheme } ://{ host } { well_known_path } '
332
358
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 ()
353
366
354
367
355
368
class TaskHijackingChecks :
0 commit comments