From abd14e074f4591503c12431b403d46755875b3c1 Mon Sep 17 00:00:00 2001 From: Nineteen93 <107993263+Nineteen93@users.noreply.github.com> Date: Mon, 22 Jul 2024 21:23:57 +0200 Subject: [PATCH] Update core.py some changes in enumerate_processes function so that the processes can be listed on the old Android verions --- keydive/core.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/keydive/core.py b/keydive/core.py index 6cfaf50..9e5594b 100644 --- a/keydive/core.py +++ b/keydive/core.py @@ -151,12 +151,11 @@ class Core: # https://github.com/frida/frida/issues/1225#issuecomment-604181822 prompt = ['adb', '-s', str(self.device.id), 'shell', 'ps'] - sp = subprocess.run([*prompt, '-A'], capture_output=True) - if sp.returncode != 0: - sp = subprocess.run(prompt, capture_output=True) - + lines = subprocess.run([*prompt, '-A'], capture_output=True).stdout.decode('utf-8').strip().splitlines() + if len(lines) <= 1: + lines = subprocess.run(prompt, capture_output=True).stdout.decode('utf-8').strip().splitlines() # Iterate through lines starting from the second line (skipping header) - for line in sp.stdout.decode('utf-8').splitlines()[1:]: + for line in lines[1:]: try: line = line.split() # USER,PID,PPID,VSZ,RSS,WCHAN,ADDR,S,NAME name = ' '.join(line[8:]).strip()