mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-07-09 11:31:49 +00:00
try...catch attempt to decode connection request in incompatible logins
to allow protocol version hacking without it being so damn inconvenient
This commit is contained in:
parent
e95b1d4b00
commit
8ae663425f
@ -28,6 +28,7 @@ namespace pocketmine\network\mcpe\protocol;
|
|||||||
|
|
||||||
use pocketmine\network\mcpe\NetworkSession;
|
use pocketmine\network\mcpe\NetworkSession;
|
||||||
use pocketmine\utils\BinaryStream;
|
use pocketmine\utils\BinaryStream;
|
||||||
|
use pocketmine\utils\MainLogger;
|
||||||
use pocketmine\utils\Utils;
|
use pocketmine\utils\Utils;
|
||||||
|
|
||||||
class LoginPacket extends DataPacket{
|
class LoginPacket extends DataPacket{
|
||||||
@ -73,9 +74,24 @@ class LoginPacket extends DataPacket{
|
|||||||
$this->offset -= 6;
|
$this->offset -= 6;
|
||||||
$this->protocol = $this->getInt();
|
$this->protocol = $this->getInt();
|
||||||
}
|
}
|
||||||
return; //Do not attempt to continue decoding for non-accepted protocols
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try{
|
||||||
|
$this->decodeConnectionRequest();
|
||||||
|
}catch(\Throwable $e){
|
||||||
|
if($this->protocol === ProtocolInfo::CURRENT_PROTOCOL){
|
||||||
|
throw $e;
|
||||||
|
}
|
||||||
|
|
||||||
|
$logger = MainLogger::getLogger();
|
||||||
|
$logger->debug(get_class($e) . " was thrown while decoding connection request in login (protocol version " . ($this->protocol ?? "unknown") . "): " . $e->getMessage());
|
||||||
|
foreach(\pocketmine\getTrace(0, $e->getTrace()) as $line){
|
||||||
|
$logger->debug($line);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function decodeConnectionRequest() : void{
|
||||||
$buffer = new BinaryStream($this->getString());
|
$buffer = new BinaryStream($this->getString());
|
||||||
|
|
||||||
$this->chainData = json_decode($buffer->get($buffer->getLInt()), true);
|
$this->chainData = json_decode($buffer->get($buffer->getLInt()), true);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user