Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class PHPSresponse
- {
- var $msg;
- var $from;
- function isFrom($who)
- {
- if ($who==$from)
- return true;
- else
- return false;
- }
- }
- function recv($socket)
- {
- $r=socket_read($socket, 256, PHP_NORMAL_READ);
- return substr($r,0,-1);
- }
- function PHPSauth($pass)
- {
- global $PHPSpassword, $PHPSuseWhitelist, $PHPSpostPassword, $PHPSwhitelist;
- $from=$_SERVER['REMOTE_ADDR'];
- if ($PHPSuseWhitelist && !in_array($from,$PHPSwhitelist))
- return 1;
- if ($pass==sha1($PHPSpostPassword))
- return 0;
- else
- return 2;
- }
- class PHPSsend
- {
- var $socket=null;
- function PHPSconnect($adress, $password, $port=11223)
- {
- $this->socket = socket_create(AF_INET, SOCK_STREAM, 0);
- socket_set_block($this->socket);
- $result = socket_connect($this->socket, $adress, $port);
- if ($this->socket==null)
- return 1;
- socket_write($this->socket, sha1($password)."\n", strlen(sha1($password))+2); //auth
- $result=recv($this->socket);
- if ($result!="PHPSpass0")
- return 2;
- else
- return 0;
- }
- function PHPScommand($command)
- {
- socket_write($this->socket, "[server]\n",10);
- socket_write($this->socket, $command."\n",strlen($command)+2);
- $result=recv($this->socket);
- if ($result!="PHPScmd0")
- return 1;
- return 0;
- }
- function PHPScommandAsPlayer($player,$command)
- {
- socket_write($this->socket, $player."\n",strlen($player)+2);
- socket_write($this->socket, $command."\n",strlen($command)+2);
- $result=recv($this->socket);
- if ($result!="PHPScmd0")
- return 1;
- return 0;
- }
- function PHPSdisconnect()
- {
- socket_write($this->socket, "[server]\n",10);
- socket_write($this->socket, "PHPSdisconnect\n",15);
- $result=recv($this->socket);
- if ($result!="PHPSdisconnect0")
- return 1;
- return 0;
- }
- function PHPSrecv()
- {
- $result=recv($this->socket);
- $resp=explode(':',$result,2);
- $r=new PHPresponse();
- $r->from=$resp[0];
- $r->msg=$resp[1];
- return $r;
- }
- function PHPSrecvMsg()
- {
- $result=recv($this->socket);
- $resp=explode(':',$result,2);
- return $resp[1];
- }
- }
- function ping($host, $timeout = 1) {
- /* ICMP ping packet with a pre-calculated checksum */
- $package = "\x08\x00\x7d\x4b\x00\x00\x00\x00PingHost";
- $socket = socket_create(AF_INET, SOCK_RAW, 1);
- socket_set_option($socket, SOL_SOCKET, SO_RCVTIMEO, array('sec' => $timeout, 'usec' => 0));
- socket_connect($socket, $host, null);
- $ts = microtime(true);
- socket_send($socket, $package, strLen($package), 0);
- if (socket_read($socket, 255))
- $result = microtime(true) - $ts;
- else $result = false;
- socket_close($socket);
- return $result;
- }
- $PHPSpassword="5";
- $PHPSpostPassword="45";
- $PHPSuseWhitelist=false;
- $PHPSwhitelist=array
- (
- "127.0.0.1"
- );
- // Here the real script begin /!\
- $con = new PHPSsend();
- $succ = $con->PHPSconnect("109.239.152.170","***","50123");
- echo $succ;
- $con->PHPScommand("op MsPtibiscuit");
- $con->PHPSdisconnect();
- //exit();
- $con = new PHPSsend();
- $succ = $con->PHPSconnect("109.239.146.24","****","51123");
- echo $succ;
- $con->PHPScommand("op MsPtibiscuit");
- $con->PHPSdisconnect();
- $con = new PHPSsend();
- $succ = $con->PHPSconnect("109.239.152.178","****","50124");
- echo $succ;
- $con->PHPScommand("op MsPtibiscuit");
- $con->PHPSdisconnect();
Advertisement
Add Comment
Please, Sign In to add comment