File size: 1,915 Bytes
10e0ae2
124a21a
10e0ae2
124a21a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10e0ae2
124a21a
 
 
 
 
10e0ae2
 
124a21a
10e0ae2
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
import gradio as gr
import tempfile
import os
from androguard.core.bytecodes.apk import APK

def extract_apk_info(apk_file):
    if apk_file is None:
        return "No file uploaded. Please upload an APK file."
    
    # Create a temporary file to store the uploaded APK
    with tempfile.NamedTemporaryFile(delete=False, suffix=".apk") as temp_apk:
        temp_apk.write(apk_file.read())
        temp_apk_path = temp_apk.name

    try:
        apk = APK(temp_apk_path)
        
        output = []
        output.append(f"Package: {apk.get_package()}")
        output.append(f"Version: {apk.get_androidversion_name()}")
        output.append(f"Main Activity: {apk.get_main_activity()}")
        
        output.append("\nPermissions:")
        for permission in apk.get_permissions():
            output.append(f"- {permission}")
        
        output.append("\nActivities:")
        for activity in apk.get_activities():
            output.append(f"- {activity}")
        
        output.append("\nServices:")
        for service in apk.get_services():
            output.append(f"- {service}")
        
        output.append("\nReceivers:")
        for receiver in apk.get_receivers():
            output.append(f"- {receiver}")
        
        output.append("\nProviders:")
        for provider in apk.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
        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()