[INACTIVE][DEV] RemoteTCP v1.0 - crypted server query [602]

Discussion in 'Inactive/Unsupported Plugins' started by cyberbobjr, Mar 30, 2011.

  1. Offline

    cyberbobjr

    RemoteTCP Plugin
    Version: v1.0
    This plugin let you query your minecraft server with crypted request. A PHP example is provided.

    Features:
    • Crypted transaction
    • Minequery compatible
    • JSON output for the result
    The plugin is free, but you can buy the source.
    Download the plugin
    Buy the source

    Usage:
    Be sure to use the same key and the same password in the request and in the "remoteTCP.properties" file.

    This plugin was used for a Wordpress plugin : Minecraft Reguser for Wordpress.
    More details here.

    Configuration (open)

    The file remoteTCP.properties contains the setting for the plugin :
    port=6790 // Port which RemoteTCP will listen to
    key=remoteTCP // The key for the encryption system
    password=mypassword // One security more

    Command reference (open)

    Minequery
    you can send directly (without encryption) the command "query" or "query_json" for getting information about your server.

    Commands :
    json_encode(array("command"=>"query"))
    json_encode(array("command"=>"query_json")) // for a json result

    Return :
    the same result as Minequery

    Currentime
    Return the time of the server.

    Commands :
    json_encode(array("command"=>"currentime","parameters"=>"world","password"=>"password"))

    Parameters :
    Parameters : the name of the world
    Password : password set in remoteTCP.properties

    Return :
    Array with this information
    ["result"] = "ok" if ok or "error" if not
    ["time"] = time in String format

    Inventory list
    Return the inventory of a player.

    Commands :
    json_encode(array("command"=>"invprobe","player"=>"player","password"=>"password"))

    Parameters :
    player: the name of the player
    Password : password set in remoteTCP.properties

    Return :
    Array with inventory
    ["result"] = "ok" if ok or "error" if not
    ["items"] = items in array format

    give items
    Give an item to a player

    Commands :
    json_encode(array("command"=>"invadd","player"=>"player","type"=>"type","amount"=>"amount","password"=>"password"))

    Parameters :
    player: the name of the player
    type: the type of object to give (see Data value in Minecraft wiki)
    amount: amount of items to give
    Password : password set in remoteTCP.properties

    Return :
    ["result"] = "ok" if ok or "error" if not

    Add user
    Add an user to Permissions plugin

    Commands :
    json_encode(array("command"=>"adduser","player"=>"player","group"=>"group","world"=>"world","password"=>"password"))

    Parameters :
    player : the name of the player to add
    group : the group belong to the player
    world : in which world the player will be added
    Password : password set in remoteTCP.properties

    Return :
    ["result"] = "ok" if ok or "error" if not

    List worlds
    List all the worlds in Minecraft

    Commands :
    json_encode(array("command"=>"listworlds","password"=>"password"))

    Return :
    ["result"] = "ok" if ok or "error" if not
    ["worlds"] = array of all the worlds

    List groups
    List all the groups in a given world in Minecraft

    Commands :
    json_encode(array("command"=>"listgroups","world"=>"world","password"=>"password"))

    Parameters :
    world : in which world the search will be done
    Password : password set in remoteTCP.properties

    Return :
    ["result"] = "ok" if ok or "error" if not
    ["groups"] = array of all the groups in the world


    PHP Example (open)

    function getWorlds()
    {
    // $_POST contain settings
    // $_POST['server'] = Bukkit Server
    // $_POST['port'] = RemoteTCP port
    // $_POST['password'] = RemoteTCP password
    // $_POST['key'] = RemoteTCP key

    if (!empty($_POST['server']))

    {
    $string = json_encode(array('command'=>'listworlds','password'=>$_POST['password']));
    $result = sendCommand($_POST['server'],$_POST['port'],$string,$_POST['key']);
    $result = (array)json_decode($result);
    if ($result['result']=='ok')
    echo json_encode($result['worlds']);
    else
    echo "";
    }
    }

    // Example function for Minequery request
    function sendMinequeryCommand($host,$port)
    {
    // Minequery command is not necessary encrypted
    $string = "query"; // or query_json
    $socket = @fsockopen($host, $port, $codeErreur, $msgErreur,30);
    if (!$socket)
    {
    echo 'Error, no connection';
    }
    fwrite($socket,$string."\n");
    $response = "";
    while(!feof($socket)) {
    $response .= fgets($socket, 1024);
    }
    return $response;
    }

    function sendCommand($host,$port,$string,$key)
    {
    $socket = @fsockopen($host, $port, $codeErreur, $msgErreur,30);
    if (!$socket)
    {
    echo 'Error, no connection';
    }
    $string = encrypt($string,$key);
    fwrite($socket,$string."\n");
    $response = "";
    while(!feof($socket)) {
    $response .= fgets($socket, 1024);
    }
    return $response;
    }

    function hex2bin($hexdata) {
    $bindata = "";
    for ($i = 0; $i < strlen($hexdata); $i += 2) {
    $bindata .= chr(hexdec(substr($hexdata, $i, 2)));
    }
    return $bindata;
    }

    function encrypt($text,$secret_key) {
    $cipher = "rijndael-128";
    $mode = "cbc";
    //$secret_key = "D4:6E:AC:3F:F0:BE";
    //iv length should be 16 bytes
    $iv = "fedcba9876543210";

    // Make sure the key length should be 16 bytes
    $key_len = strlen($secret_key);
    if($key_len < 16 ){
    $addS = 16 - $key_len;
    for($i =0 ;$i < $addS; $i++){
    $secret_key.=" ";
    }
    }else{
    $secret_key = substr($secret_key, 0, 16);
    }

    $td = mcrypt_module_open($cipher, "", $mode, $iv);
    mcrypt_generic_init($td, $secret_key, $iv);
    $cyper_text = mcrypt_generic($td, $text);
    mcrypt_generic_deinit($td);
    mcrypt_module_close($td);
    return bin2hex($cyper_text);
    }

    Changelog:
    Version 1.0
    • Initial release
     
  2. Offline

    BorderKeeper

    Awesome. Was waiting long time for plugin that register users directly on web
     
  3. Offline

    cyberbobjr

    Hi, i'll add next functions soon for stats plugin. Regards
     
  4. Offline

    Fusioneko

    Hello, after taking a look at this, I'm extremely excited to sit down, and play with it. Seeing the PHP examples, is exactly what I have been searching for.

    I do hope to see you expand it a bit, if possible, I'd like to see it's functions expanded. I am still reviewing the functions, and I am quite pleased. So I thought I'd offer my own vision.

    I've been looking for a plugin that allowed me to communicate with PHP, and thus since I've found it.. I'd like to really see more flexibility, I can see you can give items, but can you take them? Also, can you edit users already in the permissions? View the current permissions? I'd like to see those, Although I wouldn't want to ask of to much.

    I really do hope to see my questions answered. I'd also like to see the ability to maybe, send in actual server commands straight to the console as well?
     
  5. Offline

    cyberbobjr

    Hi,
    It's planned :)
    It's planned too, but not in the next version, in the afternext i think.
    Easy, planned in the next version.
    Why not, i must think about that.

    If you know Java, you can buy the source if you want :p and fork it :) it's allowed.

    Regards
     
  6. Offline

    Plague

    considered inactive
     

Share This Page