gaffe23 / linux-inject

Tool for injecting a shared object into a Linux process
Other
1.1k stars 246 forks source link

Using strace with linux-inject #5

Open Aakash16 opened 8 years ago

Aakash16 commented 8 years ago

Thanks for creating awesome injection library. I am able to successfully inject with help of your technique. But when I run sample-target with strace the injection fails with message: ptrace(PTRACE_ATTACH) failed please help.

gaffe23 commented 8 years ago

Unfortunately, trying to run sample-target under strace presents a bit of a chicken-and-egg problem.

strace works by attaching to the target application using ptrace. However, linux-inject itself also needs to be able to attach to the target application using ptrace. Two processes cannot ptrace the same application at the same time, so linux-inject can't attach when strace is already attached.

As a result, you can't use linux-inject on an application that is running under strace.

Aakash16 commented 8 years ago

Thank you for your reply. Now I understand the problem.

On 2/17/16, gaffe23 notifications@github.com wrote:

Unfortunately, trying to run sample-target under strace presents a bit of a chicken-and-egg problem.

strace works by attaching to the target application using ptrace. However, linux-inject itself also needs to be able to attach to the target application using ptrace. Two processes cannot ptrace the same application at the same time, so linux-inject can't attach when strace is already attached.

As a result, you can't use linux-inject on an application that is running under strace.


Reply to this email directly or view it on GitHub: https://github.com/gaffe23/linux-inject/issues/5#issuecomment-184906899