mirror of
https://github.com/zhaarey/AppleMusicDecrypt.git
synced 2025-10-23 15:11:06 +00:00
fix: adapt Android Emulator
This commit is contained in:
18
src/adb.py
18
src/adb.py
@@ -44,12 +44,18 @@ class Device:
|
|||||||
raise ADBConnectException
|
raise ADBConnectException
|
||||||
self.device = self.client.device(f"{host}:{port}")
|
self.device = self.client.device(f"{host}:{port}")
|
||||||
|
|
||||||
def _execute_command(self, cmd: str, su: bool = False) -> Optional[str]:
|
def _execute_command(self, cmd: str, su: bool = False, sh: bool = False) -> Optional[str]:
|
||||||
if su:
|
whoami = self.device.shell("whoami")
|
||||||
cmd = cmd.replace("\"", "\\\"")
|
final_cmd = cmd
|
||||||
output = self.device.shell(f"{self.suMethod} \"{cmd}\"")
|
if whoami.strip() != "root" and su:
|
||||||
else:
|
if self.suMethod == "su -c":
|
||||||
output = self.device.shell(cmd, timeout=30)
|
replaced_cmd = cmd.replace("\"", "\\\"")
|
||||||
|
final_cmd = f"{self.suMethod} \"{replaced_cmd}\""
|
||||||
|
else:
|
||||||
|
final_cmd = f"{self.suMethod} {final_cmd}"
|
||||||
|
if sh:
|
||||||
|
final_cmd = f"sh -c '{final_cmd}'"
|
||||||
|
output = self.device.shell(final_cmd, timeout=30)
|
||||||
if not output:
|
if not output:
|
||||||
return ""
|
return ""
|
||||||
return output
|
return output
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ class NewInteractiveShell:
|
|||||||
logger.add(lambda msg: print_formatted_text(ANSI(msg), end=""), colorize=True, level="INFO")
|
logger.add(lambda msg: print_formatted_text(ANSI(msg), end=""), colorize=True, level="INFO")
|
||||||
|
|
||||||
for device_info in self.config.devices:
|
for device_info in self.config.devices:
|
||||||
device = Device(frida_path=device_info.fridaPath)
|
device = Device(frida_path=device_info.fridaPath, su_method=device_info.suMethod)
|
||||||
device.connect(device_info.host, device_info.port)
|
device.connect(device_info.host, device_info.port)
|
||||||
logger.info(f"Device {device_info.host}:{device_info.port} has connected")
|
logger.info(f"Device {device_info.host}:{device_info.port} has connected")
|
||||||
self.devices.append(device)
|
self.devices.append(device)
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ class Device(BaseModel):
|
|||||||
port: int
|
port: int
|
||||||
agentPort: int
|
agentPort: int
|
||||||
fridaPath: str
|
fridaPath: str
|
||||||
|
suMethod: str
|
||||||
|
|
||||||
|
|
||||||
class Download(BaseModel):
|
class Download(BaseModel):
|
||||||
|
|||||||
Reference in New Issue
Block a user