Remotely send commands to a server [1.3.1][PHP]

Macemore

Circumcised pineapples
Aug 26, 2011
1,681
819
Before we start you need:
1) To be owner of the server, or access to the files.
2) How to copy 'n paste
3) use common sense
4) Have Craftbukkit 1.3.1
5) using Xampp, or some kind of webserver

Alright here we go!
First off, make sure you're running if you're not, GO GET IT!
Install PHPSend plugin by downloading the files and copy the files to the plugins folder where your server is located.

Next open up xampp, or what ever webserver/webhost you use and copy these files into it:
PHPSend.php
PHP:
<?php
 
error_reporting(0);
 
class PHPresponse
{
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);
}
 
class PHPsend
{
var $socket=null;
 
function PHPconnect($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, md5($password)."\n", strlen(md5($password))+2); //auth
$result=recv($this->socket);
 
/*echo 'RESULT: '.$result."\n";
echo md5($result)."\n";*/
 
if ($result!="PHPpass0")
return 2;
else
return 0;
}
 
function PHPcommand($command)
{
socket_write($this->socket, $command."\n",strlen($command)+2);
$result=recv($this->socket);
 
if ($result!="PHPcmd0")
return 1;
return 0;
}
 
function PHPdisconnect()
{
socket_write($this->socket, "PHPdisconnect\n",15);
$result=recv($this->socket);
 
if ($result!="PHPdisconnect0")
return 1;
return 0;
}
 
function PHPrecv()
{
$result=recv($this->socket);
$resp=explode(':',$result,2);
$r=new PHPresponse();
$r->from=$resp[0];
$r->msg=$resp[1];
return $r;
}
 
function PHPrecvMsg()
{
$result=recv($this->socket);
$resp=explode(':',$result,2);
return $resp[1];
}
}
 
?>

sendphp.php
PHP:
<?php
 
# Configuration #
$connect['server'] = '127.0.0.1'; # Server's IP address #
$connect['password'] = '3fc3168e44e3ef90'; # PHPSend's Password #
$connect['port'] = '11223'; # The port PHPSend opperates on #
# Do NOT touch anything below this line, please #
$command = $_POST['command'];
 
include('PHPsend.php'); # Include the API #
 
$con = new PHPsend();
$succ = $con->PHPconnect($connect['server'],$connect['password'],$connect['port']);
if($succ == '0') {
    $con->PHPcommand($command);
    echo 'Command successfully executed';
} elseif($succ == '1') {
    echo 'Could not connect to server, are your details correct?';
} elseif($succ == '2') {
    echo 'incorrect password, please check your password and try again';
} else {
    echo 'an unexpected error occured (Error code: 1)';
}
?>
Index.php
PHP:
<html>
    <head>
        <title>PHPSend Command</title>
    </head>
    <body>
        <form name='send' action='sendphp.php' method ='post'"'>
            <form name="input" action="html_form_action.asp" method="get">
            Command: <input type="text" name="command" />
            <input type="submit" value="Send" />
      </form>
    </body>
</html>
OR Download here:
Once you have all three of those files, go to sendphp.php and change the configuration on lines 4-6 to your server details. then load up index.php and enjoy :)
Credits:
90% me
10% - PHPSend.php and PHPSend plugin :)
Please don't release this anywhere else without my permission, if you need any assistance feel free to PM me, but please DON'T post it the thread. It's annoying.
Enjoy.
 

Sledmore

Chaturbate Livestreamer
Staff member
FindRetros Moderator
Jul 24, 2010
5,194
3,901
Looks and sounds good, just a tip, if you don't use XAMPP, you'll probably have to edit your php.ini for the sockets ^^
 

Users who are viewing this thread

Top