/// <summary> /// Returns a <see cref="System.String" /> that represents this instance. /// </summary> /// <returns> /// A <see cref="System.String" /> that represents this instance. /// </returns> public override string ToString() { var sb = new StringBuilder(); sb.AppendLine("A SSLv3-compatible ClientHello handshake was found. Titanium extracted the parameters below."); sb.AppendLine(); sb.AppendLine($"Version: {SslVersionToString(MajorVersion, MinorVersion)}"); sb.AppendLine($"Random: {string.Join(" ", Random.Select(x => x.ToString("X2")))}"); sb.AppendLine($"\"Time\": {Time}"); sb.AppendLine($"SessionID: {string.Join(" ", SessionId.Select(x => x.ToString("X2")))}"); if (Extensions != null) { sb.AppendLine("Extensions:"); foreach (var extension in Extensions) { sb.AppendLine($"{extension.Name}: {extension.Data}"); } } if (CompressionData.Length > 0) { int compressionMethod = CompressionData[0]; string compression = compressions.Length > compressionMethod ? compressions[compressionMethod] : $"unknown [0x{compressionMethod:X2}]"; sb.AppendLine($"Compression: {compression}"); } if (Ciphers.Length > 0) { sb.AppendLine("Ciphers:"); foreach (int cipherSuite in Ciphers) { string cipherStr; if (!SslCiphers.Ciphers.TryGetValue(cipherSuite, out cipherStr)) { cipherStr = "unknown"; } sb.AppendLine($"[0x{cipherSuite:X4}] {cipherStr}"); } } return(sb.ToString()); }
/// <summary> /// Returns a <see cref="System.String" /> that represents this instance. /// </summary> /// <returns> /// A <see cref="System.String" /> that represents this instance. /// </returns> public override string ToString() { var sb = new StringBuilder(); sb.AppendLine($"A SSLv{HandshakeVersion}-compatible ServerHello handshake was found. Titanium extracted the parameters below."); sb.AppendLine(); sb.AppendLine($"Version: {SslVersionToString(MajorVersion, MinorVersion)}"); sb.AppendLine($"Random: {string.Join(" ", Random.Select(x => x.ToString("X2")))}"); sb.AppendLine($"\"Time\": {Time}"); sb.AppendLine($"SessionID: {string.Join(" ", SessionId.Select(x => x.ToString("X2")))}"); if (Extensions != null) { sb.AppendLine("Extensions:"); foreach (var extension in Extensions.Values.OrderBy(x => x.Position)) { sb.AppendLine($"{extension.Name}: {extension.Data}"); } } string compression = compressions.Length > CompressionMethod ? compressions[CompressionMethod] : $"unknown [0x{CompressionMethod:X2}]"; sb.AppendLine($"Compression: {compression}"); sb.Append("Cipher:"); if (!SslCiphers.Ciphers.TryGetValue(CipherSuite, out string cipherStr)) { cipherStr = "unknown"; } sb.AppendLine($"[0x{CipherSuite:X4}] {cipherStr}"); return(sb.ToString()); }