def process_manifest(manifest): try: common.manifest = os.path.abspath(str(manifest).strip()) common.manifest = re.sub("\\\\\s",' ',common.manifest) common.xmldoc = minidom.parse(common.manifest) common.logger.info(common.xmldoc.toprettyxml()) report.write_manifest(common.xmldoc) except Exception as e: try: # not human readable yet? ap = axmlprinter.AXMLPrinter(open(common.manifest, 'rb').read()) common.xmldoc = minidom.parseString(ap.getBuff()) common.logger.info(common.xmldoc.toxml()) report.write_manifest(common.xmldoc.toprettyxml()) except Exception as e: if not common.interactive_mode: common.logger.error(str(e) + "\r\nThat didnt work. Try providing an absolute path to the file") exit() common.logger.error(str(e) + "\r\nThat didnt work. Try providing an absolute path to the file\n")
def process_manifest(manifest): try: common.manifest = os.path.abspath(str(manifest).strip()) common.manifest = re.sub("\\\\\s",' ',common.manifest) common.manifest = minidom.parseString(open(common.manifest, 'r').read()).toxml() common.xmldoc = minidom.parseString(common.manifest.encode('utf-8')) report.write_manifest(common.xmldoc) common.logger.info(common.xmldoc.toxml()) except Exception as e: try: # not human readable yet? ap = axmlprinter.AXMLPrinter(open(common.manifest, 'rb').read()) common.xmldoc = minidom.parseString(ap.getBuff()) common.logger.info(common.xmldoc.toxml()) report.write_manifest(common.xmldoc.toprettyxml()) except Exception as e: if not common.interactive_mode: common.logger.error(str(e) + "\r\nThat didnt work. Try providing an absolute path to the file") exit() common.logger.error(str(e) + "\r\nThat didnt work. Try providing an absolute path to the file\n")
except Exception as e: continue try: package = defaultdict(list) mf = unpackAPK.find_manifest_in_unpacked_apk(common.apkPath, common.manifestName) ap = axmlprinter.AXMLPrinter(open(mf, 'rb').read()) manifestInXML = minidom.parseString(ap.getBuff()).toxml() if common.interactive_mode: show=raw_input("Inspect Manifest?[y/n]") if show in ['y','Y']: common.logger.info(manifestInXML) raw_input("Press ENTER key to continue") else: common.logger.info(manifestInXML) report.write_manifest(manifestInXML.encode( "utf-8" )) common.manifest = mf except IOError: common.logger.error(IOError.message) #parse xml common.xmldoc = minidom.parseString(manifestInXML.encode('utf-8')) elif common.source_or_apk==2: # Check if all required arguments are present before proceeding while True: if common.interactive_mode: common.sourceDirectory=os.path.abspath(raw_input(common.config.get('qarkhelper','SOURCE_PROMPT')).rstrip()) else: common.sourceDirectory=common.args.codepath re.sub(r'AndroidManifest.xml','',common.sourceDirectory)
try: package = defaultdict(list) result = Queue() pub.subscribe(get_manifestXML, 'manifest') thread_get_manifest = Thread(name='apktool-qark', target=apktool, args=(common.apkPath,)) thread_get_manifest.start() thread_get_manifest.join() common.manifest = minidom.parseString(common.manifest).toxml() if common.interactive_mode: show=raw_input("Inspect Manifest?[y/n]") if show in ['y','Y']: common.logger.info(common.manifest) raw_input("Press ENTER key to continue") else: common.logger.info(common.manifest) report.write_manifest(common.manifest.encode( "utf-8" )) #common.manifest = mf except IOError: common.logger.error(IOError.message) #parse xml common.xmldoc = minidom.parseString(common.manifest.encode('utf-8')) elif common.source_or_apk==2: # Check if all required arguments are present before proceeding while True: if common.interactive_mode: common.sourceDirectory=os.path.abspath(raw_input(common.config.get('qarkhelper','SOURCE_PROMPT')).rstrip()) else: common.sourceDirectory=common.args.codepath re.sub(r'AndroidManifest.xml','',common.sourceDirectory)
except Exception as e: continue try: package = defaultdict(list) mf = unpackAPK.findManifestInUnpackedAPK(common.apkPath, common.manifestName) ap = axmlprinter.AXMLPrinter(open(mf, 'rb').read()) manifestInXML = minidom.parseString(ap.getBuff()).toxml() if common.interactive_mode: show=raw_input("Inspect Manifest?[y/n]") if show in ['y','Y']: common.logger.info(manifestInXML) raw_input("Press ENTER key to continue") else: common.logger.info(manifestInXML) report.write_manifest(manifestInXML.encode( "utf-8" )) common.manifest = mf except IOError: common.logger.error(IOError.message) #parse xml common.xmldoc = minidom.parseString(manifestInXML.encode('utf-8')) elif common.source_or_apk==2: # Check if all required arguments are present before proceeding while True: if common.interactive_mode: common.sourceDirectory=os.path.abspath(raw_input(common.config.get('qarkhelper','SOURCE_PROMPT')).rstrip()) else: common.sourceDirectory=common.args.codepath re.sub(r'AndroidManifest.xml','',common.sourceDirectory)