kmaork / pyinjector

Inject shared libraries into running processes
MIT License
86 stars 16 forks source link

How to use? #10

Closed NKITANAS closed 2 years ago

NKITANAS commented 2 years ago

(I'm on Linux)Whenever I type in pid as an existing process name, and path_to_so_file as an existing dll path, it says syntax error for the pid part. What am I doing wrong?

kmaork commented 2 years ago

The pid is the process id, it is a number used as a unique identifier for your process. To find that number you can use various tools depending on your context, for example the ps command.

NKITANAS commented 2 years ago

Still doesn't work. Says syntax error. I'm using python 3, is that the problem?

kmaork commented 2 years ago

Please comment your code and the exception you are getting

NKITANAS commented 2 years ago

from pyinjector import inject inject(223144, "dllpath") ./main.py line 2: syntax error near unexpected token '223144' ./main.py line 2: inject(223144, "dllpath") (dllpath is the path for the dll(It's in the same folder as the script))

NKITANAS commented 2 years ago

Update: When I debug the script, it says exception has occurred: InjectorPermissionError

kmaork commented 2 years ago

Sounds like you fixed the syntax error, now you can use the error message in the permission error to fix it.

NKITANAS commented 2 years ago

After I followed the instructions, it says InjectorError injector_inject returned -5: dlopen failed

kmaork commented 2 years ago

Are you giving it the correct path?

NKITANAS commented 2 years ago

Yes, I tried to give it an invalid path, and it said invalid path in the debugger. In the terminal, however, it always said invalid path so I'm not sure.

NKITANAS commented 2 years ago

I get it now. It sees the library but fails to open it. Any idea why?

kmaork commented 2 years ago

You could try to load the so directly to see if it is valid. It might be compiled for a different architecture from the target process (e.g. 32/64 bit)