private static void TestMac(int suffix) { var start = DateTime.Now; Interlocked.Increment(ref _current); using (var tcp = new TcpClient(AddressFamily.InterNetworkV6)) { tcp.Connect(_omm, 16321); var socket = tcp.Client; socket.ReceiveTimeout = 10000; var auth = new byte[0x24]; var init = _init.AsSpan().ToArray(); BinaryPrimitives.WriteInt32LittleEndian(init.AsSpan(0xf), suffix); socket.Receive(auth, SocketFlags.None, out var error); if (error == SocketError.TimedOut) { Console.WriteLine($"Timeout for MAC 003042{HexEncoding.ByteToHex(init.AsSpan(0xf,3))}"); return; } var sysAuth = auth.AsSpan(4); using (var md5 = MD5.Create()) { var data = new byte[sysAuth.Length + init.Length - 0x10 + _signatureKey.Length]; sysAuth.CopyTo(data); init.CopyTo(data.AsSpan(sysAuth.Length)); _signatureKey.CopyTo(data.AsMemory(sysAuth.Length + init.Length - 0x10)); var hash = md5.ComputeHash(data); hash.AsSpan().CopyTo(init.AsSpan(0x104)); } socket.Send(init); var ack = new byte[8]; var read = socket.Receive(ack); if (read != 0) { Console.WriteLine($"Found valid MAC 003042{HexEncoding.ByteToHex(init.AsSpan(0xf,3))}"); Console.WriteLine($"Took {DateTime.Now.Subtract(start).TotalMilliseconds}ms"); } } }