letaken-olam commited on
Commit
31b2dae
·
verified ·
1 Parent(s): 1ede37d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +44 -13
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
- if "WebView" in ins.get_output() or "WebView" in ins.get_name():
17
- return "⚠️ האפליקציה כוללת שימוש ב־WebView (בקוד)"
 
 
 
 
 
 
 
18
  except Exception:
19
- continue # מתודות חיצוניות, בלי קוד וכו'
20
 
21
- # בדיקת הרשאות
 
22
  try:
23
- perms = a.get_permissions()
24
- if "android.permission.INTERNET" in perms:
25
- return "⚠️ האפליקציה דורשת גישת אינטרנט – ייתכן שיש WebView"
26
- except Exception:
 
27
  pass
28
 
29
- return "✅ לא נמצא שימוש ב־WebView"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
30
  except Exception as e:
31
- return f"שגיאה כללית בניתוח הקובץ: {str(e)}"
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="בודק שימוש ב־WebView באפליקציית APK",
38
- description="בודק אם האפליקציה כוללת שימוש פנימי ברכיב WebView, שעשוי לאפשר גלישה לא מסוננת.",
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()