-
Notifications
You must be signed in to change notification settings - Fork 3
/
ExtractAPK.py
executable file
·56 lines (47 loc) · 1.49 KB
/
ExtractAPK.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
47
48
49
50
51
52
53
54
55
56
#-- coding:utf-8 --
import os
import re
import logging
logging.basicConfig(level=logging.DEBUG,
format='%(asctime)s %(filename)s[line:%(lineno)d] %(levelname)s %(message)s',
datefmt='%a, %d %b %Y %H:%M:%S',
filename='./log/extractAPK_log.log',
filemode='w')
# 反编译APK
def extractapk(filepath,file,savepath):
try:
cmd = "jadx-1/bin/jadx -d " + savepath + "/" + file + "_res " + filepath + "/" + file
#cmd = "jadx -d "+ savepath + "/" + file + "_res " + filepath + "/" + file
print(cmd)
os.system(cmd)
except Exception as e:
print('some error occurred in ExtractAPK.extractapk: ', e)
logging.info('some error occurred in ExtractAPK.extractapk: ', e)
pass
# 获取APK列表
def getapks(filepath):
return os.listdir(filepath)
def checkresult(file,savepath):
try:
if (os.path.exists(savepath + "/" + file+"_res")):
print(file+"--> already done!")
return True
else:
return False
except Exception as e:
print('some error occurred in ExtractAPK.checkresult: ', e)
logging.info('some error occurred in ExtractAPK.checkresult: ', e)
pass
def doextract(filepath,savepath):
try:
apks = getapks(filepath)
for file in apks:
if checkresult(file,savepath):
continue
else:
extractapk(filepath,file,savepath)
print(file+"--> done!")
except Exception as e:
print('some error occurred in ExtractAPK.doextract: ', e)
logging.info('some error occurred in ExtractAPK.doextract: ', e)
pass