Exemplo n.º 1
0
        private void ParseServerHelloExtension(int iExtType, byte[] arrData)
        {
            if (this._Extensions == null)
            {
                this._Extensions = new List <string>();
            }
            if (iExtType <= 35)
            {
                switch (iExtType)
                {
                case 0:
                    this._Extensions.Add(string.Format("\tserver_name\t{0}", Utilities.ByteArrayToString(arrData)));
                    return;

                case 1:
                    this._Extensions.Add(string.Format("\tmax_fragment_length\t{0}", Utilities.ByteArrayToString(arrData)));
                    return;

                case 2:
                    this._Extensions.Add(string.Format("\tclient_certificate_url\t{0}", Utilities.ByteArrayToString(arrData)));
                    return;

                case 3:
                    this._Extensions.Add(string.Format("\ttrusted_ca_keys\t{0}", Utilities.ByteArrayToString(arrData)));
                    return;

                case 4:
                    this._Extensions.Add(string.Format("\ttruncated_hmac\t{0}", Utilities.ByteArrayToString(arrData)));
                    return;

                case 5:
                    this._Extensions.Add(string.Format("\tstatus_request\t{0}", Utilities.ByteArrayToString(arrData)));
                    return;

                case 6:
                    this._Extensions.Add(string.Format("\tuser_mapping\t{0}", Utilities.ByteArrayToString(arrData)));
                    return;

                case 7:
                case 8:
                case 15:
                    break;

                case 9:
                    this._Extensions.Add(string.Format("\tcert_type\t{0}", Utilities.ByteArrayToString(arrData)));
                    return;

                case 10:
                    this._Extensions.Add(string.Format("\telliptic_curves\t{0}", HTTPSUtilities.GetECCCurvesAsString(arrData)));
                    return;

                case 11:
                    this._Extensions.Add(string.Format("\tec_point_formats\t{0}", HTTPSUtilities.GetECCPointFormatsAsString(arrData)));
                    return;

                case 12:
                    this._Extensions.Add(string.Format("\tsrp_rfc_5054\t{0}", Utilities.ByteArrayToString(arrData)));
                    return;

                case 13:
                    this._Extensions.Add(string.Format("\tsignature_algorithms\t{0}", Utilities.ByteArrayToString(arrData)));
                    return;

                case 14:
                    this._Extensions.Add(string.Format("\tuse_srtp\t{0}", Utilities.ByteArrayToString(arrData)));
                    return;

                case 16:
                {
                    string protocolListAsString = HTTPSUtilities.GetProtocolListAsString(arrData);
                    this._Extensions.Add(string.Format("\tALPN\t\t{0}", protocolListAsString));
                    if (protocolListAsString.Contains("spdy/"))
                    {
                        this.bALPNToSPDY = true;
                        return;
                    }
                    return;
                }

                default:
                    if (iExtType == 35)
                    {
                        this._Extensions.Add(string.Format("\tSessionTicket TLS\t{0}", Utilities.ByteArrayToString(arrData)));
                        return;
                    }
                    break;
                }
            }
            else
            {
                if (iExtType != 13172)
                {
                    if (iExtType == 30031)
                    {
                        this._Extensions.Add(string.Format("\tchannel_id(GoogleDraft)\t{0}", Utilities.ByteArrayToString(arrData)));
                        return;
                    }
                    if (iExtType == 65281)
                    {
                        this._Extensions.Add(string.Format("\trenegotiation_info\t{0}", Utilities.ByteArrayToString(arrData)));
                        return;
                    }
                }
                else
                {
                    string extensionString = HTTPSUtilities.GetExtensionString(arrData);
                    this._Extensions.Add(string.Format("\tNextProtocolNegotiation\t{0}", extensionString));
                    if (extensionString.Contains("spdy/"))
                    {
                        this.bNPNToSPDY = true;
                        return;
                    }
                    return;
                }
            }
            this._Extensions.Add(string.Format("\t0x{0:x4}\t\t{1}", iExtType, Utilities.ByteArrayToString(arrData)));
        }
Exemplo n.º 2
0
        private void ParseClientHelloExtension(int iExtType, byte[] arrData)
        {
            if (this._Extensions == null)
            {
                this._Extensions = new List <string>();
            }
            if (iExtType <= 35)
            {
                switch (iExtType)
                {
                case 0:
                {
                    StringBuilder stringBuilder = new StringBuilder();
                    int           num2;
                    for (int i = 2; i < arrData.Length; i += 3 + num2)
                    {
                        int num = (int)arrData[i];
                        num2 = ((int)arrData[i + 1] << 8) + (int)arrData[i + 2];
                        string @string = Encoding.ASCII.GetString(arrData, i + 3, num2);
                        if (num == 0)
                        {
                            this._ServerNameIndicator = @string;
                            stringBuilder.AppendFormat("{0}{1}", (stringBuilder.Length > 1) ? "; " : string.Empty, @string);
                        }
                    }
                    this._Extensions.Add(string.Format("\tserver_name\t{0}", stringBuilder.ToString()));
                    return;
                }

                case 1:
                    this._Extensions.Add(string.Format("\tmax_fragment_length\t{0}", Utilities.ByteArrayToString(arrData)));
                    return;

                case 2:
                    this._Extensions.Add(string.Format("\tclient_certificate_url\t{0}", Utilities.ByteArrayToString(arrData)));
                    return;

                case 3:
                    this._Extensions.Add(string.Format("\ttrusted_ca_keys\t{0}", Utilities.ByteArrayToString(arrData)));
                    return;

                case 4:
                    this._Extensions.Add(string.Format("\ttruncated_hmac\t{0}", Utilities.ByteArrayToString(arrData)));
                    return;

                case 5:
                    this._Extensions.Add(string.Format("\tstatus_request\t{0}", Utilities.ByteArrayToString(arrData)));
                    return;

                case 6:
                    this._Extensions.Add(string.Format("\tuser_mapping\t{0}", Utilities.ByteArrayToString(arrData)));
                    return;

                case 7:
                case 8:
                case 15:
                    break;

                case 9:
                    this._Extensions.Add(string.Format("\tcert_type\t{0}", Utilities.ByteArrayToString(arrData)));
                    return;

                case 10:
                    this._Extensions.Add(string.Format("\telliptic_curves\t{0}", HTTPSUtilities.GetECCCurvesAsString(arrData)));
                    return;

                case 11:
                    this._Extensions.Add(string.Format("\tec_point_formats\t{0}", HTTPSUtilities.GetECCPointFormatsAsString(arrData)));
                    return;

                case 12:
                    this._Extensions.Add(string.Format("\tsrp_rfc_5054\t{0}", Utilities.ByteArrayToString(arrData)));
                    return;

                case 13:
                    this._Extensions.Add(string.Format("\tsignature_algorithms\t{0}", Utilities.ByteArrayToString(arrData)));
                    return;

                case 14:
                    this._Extensions.Add(string.Format("\tuse_srtp\t{0}", Utilities.ByteArrayToString(arrData)));
                    return;

                case 16:
                {
                    string protocolListAsString = HTTPSUtilities.GetProtocolListAsString(arrData);
                    this._Extensions.Add(string.Format("\tALPN\t\t{0}", protocolListAsString));
                    return;
                }

                default:
                    if (iExtType == 35)
                    {
                        this._Extensions.Add(string.Format("\tSessionTicket TLS\t{0}", Utilities.ByteArrayToString(arrData)));
                        return;
                    }
                    break;
                }
            }
            else
            {
                if (iExtType == 13172)
                {
                    this._Extensions.Add(string.Format("\tNextProtocolNegotiation\t{0}", Utilities.ByteArrayToString(arrData)));
                    return;
                }
                if (iExtType == 30031)
                {
                    this._Extensions.Add(string.Format("\tchannel_id(GoogleDraft)\t{0}", Utilities.ByteArrayToString(arrData)));
                    return;
                }
                if (iExtType == 65281)
                {
                    this._Extensions.Add(string.Format("\trenegotiation_info\t{0}", Utilities.ByteArrayToString(arrData)));
                    return;
                }
            }
            this._Extensions.Add(string.Format("\t0x{0:x4}\t\t{1}", iExtType, Utilities.ByteArrayToString(arrData)));
        }