frida / frida-website

Frida's website
MIT License
83 stars 192 forks source link

AttributeError: 'module' object has no attribute 'attach' #6

Closed MarkSwanson closed 10 years ago

MarkSwanson commented 10 years ago

Using example.py on the website: (and frida-1.0.8)

Traceback (most recent call last): File "./frida.py", line 1, in import frida File "/home/maswanso/src/test/spidermonkey/frida.py", line 2, in p = frida.attach("cat") AttributeError: 'module' object has no attribute 'attach'

This happens with 1.0.5 and 1.0.8. Ubuntu 12 - 64-bit. Python 2.7.3

Proof I'm using 1.0.8: strings /usr/local/bin/frida-trace

!/usr/bin/python

EASY-INSTALL-ENTRY-SCRIPT: 'frida==1.0.8','console_scripts','frida-trace'

requires = 'frida==1.0.8' import sys from pkg_resources import load_entry_point if name == 'main': sys.exit( load_entry_point('frida==1.0.8', 'console_scripts', 'frida-trace')() )

NOTE: frida-discover worked

NOTE: frida-trace seems to work. I get: frida-trace -i uv_accept testprog Uploading data... Started tracing 1 function. Press ENTER to stop. y/handlers/libuv.so.11.0.0/uv_accept.js"

(and it logs when uv_accept is called) YAY!

Modifying the handlers javascript also works. Yay!

However, I'm still unable to use the python API. It doesn't help if I sudo to root.

I read that I can do much more with the Python API. However, I can't seem to find what new features are available using the Python API. It seems to me that the Python API has identical features to the JavaScript (__handlers*) - except that you can more easily switch between different scripts. Is that the difference in a nutshell?

Thanks

oleavr commented 10 years ago

It looks like you named your python module frida.py, so when you do import frida there it imports itself and tries to call .attach(). Could you try renaming it and see if you hit any other issues?

As for the python API it basically lets you inject scripts into remote processes, and provides you with a bi-directional communication channel with each. Then using the JavaScript API you'll be able to instrument those processes as you want, and build a user-experience on the Python side. You could for example have a GUI app that instruments SSL APIs and build your own Wireshark for encrypted network protocols. Or, you could build a tool for inspecting GUI applications (like WebKit Inspector, drilling down in view hierarchies etc.), or maybe a custom debugger REPL for your application (instead of building that into the application with the maintenance burden that implies). So basically frida-trace is just one example of how you can use Frida for function tracing with console output, but I'm sure there are much cooler things that can be done.

MarkSwanson commented 10 years ago

Good catch. I renamed frida.py to fridaTest.py and it works. D'oh!

I'm creating a new library that has to integrate with a large monolithic application. With Frida I don't have to edit/recompile the large app to introduce debug/tracing code. Frida is going to save me time.

Good job and thank you for Frida.

oleavr commented 10 years ago

Glad to hear. That sounds like a really cool use-case btw!

mkey commented 8 years ago

Allow me to add another D'oh!

As I was naming it frida.py I was thinking "that can't be good, don't do it, do not do it" but I did it and landed here. Dumbass.