Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -5,7 +5,12 @@ def check_apk_for_webview(apk_file):
|
|
| 5 |
try:
|
| 6 |
a, d, dx = AnalyzeAPK(apk_file.name)
|
| 7 |
|
| 8 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
for method_analysis in dx.get_methods():
|
| 10 |
try:
|
| 11 |
method = method_analysis.get_method()
|
|
@@ -13,29 +18,55 @@ def check_apk_for_webview(apk_file):
|
|
| 13 |
if code:
|
| 14 |
bc = code.get_bc()
|
| 15 |
for ins in bc.get_instructions():
|
| 16 |
-
|
| 17 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
except Exception:
|
| 19 |
-
continue
|
| 20 |
|
| 21 |
-
#
|
|
|
|
| 22 |
try:
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
|
|
|
| 27 |
pass
|
| 28 |
|
| 29 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 30 |
except Exception as e:
|
| 31 |
-
return f"שגיאה
|
| 32 |
|
| 33 |
iface = gr.Interface(
|
| 34 |
fn=check_apk_for_webview,
|
| 35 |
inputs=gr.File(label="בחר קובץ APK", file_types=[".apk"]),
|
| 36 |
outputs="text",
|
| 37 |
-
title="
|
| 38 |
-
description="בודק אם
|
| 39 |
)
|
| 40 |
|
| 41 |
iface.launch()
|
|
|
|
| 5 |
try:
|
| 6 |
a, d, dx = AnalyzeAPK(apk_file.name)
|
| 7 |
|
| 8 |
+
found_webview = False
|
| 9 |
+
found_client = False
|
| 10 |
+
found_urls = []
|
| 11 |
+
method_hits = []
|
| 12 |
+
|
| 13 |
+
# חיפוש בקוד דקס
|
| 14 |
for method_analysis in dx.get_methods():
|
| 15 |
try:
|
| 16 |
method = method_analysis.get_method()
|
|
|
|
| 18 |
if code:
|
| 19 |
bc = code.get_bc()
|
| 20 |
for ins in bc.get_instructions():
|
| 21 |
+
output = ins.get_output()
|
| 22 |
+
if any(x in output for x in ["WebView", "WebViewClient", "WebChromeClient"]):
|
| 23 |
+
method_hits.append(f"{ins.get_name()} - {output}")
|
| 24 |
+
if "WebViewClient" in output or "WebChromeClient" in output:
|
| 25 |
+
found_client = True
|
| 26 |
+
if "WebView" in output:
|
| 27 |
+
found_webview = True
|
| 28 |
+
if "loadUrl" in output or "http" in output:
|
| 29 |
+
found_urls.append(output)
|
| 30 |
except Exception:
|
| 31 |
+
continue
|
| 32 |
|
| 33 |
+
# ניתוח AndroidManifest.xml
|
| 34 |
+
manifest_info = ""
|
| 35 |
try:
|
| 36 |
+
activities = a.get_activities()
|
| 37 |
+
for act in activities:
|
| 38 |
+
if "webview" in act.lower():
|
| 39 |
+
manifest_info += f"יתכן Activity עם WebView: {act}\n"
|
| 40 |
+
except:
|
| 41 |
pass
|
| 42 |
|
| 43 |
+
result = ""
|
| 44 |
+
|
| 45 |
+
if found_webview:
|
| 46 |
+
result += "⚠️ נמצא שימוש ב־WebView בקוד:\n" + "\n".join(method_hits[:5]) + "\n\n"
|
| 47 |
+
else:
|
| 48 |
+
result += "✅ לא נמצא שימוש ודאי ב־WebView בקוד.\n"
|
| 49 |
+
|
| 50 |
+
if found_client:
|
| 51 |
+
result += "📌 נמצא שימוש ב־WebViewClient או WebChromeClient\n"
|
| 52 |
+
|
| 53 |
+
if found_urls:
|
| 54 |
+
result += f"🌐 קריאות ל־URL בקוד: {len(found_urls)} (למשל: {found_urls[0][:80]})\n"
|
| 55 |
+
|
| 56 |
+
if manifest_info:
|
| 57 |
+
result += f"📄 מתוך ה־Manifest:\n{manifest_info}"
|
| 58 |
+
|
| 59 |
+
return result.strip()
|
| 60 |
+
|
| 61 |
except Exception as e:
|
| 62 |
+
return f"שגיאה בניתוח הקובץ: {str(e)}"
|
| 63 |
|
| 64 |
iface = gr.Interface(
|
| 65 |
fn=check_apk_for_webview,
|
| 66 |
inputs=gr.File(label="בחר קובץ APK", file_types=[".apk"]),
|
| 67 |
outputs="text",
|
| 68 |
+
title="סריקה מתקדמת ל־WebView באפליקציית APK",
|
| 69 |
+
description="בודק אם יש שימוש ודאי ב־WebView, WebViewClient, או טעינת URL מתוך הקוד וה־Manifest.",
|
| 70 |
)
|
| 71 |
|
| 72 |
iface.launch()
|