Skip to content

Commit

Permalink
added xapk handling
Browse files Browse the repository at this point in the history
  • Loading branch information
ajinabraham committed Dec 30, 2020
1 parent 383046b commit a558693
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions StaticAnalyzer/views/android/xapk.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# -*- coding: utf_8 -*-
"""Handle XAPK File."""
import logging
from json import load
from shutil import move

from StaticAnalyzer.views.shared_func import unzip

logger = logging.getLogger(__name__)


def handle_xapk(app_dic):
"""Unzip and Extract APK."""
data = None
xapk = app_dic['app_dir'] / (app_dic['md5'] + '.xapk')
apk = app_dic['app_dir'] / (app_dic['md5'] + '.apk')
files = unzip(xapk.as_posix(), app_dic['app_dir'])
if 'manifest.json' not in files:
logger.error('Manifest file not found in XAPK')
return False
manifest = app_dic['app_dir'] / 'manifest.json'
with open(manifest) as f:
data = load(f)
if not data:
logger.error('Manifest file is empty')
return False
apks = data.get('split_apks')
if not apks:
logger.error('Split APKs not found')
return False
for a in apks:
if a['id'] == 'base':
base_apk = app_dic['app_dir'] / a['file']
move(base_apk, apk)
return True
return None

0 comments on commit a558693

Please sign in to comment.