1 |
<? |
<? |
|
// $address = "192.168.0.6"; |
|
|
// $port = "6666"; |
|
|
// |
|
|
// // create and connect socket |
|
|
// $sock = socket_create(AF_INET, SOCK_STREAM, SOL_TCP); |
|
|
// socket_connect($sock, $address, $port); |
|
|
// |
|
|
// // send the message to the daemon |
|
|
// //$mesg = "resolution=800x600\nquit"; |
|
|
// $mesg = "resolution\nquit"; |
|
|
// //$mesg = "printer\ngfxcard\nnetcard\nkeyboard\nmouse\nsound\nquit"; |
|
|
// socket_write($sock, $mesg, strlen($mesg)); |
|
|
// |
|
|
// // close socket |
|
|
// socket_close($sock); |
|
|
|
|
|
|
|
|
/* fgets needs 'auto-detect-line-endings = On' in php.ini to detect unix CRLFs! |
|
|
* see: http://www.php.net/manual/de/filesystem.configuration.php#ini.auto-detect-line-endings |
|
|
*/ |
|
|
|
|
|
// // ssl |
|
|
// $fp = fsockopen("sslv3://192.168.0.6", 6666, $errno, $errstr, 30); |
|
|
// if (!$fp) { |
|
|
// echo "$errstr ($errno)<br />\n"; |
|
|
// } else { |
|
|
// $out = "resolution\n"; |
|
|
// $out .= "quit\n"; |
|
|
// fwrite($fp, $out); |
|
|
// while (!feof($fp)) { |
|
|
// echo fgets($fp, 128); |
|
|
// } |
|
|
// fclose($fp); |
|
|
// } |
|
|
|
|
2 |
include("config.inc.php"); |
include("config.inc.php"); |
3 |
|
|
4 |
function mcore_socket_send($ip, $port, $cmd) |
function mcore_socket_send($ip, $port, $cmd) |
5 |
{ |
{ |
6 |
// use sslv3 |
global $mcore_certificate; |
|
$schema = "sslv3://"; |
|
7 |
|
|
8 |
|
// do not print output of system |
9 |
|
ob_start(); |
10 |
$fingerprint = system("openssl x509 -noout -modulus -in ".$mcore_certificate." | openssl sha1 | sed 's:(stdin)=\ ::'", $retval); |
$fingerprint = system("openssl x509 -noout -modulus -in ".$mcore_certificate." | openssl sha1 | sed 's:(stdin)=\ ::'", $retval); |
11 |
|
ob_clean(); |
12 |
if ($retval == 0) |
if ($retval == 0) |
13 |
{ |
{ |
14 |
$fp = fsockopen($schema.$ip, $port, $errno, $errstr, 30); |
ob_start(); |
15 |
if (!$fp) { |
system("/usr/bin/mcore-socket-send --ip='".$ip."' --port='".$port."' --fingerprint='".$fingerprint."' --command='".$cmd."'", $sockretval); |
16 |
echo "$errstr ($errno)<br />\n"; |
ob_clean(); |
17 |
} else { |
if ($sockretval != 0) echo "socket send failed"; |
|
$out = "certauth 7acca14a60139d47d5ea591816991ef733b1e500\n"; |
|
|
$out .= $cmd."\n"; |
|
|
$out .= "quit\n"; |
|
|
fwrite($fp, $out); |
|
|
while (!feof($fp)) { |
|
|
echo fgets($fp, 128); |
|
|
} |
|
|
fclose($fp); |
|
|
} |
|
18 |
} |
} |
19 |
} |
} |
20 |
?> |
?> |