-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathbuild.py
89 lines (64 loc) · 2.36 KB
/
build.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#!/user/bin/env python3
import os
import shutil
import zipfile
PATH_BASE = os.path.abspath(os.path.dirname(__file__))
PATH_BASE_MODULE = os.path.join(PATH_BASE, "base")
PATH_BUILDS = os.path.join(PATH_BASE, "builds")
def traverse_path_to_list(file_list, path):
for dp, dn, fn in os.walk(path):
for f in fn:
if f == "placeholder" or f == ".gitkeep":
continue
file_list.append(os.path.join(dp, f))
def create_module_prop(path, frida_release):
# Create module.prop file.
module_prop = """id=magiskfurtif
name=MagiskFurtif
version=v{0}
versionCode={1}
author=Furtif
description=Runs FurtiF Tools on boot with magisk.
support=https://github.com/Furtif/magisk-furtif/issues
minMagisk=1530""".format(frida_release, frida_release.replace(".", ""))
with open(os.path.join(path, "module.prop"), "w", newline='\n') as f:
f.write(module_prop)
def create_module(frida_release):
# Create directory.
module_dir = os.path.join(PATH_BUILDS)
module_zip = os.path.join(PATH_BUILDS, "MagiskFurtif-{0}.zip".format(frida_release))
if os.path.exists(module_dir):
shutil.rmtree(module_dir)
if os.path.exists(module_zip):
os.remove(module_zip)
# Copy base module into module dir.
shutil.copytree(PATH_BASE_MODULE, module_dir)
# cd into module directory.
os.chdir(module_dir)
# Create module.prop.
create_module_prop(module_dir, frida_release)
# Create flashable zip.
print("Building Magisk module.")
file_list = ["install.sh", "module.prop"]
traverse_path_to_list(file_list, "./common")
traverse_path_to_list(file_list, "./system")
traverse_path_to_list(file_list, "./META-INF")
with zipfile.ZipFile(module_zip, "w") as zf:
for file_name in file_list:
path = os.path.join(module_dir, file_name)
if not os.path.exists(path):
print("File {0} does not exist..".format(path))
continue
zf.write(path, arcname=file_name)
def main():
# Create necessary folders.
if not os.path.exists(PATH_BUILDS):
os.makedirs(PATH_BUILDS)
# Fetch frida information.
frida_release = "1.8"
print("MagiskFurtif version is {0}.".format(frida_release))
# Create flashable modules.
create_module(frida_release)
print("Done.")
if __name__ == "__main__":
main()