Results 1 to 4 of 4
so I was bored and wanted to create a small web interface for a few tasks. currently, I'm using POST to get arguments and then PHP's exec() to run a ...
- 07-24-2009 #1Just Joined!
- Join Date
- Aug 2008
- Location
- Seattle, WA
- Posts
- 46
PHP exec security
so I was bored and wanted to create a small web interface for a few tasks. currently, I'm using POST to get arguments and then PHP's exec() to run a small shell script.
the scripts are all in password-protected directories, so I'm not terribly worried about them actually being abused, but I'm curious as to the best way to protect against command injection.
here's an example:
php
shellCode:$cmd = "/$somepath/passwd.sh ".$username." ".$password." ".$new_password; exec($cmd, $output, $return);
if I feed it the arguments 'someuser;' 'ls' and '/', it will actually do an 'ls' and return the output. I havent found any other commands that return output, but invalid input definitely boggles the shellscript's return code, which the PHP script uses for error handling. is there a way to deal with this kind of attack? is there a less kludgy way of solving this problem?Code:passwd $1 <<EOF $2 $3 $3 EOF
thanks,
-rb
- 08-22-2009 #2
- 08-22-2009 #3Just Joined!
- Join Date
- Aug 2008
- Location
- Seattle, WA
- Posts
- 46
oh yes. I'm aware of how terrifyingly insecure it is.
any thoughts on a less insane way of doing it?
- 08-23-2009 #4


Reply With Quote
