protected void HandleRSAKey(GSPacketIn packet) { RSAParameters parameters = default(RSAParameters); parameters.Modulus = packet.ReadBytes(128); parameters.Exponent = packet.ReadBytes(); RSACryptoServiceProvider rSACryptoServiceProvider = new RSACryptoServiceProvider(); rSACryptoServiceProvider.ImportParameters(parameters); this.SendRSALogin(rSACryptoServiceProvider, this.m_key); }
protected void HandleRSAKey(GSPacketIn packet) { RSAParameters para = new RSAParameters(); para.Modulus = packet.ReadBytes(128); para.Exponent = packet.ReadBytes(); RSACryptoServiceProvider rsa = new RSACryptoServiceProvider(); rsa.ImportParameters(para); SendRSALogin(rsa, _loginKey); }
protected void HandleRSAKey(GSPacketIn packet) { RSAParameters para = default(RSAParameters); para.Modulus = packet.ReadBytes(128); para.Exponent = packet.ReadBytes(); RSACryptoServiceProvider rsa = new RSACryptoServiceProvider(); rsa.ImportParameters(para); this.SendKeyAndName(); }
private void HandleRSAKey(GSPacketIn pkg) { RSAParameters para = default(RSAParameters); para.Modulus = pkg.ReadBytes(128); para.Exponent = pkg.ReadBytes(); RSACryptoServiceProvider rsa = new RSACryptoServiceProvider(); rsa.ImportParameters(para); this.SendRSALogin(rsa, "a3sdfi792kkliasfasdfshu290l-z:)(*"); }
protected void HandleRSAKey(GSPacketIn packet) { RSAParameters para = default(RSAParameters); para.Modulus = packet.ReadBytes(128); para.Exponent = packet.ReadBytes(); RSACryptoServiceProvider rsa = new RSACryptoServiceProvider(); rsa.ImportParameters(para); this.SendRSALogin(rsa, this.m_loginKey); this.SendListenIPPort(IPAddress.Parse(GameServer.Instance.Config.GameIP), GameServer.Instance.Config.GamePort); }
protected void HandleRSAKey(GSPacketIn packet) { RSAParameters para = new RSAParameters(); // packet.ReadBytes(2); para.Modulus = packet.ReadBytes(128); para.Exponent = packet.ReadBytes(); RSACryptoServiceProvider rsa = new RSACryptoServiceProvider(); rsa.ImportParameters(para); SendRSALogin(rsa, m_loginKey); SendListenIPPort(IPAddress.Parse(GameServer.Instance.Configuration.Ip), GameServer.Instance.Configuration.Port); }
public void HandleLogin(GSPacketIn pkg) { string[] strArray = Encoding.UTF8.GetString(this._rsa.Decrypt(pkg.ReadBytes(), false)).Split(new char[1] { ',' }); if (strArray.Length == 2) { this._rsa = (RSACryptoServiceProvider)null; int id = int.Parse(strArray[0]); this.Info = ServerMgr.GetServerInfo(id); if (this.Info == null || this.Info.State != 1) { ServerClient.log.ErrorFormat("Error Login Packet from {0} want to login serverid:{1}", (object)this.TcpEndpoint, (object)id); this.Disconnect(); } else { this.Strict = false; CenterServer.Instance.SendConfigState(); this.Info.Online = 0; this.Info.State = 2; } } else { ServerClient.log.ErrorFormat("Error Login Packet from {0}", (object)this.TcpEndpoint); this.Disconnect(); } }
public void HandleLogin(GSPacketIn pkg) { byte[] rgb = pkg.ReadBytes(); string[] temp = Encoding.UTF8.GetString(this.m_rsa.Decrypt(rgb, false)).Split(new char[] { ',' }); if (temp.Length == 2) { this.m_rsa = null; int id = int.Parse(temp[0]); base.Strict = false; if (temp[1] != FightServer.Instance.Configuration.FightKey) { log.Debug(temp[1]); ServerClient.log.ErrorFormat("Error Login Packet from {0}", base.TcpEndpoint); this.Disconnect(); } } else { ServerClient.log.ErrorFormat("Error Login Packet from {0}", base.TcpEndpoint); this.Disconnect(); } }
/// <summary> /// 战斗服务器登陆 /// </summary> /// <param name="pkg"></param> public void HandleLogin(GSPacketIn pkg) { //pkg.ReadBytes(2); byte[] rgb = pkg.ReadBytes(); string[] temp = Encoding.UTF8.GetString(_rsa.Decrypt(rgb, false)).Split(','); if (temp.Length == 2) { _rsa = null; int id = int.Parse(temp[0]); Info = ServerMgr.GetServerInfo(id); if (Info == null || Info.State != 1) { log.ErrorFormat("Error Login Packet from {0} want to login serverid:{1}", TcpEndpoint, id); Disconnect(); } else { Strict = false; //SendASS(CenterServer.Instance.ASSState); CenterServer.Instance.SendConfigState(); Info.Online = 0; Info.State = 2; } } else { log.ErrorFormat("Error Login Packet from {0}", TcpEndpoint); Disconnect(); } }
public void HandleLogin(GSPacketIn pkg) { var x = pkg.ReadInt(); byte[] rgb = pkg.ReadBytes(x); string content = Encoding.UTF8.GetString(this._rsa.Decrypt(rgb, false)); if (content == MANAGER_KEY) { this.IsManager = true; base.Strict = false; CenterServer.log.Info($"Connected to manager {this.TcpEndpoint}"); return; } else if (content == CLIENT_KEY) { this._rsa = null; int id = pkg.ReadInt(); this.Info = new ServerInfo(); base.Strict = false; var info = this.Info; info.ID = id; info.IP = pkg.ReadString(); info.LowestLevel = 0; info.MustLevel = 100; info.Name = pkg.ReadString(); info.Online = 0; info.Port = pkg.ReadInt(); info.State = 4; if (ServerMgr.Add(id, Info)) { } else { this.Disconnect(); } } else { ServerClient.log.ErrorFormat("Error Login Packet from {0},content:{1}", base.TcpEndpoint, content); this.Disconnect(); } }
public void HandleLogin(GSPacketIn pkg) { byte[] rgb = pkg.ReadBytes(); string[] array = Encoding.UTF8.GetString(this.m_rsa.Decrypt(rgb, false)).Split(new char[] { ',' }); if (array.Length == 2) { this.m_rsa = null; int.Parse(array[0]); base.Strict = false; return; } ServerClient.log.ErrorFormat("Error Login Packet from {0}", base.TcpEndpoint); this.Disconnect(); }
/// <summary> /// 战斗服务器登陆 /// </summary> /// <param name="pkg"></param> public void HandleLogin(GSPacketIn pkg) { byte[] rgb = pkg.ReadBytes(); string[] temp = Encoding.UTF8.GetString(m_rsa.Decrypt(rgb, false)).Split(','); if (temp.Length == 2) { m_rsa = null; int id = int.Parse(temp[0]); //Info = ServerMgr.GetServerInfo(id); Strict = false; } else { log.ErrorFormat("Error Login Packet from {0}", TcpEndpoint); Disconnect(); } }
public int HandlePacket(GameClient client, GSPacketIn packet) { try { GSPacketIn pkg = new GSPacketIn((byte)ePackageType.LOGIN); pkg.ClientID = packet.ClientID; if (client.Player == null) { int version = packet.ReadInt(); int clientType = packet.ReadInt(); byte[] src = packet.ReadBytes(); //解密 try { src = WorldMgr.RsaCryptor.Decrypt(src, false); } catch (ExecutionEngineException e) { client.Out.SendKitoff(LanguageMgr.GetTranslation("UserLoginHandler.RsaCryptorError")); client.Disconnect(); GameServer.log.Error("ExecutionEngineException", e); return(0); } catch (Exception ex) { //防止攻击,如果解密出错,直接断开连接 client.Out.SendKitoff(LanguageMgr.GetTranslation("UserLoginHandler.RsaCryptorError")); client.Disconnect(); GameServer.log.Error("RsaCryptor", ex); return(0); } //DateTime date = new DateTime(src[0] * 256 + src[1], src[2], src[3], src[4], src[5], src[6]); int fms_key = (src[7] << 8) + src[8]; client.SetFsm(fms_key, version); //string edition = GameServer.Instance.Configuration.Edition; string edition = GameServer.Edition; //if (version.ToString() != edition && edition != "0") //{ // client.Out.SendKitoff(LanguageMgr.GetTranslation("UserLoginHandler.EditionError")); // //client.Out.SendEditionError(LanguageMgr.GetTranslation("UserLoginHandler.EditionError")); // client.Disconnect(); // return 0; //} string[] temp = Encoding.UTF8.GetString(src, 9, src.Length - 9).Split(','); if (temp.Length == 2) { string user = temp[0]; string pass = temp[1]; //TimeSpan span = date - DateTime.UtcNow; //if (Math.Abs(span.TotalMinutes) < 5) //{ if (!LoginMgr.ContainsUser(user)) { bool isFirst = false; BaseInterface inter = BaseInterface.CreateInterface(); PlayerInfo cha = inter.LoginGame(user, pass, ref isFirst); if (cha != null && cha.ID != 0) { if (cha.ID == -2) { //帐号被禁用 client.Out.SendKitoff(LanguageMgr.GetTranslation("UserLoginHandler.Forbid")); client.Disconnect(); return(0); } if (!isFirst) { client.Player = new GamePlayer(cha.ID, user, client, cha); LoginMgr.Add(cha.ID, client); client.Server.LoginServer.SendAllowUserLogin(cha.ID); client.Out.SendLoginSuccess2(); client.Version = version; } else { client.Out.SendKitoff(LanguageMgr.GetTranslation("UserLoginHandler.Register")); client.Disconnect(); } } else { //client.Out.SendLoginFailed("用户名密码错误"); client.Out.SendKitoff(LanguageMgr.GetTranslation("UserLoginHandler.OverTime")); client.Disconnect(); } } else { //避免攻击,有另外的客户端在登陆,则断掉次客户端。 client.Out.SendKitoff(LanguageMgr.GetTranslation("UserLoginHandler.LoginError")); client.Disconnect(); } } else { client.Out.SendKitoff(LanguageMgr.GetTranslation("UserLoginHandler.LengthError")); //验证格式错误,端口连接 client.Disconnect(); } } } catch (Exception ex) { client.Out.SendKitoff(LanguageMgr.GetTranslation("UserLoginHandler.ServerError")); client.Disconnect(); GameServer.log.Error(LanguageMgr.GetTranslation("UserLoginHandler.ServerError"), ex); } return(1); }
public int HandlePacket(GameClient client, GSPacketIn packet) { try { if (client.Player == null) { int version = packet.ReadInt(); packet.ReadInt(); byte[] array = new byte[8]; byte[] array2 = packet.ReadBytes(); try { array2 = WorldMgr.RsaCryptor.Decrypt(array2, false); } catch (ExecutionEngineException exception) { client.Out.SendKitoff(LanguageMgr.GetTranslation("UserLoginHandler.RsaCryptorError", new object[0])); client.Disconnect(); GameServer.log.Error("ExecutionEngineException", exception); int result = 0; return(result); } catch (Exception exception2) { client.Out.SendKitoff(LanguageMgr.GetTranslation("UserLoginHandler.RsaCryptorError", new object[0])); client.Disconnect(); GameServer.log.Error("RsaCryptor", exception2); int result = 0; return(result); } string arg_B1_0 = GameServer.Edition; for (int i = 0; i < 8; i++) { array[i] = array2[i + 7]; } client.setKey(array); string[] array3 = Encoding.UTF8.GetString(array2, 15, array2.Length - 15).Split(new char[] { ',' }); if (array3.Length == 2) { string text = array3[0]; string pass = array3[1]; if (!LoginMgr.ContainsUser(text)) { bool flag = false; BaseInterface baseInterface = BaseInterface.CreateInterface(); PlayerInfo playerInfo = baseInterface.LoginGame(text, pass, ref flag); if (playerInfo != null && playerInfo.ID != 0) { if (playerInfo.ID == -2) { client.Out.SendKitoff(LanguageMgr.GetTranslation("UserLoginHandler.Forbid", new object[0])); client.Disconnect(); int result = 0; return(result); } if (!flag) { client.Player = new GamePlayer(playerInfo.ID, text, client, playerInfo); LoginMgr.Add(playerInfo.ID, client); client.Server.LoginServer.SendAllowUserLogin(playerInfo.ID); client.Version = version; } else { client.Out.SendKitoff(LanguageMgr.GetTranslation("UserLoginHandler.Register", new object[0])); client.Disconnect(); } } else { client.Out.SendKitoff(LanguageMgr.GetTranslation("UserLoginHandler.OverTime", new object[0])); client.Disconnect(); } } else { client.Out.SendKitoff(LanguageMgr.GetTranslation("UserLoginHandler.LoginError", new object[0])); client.Disconnect(); } } else { client.Out.SendKitoff(LanguageMgr.GetTranslation("UserLoginHandler.LengthError", new object[0])); client.Disconnect(); } } } catch (Exception exception3) { client.Out.SendKitoff(LanguageMgr.GetTranslation("UserLoginHandler.ServerError", new object[0])); client.Disconnect(); GameServer.log.Error(LanguageMgr.GetTranslation("UserLoginHandler.ServerError", new object[0]), exception3); } return(1); }
public int HandlePacket(GameClient client, GSPacketIn packet) { int result; try { GSPacketIn pkg = packet.Clone(); pkg.ClearContext(); if (client.Player == null) { int version = packet.ReadInt(); int clientType = packet.ReadInt(); byte[] src = packet.ReadBytes(); try { src = WorldMgr.RsaCryptor.Decrypt(src, false); } //catch (ExecutionEngineException e) //{ // client.Out.SendKitoff(LanguageMgr.GetTranslation("UserLoginHandler.RsaCryptorError", new object[0])); /// client.Disconnect(); // GameServer.log.Error("ExecutionEngineException", e); // result = 0; // return result; //} catch (Exception ex) { client.Out.SendKitoff(LanguageMgr.GetTranslation("UserLoginHandler.RsaCryptorError", new object[0])); client.Disconnect(); GameServer.log.Error("RsaCryptor", ex); result = 0; return(result); } int fms_key = ((int)src[7] << 8) + (int)src[8]; client.SetFsm(fms_key, version); string edition = GameServer.Edition; if (version < int.Parse(GameServer.Edition) || version >= int.Parse(GameServer.Edition) + 1000) { client.Out.SendKitoff(LanguageMgr.GetTranslation("UserLoginHandler.EditionError", new object[0])); GameServer.log.Error("Edition Error"); client.Disconnect(); result = 0; return(result); } string[] temp = Encoding.UTF8.GetString(src, 9, src.Length - 9).Split(new char[] { ',' }); if (temp.Length == 2) { string user = temp[0]; string pass = temp[1]; if (!LoginMgr.ContainsUser(user)) { bool isFirst = false; LSJInterface inter = LSJInterface.CreateInterface(); PlayerInfo cha = null; int userID = 0; if (OpenAPIs.ValidateLoginAndGetID(user, pass, ref userID, ref isFirst)) { cha = new PlayerInfo { ID = userID, UserName = user }; } if (cha != null && cha.ID != 0) { if (cha.ID == -2) { client.Out.SendKitoff(LanguageMgr.GetTranslation("UserLoginHandler.Forbid", new object[0])); client.Disconnect(); result = 0; return(result); } if (!isFirst) { client.Player = new GamePlayer(cha.ID, user, client, cha, this.GetClientType(clientType)); LoginMgr.Add(cha.ID, client); client.Server.LoginServer.SendAllowUserLogin(cha.ID); client.Version = version; } else { client.Out.SendKitoff(LanguageMgr.GetTranslation("UserLoginHandler.Register", new object[0])); client.Disconnect(); } } else { client.Out.SendKitoff(LanguageMgr.GetTranslation("UserLoginHandler.OverTime", new object[0])); client.Disconnect(); } } else { client.Out.SendKitoff(LanguageMgr.GetTranslation("UserLoginHandler.LoginError", new object[0])); client.Disconnect(); } } else { client.Out.SendKitoff(LanguageMgr.GetTranslation("UserLoginHandler.LengthError", new object[0])); client.Disconnect(); } } } catch (Exception ex) { client.Out.SendKitoff(LanguageMgr.GetTranslation("UserLoginHandler.ServerError", new object[0])); client.Disconnect(); GameServer.log.Error(LanguageMgr.GetTranslation("UserLoginHandler.ServerError", new object[0]), ex); } result = 1; return(result); }