public string this[string propertyName] { get { string error = null; switch (propertyName) { case "Username": if (string.IsNullOrEmpty(Username)) { error = "You must provide a username."; } else if (Username.Length > 15) { error = "Your username cannot be longer than 15 characters."; } break; case "Password": if (string.IsNullOrEmpty(Password)) { error = "You must provide a password."; } break; case "CdKey": if (string.IsNullOrEmpty(CdKey)) { error = "You must provide a cdkey."; } else if (CdKey.Contains("-")) { error = "Your cdkey cannot contain any dashes."; } break; case "HomeChannel": if (string.IsNullOrEmpty(HomeChannel)) { error = "You must provide a home channel."; } else if (HomeChannel.Length > 15) { error = "Your home channel cannot be longer than 15 characters."; } break; } return(error); } }
/// <summary> /// Creates a standard Version 2 Battle.net FTP request. /// </summary> /// <param name="productId">The four-character identifier for the product being emulated by this request.</param> /// <param name="fileName">The full or relative path to the file as it is to be stored on the local /// machine. The name portion of the file must be the filename being requested from the service.</param> /// <param name="fileTime">The last-write time of the file. If the file is not available, this parameter /// can be <b>null</b> (<b>Nothing</b> in Visual Basic).</param> /// <param name="cdKey">The CD key of the client being emulated.</param> public BnFtpVersion2Request(string productId, string fileName, DateTime fileTime, string cdKey) : base(fileName, productId, fileTime) { string prod = Product; if (prod != Resources.war3 && prod != Resources.w3xp) { throw new ArgumentOutOfRangeException(Resources.param_productId, productId, Resources.bnftp_ver2invalidProduct); } m_key = new CdKey(cdKey); }
protected void AuthInfoRequest(byte type, List <byte> data) { _serverToken = BitConverter.ToUInt32(data.ToArray(), 8); List <byte> temp = data.GetRange(16, 8); String mpq_file_time = System.Text.Encoding.ASCII.GetString(temp.ToArray()); int offset; if (data[24] == 0x76) { offset = 24; } else { offset = 24; } String mpq_file_name = ReadNullTerminatedString(System.Text.Encoding.ASCII.GetString(data.ToArray()), ref offset); String formula_string = ReadNullTerminatedString(System.Text.Encoding.ASCII.GetString(data.ToArray()), ref offset); /* * Download MPQ would go here. */ uint exe_checksum = AdvancedCheckRevision.FastComputeHash(formula_string, mpq_file_name, System.IO.Path.Combine(Globals.BinaryDirectory, "Game.exe"), System.IO.Path.Combine(Globals.BinaryDirectory, "Bnclient.dll"), System.IO.Path.Combine(Globals.BinaryDirectory, "D2Client.dll")); uint client_token = (uint)System.Environment.TickCount; List <byte> classic_hash = new List <byte>(), lod_hash = new List <byte>(), classic_public = new List <byte>(), lod_public = new List <byte>(); if (!CdKey.GetD2KeyHash(_classicKey, ref client_token, _serverToken, ref classic_hash, ref classic_public)) { OnUpdateStatus(Client.Status.StatusInvalidCdKey); } if (!CdKey.GetD2KeyHash(_expansionKey, ref client_token, _serverToken, ref lod_hash, ref lod_public)) { OnUpdateStatus(Client.Status.StatusInvalidExpCdKey); } byte[] packet = Connection.BuildPacket((byte)0x51, BitConverter.GetBytes(client_token), BitConverter.GetBytes(0x01000001), BitConverter.GetBytes(exe_checksum), BitConverter.GetBytes(0x00000002), Nulls, Ten, Six, classic_public, Nulls, classic_hash, Ten, BitConverter.GetBytes((UInt32)10), lod_public, Nulls, lod_hash, System.Text.Encoding.UTF8.GetBytes(_exeInfo), Zero, System.Text.Encoding.ASCII.GetBytes(Settings.Instance.CdKeyUser()), Zero); Connection.Write(packet); }
/// <summary> /// Creates a standard Version 2 Battle.net FTP request. /// </summary> /// <param name="product">The product being emulated by this request.</param> /// <param name="fileName">The full or relative path to the file as it is to be stored on the local /// machine. The name portion of the file must be the filename being requested from the service.</param> /// <param name="fileTime">The last-write time of the file. If the file is not available, this parameter /// can be <b>null</b> (<b>Nothing</b> in Visual Basic).</param> /// <param name="cdKey">The CD key of the client being emulated.</param> public BnFtpVersion2Request(string fileName, ClassicProduct product, DateTime fileTime, CdKey cdKey) : base(fileName, product, fileTime) { string prod = Product.ProductCode; if (prod != "WAR3" && prod != "W3XP") { throw new ArgumentOutOfRangeException("product", product, "Only Warcraft III clients are valid for Battle.net version 2 FTP requests."); } if (!cdKey.IsValid) { throw new ArgumentException("The specified CD key is not valid.", "cdKey"); } _key = cdKey; }
private bool Validate(CdKey key) { var total = 1; foreach (var num in key.GetLast()) { total *= Convert.ToInt32(num.ToString()); } var valid = key.GetFirst() != "333" && key.GetFirst() != "444" && key.GetFirst() != "555" && key.GetFirst() != "666" && key.GetFirst() != "777" && key.GetFirst() != "888" && key.GetFirst() != "999" && (key.GetFirst().Length == 3 && key.GetLast().Length == 7) && total % 7 == 0 && (key.GetLast()[6] != '0' && key.GetLast()[6] != '8' && key.GetLast()[6] != '9'); return(valid); }
public BattleNetSettings() { Console.Write("Username: "******"Password: "******"CD Key: "); CdKey1 = new CdKey(Console.ReadLine()); Client = ClassicProduct.StarcraftRetail; VersionByte = 0xd3; GameExe = @"C:\GameFiles\STAR\Starcraft.exe"; GameFile2 = @"C:\GameFiles\STAR\Storm.dll"; GameFile3 = @"C:\GameFiles\STAR\Battle.snp"; ImageFile = @"C:\GameFiles\STAR\STAR.bin"; Gateway = Gateway.USEast; CdKeyOwner = Username; PingMethod = PingKind.ReplyBeforeVersioning; }
public AuthCheckRequestPacket( uint clientToken, uint serverToken, int version, byte[] checksum, byte[] info, CdKey classic, CdKey expansion ) : base(BuildPacket( Sid.AUTH_CHECK, BitConverter.GetBytes(clientToken), BitConverter.GetBytes(version), checksum, KeyCount, IsSpawn, BitConverter.GetBytes(classic.KeyLength), BitConverter.GetBytes(classic.Product), classic.Public, BitConverter.GetBytes(0x00), classic.ComputeHash(clientToken, serverToken), BitConverter.GetBytes(expansion.KeyLength), BitConverter.GetBytes(expansion.Product), expansion.Public, BitConverter.GetBytes(0x00), expansion.ComputeHash(clientToken, serverToken), info, Encoding.ASCII.GetBytes("D2NG\0") ) ) { Log.Verbose($"Writing AuthCheck\n" + $"\tType: {Type}\n" + $"\tClient Token: {clientToken}\n" + $"\tServer Token: {serverToken}\n" + $"\tVersion: {version}\n" + $"\tChecksum: {BitConverter.ToString(checksum)}\n" + $"\tInfo: {BitConverter.ToString(info)}\n"); }
private static void ValidateSettings(IBattleNetSettings settings) { BattleNetSettingsErrors errors = BattleNetSettingsErrors.None; if (!File.Exists(settings.GameExe)) { errors |= BattleNetSettingsErrors.GameExeMissingOrNotFound; } if (!File.Exists(settings.GameFile2)) { errors |= BattleNetSettingsErrors.GameFile2MissingOrNotFound; } if (!File.Exists(settings.GameFile3)) { errors |= BattleNetSettingsErrors.GameFile3MissingOrNotFound; } if (string.IsNullOrEmpty(settings.Username)) { errors |= BattleNetSettingsErrors.UserNameNull; } if (!Enum.IsDefined(typeof(PingType), settings.PingMethod)) { errors |= BattleNetSettingsErrors.InvalidPingType; } if (string.IsNullOrEmpty(settings.Gateway.ServerHost)) { errors |= BattleNetSettingsErrors.InvalidGatewayServer; } if (settings.CdKeyOwner == null) { settings.CdKeyOwner = string.Empty; } if (settings.Password == null) { settings.Password = string.Empty; } Product productToUse = Product.GetByProductCode(settings.Client); if (productToUse == null) { errors |= BattleNetSettingsErrors.InvalidEmulationClient; } else { if (!productToUse.CanConnect) { errors |= BattleNetSettingsErrors.InvalidEmulationClient; } if (string.IsNullOrEmpty(settings.CdKey1)) { errors |= BattleNetSettingsErrors.PrimaryCdKeyMissingOrInvalid; } else { try { CdKey test = new CdKey(settings.CdKey1); if (!test.IsValid) { errors |= BattleNetSettingsErrors.PrimaryCdKeyMissingOrInvalid; } } catch { errors |= BattleNetSettingsErrors.PrimaryCdKeyMissingOrInvalid; } } if (productToUse.NeedsTwoKeys && string.IsNullOrEmpty(settings.CdKey2)) { errors |= BattleNetSettingsErrors.SecondaryCdKeyMissingOrInvalid; } else { if (productToUse.NeedsTwoKeys) { try { CdKey test2 = new CdKey(settings.CdKey2); if (!test2.IsValid) { errors |= BattleNetSettingsErrors.SecondaryCdKeyMissingOrInvalid; } } catch { errors |= BattleNetSettingsErrors.SecondaryCdKeyMissingOrInvalid; } } } if (productToUse.NeedsLockdown) { if (string.IsNullOrEmpty(settings.ImageFile) || !File.Exists(settings.ImageFile)) { errors |= BattleNetSettingsErrors.LockdownFileMissingOrNotFound; } } } if (errors != BattleNetSettingsErrors.None) { throw new BattleNetSettingsErrorsException(errors); } }
public void Handle_SID_AUTH_INFO(BncsReader Reader) { int num = Reader.ReadInt32(); int num2 = Reader.ReadInt32(); int num3 = Reader.ReadInt32(); long num4 = Reader.ReadInt64(); string mpqName = Reader.ReadCString(); byte[] array = Reader.ReadNullTerminatedByteArray(); List <string> list = new List <string>(); this.g_iServerToken = num2; int num5; if (this.Exp) { num5 = 2; } else { num5 = 1; } BattleNetClient battleNetClient = new BattleNetClient(this.Exp); checked { string[] array2 = new string[num5]; CdKey[] array3 = new CdKey[num5]; byte[][] array4 = new byte[num5][]; int[] array5 = new int[num5]; array2[0] = this.BnetInfo.ClassicCdKey; array2[0] = array2[0].Replace("-", ""); array2[0] = array2[0].Replace(" ", ""); if (num5 >= 2) { array2[1] = this.BnetInfo.ExpCdKey; array2[1] = array2[1].Replace("-", ""); array2[1] = array2[1].Replace(" ", ""); } int arg_111_0 = 0; int num6 = num5 - 1; for (int i = arg_111_0; i <= num6; i++) { try { array5[i] = array2[i].Length; array3[i] = CdKey.CreateDecoder(array2[i]); array4[i] = array3[i].GetHash(this.g_iClientToken, this.g_iServerToken); if (!array3[i].IsValid) { this.WriteToLog("Warning Cd-Key(" + Conversions.ToString(i) + ") is invalid", Color.Red); this.Disconnect(); } } catch (Exception expr_186) { ProjectData.SetProjectError(expr_186); this.WriteToLog("Error while preparing the cd-key " + i, Color.Red); this.Disconnect(); ProjectData.ClearProjectError(); return; } } string str = ""; char[] array6 = new char[array.Length]; int arg_1EF_0 = 0; int num7 = array.Length - 1; for (int j = arg_1EF_0; j <= num7; j++) { array6[j] = Strings.ChrW((int)array[j]); } int exeInfo = CheckRevision.GetExeInfo(battleNetClient.g_sHashes[0], out str); int i2 = CheckRevision.DoCheckRevision(new string(array6), battleNetClient.g_sHashes, CheckRevision.ExtractMPQNumber(mpqName)); BncsPacket bncsPacket = new BncsPacket(81); bncsPacket.InsertInt32(this.g_iClientToken); bncsPacket.InsertInt32(exeInfo); bncsPacket.InsertInt32(i2); bncsPacket.InsertInt32(num5); bncsPacket.InsertBoolean(false); int arg_27B_0 = 0; int num8 = num5 - 1; for (int k = arg_27B_0; k <= num8; k++) { bncsPacket.InsertInt32(array5[k]); bncsPacket.InsertInt32(array3[k].Product); bncsPacket.InsertInt32(array3[k].Value1); bncsPacket.InsertInt32(0); bncsPacket.InsertByteArray(array4[k]); } bncsPacket.InsertCString(str); bncsPacket.InsertCString(this.BnetInfo.CdKeyOwner); this.SendPacket(bncsPacket.UnderlyingBuffer); } }
/// <summary> /// Creates a Version 2 Battle.net FTP request specifically for banner ad downloads. /// </summary> /// <param name="product">The product being emulated by this request.</param> /// <param name="fileName">The full or relative path to the file as it is to be stored on the local /// machine. The name portion of the file must be the filename being requested from the service.</param> /// <param name="fileTime">The last-write time of the file. If the file is not available, this parameter /// can be <b>null</b> (<b>Nothing</b> in Visual Basic).</param> /// <param name="cdKey">The CD key of the client being emulated.</param> /// <param name="adId">The banner ID provided by Battle.net's ad notice message.</param> /// <param name="adFileExtension">The banner filename extension provided by Battle.net's ad notice message.</param> /// <remarks> /// <para>Although it is not specifically required to download banner ads, it is recommended for forward-compatibility /// with the Battle.net protocol that this constructor is used.</para> /// </remarks> public BnFtpVersion2Request(string fileName, ClassicProduct product, DateTime fileTime, CdKey cdKey, int adId, string adFileExtension) : this(fileName, product, fileTime, cdKey) { _ad = true; _adId = adId; _adExt = adFileExtension; }
private async void HandleAuthInfo(BncsReader dr) { try { //DataReader dr = new DataReader(data.Data); //if (m_pingPck != null) //{ // Send(m_pingPck); // m_pingPck = null; //} _received0x50 = true; _loginType = dr.ReadUInt32(); _srvToken = dr.ReadInt32(); _udpVal = dr.ReadUInt32(); _mpqFileTime = dr.ReadInt64(); _versioningFilename = dr.ReadCString(); _usingLockdown = _versioningFilename.StartsWith("LOCKDOWN", StringComparison.OrdinalIgnoreCase); int crResult = -1, exeVer = -1; string exeInfo = null; if (!_usingLockdown) { _valString = dr.ReadCString(); int mpqNum = CheckRevision.ExtractMPQNumber(_versioningFilename); crResult = CheckRevision.DoCheckRevision(_valString, new Stream[] { File.OpenRead(_settings.GameExe), File.OpenRead(_settings.GameFile2), File.OpenRead(_settings.GameFile3) }, mpqNum); exeVer = CheckRevision.GetExeInfo(_settings.GameExe, out exeInfo); } else { _ldValStr = dr.ReadNullTerminatedByteArray(); string dllName = _versioningFilename.Replace(".mpq", ".dll"); BnFtpVersion1Request req = new BnFtpVersion1Request(_settings.Client, _versioningFilename, null); req.Gateway = _settings.Gateway; req.LocalFileName = Path.Combine(Path.GetTempPath(), _versioningFilename); await req.ExecuteRequest(); string ldPath = null; using (MpqArchive arch = MpqServices.OpenArchive(req.LocalFileName)) { if (arch.ContainsFile(dllName)) { ldPath = Path.Combine(Path.GetTempPath(), dllName); arch.SaveToPath(dllName, Path.GetTempPath(), false); } } _ldDigest = CheckRevision.DoLockdownCheckRevision(_ldValStr, new string[] { _settings.GameExe, _settings.GameFile2, _settings.GameFile3 }, ldPath, _settings.ImageFile, ref exeVer, ref crResult); } string prodCode = _settings.Client.ProductCode; if (prodCode == "WAR3" || prodCode == "W3XP") { _w3srv = dr.ReadByteArray(128); if (!NLS.ValidateServerSignature(_w3srv, _connection.RemoteEP.Address.GetAddressBytes())) { //OnError(new ErrorEventArgs(ErrorType.Warcraft3ServerValidationFailure, Strings.War3ServerValidationFailed, false)); //Close(); //return; } } // BattleNetClientResources.IncomingBufferPool.FreeBuffer(data.Data); CdKey key1 = _settings.CdKey1, key2 = _settings.CdKey2; _clientToken = new Random().Next(); byte[] key1Hash = key1.GetHash(_clientToken, _srvToken); if (WardenHandler != null) { try { if (!WardenHandler.InitWarden(BitConverter.ToInt32(key1Hash, 0))) { WardenHandler.UninitWarden(); //OnError(new ErrorEventArgs(ErrorType.WardenModuleFailure, "The Warden module failed to initialize. You will not be immediately disconnected; however, you may be disconnected after a short period of time.", false)); WardenHandler = null; } } catch (Win32Exception we) { //OnError(new ErrorEventArgs(ErrorType.WardenModuleFailure, "The Warden module failed to initialize. You will not be immediately disconnected; however, you may be disconnected after a short period of time.", false)); //OnError(new ErrorEventArgs(ErrorType.WardenModuleFailure, string.Format(CultureInfo.CurrentCulture, "Additional information: {0}", we.Message), false)); WardenHandler.UninitWarden(); WardenHandler = null; } } BncsPacket pck0x51 = new BncsPacket(BncsPacketId.AuthCheck, _connection.NetworkBuffers.Acquire()); pck0x51.InsertInt32(_clientToken); pck0x51.InsertInt32(exeVer); pck0x51.InsertInt32(crResult); if (prodCode == "D2XP" || prodCode == "W3XP") { pck0x51.InsertInt32(2); } else { pck0x51.InsertInt32(1); } pck0x51.InsertBoolean(false); pck0x51.InsertInt32(key1.Key.Length); pck0x51.InsertInt32(key1.Product); pck0x51.InsertInt32(key1.Value1); pck0x51.InsertInt32(0); pck0x51.InsertByteArray(key1Hash); if (key2 != null) { pck0x51.InsertInt32(key2.Key.Length); pck0x51.InsertInt32(key2.Product); pck0x51.InsertInt32(key2.Value1); pck0x51.InsertInt32(0); pck0x51.InsertByteArray(key2.GetHash(_clientToken, _srvToken)); } if (_usingLockdown) { pck0x51.InsertByteArray(_ldDigest); pck0x51.InsertByte(0); } else { pck0x51.InsertCString(exeInfo); } pck0x51.InsertCString(_settings.CdKeyOwner); await pck0x51.SendAsync(_connection); } catch (Exception ex) { //OnError(new ErrorEventArgs(ErrorType.General, "There was an error while initializing your client. Refer to the exception message for more information.\n" + ex.ToString(), true)); Disconnect(); Console.WriteLine(ex.ToString()); } }
private void HandleAuthInfo(ParseData data) { try { DataReader dr = new DataReader(data.Data); if (m_pingPck != null) { Send(m_pingPck); m_pingPck = null; } m_received0x50 = true; m_loginType = dr.ReadUInt32(); m_srvToken = dr.ReadUInt32(); m_udpVal = dr.ReadUInt32(); m_mpqFiletime = dr.ReadInt64(); m_versioningFilename = dr.ReadCString(); m_usingLockdown = m_versioningFilename.StartsWith("LOCKDOWN", StringComparison.OrdinalIgnoreCase); int crResult = -1, exeVer = -1; string exeInfo = null; if (!m_usingLockdown) { m_valString = dr.ReadCString(); int mpqNum = CheckRevision.ExtractMPQNumber(m_versioningFilename); crResult = CheckRevision.DoCheckRevision(m_valString, new string[] { m_settings.GameExe, m_settings.GameFile2, m_settings.GameFile3 }, mpqNum); exeVer = CheckRevision.GetExeInfo(m_settings.GameExe, out exeInfo); } else { m_ldValStr = dr.ReadNullTerminatedByteArray(); string dllName = m_versioningFilename.Replace(".mpq", ".dll"); BnFtpVersion1Request req = new BnFtpVersion1Request(m_settings.Client, m_versioningFilename, null); req.Server = m_settings.Gateway.ServerHost; req.LocalFileName = Path.Combine(Path.GetTempPath(), m_versioningFilename); req.ExecuteRequest(); string ldPath = null; using (MpqArchive arch = MpqServices.OpenArchive(req.LocalFileName)) { if (arch.ContainsFile(dllName)) { ldPath = Path.Combine(Path.GetTempPath(), dllName); arch.SaveToPath(dllName, Path.GetTempPath(), false); } } m_ldDigest = CheckRevision.DoLockdownCheckRevision(m_ldValStr, new string[] { m_settings.GameExe, m_settings.GameFile2, m_settings.GameFile3 }, ldPath, m_settings.ImageFile, ref exeVer, ref crResult); } m_prodCode = m_settings.Client; if (m_prodCode == "WAR3" || m_prodCode == "W3XP") { m_w3srv = dr.ReadByteArray(128); if (!NLS.ValidateServerSignature(m_w3srv, RemoteEP.Address.GetAddressBytes())) { OnError(new ErrorEventArgs(ErrorType.Warcraft3ServerValidationFailure, Strings.War3ServerValidationFailed, false)); //Close(); //return; } } BattleNetClientResources.IncomingBufferPool.FreeBuffer(data.Data); CdKey key1, key2 = null; key1 = new CdKey(m_settings.CdKey1); if (m_prodCode == "D2XP" || m_prodCode == "W3XP") { key2 = new CdKey(m_settings.CdKey2); } m_clientToken = unchecked ((uint)new Random().Next()); byte[] key1Hash = key1.GetHash(m_clientToken, m_srvToken); if (m_warden != null) { try { if (!m_warden.InitWarden(BitConverter.ToInt32(key1Hash, 0))) { m_warden.UninitWarden(); OnError(new ErrorEventArgs(ErrorType.WardenModuleFailure, "The Warden module failed to initialize. You will not be immediately disconnected; however, you may be disconnected after a short period of time.", false)); m_warden = null; } } catch (Win32Exception we) { OnError(new ErrorEventArgs(ErrorType.WardenModuleFailure, "The Warden module failed to initialize. You will not be immediately disconnected; however, you may be disconnected after a short period of time.", false)); OnError(new ErrorEventArgs(ErrorType.WardenModuleFailure, string.Format(CultureInfo.CurrentCulture, "Additional information: {0}", we.Message), false)); m_warden.UninitWarden(); m_warden = null; } } BncsPacket pck0x51 = new BncsPacket((byte)BncsPacketId.AuthCheck); pck0x51.Insert(m_clientToken); pck0x51.Insert(exeVer); pck0x51.Insert(crResult); if (m_prodCode == "D2XP" || m_prodCode == "W3XP") { pck0x51.Insert(2); } else { pck0x51.Insert(1); } pck0x51.Insert(false); pck0x51.Insert(key1.Key.Length); pck0x51.Insert(key1.Product); pck0x51.Insert(key1.Value1); pck0x51.Insert(0); pck0x51.Insert(key1Hash); if (key2 != null) { pck0x51.Insert(key2.Key.Length); pck0x51.Insert(key2.Product); pck0x51.Insert(key2.Value1); pck0x51.Insert(0); pck0x51.Insert(key2.GetHash(m_clientToken, m_srvToken)); } if (m_usingLockdown) { pck0x51.InsertByteArray(m_ldDigest); pck0x51.InsertByte(0); } else { pck0x51.InsertCString(exeInfo); } pck0x51.InsertCString(m_settings.CdKeyOwner); Send(pck0x51); } catch (Exception ex) { OnError(new ErrorEventArgs(ErrorType.General, "There was an error while initializing your client. Refer to the exception message for more information.\n" + ex.ToString(), true)); Close(); } }
private static void Parse0x50(ClientSocket cs, Receiver receiver) { receiver.SkipLength(4); // Int32 logonType = receiver.GetInt32(); cs.ServerToken = receiver.GetInt32(); cs.ClientToken = receiver.GetInt32(); receiver.SkipLength(8); // long mpqFiletime = receiver.GetInt64(); string mpqFilename = receiver.GetNTString(); byte[] checksumFormula = receiver.GetNTBytes(); int crResult = -1, exeVer = -1, checkRevisionPass = 0; mpqFilename = mpqFilename.Substring(0, (mpqFilename.Length - 4)) + ".dll"; byte[] exeInfo = CheckRevision.DoLockdownCheckRevision(checksumFormula, KryX2.Settings.GeneratedSettings.HashFiles, KryX2.Settings.GeneratedSettings.LockdownPath, mpqFilename, KryX2.Settings.GeneratedSettings.StarBin, ref exeVer, ref crResult); if (crResult == -1 || exeVer == -1) //if (checkRevisionPass != 1 || exeVer == 0) { //bad hashes perhaps Chat.Add(Color.Yellow, "CheckrevisionPass " + checkRevisionPass.ToString() + NewLine); Chat.Add(Color.White, "Exeversoin " + exeVer.ToString() + Environment.NewLine); //Chat.Add(Color.White, "No hashes or cr result is bad " + crResult + " / " + exeVer + NewLine); return; } CdKey cdkey; byte[] key1Hash; try { cdkey = new CdKey(cs.CdKey); key1Hash = cdkey.GetHash(cs.ClientToken, cs.ServerToken); } catch { Chat.Add(Color.Yellow, "Couldn't decode key." + NewLine); return; } Builder builder = new Builder(); builder.InsertInt32(cs.ClientToken); builder.InsertInt32(exeVer); builder.InsertInt32(crResult); builder.InsertInt32(1); //keys used builder.InsertInt32(0); //spawn? builder.InsertInt32(13); //key length builder.InsertInt32(cdkey.Product); builder.InsertInt32(cdkey.Value1); builder.InsertInt32(0); builder.InsertByteArray(key1Hash); builder.InsertByteArray(exeInfo); builder.InsertByte(0); builder.InsertNTString(RandomName()); //in use by builder.SendPacket(cs, 0x51); }