import gradio as gr from androguard.misc import AnalyzeAPK def check_apk_for_webview(apk_file): try: a, d, dx = AnalyzeAPK(apk_file.name) found_webview = False found_client = False found_urls = [] method_hits = [] # חיפוש בקוד דקס for method_analysis in dx.get_methods(): try: method = method_analysis.get_method() code = method.get_code() if code: bc = code.get_bc() for ins in bc.get_instructions(): output = ins.get_output() if any(x in output for x in ["WebView", "WebViewClient", "WebChromeClient"]): method_hits.append(f"{ins.get_name()} - {output}") if "WebViewClient" in output or "WebChromeClient" in output: found_client = True if "WebView" in output: found_webview = True if "loadUrl" in output or "http" in output: found_urls.append(output) except Exception: continue # ניתוח AndroidManifest.xml manifest_info = "" try: activities = a.get_activities() for act in activities: if "webview" in act.lower(): manifest_info += f"יתכן Activity עם WebView: {act}\n" except: pass result = "" if found_webview: result += "⚠️ נמצא שימוש ב־WebView בקוד:\n" + "\n".join(method_hits[:5]) + "\n\n" else: result += "✅ לא נמצא שימוש ודאי ב־WebView בקוד.\n" if found_client: result += "📌 נמצא שימוש ב־WebViewClient או WebChromeClient\n" if found_urls: result += f"🌐 קריאות ל־URL בקוד: {len(found_urls)} (למשל: {found_urls[0][:80]})\n" if manifest_info: result += f"📄 מתוך ה־Manifest:\n{manifest_info}" return result.strip() except Exception as e: return f"שגיאה בניתוח הקובץ: {str(e)}" iface = gr.Interface( fn=check_apk_for_webview, inputs=gr.File(label="בחר קובץ APK", file_types=[".apk"]), outputs="text", title="סריקה מתקדמת ל־WebView באפליקציית APK", description="בודק אם יש שימוש ודאי ב־WebView, WebViewClient, או טעינת URL מתוך הקוד וה־Manifest.", ) iface.launch()