public BigInteger GetM(string Username, BigInteger s, BigInteger A, BigInteger B, BigInteger K) { Sha1Hash sha; sha = new Sha1Hash(); byte[] hash = sha.Final(N); sha = new Sha1Hash(); byte[] ghash = sha.Final(g); for (int i = 0; i < 20; ++i) { hash[i] ^= ghash[i]; } // TODO: do t2 and t4 need to be BigInts? Could we just use the byte[]? BigInteger t3 = new BigInteger(hash); sha = new Sha1Hash(); sha.Update(Username); BigInteger t4 = new BigInteger(sha.Final()); sha = new Sha1Hash(); sha.Update(t3); sha.Update(t4); sha.Update(s); sha.Update(A); sha.Update(B); return(new BigInteger(sha.Final(K))); }
// HandleLogonProof stuff public static BigInteger Getu(BigInteger A, BigInteger B) { Sha1Hash h = new Sha1Hash(); h.Update(A); return(new BigInteger(h.Final(B))); }
public static BigInteger Getx(BigInteger Salt, byte[] LogonHash) { Sha1Hash h = new Sha1Hash(); h.Update(Salt); h.Update(LogonHash); return(new BigInteger(h.Final())); }
public static byte[] GetM2(BigInteger A, BigInteger M, BigInteger K) { Sha1Hash h = new Sha1Hash(); h.Update(A); h.Update(M); return(h.Final(K)); }
public static byte[] GetLogonHash(string Username, string Password) { Sha1Hash h = new Sha1Hash(); string sI = String.Format("{0}:{1}", Username, Password.ToUpper()); h.Update(sI); return(h.Final()); }
public void FillUp() { sh.Initialize(); sh.Update(o1); sh.Update(o0); sh.Update(o2); memcopy(o0, sh.Final()); taken = 0; }
public void DoAuthSession() { try { PacketOut packet = new PacketOut(WorldServerOpCode.CMSG_AUTH_SESSION); Sha1Hash sha = new Sha1Hash(); sha.Update(mUsername); sha.Update(new byte[4]); // t sha.Update(ClientSeed); sha.Update(ServerSeed); sha.Update(mKey); byte[] Digest = sha.Final(); packet.Write((UInt32)Config.Version.build); packet.Write((UInt32)0); packet.Write(mUsername); packet.Write((UInt32)0); packet.Write(ClientSeed); packet.Write((UInt64)0); packet.Write(Digest); bool WantToCrash = false; if (WantToCrash) { byte[] addons = { (byte)0x00 }; byte[] buffer2 = mClient.Shared.Compression.Compress(addons); UInt32 Size = (UInt32)addons.Length; packet.Write(Size); packet.Write(buffer2); } else { byte[] addon_data = { 0x56, 0x01, 0x00, 0x00, 0x78, 0x9c, 0x75, 0xcc, 0xbd, 0x0e, 0xc2, 0x30, 0x0c, 0x04, 0xe0, 0xf2, 0x1e, 0xbc, 0x0c, 0x61, 0x40, 0x95, 0xc8, 0x42, 0xc3, 0x8c, 0x4c, 0xe2, 0x22, 0x0b, 0xc7, 0xa9, 0x8c, 0xcb, 0x4f, 0x9f, 0x1e, 0x16, 0x24, 0x06, 0x73, 0xeb, 0x77, 0x77, 0x81, 0x69, 0x59, 0x40, 0xcb, 0x69, 0x33, 0x67, 0xa3, 0x26, 0xc7, 0xbe, 0x5b, 0xd5, 0xc7, 0x7a, 0xdf, 0x7d, 0x12, 0xbe, 0x16, 0xc0, 0x8c, 0x71, 0x24, 0xe4, 0x12, 0x49, 0xa8, 0xc2, 0xe4, 0x95, 0x48, 0x0a, 0xc9, 0xc5, 0x3d, 0xd8, 0xb6, 0x7a, 0x06, 0x4b, 0xf8, 0x34, 0x0f, 0x15, 0x46, 0x73, 0x67, 0xbb, 0x38, 0xcc, 0x7a, 0xc7, 0x97, 0x8b, 0xbd, 0xdc, 0x26, 0xcc, 0xfe, 0x30, 0x42, 0xd6, 0xe6, 0xca, 0x01, 0xa8, 0xb8, 0x90, 0x80, 0x51, 0xfc, 0xb7, 0xa4, 0x50, 0x70, 0xb8, 0x12, 0xf3, 0x3f, 0x26, 0x41, 0xfd, 0xb5, 0x37, 0x90, 0x19, 0x66, 0x8f }; packet.Write(addon_data); } Send(packet); mCrypt = new PacketCrypt(mKey); mCrypt.Init(); } catch (Exception e) { Log.WriteLine(LogType.Error, e.StackTrace); } }
public Sha1Warden(byte[] buff, UInt32 size) { sh = new Sha1Hash(); taken = size / 2; byte[] buff2 = new byte[taken]; memcopy(buff2, buff); sh.Initialize(); sh.Update(buff2); memcopy(o1, sh.Final()); byte[] buff3 = new byte[20]; memcopy(buff3, buff, 20); sh.Initialize(); sh.Update(buff3); memcopy(o2, sh.Final()); memset(o0, 0x00); FillUp(); }
private byte[] GenerateCrc(byte[] crcsalt) { Sha1Hash sha; string[] files = { "WoW.bin", "DivxDecoder.bin", "Unicows.bin" }; byte[] buffer1 = new byte[0x40]; byte[] buffer2 = new byte[0x40]; for (int i = 0; i < 0x40; ++i) { buffer1[i] = 0x36; buffer2[i] = 0x5c; } for (int i = 0; i < crcsalt.Length; ++i) { buffer1[i] ^= crcsalt[i]; buffer2[i] ^= crcsalt[i]; } sha = new Sha1Hash(); sha.Update(buffer1); foreach (string filename in files) { if (!File.Exists(@"crc\" + filename)) { Log.WriteLine(LogType.Error, "CRC File {0} doesn't exist!", filename); } FileStream fs = new FileStream(@"crc\" + filename, FileMode.Open, FileAccess.Read); byte[] Buffer = new byte[fs.Length]; fs.Read(Buffer, 0, (int)fs.Length); sha.Update(Buffer); } byte[] hash1 = sha.Final(); sha = new Sha1Hash(); sha.Update(buffer2); sha.Update(hash1); return(sha.Final()); }
public static void HandleAuthChallenge(ref PacketReader packet1, ref World manager) { manager.ServerSeed = packet1.ReadUInt32(); manager.ClientSeed = (UInt32)0; try { PacketWriter packet = new PacketWriter(WorldServerOpCode.CMSG_AUTH_SESSION); Sha1Hash sha = new Sha1Hash(); sha.Update(manager.mUsername); sha.Update(new byte[4]); // t sha.Update(manager.ClientSeed); sha.Update(manager.ServerSeed); sha.Update(manager.mKey); byte[] Digest = sha.Final(); packet.Write((uint)5875); packet.Write((uint)0); packet.Write(manager.mUsername); packet.Write(manager.ClientSeed); packet.Write(Digest); byte[] addon_data = { 0x56, 0x01, 0x00, 0x00, 0x78, 0x9c, 0x75, 0xcc, 0xbd, 0x0e, 0xc2, 0x30, 0x0c, 0x04, 0xe0, 0xf2, 0x1e, 0xbc, 0x0c, 0x61, 0x40, 0x95, 0xc8, 0x42, 0xc3, 0x8c, 0x4c, 0xe2, 0x22, 0x0b, 0xc7, 0xa9, 0x8c, 0xcb, 0x4f, 0x9f, 0x1e, 0x16, 0x24, 0x06, 0x73, 0xeb, 0x77, 0x77, 0x81, 0x69, 0x59, 0x40, 0xcb, 0x69, 0x33, 0x67, 0xa3, 0x26, 0xc7, 0xbe, 0x5b, 0xd5, 0xc7, 0x7a, 0xdf, 0x7d, 0x12, 0xbe, 0x16, 0xc0, 0x8c, 0x71, 0x24, 0xe4, 0x12, 0x49, 0xa8, 0xc2, 0xe4, 0x95, 0x48, 0x0a, 0xc9, 0xc5, 0x3d, 0xd8, 0xb6, 0x7a, 0x06, 0x4b, 0xf8, 0x34, 0x0f, 0x15, 0x46, 0x73, 0x67, 0xbb, 0x38, 0xcc, 0x7a, 0xc7, 0x97, 0x8b, 0xbd, 0xdc, 0x26, 0xcc, 0xfe, 0x30, 0x42, 0xd6, 0xe6, 0xca, 0x01, 0xa8, 0xb8, 0x90, 0x80, 0x51, 0xfc, 0xb7, 0xa4, 0x50, 0x70, 0xb8, 0x12, 0xf3, 0x3f, 0x26, 0x41, 0xfd, 0xb5, 0x37, 0x90, 0x19, 0x66, 0x8f }; packet.Write(addon_data); manager.Send(packet); manager.mCrypt = new PacketCrypt(manager.mKey); manager.mCrypt.Init(); manager.mCrypt.init(manager.mKey); } catch (Exception e) { Debug.LogWarning(e.StackTrace); } }
private byte[] GenerateCrc(byte[] crcsalt) { Sha1Hash sha; byte[] buffer1 = new byte[0x40]; byte[] buffer2 = new byte[0x40]; for (int i = 0; i < 0x40; ++i) { buffer1[i] = 0x36; buffer2[i] = 0x5c; } for (int i = 0; i < crcsalt.Length; ++i) { buffer1[i] ^= crcsalt[i]; buffer2[i] ^= crcsalt[i]; } sha = new Sha1Hash(); sha.Update(buffer1); try { FileStream fs = new FileStream("hash.bin", FileMode.Open, FileAccess.Read); byte[] Buffer = new byte[fs.Length]; fs.Read(Buffer, 0, (int)fs.Length); sha.Update(Buffer); } catch (Exception e) { BoogieCore.Log(LogType.Error, e.Message); } byte[] hash1 = sha.Final(); sha = new Sha1Hash(); sha.Update(buffer2); sha.Update(hash1); return(sha.Final()); }
// Converts S to K // K is the Key which is passed to the Crypt class public static byte[] ShaInterleave(BigInteger S) { byte[] t = S; int HalfSize = t.Length / 2; // Untested. I previously hard coded this as 16 byte[] t1 = new byte[HalfSize]; for (int i = 0; i < HalfSize; i++) { t1[i] = t[i * 2]; } Sha1Hash sha = new Sha1Hash(); byte[] t1hash = sha.Final(t1); byte[] vK = new byte[40]; for (int i = 0; i < 20; i++) { vK[i * 2] = t1hash[i]; } for (int i = 0; i < HalfSize; i++) { t1[i] = t[i * 2 + 1]; } sha = new Sha1Hash(); t1hash = sha.Final(t1); for (int i = 0; i < 20; i++) { vK[i * 2 + 1] = t1hash[i]; } return(vK); }
public void DoLogonProof() { Sha1Hash sha; byte[] files_crc; // Generate CRC/hashes of the Game Files files_crc = GenerateCrc(crcsalt); // get crc_hash from files_crc sha = new Sha1Hash(); sha.Update(A); sha.Update(files_crc); byte[] crc_hash = sha.Final(); wout.Write((byte)RLOp.AUTH_LOGON_PROOF); wout.Write(A); // 32 bytes wout.Write(M); // 20 bytes wout.Write(crc_hash); // 20 bytes wout.Write((byte)0); // number of keys wout.Write((byte)0); // unk (1.11.x) wout.Flush(); }
private void Handle_AuthRequest(WoWReader wr) { BoogieCore.Log(LogType.System, "WS: Recieved Authentication Challenge: Sending out response"); ServerSeed = wr.ReadUInt32(); ClientSeed = (UInt32)random.Next(); Sha1Hash sha = new Sha1Hash(); sha.Update(mUsername); sha.Update(0); // t sha.Update(ClientSeed); sha.Update(ServerSeed); sha.Update(Key); byte[] Digest = sha.Final(); WoWWriter ww = new WoWWriter(OpCode.CMSG_AUTH_SESSION); ww.Write(BoogieCore.configFile.ReadInteger("WoW", "Build")); ww.Write((UInt32)0); ww.Write(mUsername); ww.Write(ClientSeed); ww.Write(Digest); StreamReader SR; WoWWriter buffer = new WoWWriter(); SR = File.OpenText("Addons.txt"); string Line = SR.ReadLine(); while (Line != null) { string[] Fields = new string[3]; string Name = null; UInt64 Checksum = 0; byte unk = 0x0; Fields = Line.Split(':'); Name = Fields[0]; Checksum = UInt64.Parse(Fields[1]); //unk = (Fields[2].ToCharArray())[0]; if (Name != null && Checksum > 0) { buffer.Write(Name); buffer.Write(Checksum); buffer.Write(unk); //BoogieCore.Log("Adding addon {0} with the checksum {1}", Name, Checksum); } Line = SR.ReadLine(); } SR.Close(); byte[] buffer2 = Foole.Utils.Compression.Compress(buffer.ToArray()); UInt32 Size = (UInt32)buffer.ToArray().Length; ww.Write(Size); ww.Write(buffer2); Send(ww); mCrypt.Init(Key); }
public void AuthChallangeRequest(PacketIn packetIn) { packetIn.ReadByte(); byte error = packetIn.ReadByte(); if (error != 0x00) { Log.WriteLine(LogType.Error, "Authentication error: {0}", (AccountStatus)error); Disconnect(); return; } B = new BigInteger(packetIn.ReadBytes(32)); // Varies byte glen = packetIn.ReadByte(); // Length = 1 g = packetIn.ReadBytes(glen); // g = 7 byte Nlen = packetIn.ReadByte(); // Length = 32 N = packetIn.ReadBytes(Nlen); // N = B79B3E2A87823CAB8F5EBFBF8EB10108535006298B5BADBD5B53E1895E644B89 Salt = new BigInteger(packetIn.ReadBytes(32)); // Salt = 3516482AC96291B3C84B4FC204E65B623EFC2563C8B4E42AA454D93FCD1B56BA crcsalt = packetIn.ReadBytes(16); // Varies BigInteger S; srp = new Srp6(new BigInteger(N), new BigInteger(g)); do { a = BigInteger.Random(19 * 8); A = srp.GetA(a); I = Srp6.GetLogonHash(mUsername, mPassword); BigInteger x = Srp6.Getx(Salt, I); BigInteger u = Srp6.Getu(A, B); S = srp.ClientGetS(a, B, x, u); }while (S < 0); mKey = Srp6.ShaInterleave(S); M = srp.GetM(mUsername, Salt, A, B, new BigInteger(mKey)); packetIn.ReadByte(); Sha1Hash sha; byte[] files_crc; // Generate CRC/hashes of the Game Files if (Config.Retail) { files_crc = GenerateCrc(crcsalt); } else { files_crc = new byte[20]; } // get crc_hash from files_crc sha = new Sha1Hash(); sha.Update(A); sha.Update(files_crc); byte[] crc_hash = sha.Final(); PacketOut packet = new PacketOut(LogonServerOpCode.AUTH_LOGON_PROOF); packet.Write(A); // 32 bytes packet.Write(M); // 20 bytes packet.Write(crc_hash); // 20 bytes packet.Write((byte)0); // number of keys packet.Write((byte)0); // unk (1.11.x) Send(packet); }
public void AuthChallangeRequest(PacketReader packetIn) { packetIn.ReadByte(); AuthResult result = (AuthResult)packetIn.ReadByte(); switch (result) { case AuthResult.WOW_SUCCESS: break; case AuthResult.WOW_FAIL_BANNED: Global.showNotifyBox("This account has been closed and is no longer available for use.", "Okay"); return; break; case AuthResult.WOW_FAIL_UNKNOWN_ACCOUNT: Global.showNotifyBox("Unknown Account/Invalid Password.", "Okay"); return; break; case AuthResult.WOW_FAIL_INCORRECT_PASSWORD: Global.showNotifyBox("Unknown Account/Invalid Password.", "Okay"); return; break; default: break; } B = new BigInteger(packetIn.ReadBytes(32)); byte glen = packetIn.ReadByte(); g = packetIn.ReadBytes(glen); byte Nlen = packetIn.ReadByte(); N = packetIn.ReadBytes(Nlen); Salt = new BigInteger(packetIn.ReadBytes(32)); crcsalt = packetIn.ReadBytes(16); BigInteger S; srp = new Srp6(new BigInteger(N), new BigInteger(g)); do { a = BigInteger.Random(19 * 8); A = srp.GetA(a); I = Srp6.GetLogonHash(mUsername, mPassword); BigInteger x = Srp6.Getx(Salt, I); BigInteger u = Srp6.Getu(A, B); S = srp.ClientGetS(a, B, x, u); }while (S < 0); mKey = Srp6.ShaInterleave(S); M = srp.GetM(mUsername, Salt, A, B, new BigInteger(mKey)); packetIn.ReadByte(); Sha1Hash sha; byte[] files_crc; files_crc = new byte[20]; sha = new Sha1Hash(); sha.Update(A); sha.Update(files_crc); byte[] crc_hash = sha.Final(); PacketWriter packet = new PacketWriter(LogonServerOpCode.AUTH_LOGON_PROOF); packet.Write(A); packet.Write(M); packet.Write(crc_hash); packet.Write((byte)0); packet.Write((byte)0); Send(packet); }