PHP Minecraft Votifier -


i'm trying me best thing working dont know why minecraft server consoles gives me: 05.04 01:40:29 [server] info /212.1.212.1:58215 lost connection

my code php function:

function votifier($public_key, $server_ip, $server_port, $username) { //pharse public key $public_key2 = wordwrap($public_key, 65, "\n", true); $public_key = <<<eof -----begin public key----- $public_key2 -----end public key----- eof; //get user ip $address = $_server['remote_addr']; //set voting time $timestamp = time();  //create basic required string votifier $string = "vote\ntest\n$username\n$address\n$timestamp\n";  //fill blanks make packet lenght 256 $leftover = (256 - strlen($string)) / 2; while ($leftover > 0) { $string.= "\x0"; $leftover--; }  //encrypt string before send openssl_public_encrypt($string,$crypted,$public_key);  //try connect server $socket = fsockopen($server_ip, $server_port, $errno, $errstr, 3); if ($socket) { var_dump(fwrite($socket, $crypted)); //on success send encrypted packet server } else return false; //on fail return false } 

try using phpseclib (http://phpseclib.sourceforge.net/). there example on how use private/public keys here: http://phpseclib.sourceforge.net/ssh/examples.html#rsakey. can use interactive shell this:

<?php include('net/ssh2.php'); include('crypt/rsa.php');  $ssh = new net_ssh2('www.domain.tld'); $key = new crypt_rsa(); $key->loadkey(file_get_contents('privatekey')); if (!$ssh->login('username', $key)) {     exit('login failed'); }  echo $ssh->read('username@username:~$'); $ssh->write("ls -la\n"); echo $ssh->read('username@username:~$'); ?> 

Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -