public static void InitWarden() { MaievData m = new(Realmserver.SS_Hash); var seedOut = m.GetBytes(16); var seedIn = m.GetBytes(16); Maiev.KeyOut = RC4.Init(seedOut); Maiev.KeyIn = RC4.Init(seedIn); }
public SimpleMacEncryptionSend() : base() { MetaData.Name = "Simple Mac Encryption"; MetaData.Version = "0.1.0.0"; MetaData.HelpString = "none"; MetaData.Author = "Brian W. (schizo)"; MetaData.Contact = "*****@*****.**"; MetaData.Description = ""; key = new SHA256Managed().ComputeHash(ASCIIEncoding.ASCII.GetBytes("Dear truck, CODE SOMETHING")); RC4 r = new RC4(); r.Init(key); key = r.GetKeyState(); }
public void MaievInit(ref WS_PlayerData.CharacterObject objCharacter) { byte[] i = WorldServiceLocator._WorldServer.ClsWorldServer.Cluster.ClientGetCryptKey(objCharacter.client.Index); MaievData j = new(i); byte[] seedOut = j.GetBytes(16); byte[] seedIn = j.GetBytes(16); objCharacter.WardenData.KeyOut = RC4.Init(seedOut); objCharacter.WardenData.KeyIn = RC4.Init(seedIn); objCharacter.WardenData.Ready = true; objCharacter.WardenData.Scan = new WS_Warden.WardenScan(ref objCharacter); objCharacter.WardenData.xorByte = 0; objCharacter.WardenData.K = i; WorldServiceLocator._Functions.RAND_bytes(ref objCharacter.WardenData.Seed, 16); MaievSendModule(ref objCharacter); }
public bool LoadModule(string Name, ref byte[] Data, byte[] Key) { Key = RC4.Init(Key); RC4.Crypt(ref Data, Key); var UncompressedLen = BitConverter.ToInt32(Data, 0); if (UncompressedLen < 0) { Console.WriteLine("[WARDEN] Failed to decrypt {0}, incorrect length.", Name); return(false); } var CompressedData = new byte[(Data.Length - 0x108)]; Array.Copy(Data, 4, CompressedData, 0, CompressedData.Length); var dataPos = 4 + CompressedData.Length; var Sign = Conversions.ToString((char)Data[dataPos + 3]) + (char)Data[dataPos + 2] + (char)Data[dataPos + 1] + (char)Data[dataPos]; if (Sign != "SIGN") { Console.WriteLine("[WARDEN] Failed to decrypt {0}, sign missing.", Name); return(false); } dataPos += 4; var Signature = new byte[256]; Array.Copy(Data, dataPos, Signature, 0, Signature.Length); // Check signature if (CheckSignature(Signature, Data, Data.Length - 0x104) == false) { Console.WriteLine("[WARDEN] Signature fail on Warden Module."); return(false); } var DecompressedData = new ZipService().DeCompress(CompressedData); MemoryStream ms = new(DecompressedData); BinaryReader br = new(ms); ModuleData = PrepairModule(ref br); ms.Close(); ms.Dispose(); br = null; Console.WriteLine("[WARDEN] Successfully prepaired Warden Module."); return(InitModule(ref ModuleData)); }
public Eeprom(string file) { Data = File.ReadAllBytes(file); if (Data.Length != Size) { throw new InvalidDataException("EEPROM must be 256 bytes."); } Stream = new MemoryStream(Data); Reader = new BinaryReader(Stream); Writer = new BinaryWriter(Stream); HmacSha1 sha = new HmacSha1(); RC4 rc4 = new RC4(); EepromVersion version = 0; // loop through each version attempting to decrypt the security data while (version <= EepromVersion.RetailLast) { byte[] origHash = Data.Subset(0, 20); // decrypt according to the specified version rc4.Init(sha.Compute(version, origHash)); byte[] decrypted = Data.Subset(0x14, 0x1C); rc4.Crypt(decrypted, 0, decrypted.Length); // if decrypted data hash matches the original then it's valid and the specific version is now known if (origHash.IsEqual(sha.Compute(version, decrypted))) { // update with the decrypted data Stream.Position = 0x14; Writer.Write(decrypted); // set the detected version Version = version; break; } version++; } }
/// <summary> /// Saves the eeprom contents to file. /// If the version is unknown the security section will not be overwritten. /// </summary> /// <param name="file"></param> public void Save(string file) { UpdateChecksums(); // skip writing security section if version is unknown if (Version == EepromVersion.Unknown) { using (FileStream fs = new FileStream(file, FileMode.Open, FileAccess.Write, FileShare.None)) { fs.Position = 0x30; fs.Write(Data, 0x30, Size - 0x30); } } else { // copy data to a separate buffer byte[] eepromCopy = new byte[Size]; Data.CopyTo(eepromCopy, 0); // update security section of copy if (Version != EepromVersion.Unknown) { HmacSha1 sha = new HmacSha1(); RC4 rc4 = new RC4(); // hash decrypted confounder/hddkey/region byte[] hash = sha.Compute(Version, eepromCopy.Subset(0x14, 0x1C)); hash.CopyTo(eepromCopy, 0); // re-encrypt data rc4.Init(sha.Compute(Version, hash)); rc4.Crypt(eepromCopy, 20, 28); } File.WriteAllBytes(file, eepromCopy); } }