public Package PlayerJoin(McpeLogin package, Player player) { if (!_notdefaultlevel) { player.Level.BlockBreak += OnBreak; player.Level.BlockPlace += OnPlace; _notdefaultlevel = true; } if (!(_registerlist.Contains(player.User))) { player.AddPopup(new Popup() { Message = "Используй /reg [пароль] для регистрации", MessageType = MessageType.Popup }); } else { player.User = _registerlist.Find(t => t.UserName == player.Username); if (!player.User.IsAuthenticated) player.AddPopup(new Popup() { Message = "Используй /auth [пароль] чтобы войти", MessageType = MessageType.Popup }); } return package; }
public virtual void HandleMcpeLogin(McpeLogin message) { // Only one login! lock (_loginSyncLock) { if (_session.Username != null) { Log.Info($"Player {_session.Username} doing multiple logins"); return; // Already doing login } _session.Username = string.Empty; } _playerInfo.ProtocolVersion = message.protocolVersion; if (MiNetServer.IsRunningOnMono()) { DecodeCertMono(message); } else { DecodeCert(message); } }
public void TestUuid() { var rfc4122Bytes = new byte[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf }; UUID uuid = new UUID(rfc4122Bytes); Assert.AreEqual(rfc4122Bytes, uuid.GetBytes()); Skin skin = new Skin { Slim = false, Texture = Encoding.Default.GetBytes(new string('Z', 8192)) }; var packet = McpeLogin.CreateObject(); packet.username = "******"; packet.protocol = 34; packet.protocol2 = 34; packet.clientId = new Random().Next(); packet.clientUuid = new UUID(Guid.NewGuid().ToByteArray()); packet.serverAddress = "83.249.65.92:19132"; packet.clientSecret = "iwmvi45hm85oncyo58"; packet.skin = skin; var bytes = packet.Encode(); Console.WriteLine(Package.HexDump(bytes, 16)); UUID uuid2 = new UUID(rfc4122Bytes); Dictionary <UUID, string> uuiDictionary = new Dictionary <UUID, string>(); uuiDictionary.Add(uuid, "test"); Assert.AreEqual("test", uuiDictionary[uuid2]); }
public void SendLogin(string username) { Skin skin = new Skin { Slim = false, Texture = Encoding.Default.GetBytes(new string('Z', 8192)) }; skin.SkinType = "Standard_Custom"; //Skin skin = new Skin { Slim = false, Texture = Encoding.Default.GetBytes(new string('Z', 16384)) }; var packet = new McpeLogin() { username = username, protocol = 38, protocol2 = 38, clientId = ClientId, clientUuid = new UUID(Guid.NewGuid().ToByteArray()), serverAddress = _serverEndpoint.Address + ":" + _serverEndpoint.Port, clientSecret = "iwmvi45hm85oncyo58", //clientSecret = Encoding.ASCII.GetString(MD5.Create().ComputeHash(Encoding.UTF8.GetBytes("" + ClientId + _serverEndpoint.Address + _serverEndpoint.Port))), skin = skin, }; byte[] buffer = Player.CompressBytes(packet.Encode(), CompressionLevel.Fastest, true); McpeBatch batch = new McpeBatch(); batch.payloadSize = buffer.Length; batch.payload = buffer; batch.Encode(); SendPackage(batch); LoginSent = true; }
public void TestUuid() { var rfc4122Bytes = new byte[] {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf}; UUID uuid = new UUID(rfc4122Bytes); Assert.AreEqual(rfc4122Bytes, uuid.GetBytes()); Skin skin = new Skin {Slim = false, Texture = Encoding.Default.GetBytes(new string('Z', 8192))}; var packet = new McpeLogin() { username = "******", protocol = 34, protocol2 = 34, clientId = new Random().Next(), clientUuid = new UUID(Guid.NewGuid().ToByteArray()), serverAddress = "83.249.65.92:19132", clientSecret = "iwmvi45hm85oncyo58", skin = skin, }; var bytes = packet.Encode(); Console.WriteLine(Package.HexDump(bytes, 16)); UUID uuid2 = new UUID(rfc4122Bytes); Dictionary<UUID, string> uuiDictionary = new Dictionary<UUID, string>(); uuiDictionary.Add(uuid, "test"); Assert.AreEqual("test", uuiDictionary[uuid2]); }
public virtual void HandleMcpeLogin(McpeLogin message) { // Only one login! lock (_loginSyncLock) { if (_session.Username != null) { Log.Info($"Player {_session.Username} doing multiple logins"); return; // Already doing login } _session.Username = string.Empty; } if (message.protocolVersion < 111) { Log.Warn($"Wrong version ({message.protocolVersion}) of Minecraft Pocket Edition, client need an upgrade."); _session.Disconnect($"Wrong version ({message.protocolVersion}) of Minecraft Pocket Edition, please upgrade."); return; } DecodeCert(message); _playerInfo.Edition = message.edition; ////string fileName = Path.GetTempPath() + "Skin_" + Skin.SkinType + ".png"; ////Log.Info($"Writing skin to filename: {fileName}"); ////Skin.SaveTextureToFile(fileName, Skin.Texture); }
public void TestUuid() { var rfc4122Bytes = new byte[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf }; UUID uuid = new UUID(rfc4122Bytes); Assert.AreEqual(rfc4122Bytes, uuid.GetBytes()); Skin skin = new Skin { Slim = false, Texture = Encoding.Default.GetBytes(new string('Z', 8192)) }; var packet = new McpeLogin() { username = "******", protocol = 34, protocol2 = 34, clientId = new Random().Next(), clientUuid = new UUID(), serverAddress = "83.249.65.92:19132", clientSecret = "iwmvi45hm85oncyo58", skin = skin, }; var bytes = packet.Encode(); Console.WriteLine(Package.HexDump(bytes, 16)); }
public virtual void HandleMcpeLogin(McpeLogin message) { //Disconnect("Este servidor ya no existe. Por favor, conecta a " + ChatColors.Aqua + "play.bladestorm.net" + ChatColors.White + " para seguir jugando."); ////Disconnect("This server is closed. Please connect to " + ChatColors.Aqua + "play.bladestorm.net" + ChatColors.White + " to continue playing."); //return; // Only one login! lock (_loginSyncLock) { if (_session.Username != null) { Log.Info($"Player {_session.Username} doing multiple logins"); return; // Already doing login } _session.Username = string.Empty; } if (message.protocolVersion < 111) { Log.Warn($"Wrong version ({message.protocolVersion}) of Minecraft Pocket Edition, client need an upgrade."); _session.Disconnect($"Wrong version ({message.protocolVersion}) of Minecraft Pocket Edition, please upgrade."); return; } // THIS counter exist to protect the level from being swamped with player list add // attempts during startup (normally). DecodeCert(message); _playerInfo.Edition = message.edition; //if (!message.username.Equals("gurun") && !message.username.Equals("TruDan") && !message.username.Equals("Morehs")) //{ // if (serverInfo.NumberOfPlayers > serverInfo.MaxNumberOfPlayers) // { // Disconnect("Too many players (" + serverInfo.NumberOfPlayers + ") at this time, please try again."); // return; // } // // Use for loadbalance only right now. // if (serverInfo.ConnectionsInConnectPhase > serverInfo.MaxNumberOfConcurrentConnects) // { // Disconnect("Too many concurrent logins (" + serverInfo.ConnectionsInConnectPhase + "), please try again."); // return; // } //} //if (message.username == null || message.username.Trim().Length == 0 || !Regex.IsMatch(message.username, "^[A-Za-z0-9_-]{3,56}$")) //{ // Disconnect("Invalid username."); // return; //} ////string fileName = Path.GetTempPath() + "Skin_" + Skin.SkinType + ".png"; ////Log.Info($"Writing skin to filename: {fileName}"); ////Skin.SaveTextureToFile(fileName, Skin.Texture); }
public Package HandleJoin(McpeLogin packet, Player player) { player.SpawnPosition = new PlayerLocation(spawnPos); player.HealthManager = new PlayerHealthManager(player, this); // show a little welcome message player.AddPopup(new Popup() { MessageType = MessageType.Tip, Message = "§aWelcome on MiniPE!", Duration = 30 }); return(packet); }
public void onBan(McpeLogin package, Player player) { string sql = string.Format("SELECT admin, reason, time FROM banip WHERE player='{0}' OR ip='{1}' OR clientid='{2}';", player.Username.ToLower(), player.EndPoint.Address, GenerateMD5Hash(player.ClientUuid.ToString())); List <object[]> rows = Database.ExecuteQuery(sql); if (rows == null || !rows.Any()) { return; } if (rows[0][0].ToString() != null) { //Log.Info (rows); int time = Convert.ToInt32(rows[0][2].ToString()) / 86400; player.Disconnect(string.Format(LangManager.getLang(Pool.getPlayer(player).lang).getString("authme.ban.message.banned"), rows[0][0].ToString(), time, rows[0][1].ToString()), true); } }
public Package McpeLogin(McpeLogin packet, Player player) { if (PlayersKitActivated.Contains(player.Username)) { PlayersKitActivated.Remove(player.Username); } player.SendMessage(string.Format(ChatColors.Yellow + "Welcome " + player.Username), type: MessageType.Chat); player.AddPopup(new Popup() { Message = $"{ChatColors.Gold}Fury Is Godly At C# ~ USER: " + player.Username, Duration = 99999999, Priority = 1000 }); return(packet); }
public Package PlayerJoinPacket(McpeLogin login, Player player) { if (!MiNETEssentials.playerConfig.ContainsKey(login.username)) { JObject obj = new JObject(); obj["username"] = login.username; obj["lastjoin"] = DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToShortTimeString(); MiNETEssentials.playerConfig.Add(login.username, obj); MiNETEssentials.SavePlayerConfig(); MiNETEssentials.Log.Info(login.username + " has joined for the first time!"); } else MiNETEssentials.Log.Info(login.username + " has joined! Last joined: " + (string)MiNETEssentials.playerConfig[login.username]["lastjoin"]); return login; }
public void SendLogin(string username) { Skin skin = new Skin { Slim = false, Texture = Encoding.Default.GetBytes(new string('Z', 8192)) }; var packet = new McpeLogin() { clientId = 12345, username = username, protocol = 27, skin = skin }; McpeBatch batch = new McpeBatch(); byte[] buffer = CompressBytes(packet.Encode()); batch.payloadSize = buffer.Length; batch.payload = buffer; SendPackage(batch); }
public virtual void HandleMcpeLogin(McpeLogin message) { // Only one login! lock (_loginSyncLock) { if (_session.Username != null) { Log.Info($"Player {_session.Username} doing multiple logins"); return; // Already doing login } _session.Username = string.Empty; } _playerInfo.ProtocolVersion = message.protocolVersion; //_playerInfo.Edition = message.; DecodeCert(message); ////string fileName = Path.GetTempPath() + "Skin_" + Skin.SkinType + ".png"; ////Log.Info($"Writing skin to filename: {fileName}"); ////Skin.SaveTextureToFile(fileName, Skin.Texture); }
protected void DecodeCert(McpeLogin message) { byte[] buffer = message.payload; if (message.payload.Length != buffer.Length) { Log.Debug($"Wrong lenght {message.payload.Length} != {message.payload.Length}"); throw new Exception($"Wrong lenght {message.payload.Length} != {message.payload.Length}"); } if (Log.IsDebugEnabled) { Log.Debug("Lenght: " + message.payload.Length + ", Message: " + Convert.ToBase64String(buffer)); } string certificateChain; string skinData; try { var destination = new MemoryStream(buffer); destination.Position = 0; NbtBinaryReader reader = new NbtBinaryReader(destination, false); var countCertData = reader.ReadInt32(); certificateChain = Encoding.UTF8.GetString(reader.ReadBytes(countCertData)); if (Log.IsDebugEnabled) { Log.Debug($"Certificate Chain (Lenght={countCertData})\n{certificateChain}"); } var countSkinData = reader.ReadInt32(); skinData = Encoding.UTF8.GetString(reader.ReadBytes(countSkinData)); if (Log.IsDebugEnabled) { Log.Debug($"Skin data (Lenght={countSkinData})\n{skinData}"); } } catch (Exception e) { Log.Error("Parsing login", e); return; } try { { IDictionary <string, dynamic> headers = JWT.Headers(skinData); dynamic payload = JObject.Parse(JWT.Payload(skinData)); if (Log.IsDebugEnabled) { Log.Debug($"Skin JWT Header: {string.Join(";", headers)}"); } if (Log.IsDebugEnabled) { Log.Debug($"Skin JWT Payload:\n{payload.ToString()}"); } try { _playerInfo.ClientId = payload.ClientRandomId; _playerInfo.CurrentInputMode = payload.CurrentInputMode; _playerInfo.DefaultInputMode = payload.DefaultInputMode; _playerInfo.DeviceModel = payload.DeviceModel; _playerInfo.DeviceOS = payload.DeviceOS; _playerInfo.GameVersion = payload.GameVersion; _playerInfo.GuiScale = payload.GuiScale; _playerInfo.LanguageCode = payload.LanguageCode; _playerInfo.ServerAddress = payload.ServerAddress; _playerInfo.UIProfile = payload.UIProfile; _playerInfo.Skin = new Skin() { CapeData = Convert.FromBase64String((string)payload.CapeData), SkinId = payload.SkinId, SkinData = Convert.FromBase64String((string)payload.SkinData), SkinGeometryName = payload.SkinGeometryName, SkinGeometry = Convert.FromBase64String((string)payload.SkinGeometry), }; Log.Warn($"Cape data lenght={_playerInfo.Skin.CapeData.Length}"); } catch (Exception e) { Log.Error("Parsing skin data", e); } } { dynamic json = JObject.Parse(certificateChain); if (Log.IsDebugEnabled) { Log.Debug($"Certificate JSON:\n{json}"); } JArray chain = json.chain; //var chainArray = chain.ToArray(); string validationKey = null; string identityPublicKey = null; foreach (JToken token in chain) { IDictionary <string, dynamic> headers = JWT.Headers(token.ToString()); if (Log.IsDebugEnabled) { Log.Debug("Raw chain element:\n" + token.ToString()); Log.Debug($"JWT Header: {string.Join(";", headers)}"); dynamic jsonPayload = JObject.Parse(JWT.Payload(token.ToString())); Log.Debug($"JWT Payload:\n{jsonPayload}"); } // Mojang root x5u cert (string): MHYwEAYHKoZIzj0CAQYFK4EEACIDYgAE8ELkixyLcwlZryUQcu1TvPOmI2B7vX83ndnWRUaXm74wFfa5f/lwQNTfrLVHa2PmenpGI6JhIMUJaWZrjmMj90NoKNFSNBuKdm8rYiXsfaz3K36x/1U26HpG0ZxK/V1V if (!headers.ContainsKey("x5u")) { continue; } string x5u = headers["x5u"]; if (identityPublicKey == null) { if (CertificateData.MojangRootKey.Equals(x5u, StringComparison.InvariantCultureIgnoreCase)) { Log.Debug("Key is ok, and got Mojang root"); } else if (chain.Count > 1) { Log.Debug("Got client cert (client root)"); continue; } else if (chain.Count == 1) { Log.Debug("Selfsigned chain"); } } else if (identityPublicKey.Equals(x5u)) { Log.Debug("Derived Key is ok"); } if (Log.IsDebugEnabled) { Log.Debug($"x5u cert (string): {x5u}"); ECDiffieHellmanPublicKey publicKey = CryptoUtils.CreateEcDiffieHellmanPublicKey(x5u); Log.Debug($"Cert:\n{publicKey.ToXmlString()}"); } // Validate CngKey newKey = CryptoUtils.ImportECDsaCngKeyFromString(x5u); CertificateData data = JWT.Decode <CertificateData>(token.ToString(), newKey); if (data != null) { identityPublicKey = data.IdentityPublicKey; if (Log.IsDebugEnabled) { Log.Debug("Decoded token success"); } if (CertificateData.MojangRootKey.Equals(x5u, StringComparison.InvariantCultureIgnoreCase)) { Log.Debug("Got Mojang key. Is valid = " + data.CertificateAuthority); validationKey = data.IdentityPublicKey; } else if (validationKey != null && validationKey.Equals(x5u, StringComparison.InvariantCultureIgnoreCase)) { _playerInfo.CertificateData = data; } else { if (data.ExtraData == null) { continue; } // Self signed, make sure they don't fake XUID if (data.ExtraData.Xuid != null) { Log.Warn("Received fake XUID from " + data.ExtraData.DisplayName); data.ExtraData.Xuid = null; } _playerInfo.CertificateData = data; } } else { Log.Error("Not a valid Identity Public Key for decoding"); } } //TODO: Implement disconnect here { _playerInfo.Username = _playerInfo.CertificateData.ExtraData.DisplayName; _session.Username = _playerInfo.Username; string identity = _playerInfo.CertificateData.ExtraData.Identity; if (Log.IsDebugEnabled) { Log.Debug($"Connecting user {_playerInfo.Username} with identity={identity}"); } _playerInfo.ClientUuid = new UUID(identity); _session.CryptoContext = new CryptoContext { UseEncryption = Config.GetProperty("UseEncryptionForAll", false) || (Config.GetProperty("UseEncryption", true) && !string.IsNullOrWhiteSpace(_playerInfo.CertificateData.ExtraData.Xuid)), }; if (_session.CryptoContext.UseEncryption) { ECDiffieHellmanPublicKey publicKey = CryptoUtils.CreateEcDiffieHellmanPublicKey(_playerInfo.CertificateData.IdentityPublicKey); if (Log.IsDebugEnabled) { Log.Debug($"Cert:\n{publicKey.ToXmlString()}"); } // Create shared shared secret ECDiffieHellmanCng ecKey = new ECDiffieHellmanCng(384); ecKey.HashAlgorithm = CngAlgorithm.Sha256; ecKey.KeyDerivationFunction = ECDiffieHellmanKeyDerivationFunction.Hash; ecKey.SecretPrepend = Encoding.UTF8.GetBytes("RANDOM SECRET"); // Server token byte[] secret = ecKey.DeriveKeyMaterial(publicKey); if (Log.IsDebugEnabled) { Log.Debug($"SECRET KEY (b64):\n{Convert.ToBase64String(secret)}"); } { RijndaelManaged rijAlg = new RijndaelManaged { BlockSize = 128, Padding = PaddingMode.None, Mode = CipherMode.CFB, FeedbackSize = 8, Key = secret, IV = secret.Take(16).ToArray(), }; // Create a decrytor to perform the stream transform. ICryptoTransform decryptor = rijAlg.CreateDecryptor(rijAlg.Key, rijAlg.IV); MemoryStream inputStream = new MemoryStream(); CryptoStream cryptoStreamIn = new CryptoStream(inputStream, decryptor, CryptoStreamMode.Read); ICryptoTransform encryptor = rijAlg.CreateEncryptor(rijAlg.Key, rijAlg.IV); MemoryStream outputStream = new MemoryStream(); CryptoStream cryptoStreamOut = new CryptoStream(outputStream, encryptor, CryptoStreamMode.Write); _session.CryptoContext.Algorithm = rijAlg; _session.CryptoContext.Decryptor = decryptor; _session.CryptoContext.Encryptor = encryptor; _session.CryptoContext.InputStream = inputStream; _session.CryptoContext.OutputStream = outputStream; _session.CryptoContext.CryptoStreamIn = cryptoStreamIn; _session.CryptoContext.CryptoStreamOut = cryptoStreamOut; } //TODO: JSON now. throw new Exception("JSON!!!"); //var response = McpeServerToClientHandshake.CreateObject(); // response.NoBatch = true; // response.ForceClear = true; //response.token = // response.serverPublicKey = Convert.ToBase64String(ecKey.PublicKey.GetDerEncoded()); // response.tokenLength = (short) ecKey.SecretPrepend.Length; // response.token = ecKey.SecretPrepend; //_session.SendPackage(response); if (Log.IsDebugEnabled) { Log.Warn($"Encryption enabled for {_session.Username}"); } } } } if (!_session.CryptoContext.UseEncryption) { _session.MessageHandler.HandleMcpeClientToServerHandshake(null); } } catch (Exception e) { Log.Error("Decrypt", e); } }
protected virtual void HandleLogin(McpeLogin message) { Stopwatch watch = new Stopwatch(); watch.Restart(); // Only one login! lock (_loginSyncLock) { if (Username != null) { Log.DebugFormat("Player {0} doing multiple logins on Level: {1}", Username, Level.LevelId); return; // Already doing login } Username = message.username; } if (message.protocol != 27) { Disconnect("Outdated Minecraft Pocket Edition, please upgrade."); return; } var serverInfo = Server.ServerInfo; if (!message.username.Equals("gurun") && !message.username.Equals("TruDan")) { if (serverInfo.NumberOfPlayers > serverInfo.MaxNumberOfPlayers) { Disconnect("Too many players (" + serverInfo.NumberOfPlayers + ") at this time, please try again."); return; } // Use for loadbalance only right now. if (serverInfo.ConnectionsInConnectPhase > serverInfo.MaxNumberOfConcurrentConnects) { Disconnect("Too many concurrent logins (" + serverInfo.ConnectionsInConnectPhase + "), please try again."); return; } } if (message.username == null || message.username.Trim().Length == 0 || !Regex.IsMatch(message.username, "^[A-Za-z0-9_-]{3,16}$")) { Disconnect("Invalid username."); return; } if (message.skin.Texture == null) { Disconnect("Invalid skin."); return; } try { Interlocked.Increment(ref serverInfo.ConnectionsInConnectPhase); SendPlayerStatus(0); Username = message.username; ClientId = message.clientId; // Check if the user already exist, that case bumpt the old one Level.RemoveDuplicatePlayers(Username, ClientId); Level.EntityManager.AddEntity(null, this); Session = Server.SessionManager.CreateSession(this); if (Server.IsSecurityEnabled) { User = Server.UserManager.FindByName(Username); } Skin = message.skin; // Start game SendStartGame(); SendSetSpawnPosition(); SendSetTime(); SendSetDificulty(); SendAdventureSettings(); SendSetHealth(); SendSetEntityData(); Level.AddPlayer(this, string.Format("{0} joined the game!", Username), false); LastUpdatedTime = DateTime.UtcNow; SendPlayerInventory(); ThreadPool.QueueUserWorkItem(delegate(object state) { Level.SpawnToAll(this); SendChunksForKnownPosition(); }); LastUpdatedTime = DateTime.UtcNow; Log.InfoFormat("Login complete by: {0} from {2} in {1}ms", message.username, watch.ElapsedMilliseconds, EndPoint); } finally { Interlocked.Decrement(ref serverInfo.ConnectionsInConnectPhase); } }
public void SendLogin(string username) { Skin skin = new Skin {Slim = false, Texture = Encoding.Default.GetBytes(new string('Z', 8192))}; skin.SkinType = "Standard_Custom"; //Skin skin = new Skin { Slim = false, Texture = Encoding.Default.GetBytes(new string('Z', 16384)) }; var packet = new McpeLogin() { username = username, protocol = 39, protocol2 = 39, clientId = ClientId, clientUuid = new UUID(Guid.NewGuid().ToByteArray()), serverAddress = _serverEndpoint.Address + ":" + _serverEndpoint.Port, clientSecret = "iwmvi45hm85oncyo58", //clientSecret = Encoding.ASCII.GetString(MD5.Create().ComputeHash(Encoding.UTF8.GetBytes("" + ClientId + _serverEndpoint.Address + _serverEndpoint.Port))), skin = skin, }; byte[] buffer = Player.CompressBytes(packet.Encode(), CompressionLevel.Fastest, true); McpeBatch batch = new McpeBatch(); batch.payloadSize = buffer.Length; batch.payload = buffer; batch.Encode(); SendPackage(batch); LoginSent = true; }
protected virtual void HandleLogin(McpeLogin message) { //Disconnect("Este servidor ya no existe. Por favor, conecta a " + ChatColors.Aqua + "play.bladestorm.net" + ChatColors.White + " para seguir jugando."); ////Disconnect("This server is closed. Please connect to " + ChatColors.Aqua + "play.bladestorm.net" + ChatColors.White + " to continue playing."); //return; // Only one login! lock (_loginSyncLock) { if (Username != null) { Log.InfoFormat("Player {0} doing multiple logins", Username); return; // Already doing login } Username = message.username; } if (message.protocol < 43) { Server.GreylistManager.Greylist(EndPoint.Address, 30000); Disconnect($"Wrong version ({message.protocol}) of Minecraft Pocket Edition, please upgrade."); return; } //if (!message.username.Equals("gurun") && !message.username.Equals("TruDan") && !message.username.Equals("Morehs")) //{ // if (serverInfo.NumberOfPlayers > serverInfo.MaxNumberOfPlayers) // { // Disconnect("Too many players (" + serverInfo.NumberOfPlayers + ") at this time, please try again."); // return; // } // // Use for loadbalance only right now. // if (serverInfo.ConnectionsInConnectPhase > serverInfo.MaxNumberOfConcurrentConnects) // { // Disconnect("Too many concurrent logins (" + serverInfo.ConnectionsInConnectPhase + "), please try again."); // return; // } //} if (message.username == null || message.username.Trim().Length == 0 || !Regex.IsMatch(message.username, "^[A-Za-z0-9_-]{3,16}$")) { Disconnect("Invalid username."); return; } if (string.IsNullOrEmpty(message.skin.SkinType) || message.skin.Texture == null) { Disconnect("Invalid skin. Please upgrade your version of Minecraft Pocket Edition"); return; } SendPlayerStatus(0); // Hmm, login success? Username = message.username; ClientId = (int) message.clientId; ClientUuid = message.clientUuid; ClientSecret = message.clientSecret; Skin = message.skin; Log.Warn("ClientSecret: " + ClientSecret); //string fileName = Path.GetTempPath() + "Skin_" + Skin.SkinType + ".png"; //Log.Info($"Writing skin to filename: {fileName}"); //Skin.SaveTextureToFile(fileName, Skin.Texture); var serverInfo = Server.ServerInfo; if (ClientSecret != null) { var count = serverInfo.PlayerSessions.Values.Count(session => session.Player != null && ClientSecret.Equals(session.Player.ClientSecret)); if (count != 1) { Disconnect($"Invalid skin {count}."); return; } } // THIS counter exist to protect the level from being swamped with player list add // attempts during startup (normally). Interlocked.Increment(ref serverInfo.ConnectionsInConnectPhase); new Thread(Start).Start(); }
public override void HandleMcpeLogin(McpeLogin message) { base.HandleMcpeLogin(message); }
/// <summary> /// Handles the login. /// </summary> /// <param name="message">The message.</param> /// <exception cref="System.Exception"> /// No username on login /// or /// No username on login /// </exception> protected virtual void HandleLogin(McpeLogin message) { if (Username != null) return; // Already doing login Username = message.username; ClientId = message.clientId; User user = Server.UserManager.FindByName(Username); if (user != null) { Session = Server.SessionManager.FindSession(EndPoint, ClientId, Username); if (Session != null) { User = user; } } Skin = message.skin; //Skin = new Skin { Slim = false, Texture = Encoding.Default.GetBytes(new string('Z', 8192)) }; Log.WarnFormat("Login attempt by: {0}", Username); if (Username.Trim().Length == 0) { SendPackage(new McpePlayerStatus {status = 2}); return; } // Check if the user already exist, that case bumpt the old one Level.RemoveDuplicatePlayers(Username); if (Username.StartsWith("Player")) IsBot = true; // HACK if (Username.StartsWith("Wix")) return; if (Username.StartsWith("Wiz")) return; if (Username.StartsWith("Aga")) return; // Start game Level.EntityManager.AddEntity(null, this); // We send a ping here to get an initial value for chunk-sending _pingSendTime = DateTime.UtcNow.Ticks/TimeSpan.TicksPerMillisecond; SendPackage(new ConnectedPing {sendpingtime = _pingSendTime}); SendPackage(new McpePlayerStatus {status = 0}); SendStartGame(); SendSetSpawnPosition(); SendSetTime(); SendPackage(new McpeSetDifficulty {difficulty = (int) Level.Difficulty}); SendPackage(new McpeAdventureSettings {flags = Level.IsSurvival ? 0x20 : 0x80}); //SendPackage(new McpeAdventureSettings { flags = Level.IsSurvival ? 0x80 : 0x80 }); SendSetHealth(); SendPackage(new McpeSetEntityData { entityId = EntityId, metadata = GetMetadata() }); Level.AddPlayer(this, string.Format("{0} joined the game!", Username)); SendPackage(new McpeContainerSetContent { windowId = 0, slotData = Inventory.Slots, hotbarData = Inventory.ItemHotbar }); SendPackage(new McpeContainerSetContent { windowId = 0x78, // Armor windows ID slotData = Inventory.Armor, hotbarData = null }); //SendPackage(new McpePlayerStatus {status = 3}); SendChunksForKnownPosition(); //IsSpawned = true; LastUpdatedTime = DateTime.UtcNow; }
protected void DecodeCert(McpeLogin message) { // Get bytes byte[] buffer = message.payload; //Log.Debug($"Unknown byte in login packet is: {message.unknown}"); if (message.payload.Length != buffer.Length) { Log.Debug($"Wrong lenght {message.payload.Length} != {message.payload.Length}"); throw new Exception($"Wrong lenght {message.payload.Length} != {message.payload.Length}"); } // Decompress bytes Log.Debug("Lenght: " + message.payload.Length + ", Message: " + Convert.ToBase64String(buffer)); //MemoryStream stream = new MemoryStream(buffer); //if (stream.ReadByte() != 0x78) //{ // throw new InvalidDataException("Incorrect ZLib header. Expected 0x78 0x9C"); //} //stream.ReadByte(); string certificateChain; string skinData; //using (var defStream2 = new DeflateStream(stream, CompressionMode.Decompress, false)) { // Get actual package out of bytes //using (MemoryStream destination = MiNetServer.MemoryStreamManager.GetStream()) { //defStream2.CopyTo(destination); var destination = new MemoryStream(buffer); destination.Position = 0; NbtBinaryReader reader = new NbtBinaryReader(destination, false); try { var countCertData = reader.ReadInt32(); Log.Debug("Count cert: " + countCertData); certificateChain = Encoding.UTF8.GetString(reader.ReadBytes(countCertData)); Log.Debug("Decompressed certificateChain " + certificateChain); var countSkinData = reader.ReadInt32(); Log.Debug("Count skin: " + countSkinData); skinData = Encoding.UTF8.GetString(reader.ReadBytes(countSkinData)); Log.Debug("Decompressed skinData" + skinData); } catch (Exception e) { Log.Error("Parsing login", e); return; } } } try { { if (Log.IsDebugEnabled) { Log.Debug("Input SKIN string: " + skinData); } IDictionary <string, dynamic> headers = JWT.Headers(skinData); dynamic payload = JObject.Parse(JWT.Payload(skinData)); if (Log.IsDebugEnabled) { Log.Debug($"Skin JWT Header: {string.Join(";", headers)}"); } if (Log.IsDebugEnabled) { Log.Debug($"Skin JWT Payload:\n{payload.ToString()}"); } Console.WriteLine(payload); // Skin JWT Payload: //{ // "ClientRandomId": 1423700530444426768, // "CurrentInputMode": 1, // "DefaultInputMode": 1, // "DeviceModel": "ASUSTeK COMPUTER INC. N550JK", // "DeviceOS": 7, // "GameVersion": "1.2.0", // "GuiScale": 0, // "LanguageCode": "en_US", // "ServerAddress": "192.168.0.3:19132", // "SkinData": "SnNH/1+KUf97n2T/AAAAAAAAAAAAAAAAAAAAAAAAAACWlY//q6ur/5aVj/+WlY//q6ur/5aVj/+WlY//q6ur/1JSUv9zbmr/c25q/1JSUv9zbmr/UlJS/3Nuav9zbmr/AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA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Pv87Sz7/O0s+/ztLPv9AX0P/QF9D/0pzR/90Y1T/dGNU/1JLTP90Y1T/UktM/1JLTP90Y1T/VDEo/zsgHP90Y1T/UktM/1JLTP9SS0z/UktM/1JLTP9SS0z/UktM/1JLTP9SS0z/dGNU/3RjVP9SS0z/UktM/1JLTP9AX0P/SnNH/0BfQ/9Kc0f/SnNH/0pzR/9AX0P/SnNH/0BfQ/87Sz7/O0s+/0BfQ/9Kc0f/QF9D/0pzR/9Kc0f/AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=", // "SkinId": "Standard_Custom", // "UIProfile": 0 //} try { _playerInfo.ClientId = payload.ClientRandomId; _playerInfo.CurrentInputMode = payload.CurrentInputMode; _playerInfo.DefaultInputMode = payload.DefaultInputMode; _playerInfo.DeviceModel = payload.DeviceModel; _playerInfo.DeviceOS = payload.DeviceOS; _playerInfo.GameVersion = payload.GameVersion; _playerInfo.GuiScale = payload.GuiScale; _playerInfo.LanguageCode = payload.LanguageCode; _playerInfo.ServerAddress = payload.ServerAddress; _playerInfo.UIProfile = payload.UIProfile; _playerInfo.Skin = new Skin() { SkinType = payload.SkinId, Texture = Convert.FromBase64String((string)payload.SkinData), GeometryType = (string)payload.SkinGeometryName, GeometryData = Encoding.ASCII.GetString(Convert.FromBase64String((string)payload.SkinGeometryData)) }; } catch (Exception e) { Log.Error("Skin info", e); } } { if (Log.IsDebugEnabled) { Log.Debug("Input JSON string: " + certificateChain); } dynamic json = JObject.Parse(certificateChain); if (Log.IsDebugEnabled) { Log.Debug($"JSON:\n{json}"); } string validationKey = null; JArray chain = json.chain; var chainArray = chain.ToArray(); string identityPublicKey = null; foreach (dynamic o in chainArray) { IDictionary <string, dynamic> headers = JWT.Headers(o.ToString()); if (Log.IsDebugEnabled) { Log.Debug("Raw chain element:\n" + o.ToString()); Log.Debug($"JWT Header: {string.Join(";", headers)}"); dynamic jsonPayload = JObject.Parse(JWT.Payload(o.ToString())); Log.Debug($"JWT Payload:\n{jsonPayload}"); } // x5u cert (string): MHYwEAYHKoZIzj0CAQYFK4EEACIDYgAE8ELkixyLcwlZryUQcu1TvPOmI2B7vX83ndnWRUaXm74wFfa5f/lwQNTfrLVHa2PmenpGI6JhIMUJaWZrjmMj90NoKNFSNBuKdm8rYiXsfaz3K36x/1U26HpG0ZxK/V1V if (headers.ContainsKey("x5u")) { string certString = headers["x5u"]; if (identityPublicKey == null && CertificateData.MojangRootKey.Equals(certString, StringComparison.InvariantCultureIgnoreCase)) { Log.Debug("Key is ok, and got Mojang root"); } else if (identityPublicKey == null) { if (chainArray.Length > 1) { Log.Debug("Got client cert (client root)"); continue; } else if (chainArray.Length == 1) { Log.Debug("Selfsigned chain"); } } else if (identityPublicKey.Equals(certString)) { Log.Debug("Derived Key is ok"); } if (Log.IsDebugEnabled) { Log.Debug($"x5u cert (string): {certString}"); ECDiffieHellmanPublicKey publicKey = CryptoUtils.CreateEcDiffieHellmanPublicKey(certString); Log.Debug($"Cert:\n{publicKey.ToXmlString()}"); } // Validate var newKey = CryptoUtils.ImportECDsaCngKeyFromString(certString); CertificateData data = JWT.Decode <CertificateData>(o.ToString(), newKey); if (data != null) { identityPublicKey = data.IdentityPublicKey; if (Log.IsDebugEnabled) { Log.Debug("Decoded token success"); } if (CertificateData.MojangRootKey.Equals(certString, StringComparison.InvariantCultureIgnoreCase)) { Log.Debug("Got Mojang key. Is valid = " + data.CertificateAuthority); validationKey = data.IdentityPublicKey; } else if (validationKey != null && validationKey.Equals(certString, StringComparison.InvariantCultureIgnoreCase)) { _playerInfo.CertificateData = data; } else { if (data.ExtraData == null) { continue; } // Self signed, make sure they don't fake XUID if (data.ExtraData.Xuid != null) { Log.Warn("Received fake XUID from " + data.ExtraData.DisplayName); data.ExtraData.Xuid = null; } _playerInfo.CertificateData = data; } } else { Log.Error("Not a valid Identity Public Key for decoding"); } } } //TODO: Implement disconnect here { _playerInfo.Username = _playerInfo.CertificateData.ExtraData.DisplayName; _session.Username = _playerInfo.Username; string identity = _playerInfo.CertificateData.ExtraData.Identity; if (Log.IsDebugEnabled) { Log.Debug($"Connecting user {_playerInfo.Username} with identity={identity}"); } _playerInfo.ClientUuid = new UUID(identity); _session.CryptoContext = new CryptoContext { UseEncryption = Config.GetProperty("UseEncryptionForAll", false) || (Config.GetProperty("UseEncryption", true) && !string.IsNullOrWhiteSpace(_playerInfo.CertificateData.ExtraData.Xuid)), }; if (_session.CryptoContext.UseEncryption) { ECDiffieHellmanPublicKey publicKey = CryptoUtils.CreateEcDiffieHellmanPublicKey(_playerInfo.CertificateData.IdentityPublicKey); if (Log.IsDebugEnabled) { Log.Debug($"Cert:\n{publicKey.ToXmlString()}"); } // Create shared shared secret ECDiffieHellmanCng ecKey = new ECDiffieHellmanCng(384); ecKey.HashAlgorithm = CngAlgorithm.Sha256; ecKey.KeyDerivationFunction = ECDiffieHellmanKeyDerivationFunction.Hash; ecKey.SecretPrepend = Encoding.UTF8.GetBytes("RANDOM SECRET"); // Server token byte[] secret = ecKey.DeriveKeyMaterial(publicKey); if (Log.IsDebugEnabled) { Log.Debug($"SECRET KEY (b64):\n{Convert.ToBase64String(secret)}"); } { RijndaelManaged rijAlg = new RijndaelManaged { BlockSize = 128, Padding = PaddingMode.None, Mode = CipherMode.CFB, FeedbackSize = 8, Key = secret, IV = secret.Take(16).ToArray(), }; // Create a decrytor to perform the stream transform. ICryptoTransform decryptor = rijAlg.CreateDecryptor(rijAlg.Key, rijAlg.IV); MemoryStream inputStream = new MemoryStream(); CryptoStream cryptoStreamIn = new CryptoStream(inputStream, decryptor, CryptoStreamMode.Read); ICryptoTransform encryptor = rijAlg.CreateEncryptor(rijAlg.Key, rijAlg.IV); MemoryStream outputStream = new MemoryStream(); CryptoStream cryptoStreamOut = new CryptoStream(outputStream, encryptor, CryptoStreamMode.Write); _session.CryptoContext.Algorithm = rijAlg; _session.CryptoContext.Decryptor = decryptor; _session.CryptoContext.Encryptor = encryptor; _session.CryptoContext.InputStream = inputStream; _session.CryptoContext.OutputStream = outputStream; _session.CryptoContext.CryptoStreamIn = cryptoStreamIn; _session.CryptoContext.CryptoStreamOut = cryptoStreamOut; } var response = McpeServerToClientHandshake.CreateObject(); response.NoBatch = true; response.ForceClear = true; string b64Key = Convert.ToBase64String(ecKey.PublicKey.GetDerEncoded()); var j = CngKey.Create(CngAlgorithm.ECDiffieHellmanP384, null, new CngKeyCreationParameters() { ExportPolicy = CngExportPolicies.AllowPlaintextExport, KeyUsage = CngKeyUsages.AllUsages }); var jwt = JWT.Encode(new object[] { new [] { "salt", "sNUMIRcN2BSNRw93P5vGpg==" } }, j, JwsAlgorithm.ES384, new Dictionary <string, object> { { "x5u", b64Key } }); response.token = jwt; _session.SendPackage(response); if (Log.IsDebugEnabled) { Log.Warn($"Encryption enabled for {_session.Username}"); } } } } if (!_session.CryptoContext.UseEncryption) { _session.MessageHandler.HandleMcpeClientToServerHandshake(null); } } catch (Exception e) { Log.Error("Decrypt", e); } }
public Package McpeLogin(McpeLogin packet, Player player) { if (PlayersKitActivated.Contains(player.Username)) { PlayersKitActivated.Remove(player.Username); } player.SendMessage(string.Format(ChatColors.Yellow + "Welcome " + player.Username), type: MessageType.Chat); player.AddPopup(new Popup() { Message = $"{ChatColors.Gold}Fury Is Godly At C# ~ USER: " + player.Username, Duration = 99999999, Priority = 1000 }); return packet; }
/// <summary> /// Handles the login. /// </summary> /// <param name="message">The message.</param> /// <exception cref="System.Exception"> /// No username on login /// or /// No username on login /// </exception> protected virtual void HandleLogin(McpeLogin message) { if (Username != null) return; // Already doing login if (!Regex.IsMatch(message.username, "^[A-Za-z0-9_-]{3,16}$")) { SendPackage(new McpeDisconnect() {message = "Invalid username."}); return; } Username = message.username; ClientId = message.clientId; Session = Server.SessionManager.CreateSession(this); if (Server.IsSecurityEnabled) { User = Server.UserManager.FindByName(Username); } Skin = message.skin; //Skin = new Skin { Slim = false, Texture = Encoding.Default.GetBytes(new string('Z', 8192)) }; Log.WarnFormat("Login attempt by: {0}", Username); if (Username.Trim().Length == 0) { SendPackage(new McpePlayerStatus {status = 2}); return; } // Check if the user already exist, that case bumpt the old one Level.RemoveDuplicatePlayers(Username); if (Username.StartsWith("Player")) IsBot = true; // HACK //if (!Username.StartsWith("gurun")) return; // HACK if (Username.StartsWith("Wix") || EndPoint.Address.ToString().EndsWith("166.91") || (Username.StartsWith("Wiz")) || (Username.StartsWith("Anon")) || (Username.StartsWith("Gang")) || (Username.StartsWith("Pafty")) || (Username.StartsWith("tanker")) || (Username.StartsWith("Chubet")) || (Username.StartsWith("Anth")) || (Username.StartsWith("10de")) ) { SendPackage(new McpeDisconnect() {message = "From [gurun]: You've been temp banned.\nPlease try again later :-)"}); return; } // Start game Level.EntityManager.AddEntity(null, this); // We send a ping here to get an initial value for chunk-sending _pingSendTime = DateTime.UtcNow.Ticks/TimeSpan.TicksPerMillisecond; SendPackage(new ConnectedPing {sendpingtime = _pingSendTime}); SendPackage(new McpePlayerStatus {status = 0}); SendStartGame(); SendSetSpawnPosition(); SendSetTime(); SendPackage(new McpeSetDifficulty {difficulty = (int) Level.Difficulty}); SendPackage(new McpeAdventureSettings {flags = Level.IsSurvival ? 0x20 : 0x80}); //SendPackage(new McpeAdventureSettings { flags = Level.IsSurvival ? 0x80 : 0x80 }); SendSetHealth(); SendPackage(new McpeSetEntityData { entityId = EntityId, metadata = GetMetadata() }); Level.AddPlayer(this, string.Format("{0} joined the game!", Username)); SendPackage(new McpeContainerSetContent { windowId = 0, slotData = Inventory.Slots, hotbarData = Inventory.ItemHotbar }); SendPackage(new McpeContainerSetContent { windowId = 0x78, // Armor windows ID slotData = Inventory.Armor, hotbarData = null }); //SendPackage(new McpePlayerStatus {status = 3}); SendChunksForKnownPosition(); //IsSpawned = true; LastUpdatedTime = DateTime.UtcNow; if (IsBot) { InitializePlayer(); return; } }
private void SendAlexLogin(string username) { JWT.JsonMapper = new NewtonsoftMapper(); var clientKey = XblmsaService.MinecraftKeyPair;// CryptoUtils.GenerateClientKey(); ECDsa signKey = ConvertToSingKeyFormat(clientKey); string b64Key = SubjectPublicKeyInfoFactory.CreateSubjectPublicKeyInfo(clientKey.Public).GetEncoded().EncodeBase64(); string identity, xuid = ""; byte[] certChain = null; if (XblmsaService.MinecraftChain != null) { var element = XblmsaService.DecodedChain.Chain[1]; Username = username = element.ExtraData.DisplayName; identity = element.ExtraData.Identity; xuid = element.ExtraData.Xuid; certChain = XblmsaService.MinecraftChain; Log.Info($"Using signed certificate chain"); } else { long iat = DateTimeOffset.UtcNow.ToUnixTimeSeconds(); long exp = DateTimeOffset.UtcNow.AddDays(1).ToUnixTimeSeconds(); //ECDsa signKey = ConvertToSingKeyFormat(newKey); CertificateData certificateData = new CertificateData { Exp = exp, Iat = iat, ExtraData = new ExtraData { DisplayName = username, Identity = Guid.NewGuid().ToString(), XUID = "" }, Iss = "self", IdentityPublicKey = b64Key, CertificateAuthority = true, Nbf = iat, RandomNonce = new Random().Next(), }; certChain = EncodeJwt(certificateData, b64Key, signKey); } var skinData = EncodeSkinJwt(clientKey, signKey, username, b64Key); byte[] data = CryptoUtils.CompressJwtBytes(certChain, skinData, CompressionLevel.Fastest); McpeLogin loginPacket = new McpeLogin { protocolVersion = McpeProtocolInfo.ProtocolVersion, payload = data }; Session.CryptoContext = new CryptoContext() { ClientKey = clientKey, UseEncryption = false, }; SendPacket(loginPacket); // Session.CryptoContext.UseEncryption = true; }
public void HandleMcpeLogin(McpeLogin message) { WritePackage(message); }
protected void DecodeCert(McpeLogin message) { _playerInfo = new PlayerInfo(); // Get bytes byte[] buffer = message.payload; if (message.payloadLenght != buffer.Length) throw new Exception($"Wrong lenght {message.payloadLenght} != {message.payload.Length}"); // Decompress bytes Log.Debug("Lenght: " + message.payloadLenght + ", Message: " + Convert.ToBase64String(buffer)); MemoryStream stream = new MemoryStream(buffer); if (stream.ReadByte() != 0x78) { throw new InvalidDataException("Incorrect ZLib header. Expected 0x78 0x9C"); } stream.ReadByte(); string certificateChain; string skinData; using (var defStream2 = new DeflateStream(stream, CompressionMode.Decompress, false)) { // Get actual package out of bytes MemoryStream destination = MiNetServer.MemoryStreamManager.GetStream(); defStream2.CopyTo(destination); destination.Position = 0; NbtBinaryReader reader = new NbtBinaryReader(destination, false); try { var countCertData = reader.ReadInt32(); Log.Debug("Count cert: " + countCertData); certificateChain = Encoding.UTF8.GetString(reader.ReadBytes(countCertData)); Log.Debug("Decompressed certificateChain " + certificateChain); var countSkinData = reader.ReadInt32(); Log.Debug("Count skin: " + countSkinData); skinData = Encoding.UTF8.GetString(reader.ReadBytes(countSkinData)); Log.Debug("Decompressed skinData" + skinData); } catch (Exception e) { Log.Error("Parsing login", e); return; } } try { { if (Log.IsDebugEnabled) Log.Debug("Input JSON string: " + certificateChain); dynamic json = JObject.Parse(certificateChain); if (Log.IsDebugEnabled) Log.Debug($"JSON:\n{json}"); string validationKey = null; foreach (dynamic o in json.chain) { IDictionary<string, dynamic> headers = JWT.Headers(o.ToString()); if (Log.IsDebugEnabled) { Log.Debug("Raw chain element:\n" + o.ToString()); Log.Debug($"JWT Header: {string.Join(";", headers)}"); dynamic jsonPayload = JObject.Parse(JWT.Payload(o.ToString())); Log.Debug($"JWT Payload:\n{jsonPayload}"); } // x5u cert (string): MHYwEAYHKoZIzj0CAQYFK4EEACIDYgAE8ELkixyLcwlZryUQcu1TvPOmI2B7vX83ndnWRUaXm74wFfa5f/lwQNTfrLVHa2PmenpGI6JhIMUJaWZrjmMj90NoKNFSNBuKdm8rYiXsfaz3K36x/1U26HpG0ZxK/V1V if (headers.ContainsKey("x5u")) { string certString = headers["x5u"]; if (Log.IsDebugEnabled) { Log.Debug($"x5u cert (string): {certString}"); ECDiffieHellmanPublicKey publicKey = CryptoUtils.CreateEcDiffieHellmanPublicKey(certString); Log.Debug($"Cert:\n{publicKey.ToXmlString()}"); } // Validate CngKey newKey = CryptoUtils.ImportECDsaCngKeyFromString(certString); CertificateData data = JWT.Decode<CertificateData>(o.ToString(), newKey); if (data != null) { if (Log.IsDebugEnabled) Log.Debug("Decoded token success"); if (CertificateData.MojangRootKey.Equals(certString, StringComparison.InvariantCultureIgnoreCase)) { Log.Debug("Got Mojang key. Is valid = " + data.CertificateAuthority); validationKey = data.IdentityPublicKey; } else if (validationKey != null && validationKey.Equals(certString, StringComparison.InvariantCultureIgnoreCase)) { _playerInfo.CertificateData = data; } else { // Self signed, make sure they don't fake XUID if (data.ExtraData.Xuid != null) { Log.Warn("Received fake XUID from " + data.ExtraData.DisplayName); data.ExtraData.Xuid = null; } _playerInfo.CertificateData = data; } } else { Log.Error("Not a valid Identity Public Key for decoding"); } } } //TODO: Implement disconnect here { _playerInfo.Username = _playerInfo.CertificateData.ExtraData.DisplayName; _session.Username = _playerInfo.Username; string identity = _playerInfo.CertificateData.ExtraData.Identity; if (Log.IsDebugEnabled) Log.Debug($"Connecting user {_playerInfo.Username} with identity={identity}"); _playerInfo.ClientUuid = new UUID(new Guid(identity)); _session.CryptoContext = new CryptoContext { UseEncryption = Config.GetProperty("UseEncryptionForAll", false) || (Config.GetProperty("UseEncryption", true) && !string.IsNullOrWhiteSpace(_playerInfo.CertificateData.ExtraData.Xuid)), }; if (_session.CryptoContext.UseEncryption) { ECDiffieHellmanPublicKey publicKey = CryptoUtils.CreateEcDiffieHellmanPublicKey(_playerInfo.CertificateData.IdentityPublicKey); if (Log.IsDebugEnabled) Log.Debug($"Cert:\n{publicKey.ToXmlString()}"); // Create shared shared secret ECDiffieHellmanCng ecKey = new ECDiffieHellmanCng(384); ecKey.HashAlgorithm = CngAlgorithm.Sha256; ecKey.KeyDerivationFunction = ECDiffieHellmanKeyDerivationFunction.Hash; ecKey.SecretPrepend = Encoding.UTF8.GetBytes("RANDOM SECRET"); // Server token byte[] secret = ecKey.DeriveKeyMaterial(publicKey); if (Log.IsDebugEnabled) Log.Debug($"SECRET KEY (b64):\n{Convert.ToBase64String(secret)}"); { RijndaelManaged rijAlg = new RijndaelManaged { BlockSize = 128, Padding = PaddingMode.None, Mode = CipherMode.CFB, FeedbackSize = 8, Key = secret, IV = secret.Take(16).ToArray(), }; // Create a decrytor to perform the stream transform. ICryptoTransform decryptor = rijAlg.CreateDecryptor(rijAlg.Key, rijAlg.IV); MemoryStream inputStream = new MemoryStream(); CryptoStream cryptoStreamIn = new CryptoStream(inputStream, decryptor, CryptoStreamMode.Read); ICryptoTransform encryptor = rijAlg.CreateEncryptor(rijAlg.Key, rijAlg.IV); MemoryStream outputStream = new MemoryStream(); CryptoStream cryptoStreamOut = new CryptoStream(outputStream, encryptor, CryptoStreamMode.Write); _session.CryptoContext.Algorithm = rijAlg; _session.CryptoContext.Decryptor = decryptor; _session.CryptoContext.Encryptor = encryptor; _session.CryptoContext.InputStream = inputStream; _session.CryptoContext.OutputStream = outputStream; _session.CryptoContext.CryptoStreamIn = cryptoStreamIn; _session.CryptoContext.CryptoStreamOut = cryptoStreamOut; } var response = McpeServerExchange.CreateObject(); response.NoBatch = true; response.ForceClear = true; response.serverPublicKey = Convert.ToBase64String(ecKey.PublicKey.GetDerEncoded()); response.tokenLenght = (short) ecKey.SecretPrepend.Length; response.token = ecKey.SecretPrepend; _session.SendPackage(response); if (Log.IsDebugEnabled) Log.Warn($"Encryption enabled for {_session.Username}"); } } } { if (Log.IsDebugEnabled) Log.Debug("Input SKIN string: " + skinData); IDictionary<string, dynamic> headers = JWT.Headers(skinData); dynamic payload = JObject.Parse(JWT.Payload(skinData)); if (Log.IsDebugEnabled) Log.Debug($"Skin JWT Header: {string.Join(";", headers)}"); if (Log.IsDebugEnabled) Log.Debug($"Skin JWT Payload:\n{payload.ToString()}"); // Skin JWT Payload: //{ // "ClientRandomId": -1256727416, // "ServerAddress": "yodamine.com:19132", // "SkinData": "AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP9UJgn/RyEI/1YpCP9GJAj/QR8E/08qCv9NKQn/SyQF//KuaP/yrmj/8q5o//KuaP/yrmj/8q5o//KuaP/yrmj/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAAAAAAAAAAAAAAAAAA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L/AgIC/wICAv8CAgL/AAAA/wAAAP8AAAD/AAAA/wkJCf8FBQX/BgYG/wgICP8ICAj/AAAA/wgICP8ICAj/CAgI/wAAAP8AAAD/AAAA/wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgIC/wICAv8CAgL/AgIC/wICAv8CAgL/AgIC/wICAv8CAgL/AgIC/wICAv8CAgL/AgIC/wICAv8CAgL/AgIC//KuaP/yrmj/8q5o//KuaP/yrmj/AQEB/wAAAP8AAAD/BAMD/wgICP8AAAD/CQkJ/wkICP8AAAD/AAAA//KuaP8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP7+/v/+/v7//v7+//7+/v/+/v7//v7+//7+/v/+/v7//v7+//7+/v/+/v7//v7+//7+/v/+/v7//v7+//7+/v/yrmj/8q5o//KuaP/yrmj/8q5o//KuaP8AAAD/Af/3/wH/9/8B//f/Af/3/wH/9/8B//f/AwIC//KuaP/yrmj/AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==", // "SkinId": "Standard_Custom" //} _playerInfo.ServerAddress = payload.ServerAddress; _playerInfo.ClientId = payload.ClientRandomId; _playerInfo.Skin = new Skin() { SkinType = payload.SkinId, Texture = Convert.FromBase64String((string) payload.SkinData), }; } if (!_session.CryptoContext.UseEncryption) { _session.MessageHandler.HandleMcpeClientMagic(null); } } catch (Exception e) { Log.Error("Decrypt", e); } }
public Package LoginHandler(McpeLogin packet, Player player) { player.DisplayName = TextUtils.Center($"{GetNameTag(packet.username ?? "")}"); return(packet); }
protected void DecodeCertMono(McpeLogin message) { byte[] buffer = message.payload; if (message.payload.Length != buffer.Length) { Log.Debug($"Wrong lenght {message.payload.Length} != {message.payload.Length}"); throw new Exception($"Wrong lenght {message.payload.Length} != {message.payload.Length}"); } if (Log.IsDebugEnabled) { Log.Debug("Lenght: " + message.payload.Length + ", Message: " + buffer.EncodeBase64()); } string certificateChain; string skinData; try { var destination = new MemoryStream(buffer); destination.Position = 0; NbtBinaryReader reader = new NbtBinaryReader(destination, false); var countCertData = reader.ReadInt32(); certificateChain = Encoding.UTF8.GetString(reader.ReadBytes(countCertData)); if (Log.IsDebugEnabled) { Log.Debug($"Certificate Chain (Lenght={countCertData})\n{certificateChain}"); } var countSkinData = reader.ReadInt32(); skinData = Encoding.UTF8.GetString(reader.ReadBytes(countSkinData)); if (Log.IsDebugEnabled) { Log.Debug($"Skin data (Lenght={countSkinData})\n{skinData}"); } } catch (Exception e) { Log.Error("Parsing login", e); return; } try { { IDictionary <string, dynamic> headers = JWT.Headers(skinData); dynamic payload = JObject.Parse(JWT.Payload(skinData)); if (Log.IsDebugEnabled) { Log.Debug($"Skin JWT Header: {string.Join(";", headers)}"); } if (Log.IsDebugEnabled) { Log.Debug($"Skin JWT Payload:\n{payload.ToString()}"); } try { _playerInfo.ClientId = payload.ClientRandomId; _playerInfo.CurrentInputMode = payload.CurrentInputMode; _playerInfo.DefaultInputMode = payload.DefaultInputMode; _playerInfo.DeviceModel = payload.DeviceModel; _playerInfo.DeviceOS = payload.DeviceOS; _playerInfo.GameVersion = payload.GameVersion; _playerInfo.GuiScale = payload.GuiScale; _playerInfo.LanguageCode = payload.LanguageCode; _playerInfo.ServerAddress = payload.ServerAddress; _playerInfo.UIProfile = payload.UIProfile; _playerInfo.Skin = new Skin() { CapeData = Convert.FromBase64String((string)payload.CapeData), SkinId = payload.SkinId, SkinData = Convert.FromBase64String((string)payload.SkinData), SkinGeometryName = payload.SkinGeometryName, SkinGeometry = Encoding.UTF8.GetString(Convert.FromBase64String((string)payload.SkinGeometry)), }; Log.Warn($"Cape data lenght={_playerInfo.Skin.CapeData.Length}"); } catch (Exception e) { Log.Error("Parsing skin data", e); } } //var chainArray = chain.ToArray(); string validationKey = null; string identityPublicKey = null; //if (!isMono) { dynamic json = JObject.Parse(certificateChain); if (Log.IsDebugEnabled) { Log.Debug($"Certificate JSON:\n{json}"); } JArray chain = json.chain; foreach (JToken token in chain) { IDictionary <string, dynamic> headers = JWT.Headers(token.ToString()); if (Log.IsDebugEnabled) { Log.Debug("Raw chain element:\n" + token.ToString()); Log.Debug($"JWT Header: {string.Join(";", headers)}"); dynamic jsonPayload = JObject.Parse(JWT.Payload(token.ToString())); Log.Debug($"JWT Payload:\n{jsonPayload}"); } // Mojang root x5u cert (string): MHYwEAYHKoZIzj0CAQYFK4EEACIDYgAE8ELkixyLcwlZryUQcu1TvPOmI2B7vX83ndnWRUaXm74wFfa5f/lwQNTfrLVHa2PmenpGI6JhIMUJaWZrjmMj90NoKNFSNBuKdm8rYiXsfaz3K36x/1U26HpG0ZxK/V1V if (!headers.ContainsKey("x5u")) { continue; } string x5u = headers["x5u"]; if (identityPublicKey == null) { if (CertificateData.MojangRootKey.Equals(x5u, StringComparison.InvariantCultureIgnoreCase)) { Log.Debug("Key is ok, and got Mojang root"); } else if (chain.Count > 1) { Log.Debug("Got client cert (client root)"); continue; } else if (chain.Count == 1) { Log.Debug("Selfsigned chain"); } } else if (identityPublicKey.Equals(x5u)) { Log.Debug("Derived Key is ok"); } // Validate var key = PublicKeyFactory.CreateKey(x5u.DecodeBase64Url()); CertificateData data = CryptoUtils.Decode(token.ToString(), key); if (data != null) { identityPublicKey = data.IdentityPublicKey; if (Log.IsDebugEnabled) { Log.Debug("Decoded token success"); } if (CertificateData.MojangRootKey.Equals(x5u, StringComparison.InvariantCultureIgnoreCase)) { Log.Debug("Got Mojang key. Is valid = " + data.CertificateAuthority); validationKey = data.IdentityPublicKey; } else if (validationKey != null && validationKey.Equals(x5u, StringComparison.InvariantCultureIgnoreCase)) { _playerInfo.CertificateData = data; } else { if (data.ExtraData == null) { continue; } // Self signed, make sure they don't fake XUID if (data.ExtraData.Xuid != null) { Log.Warn("Received fake XUID from " + data.ExtraData.DisplayName); data.ExtraData.Xuid = null; } _playerInfo.CertificateData = data; } } else { Log.Error("Not a valid Identity Public Key for decoding"); } } } //TODO: Implement disconnect here _playerInfo.Username = _playerInfo.CertificateData.ExtraData.DisplayName; _session.Username = _playerInfo.Username; string identity = _playerInfo.CertificateData.ExtraData.Identity; if (Log.IsDebugEnabled) { Log.Debug($"Connecting user {_playerInfo.Username} with identity={identity}"); } _playerInfo.ClientUuid = new UUID(identity); bool useEncryption = (Config.GetProperty("UseEncryptionForAll", false) || (Config.GetProperty("UseEncryption", true) && !string.IsNullOrWhiteSpace(_playerInfo.CertificateData.ExtraData.Xuid))); if (useEncryption) { var publicKey = PublicKeyFactory.CreateKey(_playerInfo.CertificateData.IdentityPublicKey.DecodeBase64Url()); string namedCurve = "secp384r1"; ECKeyPairGenerator pGen = new ECKeyPairGenerator(); ECKeyGenerationParameters genParam = new ECKeyGenerationParameters( SecNamedCurves.GetOid(namedCurve), new SecureRandom()); pGen.Init(genParam); AsymmetricCipherKeyPair keyPair = pGen.GenerateKeyPair(); ECDHBasicAgreement agreement = new ECDHBasicAgreement(); agreement.Init(keyPair.Private); byte[] preHash = agreement.CalculateAgreement(publicKey).ToByteArray(); byte[] prepend = Encoding.UTF8.GetBytes("RANDOM SECRET"); byte[] secret; SHA256Managed sha = new SHA256Managed(); using (var memoryStream = new MemoryStream()) { memoryStream.Write(prepend, 0, prepend.Length); memoryStream.Write(preHash, 0, preHash.Length); memoryStream.Position = 0; secret = sha.ComputeHash(memoryStream); } sha.Dispose(); //if (Log.IsDebugEnabled) Log.Debug($"SECRET KEY (b64, {secret.Length}):\n{secret.EncodeBase64()}"); { RijndaelManaged rijAlg = new RijndaelManaged { BlockSize = 128, Padding = PaddingMode.None, Mode = CipherMode.CFB, FeedbackSize = 8, Key = secret, IV = secret.Take(16).ToArray(), }; // Create a decrytor to perform the stream transform. ICryptoTransform decryptor = rijAlg.CreateDecryptor(rijAlg.Key, rijAlg.IV); MemoryStream inputStream = new MemoryStream(); CryptoStream cryptoStreamIn = new CryptoStream(inputStream, decryptor, CryptoStreamMode.Read); ICryptoTransform encryptor = rijAlg.CreateEncryptor(rijAlg.Key, rijAlg.IV); MemoryStream outputStream = new MemoryStream(); CryptoStream cryptoStreamOut = new CryptoStream(outputStream, encryptor, CryptoStreamMode.Write); _session.CryptoContext = new CryptoContext { UseEncryption = true, Algorithm = rijAlg, Decryptor = decryptor, Encryptor = encryptor, InputStream = inputStream, OutputStream = outputStream, CryptoStreamIn = cryptoStreamIn, CryptoStreamOut = cryptoStreamOut }; var pubKey1 = ((ECPublicKeyParameters)keyPair.Public); byte[] asn = new byte[24] { 0x30, 0x76, 0x30, 0x10, 0x6, 0x7, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x2, 0x1, 0x6, 0x5, 0x2b, 0x81, 0x4, 0x0, 0x22, 0x3, 0x62, 0x0, 0x4 }; string b64Key = asn.Concat(ConvertToNCryptEccPublicBlob(pubKey1.Q).Skip(8)).ToArray().EncodeBase64(); var handshakeJson = new HandshakeData() { salt = prepend.EncodeBase64() }; string val = CryptoUtils.Encode(handshakeJson, keyPair.Private, JwsAlgorithm.ES384, new Dictionary <string, object> { { "x5u", b64Key } }); var response = McpeServerToClientHandshake.CreateObject(); response.NoBatch = true; response.ForceClear = true; response.token = val; _session.SendPackage(response); if (Log.IsDebugEnabled) { Log.Warn($"Encryption enabled for {_session.Username}"); } } } else { _session.CryptoContext = new CryptoContext { UseEncryption = false }; _session.MessageHandler.HandleMcpeClientToServerHandshake(null); } } catch (Exception e) { Log.Error("Decrypt", e); } }
protected void DecodeCert(McpeLogin message) { _playerInfo = new PlayerInfo(); // Get bytes byte[] buffer = message.payload; //Log.Debug($"Unknown byte in login packet is: {message.unknown}"); if (message.payload.Length != buffer.Length) { Log.Debug($"Wrong lenght {message.payload.Length} != {message.payload.Length}"); throw new Exception($"Wrong lenght {message.payload.Length} != {message.payload.Length}"); } // Decompress bytes Log.Debug("Lenght: " + message.payload.Length + ", Message: " + Convert.ToBase64String(buffer)); //MemoryStream stream = new MemoryStream(buffer); //if (stream.ReadByte() != 0x78) //{ // throw new InvalidDataException("Incorrect ZLib header. Expected 0x78 0x9C"); //} //stream.ReadByte(); string certificateChain; string skinData; //using (var defStream2 = new DeflateStream(stream, CompressionMode.Decompress, false)) { // Get actual package out of bytes //using (MemoryStream destination = MiNetServer.MemoryStreamManager.GetStream()) { //defStream2.CopyTo(destination); var destination = new MemoryStream(buffer); destination.Position = 0; NbtBinaryReader reader = new NbtBinaryReader(destination, false); try { var countCertData = reader.ReadInt32(); Log.Debug("Count cert: " + countCertData); certificateChain = Encoding.UTF8.GetString(reader.ReadBytes(countCertData)); Log.Debug("Decompressed certificateChain " + certificateChain); var countSkinData = reader.ReadInt32(); Log.Debug("Count skin: " + countSkinData); skinData = Encoding.UTF8.GetString(reader.ReadBytes(countSkinData)); Log.Debug("Decompressed skinData" + skinData); } catch (Exception e) { Log.Error("Parsing login", e); return; } } } try { { if (Log.IsDebugEnabled) { Log.Debug("Input SKIN string: " + skinData); } IDictionary <string, dynamic> headers = JWT.Headers(skinData); dynamic payload = JObject.Parse(JWT.Payload(skinData)); if (Log.IsDebugEnabled) { Log.Debug($"Skin JWT Header: {string.Join(";", headers)}"); } if (Log.IsDebugEnabled) { Log.Debug($"Skin JWT Payload:\n{payload.ToString()}"); } // Skin JWT Payload: //{ // "ADRole": 2, // "ClientRandomId": 1423700530444426768, // "CurrentInputMode": 1, // "DefaultInputMode": 1, // "DeviceModel": "ASUSTeK COMPUTER INC. N550JK", // "DeviceOS": 7, // "GameVersion": "1.1.0", // "GuiScale": 0, // "LanguageCode": "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5eQcv+XkHL/l5By/5eQcv90Y1T/UktM/0pzR/9filH/SnNH/1+KUf9Kc0f/QF9D/ztLPv9Kc0f/QF9D/ztLPv87Sz7/QF9D/0pzR/87Sz7/QF9D/0pzR/8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAF+KUf9filH/X4pR/0pzR/+/v7j/QF9D/7+/uP87Sz7/O0s+/ztLPv87Sz7/O0s+/ztLPv9AX0P/QF9D/0pzR/90Y1T/dGNU/1JLTP90Y1T/UktM/1JLTP90Y1T/VDEo/zsgHP90Y1T/UktM/1JLTP9SS0z/UktM/1JLTP9SS0z/UktM/1JLTP9SS0z/dGNU/3RjVP9SS0z/UktM/1JLTP9AX0P/SnNH/0BfQ/9Kc0f/SnNH/0pzR/9AX0P/SnNH/0BfQ/87Sz7/O0s+/0BfQ/9Kc0f/QF9D/0pzR/9Kc0f/AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=", // "SkinId": "Standard_Custom", // "TenantId": "", // "UIProfile": 0 //} try { _playerInfo.ADRole = payload.ADRole; _playerInfo.ClientId = payload.ClientRandomId; _playerInfo.CurrentInputMode = payload.CurrentInputMode; _playerInfo.DefaultInputMode = payload.DefaultInputMode; _playerInfo.DeviceModel = payload.DeviceModel; _playerInfo.DeviceOS = payload.DeviceOS; _playerInfo.GameVersion = payload.GameVersion; _playerInfo.GuiScale = payload.GuiScale; _playerInfo.LanguageCode = payload.LanguageCode; _playerInfo.ServerAddress = payload.ServerAddress; _playerInfo.UIProfile = payload.UIProfile; _playerInfo.Skin = new Skin() { SkinType = payload.SkinId, Texture = Convert.FromBase64String((string)payload.SkinData), }; } catch (Exception e) { Log.Error("Skin info", e); } } { if (Log.IsDebugEnabled) { Log.Debug("Input JSON string: " + certificateChain); } dynamic json = JObject.Parse(certificateChain); if (Log.IsDebugEnabled) { Log.Debug($"JSON:\n{json}"); } string validationKey = null; foreach (dynamic o in json.chain) { IDictionary <string, dynamic> headers = JWT.Headers(o.ToString()); dynamic jsonPayload = JObject.Parse(JWT.Payload(o.ToString())); if (Log.IsDebugEnabled) { Log.Debug("Raw chain element:\n" + o.ToString()); Log.Debug($"JWT Header: {string.Join(";", headers)}"); Log.Debug($"JWT Payload:\n{jsonPayload}"); } if (jsonPayload["extraData"] == null) { continue; } _playerInfo.Username = jsonPayload["extraData"]["displayName"]; _session.Username = _playerInfo.Username; string identity = jsonPayload["extraData"]["identity"]; _playerInfo.ClientUuid = new UUID(new Guid(identity).ToByteArray()); _session.CryptoContext = new CryptoContext { UseEncryption = false }; if (jsonPayload["extraData"]["XUID"] != null) { _playerInfo.CertificateData = new CertificateData { ExtraData = new ExtraData { Xuid = jsonPayload["extraData"]["XUID"] } }; } else { _playerInfo.CertificateData = new CertificateData { ExtraData = new ExtraData { Xuid = "" } }; } } } if (!_session.CryptoContext.UseEncryption) { _session.MessageHandler.HandleMcpeClientToServerHandshake(null); } } catch (Exception e) { Log.Error("Decrypt", e); } }
/// <summary> /// Handles the login. /// </summary> /// <param name="message">The message.</param> /// <exception cref="System.Exception"> /// No username on login /// or /// No username on login /// </exception> private void HandleLogin(McpeLogin message) { if (Username != null) return; // Already doing login Username = message.username; ClientId = message.clientId; Skin = message.skin; //Skin = new Skin { Slim = false, Texture = Encoding.Default.GetBytes(new string('Z', 8192)) }; Log.WarnFormat("Login attempt by: {0}", Username); if (Username.Trim().Length == 0) { SendPackage(new McpePlayerStatus {status = 2}); return; } //Success = 0; //FailedClientIsOld = 1; //FailedServerIsOld, FailedClientIsNew = 2; //FailedPlayerAuthentication = 3; //if (Server.UserManager != null) //{ // if (Username == null || Server.UserManager.FindByName(Username) == null) // { // //TODO: Must implement disconnect properly. This is not enough for the client to "get it". // SendPackage(new McpeLoginStatus {status = 3}); // return; // } //} // Check if the user already exist, that case bumpt the old one Level.RemoveDuplicatePlayers(Username); if (Username.StartsWith("Player")) IsBot = true; if (Username.StartsWith("Wix")) return; if (Username.StartsWith("Wiz")) return; //LoadFromFile(); // Start game Level.EntityManager.AddEntity(null, this); //const LOGIN_SUCCESS = 0; //const LOGIN_FAILED_CLIENT = 1; //const LOGIN_FAILED_SERVER = 2; //const PLAYER_SPAWN = 3; _pingSendTime = DateTime.UtcNow.Ticks/TimeSpan.TicksPerMillisecond; SendPackage(new ConnectedPing {sendpingtime = _pingSendTime}); SendPackage(new McpePlayerStatus {status = 0}); SendStartGame(); SendSetSpawnPosition(); SendSetTime(); SendPackage(new McpeSetDifficulty {difficulty = (int) Level.Difficulty}); SendPackage(new McpeAdventureSettings {flags = Level.IsSurvival ? 0x20 : 0x80}); //SendPackage(new McpeAdventureSettings { flags = Level.IsSurvival ? 0x80 : 0x80 }); SendSetHealth(); SendPackage(new McpeSetEntityData { entityId = EntityId, metadata = GetMetadata() }); Level.AddPlayer(this, string.Format("{0} joined the game!", Username)); SendPackage(new McpeContainerSetContent { windowId = 0, slotData = Inventory.Slots, hotbarData = Inventory.ItemHotbar }); SendPackage(new McpeContainerSetContent { windowId = 0x78, // Armor windows ID slotData = Inventory.Armor, hotbarData = null }); //SendPackage(new McpePlayerStatus {status = 3}); SendChunksForKnownPosition(); //IsSpawned = true; LastUpdatedTime = DateTime.UtcNow; }
public void SendLogin(string username) { Skin skin = new Skin {Slim = false, Texture = Encoding.Default.GetBytes(new string('Z', 8192))}; var packet = new McpeLogin() { clientId = 12345, username = username, protocol = 27, skin = skin }; McpeBatch batch = new McpeBatch(); byte[] buffer = CompressBytes(packet.Encode()); batch.payloadSize = buffer.Length; batch.payload = buffer; SendPackage(batch); }
/// <summary> /// Handles the login. /// </summary> /// <param name="message">The message.</param> /// <exception cref="System.Exception"> /// No username on login /// or /// No username on login /// </exception> protected virtual void HandleLogin(McpeLogin message) { if (Username != null) { return; // Already doing login } Username = message.username; ClientId = message.clientId; User user = Server.UserManager.FindByName(Username); if (user != null) { Session = Server.SessionManager.FindSession(EndPoint, ClientId, Username); if (Session != null) { User = user; } } Skin = message.skin; //Skin = new Skin { Slim = false, Texture = Encoding.Default.GetBytes(new string('Z', 8192)) }; Log.WarnFormat("Login attempt by: {0}", Username); if (Username.Trim().Length == 0) { SendPackage(new McpePlayerStatus { status = 2 }); return; } // Check if the user already exist, that case bumpt the old one Level.RemoveDuplicatePlayers(Username); if (Username.StartsWith("Player")) { IsBot = true; // HACK } if (Username.StartsWith("Wix")) { return; } if (Username.StartsWith("Wiz")) { return; } if (Username.StartsWith("Aga")) { return; } // Start game Level.EntityManager.AddEntity(null, this); // We send a ping here to get an initial value for chunk-sending _pingSendTime = DateTime.UtcNow.Ticks / TimeSpan.TicksPerMillisecond; SendPackage(new ConnectedPing { sendpingtime = _pingSendTime }); SendPackage(new McpePlayerStatus { status = 0 }); SendStartGame(); SendSetSpawnPosition(); SendSetTime(); SendPackage(new McpeSetDifficulty { difficulty = (int)Level.Difficulty }); SendPackage(new McpeAdventureSettings { flags = Level.IsSurvival ? 0x20 : 0x80 }); //SendPackage(new McpeAdventureSettings { flags = Level.IsSurvival ? 0x80 : 0x80 }); SendSetHealth(); SendPackage(new McpeSetEntityData { entityId = EntityId, metadata = GetMetadata() }); Level.AddPlayer(this, string.Format("{0} joined the game!", Username)); SendPackage(new McpeContainerSetContent { windowId = 0, slotData = Inventory.Slots, hotbarData = Inventory.ItemHotbar }); SendPackage(new McpeContainerSetContent { windowId = 0x78, // Armor windows ID slotData = Inventory.Armor, hotbarData = null }); //SendPackage(new McpePlayerStatus {status = 3}); SendChunksForKnownPosition(); //IsSpawned = true; LastUpdatedTime = DateTime.UtcNow; }
/// <summary> /// Handles the login. /// </summary> /// <param name="message">The message.</param> /// <exception cref="System.Exception"> /// No username on login /// or /// No username on login /// </exception> private void HandleLogin(McpeLogin message) { if (Username != null) { return; // Already doing login } Username = message.username; ClientId = message.clientId; Skin = message.skin; //Skin = new Skin { Slim = false, Texture = Encoding.Default.GetBytes(new string('Z', 8192)) }; Log.WarnFormat("Login attempt by: {0}", Username); if (Username.Trim().Length == 0) { SendPackage(new McpePlayerStatus { status = 2 }); return; } //Success = 0; //FailedClientIsOld = 1; //FailedServerIsOld, FailedClientIsNew = 2; //FailedPlayerAuthentication = 3; //if (Server.UserManager != null) //{ // if (Username == null || Server.UserManager.FindByName(Username) == null) // { // //TODO: Must implement disconnect properly. This is not enough for the client to "get it". // SendPackage(new McpeLoginStatus {status = 3}); // return; // } //} // Check if the user already exist, that case bumpt the old one Level.RemoveDuplicatePlayers(Username); if (Username.StartsWith("Player")) { IsBot = true; } if (Username.StartsWith("Wix")) { return; } if (Username.StartsWith("Wiz")) { return; } //LoadFromFile(); // Start game Level.EntityManager.AddEntity(null, this); //const LOGIN_SUCCESS = 0; //const LOGIN_FAILED_CLIENT = 1; //const LOGIN_FAILED_SERVER = 2; //const PLAYER_SPAWN = 3; _pingSendTime = DateTime.UtcNow.Ticks / TimeSpan.TicksPerMillisecond; SendPackage(new ConnectedPing { sendpingtime = _pingSendTime }); SendPackage(new McpePlayerStatus { status = 0 }); SendStartGame(); SendSetSpawnPosition(); SendSetTime(); SendPackage(new McpeSetDifficulty { difficulty = (int)Level.Difficulty }); SendPackage(new McpeAdventureSettings { flags = Level.IsSurvival ? 0x20 : 0x80 }); //SendPackage(new McpeAdventureSettings { flags = Level.IsSurvival ? 0x80 : 0x80 }); SendSetHealth(); SendPackage(new McpeSetEntityData { entityId = EntityId, metadata = GetMetadata() }); Level.AddPlayer(this, string.Format("{0} joined the game!", Username)); SendPackage(new McpeContainerSetContent { windowId = 0, slotData = Inventory.Slots, hotbarData = Inventory.ItemHotbar }); SendPackage(new McpeContainerSetContent { windowId = 0x78, // Armor windows ID slotData = Inventory.Armor, hotbarData = null }); //SendPackage(new McpePlayerStatus {status = 3}); SendChunksForKnownPosition(); //IsSpawned = true; LastUpdatedTime = DateTime.UtcNow; }
protected void DecodeCert(McpeLogin message) { _playerInfo = new PlayerInfo(); // Get bytes byte[] buffer = message.payload; //Log.Debug($"Unknown byte in login packet is: {message.unknown}"); if (message.payload.Length != buffer.Length) { Log.Debug($"Wrong lenght {message.payload.Length} != {message.payload.Length}"); throw new Exception($"Wrong lenght {message.payload.Length} != {message.payload.Length}"); } // Decompress bytes Log.Debug("Lenght: " + message.payload.Length + ", Message: " + Convert.ToBase64String(buffer)); //MemoryStream stream = new MemoryStream(buffer); //if (stream.ReadByte() != 0x78) //{ // throw new InvalidDataException("Incorrect ZLib header. Expected 0x78 0x9C"); //} //stream.ReadByte(); string certificateChain; string skinData; //using (var defStream2 = new DeflateStream(stream, CompressionMode.Decompress, false)) { // Get actual package out of bytes //using (MemoryStream destination = MiNetServer.MemoryStreamManager.GetStream()) { //defStream2.CopyTo(destination); var destination = new MemoryStream(buffer); destination.Position = 0; NbtBinaryReader reader = new NbtBinaryReader(destination, false); try { var countCertData = reader.ReadInt32(); Log.Debug("Count cert: " + countCertData); certificateChain = Encoding.UTF8.GetString(reader.ReadBytes(countCertData)); Log.Debug("Decompressed certificateChain " + certificateChain); var countSkinData = reader.ReadInt32(); Log.Debug("Count skin: " + countSkinData); skinData = Encoding.UTF8.GetString(reader.ReadBytes(countSkinData)); Log.Debug("Decompressed skinData" + skinData); } catch (Exception e) { Log.Error("Parsing login", e); return; } } } try { { if (Log.IsDebugEnabled) { Log.Debug("Input SKIN string: " + skinData); } IDictionary <string, dynamic> headers = JWT.Headers(skinData); dynamic payload = JObject.Parse(JWT.Payload(skinData)); if (Log.IsDebugEnabled) { Log.Debug($"Skin JWT Header: {string.Join(";", headers)}"); } if (Log.IsDebugEnabled) { Log.Debug($"Skin JWT Payload:\n{payload.ToString()}"); } // Skin JWT Payload: //{ // "ADRole": 2, // "ClientRandomId": -1256727416, // "CurrentInputMode": 2, // "DefaultInputMode": 2, // "DeviceModel": "SAMSUNG GT-P5210", // "DeviceOS": 1, // "GameVersion": "1.0.3.0", // "GuiScale": 0, // "ServerAddress": "192.168.0.3:19132", // "SkinData": "AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP9UJgn/RyEI/1YpCP9GJAj/QR8E/08qCv9NKQn/SyQF//KuaP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AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAgL//v7+/wICAv8CAgL/AgIC/wH/9/8B//f/AgIC/wICAv8UFBT/Af/3/wICAv8CAgL/AgIC/wICAv8CAgL/AAAA/wAAAP8AAAD/AAAA/wkJCf8FBQX/BgYG/wgICP8ICAj/AAAA/wgICP8ICAj/CAgI/wAAAP8AAAD/AAAA/wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgIC/wICAv8CAgL/AgIC/wICAv8CAgL/AgIC/wICAv8CAgL/AgIC/wICAv8CAgL/AgIC/wICAv8CAgL/AgIC//KuaP/yrmj/8q5o//KuaP/yrmj/AQEB/wAAAP8AAAD/BAMD/wgICP8AAAD/CQkJ/wkICP8AAAD/AAAA//KuaP8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP7+/v/+/v7//v7+//7+/v/+/v7//v7+//7+/v/+/v7//v7+//7+/v/+/v7//v7+//7+/v/+/v7//v7+//7+/v/yrmj/8q5o//KuaP/yrmj/8q5o//KuaP8AAAD/Af/3/wH/9/8B//f/Af/3/wH/9/8B//f/AwIC//KuaP/yrmj/AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==", // "SkinId": "Standard_Custom", // "TenantId": "", // "UIProfile": 1 //} try { _playerInfo.ADRole = payload.ADRole; _playerInfo.ClientId = payload.ClientRandomId; _playerInfo.CurrentInputMode = payload.CurrentInputMode; _playerInfo.DefaultInputMode = payload.DefaultInputMode; _playerInfo.DeviceModel = payload.DeviceModel; _playerInfo.DeviceOS = payload.DeviceOS; _playerInfo.GameVersion = payload.GameVersion; _playerInfo.GuiScale = payload.GuiScale; _playerInfo.ServerAddress = payload.ServerAddress; _playerInfo.UIProfile = payload.UIProfile; _playerInfo.Skin = new Skin() { SkinType = payload.SkinId, Texture = Convert.FromBase64String((string)payload.SkinData), }; } catch (Exception e) { Log.Error("Skin info", e); } } { if (Log.IsDebugEnabled) { Log.Debug("Input JSON string: " + certificateChain); } dynamic json = JObject.Parse(certificateChain); if (Log.IsDebugEnabled) { Log.Debug($"JSON:\n{json}"); } string validationKey = null; foreach (dynamic o in json.chain) { IDictionary <string, dynamic> headers = JWT.Headers(o.ToString()); if (Log.IsDebugEnabled) { Log.Debug("Raw chain element:\n" + o.ToString()); Log.Debug($"JWT Header: {string.Join(";", headers)}"); dynamic jsonPayload = JObject.Parse(JWT.Payload(o.ToString())); Log.Debug($"JWT Payload:\n{jsonPayload}"); } // x5u cert (string): MHYwEAYHKoZIzj0CAQYFK4EEACIDYgAE8ELkixyLcwlZryUQcu1TvPOmI2B7vX83ndnWRUaXm74wFfa5f/lwQNTfrLVHa2PmenpGI6JhIMUJaWZrjmMj90NoKNFSNBuKdm8rYiXsfaz3K36x/1U26HpG0ZxK/V1V if (headers.ContainsKey("x5u")) { string certString = headers["x5u"]; if (Log.IsDebugEnabled) { Log.Debug($"x5u cert (string): {certString}"); ECDiffieHellmanPublicKey publicKey = CryptoUtils.CreateEcDiffieHellmanPublicKey(certString); Log.Debug($"Cert:\n{publicKey.ToXmlString()}"); } // Validate CngKey newKey = CryptoUtils.ImportECDsaCngKeyFromString(certString); CertificateData data = JWT.Decode <CertificateData>(o.ToString(), newKey); if (data != null) { if (Log.IsDebugEnabled) { Log.Debug("Decoded token success"); } if (CertificateData.MojangRootKey.Equals(certString, StringComparison.InvariantCultureIgnoreCase)) { Log.Debug("Got Mojang key. Is valid = " + data.CertificateAuthority); validationKey = data.IdentityPublicKey; } else if (validationKey != null && validationKey.Equals(certString, StringComparison.InvariantCultureIgnoreCase)) { _playerInfo.CertificateData = data; } else { if (data.ExtraData == null) { continue; } // Self signed, make sure they don't fake XUID if (data.ExtraData.Xuid != null) { Log.Warn("Received fake XUID from " + data.ExtraData.DisplayName); data.ExtraData.Xuid = null; } _playerInfo.CertificateData = data; } } else { Log.Error("Not a valid Identity Public Key for decoding"); } } } //TODO: Implement disconnect here { _playerInfo.Username = _playerInfo.CertificateData.ExtraData.DisplayName; _session.Username = _playerInfo.Username; string identity = _playerInfo.CertificateData.ExtraData.Identity; if (Log.IsDebugEnabled) { Log.Debug($"Connecting user {_playerInfo.Username} with identity={identity}"); } _playerInfo.ClientUuid = new UUID(identity); _session.CryptoContext = new CryptoContext { UseEncryption = Config.GetProperty("UseEncryptionForAll", false) || (Config.GetProperty("UseEncryption", true) && !string.IsNullOrWhiteSpace(_playerInfo.CertificateData.ExtraData.Xuid)), }; if (_session.CryptoContext.UseEncryption) { ECDiffieHellmanPublicKey publicKey = CryptoUtils.CreateEcDiffieHellmanPublicKey(_playerInfo.CertificateData.IdentityPublicKey); if (Log.IsDebugEnabled) { Log.Debug($"Cert:\n{publicKey.ToXmlString()}"); } // Create shared shared secret ECDiffieHellmanCng ecKey = new ECDiffieHellmanCng(384); ecKey.HashAlgorithm = CngAlgorithm.Sha256; ecKey.KeyDerivationFunction = ECDiffieHellmanKeyDerivationFunction.Hash; ecKey.SecretPrepend = Encoding.UTF8.GetBytes("RANDOM SECRET"); // Server token byte[] secret = ecKey.DeriveKeyMaterial(publicKey); if (Log.IsDebugEnabled) { Log.Debug($"SECRET KEY (b64):\n{Convert.ToBase64String(secret)}"); } { RijndaelManaged rijAlg = new RijndaelManaged { BlockSize = 128, Padding = PaddingMode.None, Mode = CipherMode.CFB, FeedbackSize = 8, Key = secret, IV = secret.Take(16).ToArray(), }; // Create a decrytor to perform the stream transform. ICryptoTransform decryptor = rijAlg.CreateDecryptor(rijAlg.Key, rijAlg.IV); MemoryStream inputStream = new MemoryStream(); CryptoStream cryptoStreamIn = new CryptoStream(inputStream, decryptor, CryptoStreamMode.Read); ICryptoTransform encryptor = rijAlg.CreateEncryptor(rijAlg.Key, rijAlg.IV); MemoryStream outputStream = new MemoryStream(); CryptoStream cryptoStreamOut = new CryptoStream(outputStream, encryptor, CryptoStreamMode.Write); _session.CryptoContext.Algorithm = rijAlg; _session.CryptoContext.Decryptor = decryptor; _session.CryptoContext.Encryptor = encryptor; _session.CryptoContext.InputStream = inputStream; _session.CryptoContext.OutputStream = outputStream; _session.CryptoContext.CryptoStreamIn = cryptoStreamIn; _session.CryptoContext.CryptoStreamOut = cryptoStreamOut; } var response = McpeServerToClientHandshake.CreateObject(); response.NoBatch = true; response.ForceClear = true; response.serverPublicKey = Convert.ToBase64String(ecKey.PublicKey.GetDerEncoded()); response.tokenLength = (short)ecKey.SecretPrepend.Length; response.token = ecKey.SecretPrepend; _session.SendPackage(response); if (Log.IsDebugEnabled) { Log.Warn($"Encryption enabled for {_session.Username}"); } } } } if (!_session.CryptoContext.UseEncryption) { _session.MessageHandler.HandleMcpeClientToServerHandshake(null); } } catch (Exception e) { Log.Error("Decrypt", e); } }
public virtual void HandleMcpeLogin(McpeLogin message) { //Disconnect("Este servidor ya no existe. Por favor, conecta a " + ChatColors.Aqua + "play.bladestorm.net" + ChatColors.White + " para seguir jugando."); ////Disconnect("This server is closed. Please connect to " + ChatColors.Aqua + "play.bladestorm.net" + ChatColors.White + " to continue playing."); //return; // Only one login! lock (_loginSyncLock) { if (_session.Username != null) { Log.Info($"Player {_session.Username} doing multiple logins"); return; // Already doing login } _session.Username = string.Empty; } if (message.protocolVersion != 81) { _session.Disconnect($"Wrong version ({message.protocolVersion}) of Minecraft Pocket Edition, please upgrade."); return; } // THIS counter exist to protect the level from being swamped with player list add // attempts during startup (normally). DecodeCert(message); //if (!message.username.Equals("gurun") && !message.username.Equals("TruDan") && !message.username.Equals("Morehs")) //{ // if (serverInfo.NumberOfPlayers > serverInfo.MaxNumberOfPlayers) // { // Disconnect("Too many players (" + serverInfo.NumberOfPlayers + ") at this time, please try again."); // return; // } // // Use for loadbalance only right now. // if (serverInfo.ConnectionsInConnectPhase > serverInfo.MaxNumberOfConcurrentConnects) // { // Disconnect("Too many concurrent logins (" + serverInfo.ConnectionsInConnectPhase + "), please try again."); // return; // } //} //if (message.username == null || message.username.Trim().Length == 0 || !Regex.IsMatch(message.username, "^[A-Za-z0-9_-]{3,56}$")) //{ // Disconnect("Invalid username."); // return; //} ////string fileName = Path.GetTempPath() + "Skin_" + Skin.SkinType + ".png"; ////Log.Info($"Writing skin to filename: {fileName}"); ////Skin.SaveTextureToFile(fileName, Skin.Texture); }