List Info

Thread: note 74835 rejected from function.fsockopen by tularis




note 74835 rejected from function.fsockopen by tularis
user name
2007-04-30 11:22:40
Note Submitter: svidapan at in dot ibm dot com 

----

telnet client works on AIX 5.3 but does not on Linux kernel
2.6.

I have a piece of code which acts as telnet client to
connect to a remote machine and run a command say
/usr/bin/touch /root/vsk.test. It works fine on AIX v 5.3
but does not on
Linux kernel 2.6..Any idea? Please help..

<?php
/*
 * Created on Apr 30, 2007
 *
 * To change the template for this generated file go to
 * Window - - PHPeclipse - PHP - Code Templates
 */
 
 function AddMachine($formValues)
{
	
    $MachineName="xxx.yyy.zzz.com";
	$rootuser="root";
	$rootpass="password";

	$header1
=chr(0xFF).chr(0xFB).chr(0x1F).chr(0xFF).chr(0xFB).
	chr(0x20).chr(0xFF).chr(0xFB).chr(0x18).chr(0xFF).chr(0xFB)
.
	chr(0x27).chr(0xFF).chr(0xFD).chr(0x01).chr(0xFF).chr(0xFB)
.
	chr(0x03).chr(0xFF).chr(0xFD).chr(0x03).chr(0xFF).chr(0xFC)
.
	chr(0x23).chr(0xFF).chr(0xFC).chr(0x24).chr(0xFF).chr(0xFA)
.
	chr(0x1F).chr(0x00).chr(0x50).chr(0x00).chr(0x18).chr(0xFF)
.
	chr(0xF0).chr(0xFF).chr(0xFA).chr(0x20).chr(0x00).chr(0x33)
.
	chr(0x38).chr(0x34).chr(0x30).chr(0x30).chr(0x2C).chr(0x33)
.
	chr(0x38).chr(0x34).chr(0x30).chr(0x30).chr(0xFF).chr(0xF0)
.
	chr(0xFF).chr(0xFA).chr(0x27	).chr(0x00).chr(0xFF).chr(0xF0
).
	chr(0xFF).chr(0xFA).chr(0x18).chr(0x00).chr(0x58).chr(0x54)
.
	chr(0x45).chr(0x52).chr(0x4D).chr(0xFF).chr(0xF0);
	
	$header2=chr(0xFF).chr(0xFC).chr(0x01).chr(0xFF).chr(0xFC).

	chr(0x22).chr(0xFF).chr(0xFE).chr(0x05).chr(0xFF).chr(0xFC)
.chr(0x21);
		
		
	$fp = fsockopen($MachineName, 23);
	if ($fp == FALSE)
	{
		printf("Cannot connect to the Telnet port of the
machine");
	}
	$ret = fputs($fp,$header1);
	if ($ret == FALSE)
	{
		print "Problem with telnet header 1";
	}
	else if ($ret == TRUE)
	{
		print "telnet header 1 successful";
	}
	usleep(125000);
	$ret = fputs($fp,$header2);
	if ($ret == FALSE)
	{
		print "Problem with telnet header 2";
	}
	else if ($ret == TRUE)
	{
		print "telnet header 2 successful";
	}
	usleep(125000);
	
	$ret = fputs($fp,$rootuser."r");
	if ($ret == FALSE)
	{
		printf("Problem with telnet 3n");
	}
	
	usleep(125000);
	
	$ret = fputs($fp,$rootpass."r");
	if ($ret == FALSE)
	{
			printf("Problem with telnet 4.n");
	}
	
	usleep(125000);
	
	$ret = fputs($fp, "/usr/bin/touch
/root/vsk.testr");
	
	if ($ret == FALSE)
	{
		printf("Problem with telnet 6.n");
	}
	
	usleep(125000);
	
	$ret = fputs($fp, "echo Hello worldr");
	
	if ($ret == FALSE)
	{
		printf("Problem with telnet 6.n");
	} else if ($ret == TRUE)
	{
		printf("touch successful.n");
	}		
	
	//$output = fread($fp, 128);
	
	$stat = stream_get_meta_data($fp);
	print "Unread =
".$stat["unread_bytes"]." ";
	print "Timed out =
".$stat["timed_out"]." ";
	print "Blocked =
".$stat["blocked"]." ";
	print "EOF = ".$stat["eof"]."
";
	
	usleep(300000);
		
	fclose($fp);
}

AddMachine("Hello World");

?>

-- 
PHP Notes Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub
.php


[1]

about | contact  Other archives ( Real Estate discussion Medical topics )