Fix subprocess

This commit is contained in:
FoxRefire 2024-05-19 22:41:42 +09:00
parent f18c34c8d0
commit d386008aca
2 changed files with 3 additions and 3 deletions

View File

@ -64,7 +64,7 @@ class Cdm:
""" """
# https://source.android.com/docs/core/architecture/configuration/add-system-properties?#shell-commands # https://source.android.com/docs/core/architecture/configuration/add-system-properties?#shell-commands
properties = {} properties = {}
sp = subprocess.run(f'adb -s "{self.device.id}" shell getprop', capture_output=True) sp = subprocess.run(['adb', '-s', self.device.id, 'shell', 'getprop'], capture_output=True)
for line in sp.stdout.decode('utf-8').splitlines(): for line in sp.stdout.decode('utf-8').splitlines():
match = re.match(r'\[(.*?)\]: \[(.*?)\]', line) match = re.match(r'\[(.*?)\]: \[(.*?)\]', line)
if match: if match:
@ -137,7 +137,7 @@ class Cdm:
# https://github.com/frida/frida/issues/1225#issuecomment-604181822 # https://github.com/frida/frida/issues/1225#issuecomment-604181822
# Iterate through lines starting from the second line (skipping header) # Iterate through lines starting from the second line (skipping header)
processes = {} processes = {}
sp = subprocess.run(f'adb -s "{self.device.id}" shell ps', capture_output=True) sp = subprocess.run(['adb', '-s', self.device.id, 'shell', 'ps'], capture_output=True)
for line in sp.stdout.decode('utf-8').splitlines()[1:]: for line in sp.stdout.decode('utf-8').splitlines()[1:]:
try: try:
line = line.split() # USER,PID,PPID,VSZ,RSS,WCHAN,ADDR,S,NAME line = line.split() # USER,PID,PPID,VSZ,RSS,WCHAN,ADDR,S,NAME

View File

@ -29,7 +29,7 @@ if __name__ == '__main__':
logger.info('Version: %s', extractor.__version__) logger.info('Version: %s', extractor.__version__)
# Ensure the ADB server is running # Ensure the ADB server is running
sp = subprocess.run('adb start-server', capture_output=True) sp = subprocess.run(['adb', 'start-server'], capture_output=True)
if sp.returncode != 0: if sp.returncode != 0:
raise EnvironmentError('ADB is not recognized as an environment variable, see https://github.com/hyugogirubato/KeyDive/blob/main/docs/PACKAGE.md#adb-android-debug-bridge') raise EnvironmentError('ADB is not recognized as an environment variable, see https://github.com/hyugogirubato/KeyDive/blob/main/docs/PACKAGE.md#adb-android-debug-bridge')