Best Python code snippet using Airtest
apimonitor.py
Source:apimonitor.py
...63smalidir = os.path.join(outdir, "origin_smali") 64new_dexpath = os.path.join(outdir, "new.dex")65new_smalidir = os.path.join(outdir, "new_smali")66min_version = int(a.get_min_sdk_version())67if a.get_target_sdk_version():68 target_version = int(a.get_target_sdk_version())69else:70 target_version = min_version71print "min_sdk_version=%d" % min_version72print "target_sdk_version=%d" % target_version73if (not args.level) or args.level[0] < min_version:74 level = min_version75else:76 level = args.level[0]77dex_file = open(dexpath, 'w')78dex_file.write(a.get_dex())79dex_file.close()80smali_jar = os.path.join(working_dir, "smali", "smali.jar")81baksmali_jar = os.path.join(working_dir, "smali", "baksmali.jar")82cert_path = os.path.join(working_dir, "config", "apkil.cert")...
FragmentInjectionAnalyzer.py
Source:FragmentInjectionAnalyzer.py
...26 self.dx = dx27 self.vm = vm28 self.cm = cm29 def check_affected_target_sdk(self):30 return self.apk.get_target_sdk_version() is None or self.apk.get_target_sdk_version() < 1931 def check_for_fragment_injection(self, report):32 if self.check_affected_target_sdk():33 exported_activity_list = []34 if self.get_report_for_type(report, "UNPROTECTED_EXPORTED_ACTIVITY"):35 for vuln in self.get_report_for_type(report, "UNPROTECTED_EXPORTED_ACTIVITY"):36 exported_activity_list.append(self.get_vulnerability_reference_class(vuln).replace(".", "/"))37 if self.get_report_for_type(report, "NON_SIGNATURE_PROTECTED_EXPORTED_ACTIVITY"):38 for vuln in self.get_report_for_type(report, "NON_SIGNATURE_PROTECTED_EXPORTED_ACTIVITY"):39 exported_activity_list.append(self.get_vulnerability_reference_class(vuln).replace(".", "/"))40 for cls in self.vm.get_classes():41 if any(activity in cls.get_name() for activity in exported_activity_list) and (42 cls.get_superclassname() == "Landroid/preference/PreferenceActivity;" or \43 cls.get_superclassname() == "Lcom/actionbarsherlock/app/SherlockPreferenceActivity;"):44 self.add_vulnerability("FRAGMENT_INJECTION",...
BOLTSFrameworkAnalyzer.py
Source:BOLTSFrameworkAnalyzer.py
...25 self.vm = vm26 self.dx = dx27 self.cm = cm28 def check_affected_target_sdk(self):29 return self.apk.get_target_sdk_version() is None or self.apk.get_target_sdk_version() < 1730 def check_bolts_navigation(self):31 # checks if app calls any of the methods of Bolts Framework to resolve App Link32 paths = self.dx.tainted_packages.search_methods('Lbolts/AppLinkNavigation;', 'navigateInBackground', '.')33 paths += self.dx.tainted_packages.search_methods('Lbolts/AppLinkNavigation;', 'navigate', '.')34 paths += self.dx.tainted_packages.search_methods('Lbolts/WebViewAppLinkResolver;',35 'getAppLinkFromUrlInBackground', '.')36 paths = filter(lambda path: not path.get_src(self.cm)[0].startswith('Lbolts/'), paths)37 return len(paths) > 038 def check_for_bolts_framework(self):39 if self.dx.tainted_packages.search_packages("Lbolts/"):40 if self.check_bolts_navigation():41 if self.check_affected_target_sdk():42 affected = " all devices until 4.4, since the target SDK is 16 or lower" # ALL DEVICES AFFECTED43 else:...
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!