using System; using ProjectName.Network.Cryptography; using System.Text; namespace ProjectName.Network.AuthPackets { public class Authentication { byte[] Buffer; public string Username { get { string x = Encoding.Default.GetString(Buffer, 8, 32); return x.Replace("\0", ""); } } public string Password { get { byte[] PasswordArray = Encoding.Default.GetBytes(Encoding.Default.GetString(Buffer, 84, 32).Replace("\0", "")); string x = ProjectName.Network.Cryptography.PasswordDecryption.Decrypt(PasswordArray); return x.Replace("\0", ""); } } public string Server { get { string x = Encoding.Default.GetString(Buffer, 136, 16); return x.Replace("\0", "").Replace("0", ""); } } public string MacAddress { get { string x = Encoding.Default.GetString(Buffer, 152, 16); return x.Replace("\0", ""); } } public void Deserialize(byte[] buffer) { if (buffer.Length == 312) { ushort length = BitConverter.ToUInt16(buffer, 0); if (length == 312) { ushort type = BitConverter.ToUInt16(buffer, 2); if (type == 1636) { Buffer = buffer; } } } } } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ProjectName.Network.Cryptography { using System.Text; public class PasswordDecryption { static byte[] Key = new byte[32] { 90, 45, 12, 17, 35, 66, 44, 1, 02, 41, 59, 32, 36, 2, 234, 1, 10, 2, 79, 73, 202, 31, 99, 75, 7, 34, 16, 35, 101, 226, 99, 152 }; public static string Decrypt(byte[] data) { int length = Key.Length; for (int x = 0; x < data.Length; x++) { data[x] ^= Key[x % length]; data[x] ^= Key[(x * 24 % 16) % length]; data[x] ^= Key[(x * 48 % 32) % length]; } return Encoding.Default.GetString(data); } } }
public static void AuthServer_OnClientReceive(byte[] buffer, int length, ClientWrapper arg3) { var player = arg3.Connector as Client.AuthClient; player.Cryptographer.Decrypt(buffer, length); player.Queue.Enqueue(buffer, length); while (player.Queue.CanDequeue()) { byte[] packet = player.Queue.Dequeue(); ushort len = BitConverter.ToUInt16(packet, 0); ushort id = BitConverter.ToUInt16(packet, 2); if (len == 312) { player.Info = new ProjectName.Network.AuthPackets.Authentication(); player.Info.Deserialize(packet); player.Account = new AccountTable(player.Info.Username); msvcrt.msvcrt.srand(player.PasswordSeed); Forward Fw = new Forward(); if (player.Account.Password == player.Info.Password && player.Account.exists) Fw.Type = Forward.ForwardType.Ready; else Fw.Type = Forward.ForwardType.InvalidInfo; if (Fw.Type == Network.AuthPackets.Forward.ForwardType.Ready) { Fw.Identifier = player.Account.GenerateKey(); Kernel.AwaitingPool[Fw.Identifier] = player.Account; Fw.IP = Program.GameIP; Fw.Port = Program.GamePort; } player.Send(Fw); } } }