Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

frida.get_usb_device() can not works at first time. #174

Open
yxyhack opened this issue Oct 22, 2020 · 1 comment
Open

frida.get_usb_device() can not works at first time. #174

yxyhack opened this issue Oct 22, 2020 · 1 comment

Comments

@yxyhack
Copy link

yxyhack commented Oct 22, 2020

Please check the error logs as follow: (frida --version 14.0.0)

Python 3.9.0 (tags/v3.9.0:9cf6752, Oct  5 2020, 15:34:40) [MSC v.1927 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import frida
>>> frida.get_usb_device()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\Bytedance\AppData\Local\Programs\Python\Python39\lib\site-packages\frida\__init__.py", line 82, in get_usb_device
    return get_device_matching(lambda d: d.type == 'usb', timeout, **kwargs)
  File "C:\Users\Bytedance\AppData\Local\Programs\Python\Python39\lib\site-packages\frida\__init__.py", line 90, in get_device_matching
    return get_device_manager().get_device_matching(predicate, timeout, **kwargs)
  File "C:\Users\Bytedance\AppData\Local\Programs\Python\Python39\lib\site-packages\frida\core.py", line 26, in wrapper
    return f(*args, **kwargs)
  File "C:\Users\Bytedance\AppData\Local\Programs\Python\Python39\lib\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
>>> frida.get_usb_device()
Device(id="89EX0A89A", name="Pixel 3", type='usb')

As you saw it, went I call frida.get_usb_device() first time it will get an error. But if you try to call it second time, it's OK!
So I try to solve this problem as follow and it works:

try:
	device = frida.get_usb_device()
except BaseException: 
	time.sleep(3)
	device = frida.get_usb_device()
@stevenking888
Copy link

Work like charm.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants