Ejemplo n.º 1
0
def unpack():
	"""
	APK to DEX
	"""
	logger.info('Unpacking %s', common.apkPath)
	#Get the directory to unpack to
	try:
		dirname, extension = common.apkPath.rsplit(".",1)
		#workaround for cases where path may include whitespace
		file_temp = open(common.apkPath,'r')
		zf = zipfile.ZipFile(file_temp)
		logger.info('Zipfile: %s', zf)
		for filename in [ zf.namelist()]:
			if not os.path.exists(dirname + "/"):
				os.makedirs(dirname + "/")
			zf.extractall(dirname + "/", zf.namelist(), )
			logger.info('Extracted APK to %s', dirname + '/')
			common.pathToDEX = dirname + "/classes.dex"
			common.pathToUnpackedAPK = dirname + '/'
			return True
	except Exception as e:
		if not common.interactive_mode:
				logger.error(common.args.pathtoapk + common.config.get('qarkhelper', 'NOT_A_VALID_APK'))
				exit()
		logger.error(common.config.get('qarkhelper', 'NOT_A_VALID_APK_INTERACTIVE'))
		raise
Ejemplo n.º 2
0
def unpack():
    """
	APK to DEX
	"""
    logger.info('Unpacking %s', common.apkPath)
    # Get the directory to unpack to
    try:
        dirname, extension = common.apkPath.rsplit(".", 1)
        # workaround for cases where path may include whitespace
        file_temp = open(common.apkPath, 'r')
        zf = zipfile.ZipFile(filename=file_temp)
        logger.info('Zipfile: %s', zf)
        for filename in [zf.namelist()]:
            if not os.path.exists(dirname + "/"):
                os.makedirs(dirname + "/")
            zf.extractall(
                dirname + "/",
                zf.namelist(),
            )
            logger.info('Extracted APK to %s', dirname + '/')
            common.pathToDEX = dirname + "/classes.dex"
            common.pathToUnpackedAPK = dirname + '/'
            return True
    except Exception as e:
        if not common.interactive_mode:
            logger.error(common.args.pathtoapk +
                         common.config.get('qarkhelper', 'NOT_A_VALID_APK'))
            exit()
        logger.error(
            common.config.get('qarkhelper', 'NOT_A_VALID_APK_INTERACTIVE'))
        raise
Ejemplo n.º 3
0
def unpack():
    """
	APK to DEX
	"""
    logger.info('Unpacking %s', common.apkPath)
    # Get the directory to unpack to
    try:
        dirname, extension = common.apkPath.rsplit(".", 1)
        # workaround for cases where path may include whitespace
        file_temp = open(common.apkPath, 'r')
        zf = zipfile.ZipFile(file_temp)
        logger.info('Zipfile: %s', zf)
        for filename in [zf.namelist()]:
            if not os.path.exists(dirname + "/"):
                os.makedirs(dirname + "/")
            zf.extractall(
                dirname + "/",
                zf.namelist(),
            )
            logger.info('Extracted APK to %s', dirname + '/')
            common.pathToDEX = dirname + "/classes.dex"
            if not os.path.exists(
                    common.pathToDEX
            ):  # Some default/system APKs from Google don't have this file
                logger.error(
                    "The classes.dex file was not found for this APK! Please select a different APK."
                )
                raise Exception
            common.pathToUnpackedAPK = dirname + '/'
            return True
    except Exception as e:
        if not common.interactive_mode:
            logger.error(common.args.apkpath +
                         common.config.get('qarkhelper', 'NOT_A_VALID_APK'))
            exit()
        logger.error(
            common.config.get('qarkhelper', 'NOT_A_VALID_APK_INTERACTIVE'))
        raise