Execute a file instead of code fragments#25
Conversation
| if path is not None and path.exists(): | ||
| path.unlink() | ||
|
|
||
| def inject_py_script(pid: int, python_script: Path, permissions=0o644) -> None: |
There was a problem hiding this comment.
Much of the logic here is duplicated from above. I think it might be better to keep it as one function, inject_py, and check isinstance(python_code, Path) to determine the logic. Also, I think that instead of modifying injection.c, it would be easier to just read the given file here, and use the contents as code.
There was a problem hiding this comment.
If a large script is provided then it will overflow. Also relative imports will not work as expected either presumably. To me it made sense to use the Python API file parsing and execution instead of shoehorning the code into the lib?
There was a problem hiding this comment.
Yeah I agree about the advantages, but ideally I'd want to enocunter all possible errors before the injection, so they happen in python and not in C in the target process. I also wonder permission-wise, if it's better to use the injector process permissions or the injectee's permissions (and fs, btw, see #18). I will hopefully have more time to think about it later.
There was a problem hiding this comment.
Yeah I agree about the advantages, but ideally I'd want to enocunter all possible errors before the injection, so they happen in python and not in C in the target process.
Are there more errors this way? I am not sure I understand where the source of errors you're concerned about is.
As for Docker, I am already running into some issues running from within the container and being able to open libc.so. Containerisation always makes things complicated 😅
|
Thanks for the feature! I fixed CI on master, you can update your branch |
|
Not sure what is going on with the alpine, Mac and Windows tests. Something is causing the process to segfault in some cases, groan. |
|
I'm flying abroad, so sadly I can't help right now, would love to help merge this whenever I can |
You can now inject a python script path. This seemed easier to manage than trying to get my scripts as arguments on the command line.
Platforms other than Linux are not tested.