-
-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
383046b
commit a558693
Showing
1 changed file
with
36 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |