Spaces:
Running
Running
vrkforever
commited on
Commit
•
124a21a
1
Parent(s):
75e78a1
Update app.py
Browse files
app.py
CHANGED
@@ -1,66 +1,61 @@
|
|
1 |
import gradio as gr
|
2 |
-
import
|
3 |
import os
|
4 |
-
from androguard.
|
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 |
-
return f"Analysis result for {apk_data['package_name']}: {result}"
|
53 |
-
|
54 |
-
def run_analysis(file):
|
55 |
-
analyzer = SimplifiedAPKAnalyzer("apk_malware.model")
|
56 |
-
return analyzer.analyze_apk(file)
|
57 |
-
|
58 |
iface = gr.Interface(
|
59 |
-
fn=
|
60 |
-
inputs=gr.File(label="Upload APK
|
61 |
-
outputs="
|
62 |
-
title="APK
|
63 |
-
description="Upload an
|
64 |
)
|
65 |
|
|
|
66 |
iface.launch()
|
|
|
1 |
import gradio as gr
|
2 |
+
import tempfile
|
3 |
import os
|
4 |
+
from androguard.core.bytecodes.apk import APK
|
5 |
+
|
6 |
+
def extract_apk_info(apk_file):
|
7 |
+
if apk_file is None:
|
8 |
+
return "No file uploaded. Please upload an APK file."
|
9 |
+
|
10 |
+
# Create a temporary file to store the uploaded APK
|
11 |
+
with tempfile.NamedTemporaryFile(delete=False, suffix=".apk") as temp_apk:
|
12 |
+
temp_apk.write(apk_file.read())
|
13 |
+
temp_apk_path = temp_apk.name
|
14 |
+
|
15 |
+
try:
|
16 |
+
apk = APK(temp_apk_path)
|
17 |
+
|
18 |
+
output = []
|
19 |
+
output.append(f"Package: {apk.get_package()}")
|
20 |
+
output.append(f"Version: {apk.get_androidversion_name()}")
|
21 |
+
output.append(f"Main Activity: {apk.get_main_activity()}")
|
22 |
+
|
23 |
+
output.append("\nPermissions:")
|
24 |
+
for permission in apk.get_permissions():
|
25 |
+
output.append(f"- {permission}")
|
26 |
+
|
27 |
+
output.append("\nActivities:")
|
28 |
+
for activity in apk.get_activities():
|
29 |
+
output.append(f"- {activity}")
|
30 |
+
|
31 |
+
output.append("\nServices:")
|
32 |
+
for service in apk.get_services():
|
33 |
+
output.append(f"- {service}")
|
34 |
+
|
35 |
+
output.append("\nReceivers:")
|
36 |
+
for receiver in apk.get_receivers():
|
37 |
+
output.append(f"- {receiver}")
|
38 |
+
|
39 |
+
output.append("\nProviders:")
|
40 |
+
for provider in apk.get_providers():
|
41 |
+
output.append(f"- {provider}")
|
42 |
+
|
43 |
+
return "\n".join(output)
|
44 |
+
|
45 |
+
except Exception as e:
|
46 |
+
return f"Error analyzing APK: {str(e)}"
|
47 |
+
finally:
|
48 |
+
# Clean up the temporary file
|
49 |
+
os.unlink(temp_apk_path)
|
50 |
+
|
51 |
+
# Create Gradio interface
|
|
|
|
|
|
|
|
|
|
|
|
|
52 |
iface = gr.Interface(
|
53 |
+
fn=extract_apk_info,
|
54 |
+
inputs=gr.File(label="Upload APK File", file_types=['.apk']),
|
55 |
+
outputs=gr.Textbox(label="Extracted APK Information", lines=25),
|
56 |
+
title="APK Extractor",
|
57 |
+
description="Upload an APK file to extract and view its components."
|
58 |
)
|
59 |
|
60 |
+
# Launch the interface
|
61 |
iface.launch()
|