PDA

View Full Version : [ Desenvolvimento ] Disconnect MUSITE V2 > MuEmu Xteam



richard88
02/06/2016, 01:36 AM
FIle ldgame.class.php From Musite V2

<?php
new ldLanguage( str_replace(".class.", ".lang.", basename(__FILE__)), false );
class ldGame extends ldNetwork
{
public function disconnectPlayer($account)
{
try
{
if(empty($account) == true || strlen($account) > 10)
throw new Exception(GAME_INCORRENCT_LOGIN);

$this->openConnection();

$this->sendPacket("\xC1\x13\xA0\x00\x00\x00\x00\x00".str_pad($account, 10, "\x00")."\x00");

$this->getResponse();
$tmpResponse = $this->printResponse(false, true);
$tmpResponse = hexdec(substr($tmpResponse, 16, 2));
if($tmpResponse == 1)
{
sleep(1);
$this->sendPacket("\xC1\x13\xA0\x00\x00\x00\x00\x00".str_pad($account, 10, "\x00")."\x00");
sleep(1);
$this->sendPacket("\xC1\x13\xA0\x00\x00\x00\x00\x00".str_pad($account, 10, "\x00")."\x00");
sleep(1);
$this->sendPacket("\xC1\x13\xA0\x00\x00\x00\x00\x00".str_pad($account, 10, "\x00")."\x00");
throw new Exception(GAME_SUCCESS_DISCONNECT." ".$account);
}
else
throw new Exception(GAME_ERROR_DISCONNECT);
}
catch ( Exception $msg )
{
return $msg->getMessage();
}
}

public function sendMessageToAll($message)
{
try
{
if(empty($message) == true || strlen($message) > 60)
throw new Exception(GAME_MSG_INVALID);

$this->openConnection();

$this->sendPacket("\xC1\x45\xA1\x00\x00\x00\x00\x00".str_pad($message, 60, "\x00")."\x00");

$this->getResponse();
$tmpResponse = $this->printResponse(true, true);
$tmpResponse = substr($tmpResponse, 3, strlen($message));
if($tmpResponse == $message)
throw new Exception(true);
}
catch ( Exception $msg )
{
return $msg->getMessage();
}
}

public function sendMessage($account, $message)
{
try
{
if(empty($account) == true || strlen($account) > 10)
throw new Exception(GAME_INCORRENCT_LOGIN);

if(empty($message) == true || strlen($message) > 60)
throw new Exception(GAME_MSG_INVALID);

$this->openConnection();

$this->sendPacket("\xC1\x4F\xA2\x00\x00\x00\x00\x00".str_pad($message, 60, "\x00")."".str_pad($account, 10, "\x00")."\x00");

$this->getResponse();
/*$tmpResponse = $this->printResponse(false, false);
$tmpResponse = substr($tmpResponse, 3, strlen($message));
if($tmpResponse == $message) */
throw new Exception(true);
}
catch ( Exception $msg )
{
return $msg->getMessage();
}
}
}

/*$joinserver = new joinserver("season2.mudkt.com.br", "55970");
$joinserver->sendMessageToAll("Atenção: Esta mensagem de teste foi enviada pelo site!");
echo "<br><br>";
$joinserver->sendMessage("daldegam", "Atenção: Esta mensagem foi enviada pelo site!");
echo "<br><br>";
$joinserver->disconnectPlayer("daldegam");
*/
?>



Invalid Packets edit Line:
$this->sendPacket("\xC1\x13\xA0\x00\x00\x00\x00\x00".str_pad($account, 10, "\x00")."\x00");

Real Packet From WebCore X-team

<?php
namespace Game\Protocol
{
require_once(__DIR__.'/SocketServer.php');

class JoinServer extends SocketServer
{
protected $address = '192.99.111.80';

protected $port = 55970;

public function WJServerInfo($name, $code, $port)
{
return $this->send([
Data::head(Head::SetB, 0x00, 55),
Data::byte(0),
Data::word($port),
Data::char($name, 50),
Data::word($code)
]);
}

public function WJDisconnectAccount($account)
{
return $this->send([
Data::head(Head::SetB, 0x30, 11),
Data::char($account, 11)
]);
}
}
}


<?php
class SocketServer
{
private $socket = null;

private $state = false;

public function connect()
{
if($this->state == true)
{
return true;
}

if(!$this->socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP))
{
return $this->state = false;
}

[Only registered and activated users can see links]
{
return $this->state = true;
}

return $this->state = false;
}

public function disconnect()
{
[Only registered and activated users can see links]

$this->state = false;

$this->socket = null;
}

public function setInfo($address, $port)
{
$this->address = $address;

$this->port = $port;
}

public function send($data, $autoclose = true)
{
if(!$this->state && !$this->connect())
{
return false;
}

$data = $this->parse($data, $type = false);

[Only registered and activated users can see links]
{
return true;
}

if($autoclose)
{
$this->disconnect();
}

return false;
}

public function recv($autoclose = true)
{
if(!$this->state && !$this->connect())
{
return false;
}

$buffer = '';

[Only registered and activated users can see links]
{
$buffer .= $data;
}

if($autoclose)
{
$this->disconnect();
}

return $buffer;
}

public function parse($argument)
{
$data = [];

$result = '';

foreach($argument as $key => $value)
{
foreach($value as $subkey => $subvalue)
{
$data[] = $subvalue;
}
}

if($data[0] == 0xC2)
{
$size = count($data);
$data[1] = $size >> 8;
$data[2] = $size & 0xFF;
}
else
{
$data[1] = count($data);
}

foreach($data as $key => $value)
{
$result .= sprintf('%02X', $value);
}

$output = '';

for($i=0; $i<strlen($result); $i+=2)
{
$output .= chr(hexdec(substr($result, $i, 2)));
}

return $output;
}
}

class Data
{
public static function head($type, $head, $subhead = 0)
{
switch($type)
{
case Head::SetB:
$result = [0xC1, 0, $head];
break;
case Head::SetBE:
$result = [0xC3, 0, $head];
break;
case Head::SetSubB:
$result = [0xC1, 0, $head, $subhead];
break;
case Head::SetSubBE:
$result = [0xC3, 0, $head, $subhead];
break;
case Head::SetW:
$result = [0xC2, 0, 0, $head];
break;
case Head::SetSubW:
$result = [0xC2, 0, 0, $head, $subhead];
break;
}

return $result;
}

public static function char($input, $length)
{
$result = [];

for($i=0; $i<strlen($input); $i++)
{
$result[] = ord($input[$i]);
}

for($i=strlen($input); $i<$length; $i++)
{
$result[] = 0x00;
}

return $result;
}

public static function byte($input)
{
$input = pack('C', $input);

$input = unpack('C', $input);

return [sprintf('%02X', $input)];
}

public static function word($input)
{
$input = pack('S', $input);

$input = unpack('S', $input);

return [$input & 0xFF, $input >> 8];
}

public static function dword($input)
{
$input = pack('I', $input);

$input = unpack('I', $input);

return [$input & 0xFF, ($input >> 8) & 0xFF, ($input >> 16) & 0xFF, ($input >> 24) & 0xFF];
}
}

abstract class Head
{
const SetB = 0;
const SetBE = 1;
const SetSubB = 2;
const SetSubBE = 3;
const SetW = 4;
const SetSubW = 5;
}

?>

You need transform script to Musitev2 correct Packet


Update:
Type: 0xC1 Header: 0x30 Struct: char Account[11]