View Single Post

  #6 (permalink)  
Old 05-24-2007, 04:25 PM
james bond james bond is offline
Junior Member
User
 
Join Date: May 2007
My distro: Debian
Posts: 7
Rep Power: 0
james bond is on a distinguished road
Default

Jerry,

when I run this
Code:
$ php my-script-name.php
then it prints the whole php file. No errors.

This is the output of access.log when run that php page from browser

Code:
 10.10.192.49 - - [24/May/2007:15:41:45 +0600] "GET /changepassword.php HTTP/1.0" 200 1760 "-" "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.1) Gecko/20061204 Firefox/2.0.0.1"
  10.10.192.49 - - [24/May/2007:15:41:51 +0600] "POST /changepassword.php HTTP/1.0" 200 858 "http://10.10.4.200/changepassword.php" "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.1) Gecko/20061204 Firefox/2.0.0.1"
Output from error.log
Code:
 [client 10.10.192.49] PHP Notice:  Use of undefined constant PHP_SELF - assumed 'PHP_SELF' in /var/www/html/changepassword.php on line 135
  unable to change to sudoers gid: Operation not permitted
autopasswd file:

Code:
#!/usr/bin/expect -f
# wrapper to make passwd(1) be non-interactive
# username is passed as 1st arg, passwd as 2nd
set password [lindex $argv 1]
spawn passwd [lindex $argv 0]
expect "assword:"
send -- "$password\r"
expect "assword:"
send -- "$password\r"
expect eof
changed "changepassword.php" as follows: just mentioned important lines..

Code:
$shellscript = "/usr/bin/sudo /var/www/html/autopasswd ";
....
....
 if ( $callshell == true ) {
  // command to change password
   $cmd="$shellscript" . $_POST['username'] . " " . $_POST['passwd'];
   echo $cmd;
   exec($cmd,$output,$status);
Waiting for your kind response.
Reply With Quote