Skip to content

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.

@yooo1999
Copy link

yooo1999 commented Sep 7, 2025

@gaasedelen Please merge that , there is no id in module
https://frida.re/docs/javascript-api/#module

@yooo1999
Copy link

yooo1999 commented Sep 8, 2025

@datalocaltmp Even In 16.1.12 I don't see id in Module class

removed function make_maps
@datalocaltmp
Copy link

@datalocaltmp Even In 16.1.12 I don't see id in Module class

The module class in Frida does not have an id - you're correct - if you read the original frida-drcov.py you'll see that it is added in.

@algoatson I'm slightly worried that the extensive changes brough in with Frida 17 may have broken more of this; I'll have a look this evening and report back. Wondering if we should perhaps move this coverage gathering tool out into it's own repo as this portion of Lighthouse seems to be unmaintained at this point.

Process.enumerateModulesSync was dropped from frida 17, change to Process.enumerateModulesSync which seems to work fine.
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.

3 participants