Skip to content

Update frida-drcov.py #152

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

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open

Conversation

algoatson
Copy link

@algoatson algoatson commented Mar 1, 2025

frida-drcov.py modules fix - invalid index and end fields for modules.

frida-drcov.py modules fix
@datalocaltmp
Copy link

Is there an issue that this is addressing? The original method seems to work for myself without fail

@algoatson
Copy link
Author

algoatson commented Mar 17, 2025

For me the resulting maps does not contains the proper values and cause it to fail, I think the alternative I'm suggesting is better overall.

The preceding code fails to add the fields to the map:

    // We need to add the module id
    maps.map(function(o) { o.id = i++; });
    // .. and the module end point
    maps.map(function(o) { o.end = o.base.add(o.size); });

It would make sense to move this logic outside of the javascript code for frida.

I am on NixOS 24.11.714925.f44bd8ca21e0 (Vicuna) and running the default frida-drcov.py with a process of choice results in the following error, and this on any process.

> sudo python3 frida-drcov.py 883810

[*] Attaching to pid '883810' on device 'local'...
[+] Attached. Loading script...
Traceback (most recent call last):
  File "/tmp/myenv/lib/python3.11/site-packages/frida/core.py", line 562, in _on_message
    callback(message, data)
  File "/home/notrazor/.binaryninja/repositories/community/plugins/gaasedelen_lighthouse/coverage/frida/frida-drcov.py", line 242, in on_message
    populate_modules(maps)
  File "/home/notrazor/.binaryninja/repositories/community/plugins/gaasedelen_lighthouse/coverage/frida/frida-drcov.py", line 182, in populate_modules
    idx  = image['id']
           ~~~~~^^^^^^
KeyError: 'id'
Starting to stalk threads...
Traceback (most recent call last):
  File "/home/notrazor/.binaryninja/repositories/community/plugins/gaasedelen_lighthouse/coverage/frida/frida-drcov.py", line 343, in <module>
    main()
  File "/home/notrazor/.binaryninja/repositories/community/plugins/gaasedelen_lighthouse/coverage/frida/frida-drcov.py", line 324, in main
    script.load()
  File "/tmp/myenv/lib/python3.11/site-packages/frida/core.py", line 86, in wrapper
    return f(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^
  File "/tmp/myenv/lib/python3.11/site-packages/frida/core.py", line 302, in load
    self._impl.load()
frida.TransportError: timeout was reached

@algoatson
Copy link
Author

issue in question

@datalocaltmp
Copy link

Ah I see - testing with frida-16.5.1 it works fine but once I update to Frida 16.7.1 it breaks; one of the more recent frida updates has changed something and is breaking coverage collection; I'll take a look at the pull request but in the meantime that will hopefully fix others problems.

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.

2 participants