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.