Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- static void GameServer_AnnounceNewConnection(Interfaces.ISocketWrapper obj)
- {
- obj.Connector = new Client.GameState(obj.Socket);
- Client.GameState Client = obj.Connector as Client.GameState;
- Client.Send(Client.DHKeyExchance.CreateServerKeyPacket());
- }
- static void GameServer_AnnounceReceive(byte[] arg1, Interfaces.ISocketWrapper arg2)
- {
- Client.GameState Client = arg2.Connector as Client.GameState;
- // bool bf = false;
- try
- {
- Client.Cryptography.Decrypt(arg1);
- }
- catch { }
- if (Client != null)
- {
- if (Client.Exchange)
- {
- try
- {
- Client.Exchange = false;
- Client.Action = 1;
- //string PubKey = "";
- //BinaryReader reader = new BinaryReader(new MemoryStream(arg1));
- //reader.ReadBytes(11);
- //int offset = reader.ReadInt32() + 4 + 11;
- //if (offset < arg1.Length)
- //{
- // reader.ReadBytes(offset);
- // int nSize = reader.ReadInt32();
- // if (nSize > 0)
- // {
- // PubKey = Encoding.UTF7.GetString(reader.ReadBytes(nSize));
- // }
- //}
- //Console.WriteLine(PubKey);
- //Client.Cryptography = Client.DHKeyExchance.HandleClientKeyPacket(PubKey, Client.Cryptography);
- ushort position = 7;
- uint PacketLen = BitConverter.ToUInt32(arg1, position); position += 4;
- int JunkLen = BitConverter.ToInt32(arg1, position); position += 4; position += (ushort)JunkLen;
- int Len = BitConverter.ToInt32(arg1, position); position += 4;
- byte[] pubKey = new byte[Len];
- for (int x = 0; x < Len; x++)
- pubKey[x] = arg1[x + position];
- string PubKey = System.Text.UTF7Encoding.UTF7.GetString(pubKey);
- Client.Cryptography = Client.DHKeyExchance.HandleClientKeyPacket(PubKey, Client.Cryptography);
- //Client.cc = Client.DHKeyExchance.HandleClientKeyPacket2(PubKey, Client.cc);
- }
- catch
- {
- Client.Socket.Disconnect(false);
- }
- }
- else
- {
- if (!Client.Exchange && Client.Action != 0)
- Network.PacketHandler.HandleBuffer(arg1, Client);
- // Client.Action = 1;
- }
- //finally
- //{
- }
- }
- static void GameServer_AnnounceDisconnection(Interfaces.ISocketWrapper obj)
- {
- if (obj.Connector != null)
- {
- Client.GameState Client = obj.Connector as Client.GameState;
- Client.Disconnect();
- }
- }
- static void AuthServer_AnnounceNewConnection(Interfaces.ISocketWrapper obj)
- {
- Client.AuthState authState = new Client.AuthState(obj.Socket);
- authState.Cryptographer = new Network.Cryptography.AuthCryptography();
- Network.AuthPackets.PasswordCryptographySeed pcs = new PasswordCryptographySeed();
- pcs.Seed = ServerBase.Kernel.Random.Next();
- authState.PasswordSeed = pcs.Seed;
- authState.Send(pcs);
- obj.Connector = authState;
- }
- static void AuthServer_OnClientSend(byte[] arg1, Interfaces.ISocketWrapper arg2)
- {
- Client.AuthState authState = new Client.AuthState(arg2.Socket);
- authState.Cryptographer = new Network.Cryptography.AuthCryptography();
- Network.GamePackets.PasswordP1 pas = new PasswordP1();
- pas.Unknow1 = 32;
- pas.Name = authState.Account.Username;
- //authState.Send(pas);
- arg2.Connector = authState;
- }
- static void AuthServer_AnnounceReceive(byte[] arg1, Interfaces.ISocketWrapper arg2)
- {
- if (arg1.Length == 240 || arg1.Length == 276)
- {
- Client.AuthState player = arg2.Connector as Client.AuthState;
- player.Cryptographer.Decrypt(arg1);
- byte[] usernamearray = new byte[16];
- Buffer.BlockCopy(arg1, 8, usernamearray, 0, 16);
- string username = Encoding.Default.GetString(usernamearray).Replace("\0", "");
- usernames = username;
- player.Account = new AccountTable(usernames);
- byte[] passwordarray = new byte[16];
- Buffer.BlockCopy(arg1, 72, passwordarray, 0, 16);
- string password = Encoding.Default.GetString(passwordarray).Replace("\0", "");
- string NoNumPadNumbers = "";
- foreach (char c in password)
- {
- switch (c.ToString())
- {
- case "-": NoNumPadNumbers += "0"; break;
- case "#": NoNumPadNumbers += "1"; break;
- case "(": NoNumPadNumbers += "2"; break;
- case "\"": NoNumPadNumbers += "3"; break;
- case "%": NoNumPadNumbers += "4"; break;
- case "\f": NoNumPadNumbers += "5"; break;
- case "'": NoNumPadNumbers += "6"; break;
- case "$": NoNumPadNumbers += "7"; break;
- case "&": NoNumPadNumbers += "8"; break;
- case "!": NoNumPadNumbers += "9"; break;
- default: NoNumPadNumbers += c; break;
- }
- }
- password = NoNumPadNumbers;
- Forward Fw = new Forward();
- if (password == player.Account.Password)
- {
- Fw.Type = Forward.ForwardType.Ready;
- }
- else
- {
- Fw.Type = Forward.ForwardType.InvalidInfo;
- }
- if (Fw.Type != Network.AuthPackets.Forward.ForwardType.InvalidInfo)
- {
- Fw.Identifier = Network.AuthPackets.Forward.Incrementer.Next;
- ServerBase.Kernel.AwaitingPool.Add(Fw.Identifier, player.Account);
- }
- Fw.IP = GameIP;
- Fw.Port = GamePort;
- player.Send(Fw);
- }
- else
- {
- arg2.Socket.Disconnect(false);
- }
- }
- static void AuthServer_AnnounceDisconnection(Interfaces.ISocketWrapper obj)
- {
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement