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

fix(agent):check and wait for the currentApplication is ready #623

Conversation

coderiderlin
Copy link

fix a bug that Java.use("android.app.ActivityThread").currentApplication() return null in the early stage of the application startup.
just check and wait for it become ready at the frist time.
the error log as follow:

$ objection -g com.tencent.mobileqq explore
Using USB device `IN2020`
Agent injected and responds ok!
Traceback (most recent call last):
  File "C:\Python311\Scripts\objection-script.py", line 33, in <module>
    sys.exit(load_entry_point('objection==1.11.0', 'console_scripts', 'objection')())
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Python311\Lib\site-packages\click\core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Python311\Lib\site-packages\click\core.py", line 1055, in main
    rv = self.invoke(ctx)
         ^^^^^^^^^^^^^^^^
  File "C:\Python311\Lib\site-packages\click\core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Python311\Lib\site-packages\click\core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Python311\Lib\site-packages\click\core.py", line 760, in invoke
    return __callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Python311\Lib\site-packages\objection\console\cli.py", line 156, in explore
    device_info = get_device_info()
                  ^^^^^^^^^^^^^^^^^
  File "C:\Python311\Lib\site-packages\objection\commands\device.py", line 41, in get_device_info
    package_info = api.env_android()
                   ^^^^^^^^^^^^^^^^^
  File "C:\Python311\Lib\site-packages\frida\core.py", line 179, in method
    return script._rpc_request("call", js_name, args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Python311\Lib\site-packages\frida\core.py", line 86, in wrapper
    return f(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^
  File "C:\Python311\Lib\site-packages\frida\core.py", line 491, in _rpc_request
    raise result.error
frida.core.RPCException: TypeError: cannot read property 'getApplicationContext' of null
    at getApplicationContext (/script1.js:18857)
    at <anonymous> (/script1.js:19469)
    at <anonymous> (/script1.js:18835)
    at <anonymous> (frida/node_modules/frida-java-bridge/lib/vm.js:12)
    at _performPendingVmOps (frida/node_modules/frida-java-bridge/index.js:250)
    at <anonymous> (frida/node_modules/frida-java-bridge/index.js:242)
    at apply (native)
    at ne (frida/node_modules/frida-java-bridge/lib/class-factory.js:673)
    at <anonymous> (frida/node_modules/frida-java-bridge/lib/class-factory.js:651)
Asking jobs to stop...
Unloading objection agent...

@leonjza
Copy link
Member

leonjza commented May 23, 2024

Thanks for the PR! I'm not going to pull this one in. After 865fb7d there is quite a bit of work going into refactoring some of the spawning logic, removing dependencies that would cause issues like this.

Appreciate you taking the time to contribute!

@leonjza leonjza closed this May 23, 2024
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

Successfully merging this pull request may close these issues.

None yet

2 participants