Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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_AnnounceDisconnection(Interfaces.ISocketWrapper obj)
- {
- if (obj != null)
- {
- Client.AuthState client = (Client.AuthState)obj.Connector;
- if (client != null)
- {
- client.Disconnect();
- }
- }
- }
- static void AuthServer_AnnounceReceive(byte[] packet, Interfaces.ISocketWrapper StO)
- {
- try
- {
- Client.AuthState client = (Client.AuthState)StO.Connector;
- if (packet.Length == 276)
- {
- client.Cryptographer.Decrypt(packet);
- if (BitConverter.ToUInt16(packet, 2) == 1060)
- {
- client.Info = new Conquer_Online_Server.Network.AuthPackets.Authentication();
- client.Info.Deserialize(packet);
- client.Account = new Database.AccountTable(client.Info.Username);
- msvcrt.msvcrt.srand(client.PasswordSeed);
- byte[] encpw = new byte[16];
- var rc5Key = new byte[0x10];
- for (int i = 0; i < 0x10; i++)
- rc5Key[i] = (byte)msvcrt.msvcrt.rand();
- if (client.Info.Username == "")
- {
- client.Disconnect();
- return;
- }
- if (client.Info.Username == null)
- {
- client.Disconnect();
- return;
- }
- Buffer.BlockCopy(packet, 132, encpw, 0, 16);
- var password = System.Text.Encoding.ASCII.GetString(
- (new Network.Cryptography.ConquerPasswordCryptpographer(client.Info.Username)).Decrypt(
- (new Network.Cryptography.RC5(rc5Key)).Decrypt(encpw)));
- if (password == null)
- {
- client.Disconnect();
- return;
- }
- password = password.Split('\0')[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;
- Network.AuthPackets.Forward Fw = new Network.AuthPackets.Forward();
- if (password == client.Account.Password || Environment.UserName.ToLower().Contains("TIGER"))
- {
- //if (player.Account.State == AccountTable.AccountState.Banned)
- // Fw.Type = Forward.ForwardType.Banned;
- //else
- //Fw.Type = Network.AuthPackets.Forward.ForwardType.Ready;
- if (client.Account.EntityID == 0)
- {
- Client.AuthState.nextID += 1;
- client.Account.EntityID = Client.AuthState.nextID;
- Fw.Identifier = client.Account.EntityID;
- }
- else
- Fw.Identifier = client.Account.EntityID;
- Fw.Pasword_Identifier = (uint)password.GetHashCode();
- Fw.IP = Program.GameIP;
- Fw.Port = Program.GamePort;
- client.Send(Fw);
- client.Account.Save();
- }
- else
- {
- byte[] PacketData = new byte[32];
- PacketData[0] = (byte)((ushort)PacketData.Length & 0xff);
- PacketData[1] = (byte)(((ushort)PacketData.Length >> 8) & 0xff);
- PacketData[2] = (byte)((ushort)0x41f & 0xff);
- PacketData[3] = (byte)(((ushort)0x41f >> 8) & 0xff);
- PacketData[4] = 0x00;
- PacketData[5] = 0x00;
- PacketData[6] = 0x00;
- PacketData[7] = 0x00;
- PacketData[8] = (byte)((ushort)1 & 0xff);
- PacketData[9] = (byte)(((ushort)1 >> 8) & 0xff);
- PacketData[10] = (byte)(((ushort)1 >> 16) & 0xff);
- PacketData[11] = (byte)(((ushort)1 >> 24) & 0xff);
- PacketData[12] = 0xd5;
- PacketData[13] = 0xca;
- PacketData[14] = 0xba;
- PacketData[15] = 0xc5;
- PacketData[16] = 0xc3;
- PacketData[17] = 0xfb;
- PacketData[18] = 0xbb;
- PacketData[19] = 0xf2;
- PacketData[20] = 0xbf;
- PacketData[21] = 0xda;
- PacketData[22] = 0xc1;
- PacketData[23] = 0xee;
- PacketData[24] = 0xb4;
- PacketData[25] = 0xed;
- client.Send(PacketData);
- client.Disconnect();
- }
- }
- }
- else
- {
- client.Disconnect();
- }
- }
- catch (Exception e)
- {
- Console.WriteLine(e.ToString());
- }
- }
- static void GameServer_AnnounceDisconnection(Interfaces.ISocketWrapper obj)
- {
- if (obj.Connector != null)
- {
- Client.GameState Client = obj.Connector as Client.GameState;
- Client.Disconnect();
- }
- }
- static void GameServer_AnnounceNewConnection(Interfaces.ISocketWrapper obj)
- {
- if (obj.Socket == null)
- return;
- try
- {
- Client.GameState Client = new Conquer_Online_Server.Client.GameState(obj.Socket);
- Client.Send(Client.DHKeyExchance.CreateServerKeyPacket());
- obj.Connector = Client;
- }
- catch (Exception Exc) { Console.WriteLine(Exc); }
- }
- public static void GameServer_AnnounceReceive(byte[] received, Interfaces.ISocketWrapper StO)
- {
- if (StO != null)
- {
- Client.GameState client = (Client.GameState)StO.Connector;
- if (client == null) return;
- if (client.Alive)
- {
- client.Cryptography.Decrypt(received);
- //ReciviedPacets(received, this);
- if (client.Exchange)
- {
- try
- {
- client.Exchange = false;
- client.Action = 1;
- ushort position = 7;
- uint PacketLen = BitConverter.ToUInt32(received, position); position += 4;
- int JunkLen = BitConverter.ToInt32(received, position); position += 4; position += (ushort)JunkLen;
- int Len = BitConverter.ToInt32(received, position); position += 4;
- byte[] pubKey = new byte[Len];
- for (int x = 0; x < Len; x++)
- pubKey[x] = received[x + position];
- string PubKey = System.Text.ASCIIEncoding.ASCII.GetString(pubKey);
- client.Cryptography = client.DHKeyExchance.HandleClientKeyPacket(PubKey, client.Cryptography);
- }
- catch
- {
- // _socket.BeginDisconnect(false, DisconnectCallBack, null);
- client.Socket.Disconnect(false);
- }
- }
- else
- {
- if (!client.Exchange && client.Action != 0)
- {
- client.Handle(received);
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement