First of all I am showing the PHP code ….
<?php
echo ("hello");
echo exec("sendip -v -p ipv6 -6s 2001::100 -p tcp -ts 21 -td 21 2001::200 2>
&1");
echo ("hi");
?>
When I entered the command through linux command line it is working fine.The command is sending a tcp ipv6 packet on 2001::200 machine from 2001::100.
[root@udit-pc]# sendip -v -p ipv6 -6s 2001::100 -p tcp -ts 21
-td 21 2001::200 > /dev/null &
/* (-v for verbose) */
Output of above command …
Added 34 options
Initializing module ipv6
Initializing module tcp
Finalizing module tcp
Finalizing module ipv6
Final packet data:
60 00 00 00 `...
/*
here other packet
contents gets printed
*/
7D 62 00 00 }b..
61 62 63 64 abcd
Sent 64 bytes to 2001::200
Freeing module ipv6
Freeing module tcp
When I execute the php script through command line…
[root@udit-pc]# php test.php
Freeing module tcp
hellohi gets printed and packet arrived at 2001::200.
But problem arise when I try to run php script through browser…
http:://localhost/test.php
hellohi gets printed but packet does not arrive at other machine.
sh: sendip: command not found
Also in both case packet contents are not printed at terminal although using verbose option but when directly using command verbose option works fine.
I tried with many things although I do not think they would help like……
-
I added /usr/local/lib and usr/local/bin to PATH variable but no benefit.
-
chmod +s /usr/local/bin/sendip .Sticky bit set but again no benefit.
-
paste the /usr/local/bin/sendip itself in /var/www/html folder although I have changed the PATH variable but as i said i m just using hit n trial getting no clue…..
There are some output snapshots which may further help ….
[root@cc html]# echo $PATH
/usr/lib/qt-3.3/bin:/usr/kerberos/sbin:/usr/kerberos/bin:
/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:
/usr/X11R6/bin:/root/bin:/usr/local/lib
[root@cc html]# locate sendip
.....
/usr/local/bin/sendip
/usr/local/lib/sendip
.....
[root@cc bin]# chmod +s sendip
[root@cc bin]# ls -l sendip
-rwsrwsrwx 1 apache apache 41071 Sep 26 19:41 sendip
[root@cc bin]# cd /usr/local/lib/
[root@cc lib]# ls -ld sendip
drwxrwxrwx 2 root root 4096 Sep 28 22:48 sendip
[root@cc lib]# chmod +s sendip
[root@cc lib]# ls -ld sendip
drwsrwsrwx 2 root root 4096 Sep 28 22:48 sendip
When file contents are changed …….
<?php
echo exec("/usr/bin/sendip ........ 2 > &1");
?>
Then oputput is :
[root@cc html]# php test.php
Freeing module tcp[root@cc html]#
On browser….
No error gets printed but packet still not arrived.
I am stuck in between.Please suggest me what else should I rather try ??????/
is
sendip()in the path of the shell being invoked by PHP? You’re not checking for error conditions, so possibly you’re not actually executing sendip, and just getting a “no such program or file” type errors.Instead of redirecting the exec()’d command’s output to null, redirect it all to the browser so you can see what happens: