Hosdroid commited on
Commit
b63c99b
·
verified ·
1 Parent(s): 54d7780

Delete app.py

Browse files
Files changed (1) hide show
  1. app.py +0 -64
app.py DELETED
@@ -1,64 +0,0 @@
1
- import gradio as gr
2
- import subprocess
3
- import os
4
- import shutil
5
- import re
6
-
7
- def fix_apk(apk_file):
8
- if apk_file is None:
9
- return "لطفاً یک فایل انتخاب کنید.", None
10
-
11
- apk_path = apk_file.name
12
- output_dir = "extracted_apk"
13
-
14
- # پاکسازی فایل‌های قدیمی
15
- if os.path.exists(output_dir):
16
- shutil.rmtree(output_dir)
17
- if os.path.exists("fixed.apk"):
18
- os.remove("fixed.apk")
19
- if os.path.exists("final_signed_game.apk"):
20
- os.remove("final_signed_game.apk")
21
-
22
- try:
23
- # مرحله ۱: باز کردن فایل
24
- subprocess.run(["apktool", "d", apk_path, "-o", output_dir, "-f"], check=True)
25
-
26
- # مرحله ۲: ویرایش کدهای اندروید ۱۴ و ۱۵
27
- manifest_path = os.path.join(output_dir, "AndroidManifest.xml")
28
- with open(manifest_path, "r", encoding="utf-8") as f:
29
- manifest = f.read()
30
-
31
- manifest = re.sub(r'targetSdkVersion="[0-9]+"', 'targetSdkVersion="34"', manifest)
32
- manifest = manifest.replace('<activity ', '<activity android:exported="true" ')
33
-
34
- with open(manifest_path, "w", encoding="utf-8") as f:
35
- f.write(manifest)
36
-
37
- # مرحله ۳: بسته‌بندی مجدد
38
- subprocess.run(["apktool", "b", output_dir, "-o", "fixed.apk"], check=True)
39
-
40
- # مرحله ۴: ساخت کلید امنیتی (در صورت نیاز)
41
- if not os.path.exists("mykey.keystore"):
42
- subprocess.run(["keytool", "-genkey", "-v", "-keystore", "mykey.keystore", "-alias", "myalias", "-keyalg", "RSA", "-keysize", "2048", "-validity", "10000", "-storepass", "123456", "-keypass", "123456", "-dname", "CN=Android,O=Android,C=US"], check=True)
43
-
44
- # مرحله ۵: امضای نهایی
45
- subprocess.run(["apksigner", "sign", "--ks", "mykey.keystore", "--ks-pass", "pass:123456", "--out", "final_signed_game.apk", "fixed.apk"], check=True)
46
-
47
- return "جراحی با موفقیت انجام شد! حالا می‌توانید بازی را نصب کنید.", "final_signed_game.apk"
48
-
49
- except Exception as e:
50
- return f"خطا در پردازش: {str(e)}", None
51
-
52
- # ظاهر برنامه
53
- iface = gr.Interface(
54
- fn=fix_apk,
55
- inputs=gr.File(label="فایل APK قدیمی بازی را اینجا آپلود کنید"),
56
- outputs=[
57
- gr.Textbox(label="وضعیت عملیات"),
58
- gr.File(label="دانلود فایل نهایی و سالم")
59
- ],
60
- title="اتاق عمل بازی 🛠️",
61
- description="فایل بازی خود را آپلود کنید تا کدهای آن برای اجرا روی دستگاه‌های جدید بازسازی شود."
62
- )
63
-
64
- iface.launch()