Can a PIN tool instrument a bash script that contains code to run other commands?

心不动则不痛 提交于 2019-12-25 03:36:14

问题


I wrote a PIN tool that can inject some code before and after a certain function in a binary image. It is working for a single binary image.

Now , my objective is to instrument Xserver in Linux with that tool. I tried to instrument "startx" by the PIN tool and it did not work. Later, I found that startx is only a shell script that runs other commands.

What steps I need to follow if I want to instrument xserver using PIN? Is it possible to instrument a shell script somehow using PIN?


回答1:


If you want to instrument a script, you'll need to instrument the script interpreter (in your case, if your script is a shell script, you'll need to instrument your shell (e.g bash)).

In your case, as the script calls onto another script or program, you can use the -follow_execv switch which will tell pin to inject on all child processes (you can fine-tune this behavior by using one of the Follow Child Process API).

In the end it should instrument the xinit program which seems to be started by startx.



来源:https://stackoverflow.com/questions/30743298/can-a-pin-tool-instrument-a-bash-script-that-contains-code-to-run-other-commands

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!