Caner 8 months ago
parent
commit
966b38377f
1 changed files with 19 additions and 20 deletions
  1. 19 20
      main.py

+ 19 - 20
main.py

@@ -10,30 +10,29 @@ from pymobiledevice3.remote.remote_service_discovery import RemoteServiceDiscove
 import threading
 
 BUNDLE_ID = 'com.laiwang.DingTalk'
-PCPWD = 'd123456'
+# >ios17 pymobiledevice3 lockdown start-tunnel
+# <ios17:
+COMMAND = 'pymobiledevice3 remote start-tunnel' 
 
 async def main():
     try:
-        # 初始化管道服务
-        remoteService = RemoteService(RemoteServiceDiscoveryService(('127.0.0.1',7777)),'test')
-        await remoteService.connect()
         # 使用命令方式启动管道
-        # try:
-        #     # 使用 -S 参数让 sudo 从 stdin 读取密码
-        #     result = subprocess.run(
-        #         ["sudo", "-S"] + PCPWD.split(),
-        #         input="d123456\n",  # 实际应用中应从安全来源获取
-        #         text=True,
-        #         capture_output=True,
-        #         check=True
-        #     )
-        #     print("命令执行成功!")
-        #     print("输出:", result.stdout)
-        # except subprocess.CalledProcessError as e:
-        #     print(f"命令执行失败 (退出码: {e.returncode}):")
-        #     print("错误输出:", e.stderr)
-        # sleep(3)
-        # # 连接手机
+        try:
+            # 使用 -S 参数让 sudo 从 stdin 读取密码
+            result = subprocess.run(
+                ["sudo", "-S"] + COMMAND.split(),
+                input="d123456\n",
+                text=True,
+                capture_output=True,
+                check=True
+            )
+            print("命令执行成功!")
+            print("输出:", result.stdout)
+        except subprocess.CalledProcessError as e:
+            print(f"命令执行失败 (退出码: {e.returncode}):")
+            print("错误输出:", e.stderr)
+        sleep(3)
+        # 连接手机
         # lockdown = create_using_usbmux()
         # print("开发者模式",lockdown.developer_mode_status)
         # # 获取钉钉-app