-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathmain.py
More file actions
160 lines (138 loc) · 3.83 KB
/
main.py
File metadata and controls
160 lines (138 loc) · 3.83 KB
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
"""
APK FRAMEWORK DETECTOR
Author : Daniel Agyapong
Contributor: Swarup Saha
Date : 2024-12-19
"""
import sys
import zipfile
import os
class FrameWork:
FLUTTER = "Flutter"
REACT_NATIVE = "React Native"
CORDOVA = "Cordova"
XAMARIN = "Xamarin"
NATIVE = "Native (Java/Kotlin)"
UNITY = "Unity"
UNREAL = "Unreal Engine"
LIBGDX = "LibGDX"
EXPO = "Expo"
KONY = "Kony Visualizer"
class Technology:
def __init__(self, framework, directories):
self.framework = framework
self.directories = directories
tech_list = [
Technology(
framework=FrameWork.FLUTTER,
directories=[
"libflutter.so"
]
),
Technology(
framework=FrameWork.REACT_NATIVE,
directories=[
"libreactnativejni.so",
"assets/index.android.bundle",
]
),
Technology(
framework=FrameWork.CORDOVA,
directories=[
"assets/www/index.html",
"assets/www/cordova.js",
"assets/www/cordova_plugins.js"
]
),
Technology(
framework=FrameWork.XAMARIN,
directories=[
"assemblies/Sikur.Monodroid.dll",
"assemblies/Sikur.dll",
"assemblies/Xamarin.Mobile.dll",
"assemblies/mscorlib.dll",
"libmonodroid.so",
"libmonosgen-2.0.so",
]
),
Technology(
framework=FrameWork.UNITY,
directories=[
"libunity.so",
"assets/bin/Data/Managed/UnityEngine.dll",
"assets/bin/Data/Managed/UnityEditor.dll"
]
),
Technology(
framework=FrameWork.UNREAL,
directories=[
"libUE4.so",
"assets/Unreal/UE4Game/Manifest.xml"
]
),
Technology(
framework=FrameWork.LIBGDX,
directories=[
"libgdx.so",
"assets/libgdx/lwjgl.so",
"assets/libgdx.jar"
]
),
Technology(
framework=FrameWork.EXPO,
directories=[
"assets/shell-app.bundle",
"assets/expo-manifest.json"
]
),
Technology(
framework=FrameWork.KONY,
directories=[
"assets/kony.js",
"assets/konyframework.js",
"assets/KonyApps/config.json"
]
),
]
input_path = 'input/'
def detect_frameworks(app_path):
"""Return a list of detected frameworks for the given APK path."""
detected_frameworks = []
with zipfile.ZipFile(app_path, 'r') as zip_object:
file_names = zip_object.namelist()
for tech in tech_list:
if any(
any(directory in file_name for file_name in file_names)
for directory in tech.directories
):
detected_frameworks.append(tech.framework)
if not detected_frameworks:
detected_frameworks.append(FrameWork.NATIVE)
return detected_frameworks
def main():
app_name = get_app_name()
try:
detected_frameworks = detect_frameworks(app_name)
except FileNotFoundError:
print(f"File {app_name} not found.")
return
except zipfile.BadZipFile:
print(f"{app_name} is not a valid APK or zip file.")
return
print_detection_results(detected_frameworks)
def get_app_name():
args = sys.argv
if len(args) > 1:
return os.path.join(input_path, args[1])
else:
print("Please provide an app name as an argument.\nEg: python main.py app_name.apk")
sys.exit(1)
def print_detection_results(detected_frameworks):
if len(detected_frameworks) == 1:
print(f"App was written in {detected_frameworks[0]}")
else:
print("App uses multiple frameworks:")
for framework in detected_frameworks:
print(f"- {framework}")
if __name__ == "__main__":
main()