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

Failure to inject on Mac #26

Open
kmaork opened this issue Jul 11, 2023 · 8 comments
Open

Failure to inject on Mac #26

kmaork opened this issue Jul 11, 2023 · 8 comments

Comments

@kmaork
Copy link
Owner

kmaork commented Jul 11, 2023

You may get this when trying to inject on Mac: pyinjector.api.MacUnknownInjectorError: injector_attach returned -1: TASK_FOR_PID error : (os/kern) failure
This should be resolved by rerunning as root. Please comment here if it doesn't solved the issue or if you need to be able to run without root. Please state how you installed pyinjector.

@kmaork kmaork changed the title Failure to inject on Mac: MacUnknownInjectorError: TASK_FOR_PID error : (os/kern) failure Failure to inject on Mac Jul 11, 2023
@icoco
Copy link

icoco commented Jul 14, 2023

use hypno,
also sudo pip install hypno success ,
run command bellow

sudo hypno 7004 "import os; print('Hello again from', os.getpid())"                            

but throw error bellows:

raise exception_cls(func.__name__, ret, libinjector.injector_error())
pyinjector.api.MacUnknownInjectorError: injector_attach returned -1: TASK_FOR_PID error : (os/kern) failure
Mac restricts injection for security reasons. Please report this error in the issue:
https://github.com/kmaork/pyinjector/issues/26

again, use Macbook Pro M1, it could support ?

@kmaork
Copy link
Owner Author

kmaork commented Jul 14, 2023

Hey @icoco, can you please try running again, and if it fails, run ps -fp <the pid> and post the output here?

@icoco
Copy link

icoco commented Jul 16, 2023

try

sudo hypno 68523 "import os; print('Hello again from', os.getpid())"

throw

    raise exception_cls(func.__name__, ret, libinjector.injector_error())
pyinjector.api.MacUnknownInjectorError: injector_attach returned -1: TASK_FOR_PID error : (os/kern) failure

and ps -fp result bellows :

ps -fp 68523
  UID   PID  PPID   C STIME   TTY           TIME CMD
  501 68523 16847   0 10:42PM ??         0:00.07 /py/Inject/env/bin/Python /py/Inject/app/test.py

should do Disable System Integrity Protection Temporarily ?

@kmaork
Copy link
Owner Author

kmaork commented Jul 18, 2023

Thanks for checking. You can try temporarily disabling SIP, that would be helpful to make sure that it is indeed the root cause.

Also, how did you install python? Where did this /py/Inject/env/bin/Python come from?

@icoco
Copy link

icoco commented Jul 19, 2023

it work under virtualenv, so '/py/Inject/env/bin/Python' accurate point to the inner python of xcode

`
/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.9/Resources/Python.app/Contents/MacOS/Python /py/Inject/app/test.py

`

@icoco
Copy link

icoco commented Aug 21, 2023

it works, cause different python was installed on the computer, thanks for your time !

@kmaork kmaork closed this as completed Aug 21, 2023
@itay-sho
Copy link

it works, cause different python was installed on the computer, thanks for your time !

I think I experience the same problem with my M1 Mac, can you please elaborate more what was the problem and how to overcome it?

Thanks!

@kmaork kmaork reopened this Sep 20, 2023
@icoco
Copy link

icoco commented Feb 22, 2024

it works, cause different python was installed on the computer, thanks for your time !

I think I experience the same problem with my M1 Mac, can you please elaborate more what was the problem and how to overcome it?

Thanks!
sorry reply later,

I think that cause use different Python environment, assume the computer installed two version python on different location, maybe : '/Library/Frameworks/Python.framework/Versions/3.11/Resources/Python.app/Contents/MacOS/Python' and '/opt/homebrew/lib/python3.9/',

the target python application which need be injected use first, but the while inject command 'sudo hypno {process_id} xxx' , it use another, then nothing can be injected

once I make it works on the same , in fact should use ''/opt/homebrew/lib/python3.9' , then it works as expectation

hope this is helpful

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

No branches or pull requests

3 participants