File size: 2,029 Bytes
10e0ae2
124a21a
10e0ae2
3ad16bc
124a21a
 
 
 
 
c32b3d5
124a21a
ac964df
 
1d65809
32eb707
ac964df
 
3ad16bc
1d65809
124a21a
3ad16bc
 
 
1d65809
124a21a
3ad16bc
124a21a
1d65809
124a21a
3ad16bc
124a21a
1d65809
124a21a
3ad16bc
124a21a
1d65809
124a21a
3ad16bc
124a21a
1d65809
124a21a
3ad16bc
124a21a
 
 
 
 
 
 
 
c32b3d5
ac964df
124a21a
 
10e0ae2
124a21a
 
 
 
 
10e0ae2
 
124a21a
32eb707
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
import gradio as gr
import tempfile
import os
from androguard.misc import AnalyzeAPK

def extract_apk_info(apk_file):
    if apk_file is None:
        return "No file uploaded. Please upload an APK file."
    
    temp_apk_path = None
    try:
        # Create a temporary file
        with tempfile.NamedTemporaryFile(delete=False, suffix=".apk") as temp_apk:
            # Write the content directly as binary data
            temp_apk.write(apk_file)  # Write the uploaded file content as bytes
            temp_apk_path = temp_apk.name

        a, d, dx = AnalyzeAPK(temp_apk_path)

        output = []
        output.append(f"Package: {a.get_package()}")
        output.append(f"Version: {a.get_androidversion_name()}")
        output.append(f"Main Activity: {a.get_main_activity()}")

        output.append("\nPermissions:")
        for permission in a.get_permissions():
            output.append(f"- {permission}")

        output.append("\nActivities:")
        for activity in a.get_activities():
            output.append(f"- {activity}")

        output.append("\nServices:")
        for service in a.get_services():
            output.append(f"- {service}")

        output.append("\nReceivers:")
        for receiver in a.get_receivers():
            output.append(f"- {receiver}")

        output.append("\nProviders:")
        for provider in a.get_providers():
            output.append(f"- {provider}")

        return "\n".join(output)

    except Exception as e:
        return f"Error analyzing APK: {str(e)}"
    finally:
        # Clean up the temporary file
        if temp_apk_path and os.path.exists(temp_apk_path):
            os.unlink(temp_apk_path)

# Create Gradio interface
iface = gr.Interface(
    fn=extract_apk_info,
    inputs=gr.File(label="Upload APK File", file_types=['.apk']),
    outputs=gr.Textbox(label="Extracted APK Information", lines=25),
    title="APK Extractor",
    description="Upload an APK file to extract and view its components."
)

# Launch the interface
iface.launch()