コード例 #1
0
 protected internal override void EncodeRecordData(byte[] messageData, int offset, ref int currentPosition, Dictionary <string, ushort> domainNames)
 {
     DnsMessageBase.EncodeUShort(messageData, ref currentPosition, Flags);
     messageData[currentPosition++] = Protocol;
     messageData[currentPosition++] = (byte)Algorithm;
     DnsMessageBase.EncodeByteArray(messageData, ref currentPosition, PublicKey);
 }
コード例 #2
0
ファイル: TlsaRecord.cs プロジェクト: zhuyue1314/Xploit
 protected internal override void EncodeRecordData(byte[] messageData, int offset, ref int currentPosition, Dictionary <string, ushort> domainNames)
 {
     messageData[currentPosition++] = (byte)CertificateUsage;
     messageData[currentPosition++] = (byte)Selector;
     messageData[currentPosition++] = (byte)MatchingType;
     DnsMessageBase.EncodeByteArray(messageData, ref currentPosition, CertificateAssociation);
 }
コード例 #3
0
ファイル: AplRecord.cs プロジェクト: zhuyue1314/Xploit
        protected internal override void EncodeRecordData(byte[] messageData, int offset, ref int currentPosition, Dictionary <string, ushort> domainNames)
        {
            foreach (AddressPrefix addressPrefix in Prefixes)
            {
                DnsMessageBase.EncodeUShort(messageData, ref currentPosition, (ushort)addressPrefix.AddressFamily);
                messageData[currentPosition++] = addressPrefix.Prefix;

                // no increment of position pointer, just set 1 bit
                if (addressPrefix.IsNegated)
                {
                    messageData[currentPosition] = 128;
                }

                byte[] addressData = addressPrefix.Address.GetNetworkAddress(addressPrefix.Prefix).GetAddressBytes();
                int    length      = addressData.Length;
                for (; length > 0; length--)
                {
                    if (addressData[length - 1] != 0)
                    {
                        break;
                    }
                }
                messageData[currentPosition++] |= (byte)length;
                DnsMessageBase.EncodeByteArray(messageData, ref currentPosition, addressData, length);
            }
        }
コード例 #4
0
ファイル: DlvRecord.cs プロジェクト: santatic/Xploit
 protected internal override void EncodeRecordData(byte[] messageData, int offset, ref int currentPosition, Dictionary <string, ushort> domainNames)
 {
     DnsMessageBase.EncodeUShort(messageData, ref currentPosition, KeyTag);
     messageData[currentPosition++] = (byte)Algorithm;
     messageData[currentPosition++] = (byte)DigestType;
     DnsMessageBase.EncodeByteArray(messageData, ref currentPosition, Digest);
 }
コード例 #5
0
        internal byte[] GetNSec3Hash(NSec3HashAlgorithm algorithm, int iterations, byte[] salt)
        {
            IDigest digest;

            switch (algorithm)
            {
            case NSec3HashAlgorithm.Sha1:
                digest = new Sha1Digest();
                break;

            default:
                throw new NotSupportedException();
            }

            byte[] buffer = new byte[Math.Max(MaximumRecordDataLength + 1, digest.GetDigestSize()) + salt.Length];

            int length = 0;

            DnsMessageBase.EncodeDomainName(buffer, 0, ref length, this, null, true);

            for (int i = 0; i <= iterations; i++)
            {
                DnsMessageBase.EncodeByteArray(buffer, ref length, salt);

                digest.BlockUpdate(buffer, 0, length);

                digest.DoFinal(buffer, 0);
                length = digest.GetDigestSize();
            }

            byte[] res = new byte[length];
            Buffer.BlockCopy(buffer, 0, res, 0, length);

            return(res);
        }
コード例 #6
0
 protected internal override void EncodeRecordData(byte[] messageData, int offset, ref int currentPosition, Dictionary <string, ushort> domainNames)
 {
     messageData[currentPosition++] = (byte)HashAlgorithm;
     messageData[currentPosition++] = Flags;
     DnsMessageBase.EncodeUShort(messageData, ref currentPosition, Iterations);
     messageData[currentPosition++] = (byte)Salt.Length;
     DnsMessageBase.EncodeByteArray(messageData, ref currentPosition, Salt);
 }
コード例 #7
0
 protected override void EncodePublicKey(byte[] messageData, int offset, ref int currentPosition, Dictionary <string, ushort> domainNames)
 {
     DnsMessageBase.EncodeUShort(messageData, ref currentPosition, (ushort)Prime.Length);
     DnsMessageBase.EncodeByteArray(messageData, ref currentPosition, Prime);
     DnsMessageBase.EncodeUShort(messageData, ref currentPosition, (ushort)Generator.Length);
     DnsMessageBase.EncodeByteArray(messageData, ref currentPosition, Generator);
     DnsMessageBase.EncodeUShort(messageData, ref currentPosition, (ushort)PublicValue.Length);
     DnsMessageBase.EncodeByteArray(messageData, ref currentPosition, PublicValue);
 }
コード例 #8
0
ファイル: EDns.cs プロジェクト: IPA-CyberLab/IPA-DN-Cores
    internal override void EncodeData(Span <byte> messageData, ref int currentPosition)
    {
        DnsMessageBase.EncodeUShort(messageData, ref currentPosition, (ushort)(Family == AddressFamily.InterNetwork ? 1 : 2));
        messageData[currentPosition++] = SourceNetmask;
        messageData[currentPosition++] = ScopeNetmask;

        byte[] data = Address.GetAddressBytes();
        DnsMessageBase.EncodeByteArray(messageData, ref currentPosition, data, GetAddressLength());
    }
コード例 #9
0
ファイル: EDns.cs プロジェクト: IPA-CyberLab/IPA-DN-Cores
 internal override void EncodeData(Span <byte> messageData, ref int currentPosition)
 {
     messageData[currentPosition++] = Version;
     messageData[currentPosition++] = Sequence;
     DnsMessageBase.EncodeByteArray(messageData, ref currentPosition, PrimaryMacAddress.GetAddressBytes());
     if (WakeupMacAddress != null)
     {
         DnsMessageBase.EncodeByteArray(messageData, ref currentPosition, WakeupMacAddress.GetAddressBytes());
     }
     DnsMessageBase.EncodeByteArray(messageData, ref currentPosition, Password);
 }
コード例 #10
0
ファイル: TSigRecord.cs プロジェクト: santatic/Xploit
 private void EncodeRecordData(byte[] messageData, int offset, ref int currentPosition, Dictionary <string, ushort> domainNames, byte[] mac)
 {
     DnsMessageBase.EncodeDomainName(messageData, offset, ref currentPosition, TSigAlgorithmHelper.GetDomainName(Algorithm), false, domainNames);
     EncodeDateTime(messageData, ref currentPosition, TimeSigned);
     DnsMessageBase.EncodeUShort(messageData, ref currentPosition, (ushort)Fudge.TotalSeconds);
     DnsMessageBase.EncodeUShort(messageData, ref currentPosition, (ushort)mac.Length);
     DnsMessageBase.EncodeByteArray(messageData, ref currentPosition, mac);
     DnsMessageBase.EncodeUShort(messageData, ref currentPosition, OriginalID);
     DnsMessageBase.EncodeUShort(messageData, ref currentPosition, (ushort)Error);
     DnsMessageBase.EncodeUShort(messageData, ref currentPosition, (ushort)OtherData.Length);
     DnsMessageBase.EncodeByteArray(messageData, ref currentPosition, OtherData);
 }
コード例 #11
0
ファイル: HipRecord.cs プロジェクト: zhuyue1314/Xploit
 protected internal override void EncodeRecordData(byte[] messageData, int offset, ref int currentPosition, Dictionary <string, ushort> domainNames)
 {
     messageData[currentPosition++] = (byte)Hit.Length;
     messageData[currentPosition++] = (byte)Algorithm;
     DnsMessageBase.EncodeUShort(messageData, ref currentPosition, (ushort)PublicKey.Length);
     DnsMessageBase.EncodeByteArray(messageData, ref currentPosition, Hit);
     DnsMessageBase.EncodeByteArray(messageData, ref currentPosition, PublicKey);
     foreach (string server in RendezvousServers)
     {
         DnsMessageBase.EncodeDomainName(messageData, offset, ref currentPosition, server, false, domainNames);
     }
 }
コード例 #12
0
 protected internal override void EncodeRecordData(byte[] messageData, int offset, ref int currentPosition, Dictionary <string, ushort> domainNames)
 {
     DnsMessageBase.EncodeDomainName(messageData, offset, ref currentPosition, TSigAlgorithmHelper.GetDomainName(Algorithm), false, domainNames);
     EncodeDateTime(messageData, ref currentPosition, Inception);
     EncodeDateTime(messageData, ref currentPosition, Expiration);
     DnsMessageBase.EncodeUShort(messageData, ref currentPosition, (ushort)Mode);
     DnsMessageBase.EncodeUShort(messageData, ref currentPosition, (ushort)Error);
     DnsMessageBase.EncodeUShort(messageData, ref currentPosition, (ushort)Key.Length);
     DnsMessageBase.EncodeByteArray(messageData, ref currentPosition, Key);
     DnsMessageBase.EncodeUShort(messageData, ref currentPosition, (ushort)OtherData.Length);
     DnsMessageBase.EncodeByteArray(messageData, ref currentPosition, OtherData);
 }
コード例 #13
0
ファイル: RrSigRecord.cs プロジェクト: zhuyue1314/Xploit
 protected internal override void EncodeRecordData(byte[] messageData, int offset, ref int currentPosition, Dictionary <string, ushort> domainNames)
 {
     DnsMessageBase.EncodeUShort(messageData, ref currentPosition, (ushort)TypeCovered);
     messageData[currentPosition++] = (byte)Algorithm;
     messageData[currentPosition++] = Labels;
     DnsMessageBase.EncodeInt(messageData, ref currentPosition, OriginalTimeToLive);
     EncodeDateTime(messageData, ref currentPosition, SignatureExpiration);
     EncodeDateTime(messageData, ref currentPosition, SignatureInception);
     DnsMessageBase.EncodeUShort(messageData, ref currentPosition, KeyTag);
     DnsMessageBase.EncodeDomainName(messageData, offset, ref currentPosition, SignersName, false, null);
     DnsMessageBase.EncodeByteArray(messageData, ref currentPosition, Signature);
 }
コード例 #14
0
ファイル: WksRecord.cs プロジェクト: zhuyue1314/Xploit
        protected internal override void EncodeRecordData(byte[] messageData, int offset, ref int currentPosition, Dictionary <string, ushort> domainNames)
        {
            DnsMessageBase.EncodeByteArray(messageData, ref currentPosition, Address.GetAddressBytes());
            messageData[currentPosition++] = (byte)Protocol;

            foreach (ushort port in Ports)
            {
                int  octetPosition = port / 8 + currentPosition;
                int  bitPos        = port % 8;
                byte octet         = messageData[octetPosition];
                octet |= (byte)(1 << Math.Abs(bitPos - 7));
                messageData[octetPosition] = octet;
            }
            currentPosition += Ports.Max() / 8 + 1;
        }
コード例 #15
0
ファイル: NSecRecord.cs プロジェクト: zhuyue1314/Xploit
        internal static void EncodeTypeBitmap(byte[] messageData, ref int currentPosition, List <RecordType> types)
        {
            int windowEnd = 255;

            byte[] windowData   = new byte[32];
            int    windowLength = 0;

            foreach (ushort type in types.Select(t => (ushort)t))
            {
                if (type > windowEnd)
                {
                    if (windowLength > 0)
                    {
                        messageData[currentPosition++] = (byte)(windowEnd / 256);
                        messageData[currentPosition++] = (byte)windowLength;
                        DnsMessageBase.EncodeByteArray(messageData, ref currentPosition, windowData, windowLength);
                    }

                    windowEnd    = (type / 256 + 1) * 256 - 1;
                    windowLength = 0;
                }

                int typeLower = type % 256;

                int octetPos = typeLower / 8;
                int bitPos   = typeLower % 8;

                while (windowLength <= octetPos)
                {
                    windowData[windowLength] = 0;
                    windowLength++;
                }

                byte octet = windowData[octetPos];
                octet |= (byte)(1 << Math.Abs(bitPos - 7));
                windowData[octetPos] = octet;
            }

            if (windowLength > 0)
            {
                messageData[currentPosition++] = (byte)(windowEnd / 256);
                messageData[currentPosition++] = (byte)windowLength;
                DnsMessageBase.EncodeByteArray(messageData, ref currentPosition, windowData, windowLength);
            }
        }
コード例 #16
0
ファイル: IpSecKeyRecord.cs プロジェクト: santatic/Xploit
        protected internal override void EncodeRecordData(byte[] messageData, int offset, ref int currentPosition, Dictionary <string, ushort> domainNames)
        {
            messageData[currentPosition++] = Precedence;
            messageData[currentPosition++] = (byte)GatewayType;
            messageData[currentPosition++] = (byte)Algorithm;
            switch (GatewayType)
            {
            case IpSecGatewayType.IpV4:
            case IpSecGatewayType.IpV6:
                byte[] addressBuffer = IPAddress.Parse(Gateway).GetAddressBytes();
                DnsMessageBase.EncodeByteArray(messageData, ref currentPosition, addressBuffer);
                break;

            case IpSecGatewayType.Domain:
                DnsMessageBase.EncodeDomainName(messageData, offset, ref currentPosition, Gateway, false, domainNames);
                break;
            }
            DnsMessageBase.EncodeByteArray(messageData, ref currentPosition, PublicKey);
        }
コード例 #17
0
ファイル: KeyRecord.cs プロジェクト: zhuyue1314/Xploit
 protected override void EncodePublicKey(byte[] messageData, int offset, ref int currentPosition, Dictionary <string, ushort> domainNames)
 {
     DnsMessageBase.EncodeByteArray(messageData, ref currentPosition, PublicKey);
 }
コード例 #18
0
 protected internal override void EncodeRecordData(byte[] messageData, int offset, ref int currentPosition, Dictionary <string, ushort> domainNames)
 {
     DnsMessageBase.EncodeByteArray(messageData, ref currentPosition, Address.GetAddressBytes());
 }
コード例 #19
0
ファイル: EDns.cs プロジェクト: IPA-CyberLab/IPA-DN-Cores
 internal override void EncodeData(Span <byte> messageData, ref int currentPosition)
 {
     DnsMessageBase.EncodeByteArray(messageData, ref currentPosition, ClientCookie);
     DnsMessageBase.EncodeByteArray(messageData, ref currentPosition, ServerCookie);
 }
コード例 #20
0
ファイル: EDns.cs プロジェクト: IPA-CyberLab/IPA-DN-Cores
 internal override void EncodeData(Span <byte> messageData, ref int currentPosition)
 {
     DnsMessageBase.EncodeByteArray(messageData, ref currentPosition, Payload);
 }
コード例 #21
0
ファイル: UnknownOption.cs プロジェクト: BLun78/DnsProxy
 internal override void EncodeData(byte[] messageData, ref int currentPosition)
 {
     DnsMessageBase.EncodeByteArray(messageData, ref currentPosition, Data);
 }