-
Notifications
You must be signed in to change notification settings - Fork 0
/
apk_parser.py
46 lines (38 loc) · 1.47 KB
/
apk_parser.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
from pyaxmlparser import APK
import tkinter as tk
from logger import g_logger
# apk parser wrapper
class ApkParser:
def __init__(self, apk_path: str, info_label, icon_view) -> None:
self.set_apk(apk_path)
self.info_label = info_label
self.icon_view = icon_view
# update apk info (might be useful to check apk info afrer making changes to it)
def set_apk(self, apk_path: str) -> None:
try:
self.apk_path = apk_path
self.apk = APK(apk_path)
except Exception as ex:
g_logger.error(f'[ !] {ex}\n')
# apk parsing routine
def parse(self) -> bool:
if not hasattr(self, 'apk') or self.apk.is_valid_APK() == False:
return False
info_string = f'package: {self.apk.package}\n' \
f'version: {self.apk.version_name}\n' \
f'version code: {self.apk.version_code}\n' \
f'application: {self.apk.application}'
# updating corresponding label..
self.info_label.config(text=info_string)
#..and icon
icon = tk.PhotoImage(data=self.apk.icon_data, format='png')
self.icon_view.configure(image=icon)
self.icon_view.image=icon
g_logger.info('[+] Parsed apk info\n')
return True
# checks whether apk is signed or not
def is_signed(self, apk_path='') -> bool:
if not apk_path:
apk_path = self.apk_path
apk = APK(apk_path)
return apk.is_signed()