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()