Shell 无法识别别名命令
我试图追踪 WordPress 网站如何不断遭到黑客攻击,我试图追踪的一件事是哪些文件被“touch”命令攻击,以伪造最后修改日期(许多黑客这样做是为了隐藏自己和就发生在这种情况下)。我创建了一个名为 newtouch 的脚本,它仅使用时间戳记录发送给它的所有参数,然后将 touch 别名为 newtouch。当我 ssh 进入时,这工作正常,但是当我尝试从 php 调用它时,它无法识别别名。我做了一些研究,意识到这是因为 php 运行在不同的 shell 下:
$ php -r 'echo shell_exec("echo $0");' sh
主目录中没有 .profile,因此我创建了一个,但无论我在其中放入什么,由于某种原因,我都无法让 shell 识别它。为了测试,我尝试了一个名为 touch2 的简单别名,它只是回显单词 test,并在 .profile 中尝试了以下所有操作,但没有一个起作用:
alias touch2='echo test'
alias touch2 'echo test'
touch2 () {
echo test
}
无论我尝试什么,我都会得到相同的结果:
$ sh
$ alias
$ touch2
sh: touch2: command not found
$ php -r 'echo shell_exec("alias");'
$ php -r 'echo shell_exec("touch2");'
sh: touch2: command not found
感谢任何帮助,谢谢。
I am attempting to track down how a Wordpress site keeps getting hacked, and one of the things I am trying to track is which files are being hit by the "touch" command to forge the last_modified dates (which many hacks do to hide themselves and is happening in this instance). I created a script named newtouch that simply logs with a timestamp all parameters that are sent to it, and then aliased touch to be newtouch. This works fine when I ssh in, but when I attempt to call it from php it is not recognizing the alias. I did some research, and realized that is because php is running under a different shell:
$ php -r 'echo shell_exec("echo $0");'
sh
There was no .profile in the home directory, so I created one, but no matter what I put in it I cannot get the shell to recognize it for some reason. To test I tried a simple alias named touch2 that simply echoes the word test, and have tried all of the following inside of .profile, none of which worked:
alias touch2='echo test'
alias touch2 'echo test'
touch2 () {
echo test
}
regardless of which I try, I get the same results:
$ sh
$ alias
$ touch2
sh: touch2: command not found
$ php -r 'echo shell_exec("alias");'
$ php -r 'echo shell_exec("touch2");'
sh: touch2: command not found
Any help is appreciated, thank you.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)