sensepost / objection

📱 objection - runtime mobile exploration
GNU General Public License v3.0
7.22k stars 829 forks source link

[bug] getting device not found error. In wireless termux. #558

Closed Anonymous2716 closed 1 year ago

Anonymous2716 commented 2 years ago

Describe the bug In termux with local adb connection. I patched the apk installed it ran it and then if I try to explore or just objection -h 127.0.0.1 -p 27042 device-type I get the error below :


objection -h 127.0.0.1 -p 27042 device-type
Traceback (most recent call last):
  File "/data/data/com.termux/files/usr/bin/objection", line 8, in <module>
    sys.exit(cli())
  File "/data/data/com.termux/files/usr/lib/python3.10/site-packages/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "/data/data/com.termux/files/usr/lib/python3.10/site-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "/data/data/com.termux/files/usr/lib/python3.10/site-packages/click/core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/data/data/com.termux/files/usr/lib/python3.10/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/data/data/com.termux/files/usr/lib/python3.10/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "/data/data/com.termux/files/usr/lib/python3.10/site-packages/objection/console/cli.py", line 265, in device_type
    agent.inject()
  File "/data/data/com.termux/files/usr/lib/python3.10/site-packages/objection/utils/agent.py", line 202, in inject
    session = self.get_session()
  File "/data/data/com.termux/files/usr/lib/python3.10/site-packages/objection/utils/agent.py", line 145, in get_session
    self.device = self._get_device()
  File "/data/data/com.termux/files/usr/lib/python3.10/site-packages/objection/utils/agent.py", line 123, in _get_device
    device = frida.get_usb_device(5)
  File "/data/data/com.termux/files/usr/lib/python3.10/site-packages/frida/__init__.py", line 89, in get_usb_device
    return get_device_matching(lambda d: d.type == 'usb', timeout, **kwargs)
  File "/data/data/com.termux/files/usr/lib/python3.10/site-packages/frida/__init__.py", line 97, in get_device_matching
    return get_device_manager().get_device_matching(predicate, timeout, **kwargs)
  File "/data/data/com.termux/files/usr/lib/python3.10/site-packages/frida/core.py", line 26, in wrapper
    return f(*args, **kwargs)
  File "/data/data/com.termux/files/usr/lib/python3.10/site-packages/frida/core.py", line 58, in get_device_matching
    return Device(self._impl.get_device_matching(lambda d: predicate(Device(d)), raw_timeout))
frida.InvalidArgumentError: device not found ```

`netstat -anl` shows port 27042 is open . frida-ps can see Name gadget is running .

**To Reproduce**
Steps to reproduce the behavior:
1. Run command '...' Any command that tries to connect to device.

**Similar issues**
Please link the issues in this repository that is similar to yours.

For example: #358, #229 etc. 

Not aware right now . I saw a few related to this in fridas repo . I will update if I get any.

**Expected behavior**

Work normally as expected. It patched the apk by detecting connected wireless android device (localhost) 

**Evidence / Logs / Screenshot**

```objection --debug explore
[debug] Agent path is: /data/data/com.termux/files/usr/lib/python3.10/site-packages/objection/agent.js
[debug] Injecting agent...
Traceback (most recent call last):
  File "/data/data/com.termux/files/usr/bin/objection", line 8, in <module>
    sys.exit(cli())
  File "/data/data/com.termux/files/usr/lib/python3.10/site-packages/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "/data/data/com.termux/files/usr/lib/python3.10/site-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "/data/data/com.termux/files/usr/lib/python3.10/site-packages/click/core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/data/data/com.termux/files/usr/lib/python3.10/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/data/data/com.termux/files/usr/lib/python3.10/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "/data/data/com.termux/files/usr/lib/python3.10/site-packages/objection/console/cli.py", line 114, in explore
    agent.inject()
  File "/data/data/com.termux/files/usr/lib/python3.10/site-packages/objection/utils/agent.py", line 202, in inject
    session = self.get_session()
  File "/data/data/com.termux/files/usr/lib/python3.10/site-packages/objection/utils/agent.py", line 145, in get_session
    self.device = self._get_device()
  File "/data/data/com.termux/files/usr/lib/python3.10/site-packages/objection/utils/agent.py", line 123, in _get_device
    device = frida.get_usb_device(5)
  File "/data/data/com.termux/files/usr/lib/python3.10/site-packages/frida/__init__.py", line 89, in get_usb_device
    return get_device_matching(lambda d: d.type == 'usb', timeout, **kwargs)
  File "/data/data/com.termux/files/usr/lib/python3.10/site-packages/frida/__init__.py", line 97, in get_device_matching
    return get_device_manager().get_device_matching(predicate, timeout, **kwargs)
  File "/data/data/com.termux/files/usr/lib/python3.10/site-packages/frida/core.py", line 26, in wrapper
    return f(*args, **kwargs)
  File "/data/data/com.termux/files/usr/lib/python3.10/site-packages/frida/core.py", line 58, in get_device_matching
    return Device(self._impl.get_device_matching(lambda d: predicate(Device(d)), raw_timeout))
frida.InvalidArgumentError: device not found ```

**Environment :**
 - Device: Android arm-v8a 
 - OS: Android 9
 - Frida Version: 15.1.28
- Objection Version : objection: 1.11.0

**Application**

I will try later on. Let me patch few more apks and see if its the same issue.

**Additional context**
Nothing right now.
WeakestHunter43 commented 1 year ago

don't use adb in battery management all that app run in background or lock it open the app that u patched when it stuck show black or white screen open termux use this command objection -N explore

Anonymous2716 commented 1 year ago

@WeakestHunter43 that worked. But whats the reason for adb not working?