Пример #1
0
		public RecordTXT(RecordReader rr, int Length)
		{
			int pos = rr.Position;
			TXT = new List<string>();
			while ((rr.Position - pos) < Length)
				TXT.Add(rr.ReadString());
		}
Пример #2
0
		public RecordKEY(RecordReader rr)
		{
			FLAGS = rr.ReadUInt16();
			PROTOCOL = rr.ReadByte();
			ALGORITHM = rr.ReadByte();
			PUBLICKEY = rr.ReadString();
		}
Пример #3
0
		public Response(IPEndPoint iPEndPoint, byte[] data)
		{
			Error = "";
			Server = iPEndPoint;
			TimeStamp = DateTime.Now;
			MessageSize = data.Length;
			RecordReader rr = new RecordReader(data);

			Questions = new List<Question>();
			Answers = new List<AnswerRR>();
			Authorities = new List<AuthorityRR>();
			Additionals = new List<AdditionalRR>();

			header = new Header(rr);

			for (int intI = 0; intI < header.QDCOUNT; intI++)
			{
				Questions.Add(new Question(rr));
			}

			for (int intI = 0; intI < header.ANCOUNT; intI++)
			{
				Answers.Add(new AnswerRR(rr));
			}

			for (int intI = 0; intI < header.NSCOUNT; intI++)
			{
				Authorities.Add(new AuthorityRR(rr));
			}
			for (int intI = 0; intI < header.ARCOUNT; intI++)
			{
				Additionals.Add(new AdditionalRR(rr));
			}
		}
Пример #4
0
		public string ReadDomainName()
		{
			var bytes = new List<byte>();
			int length = 0;

			// get  the length of the first label
			while ((length = ReadByte()) != 0)
			{
				// top 2 bits set denotes domain name compression and to reference elsewhere
				if ((length & 0xc0) == 0xc0)
				{
					// work out the existing domain name, copy this pointer
					RecordReader newRecordReader = new RecordReader(m_Data, (length & 0x3f) << 8 | ReadByte());
					if (bytes.Count > 0)
					{
						return Encoding.UTF8.GetString(bytes.ToArray(), 0, bytes.Count) + newRecordReader.ReadDomainName();
					}
					return newRecordReader.ReadDomainName();
				}

				// if not using compression, copy a char at a time to the domain name
				while (length > 0)
				{
					bytes.Add(ReadByte());
					length--;
				}
				bytes.Add((byte)'.');
			}
			if (bytes.Count == 0)
				return ".";
			return Encoding.UTF8.GetString(bytes.ToArray(), 0, bytes.Count);
		}
Пример #5
0
		public RecordSRV(RecordReader rr)
		{
			PRIORITY = rr.ReadUInt16();
			WEIGHT = rr.ReadUInt16();
			PORT = rr.ReadUInt16();
			TARGET = rr.ReadDomainName();
		}
Пример #6
0
		public string ReadDomainName()
		{
			StringBuilder name = new StringBuilder();
			int length = 0;

			// get  the length of the first label
			while ((length = ReadByte()) != 0)
			{
				// top 2 bits set denotes domain name compression and to reference elsewhere
				if ((length & 0xc0) == 0xc0)
				{
					// work out the existing domain name, copy this pointer
					RecordReader newRecordReader = new RecordReader(m_Data, (length & 0x3f) << 8 | ReadByte());

					name.Append(newRecordReader.ReadDomainName());
					return name.ToString();
				}

				// if not using compression, copy a char at a time to the domain name
				while (length > 0)
				{
					name.Append(ReadChar());
					length--;
				}
				name.Append('.');
			}
			if (name.Length == 0)
				return ".";
			else
				return name.ToString();
		}
Пример #7
0
		public RecordNSEC(RecordReader rr)
		{
			// re-read length
			ushort RDLENGTH = rr.ReadUInt16(-2);

			RDATA = rr.ReadBytes(RDLENGTH);
		}
Пример #8
0
        public RecordSRV(RecordReader rr)
        {
            Priority = rr.ReadShort();
            Weight = rr.ReadShort();
            Port = rr.ReadShort();
            Target = rr.ReadDomainName();
 		}
Пример #9
0
		public RecordUnknown(RecordReader rr)
		{
			rr.Position -=2;
			// re-read length
			ushort RDLENGTH = rr.ReadShort();
			// skip bytes
			rr.ReadBytes(RDLENGTH);
		}
Пример #10
0
		public RecordNXT(RecordReader rr)
		{
			ushort length = rr.ReadUInt16(-2);
			NEXTDOMAINNAME = rr.ReadDomainName();
			length -= (ushort)rr.Position;
			BITMAP = new byte[length];
			BITMAP = rr.ReadBytes(length);
		}
Пример #11
0
 public RecordA(RecordReader rr)
 {
     Address = string.Format("{0}.{1}.{2}.{3}",
         rr.ReadByte(),
         rr.ReadByte(),
         rr.ReadByte(),
         rr.ReadByte());
 }
Пример #12
0
 public RecordA(RecordReader rr)
 {
     System.Net.IPAddress.TryParse(string.Format(CultureInfo.InvariantCulture, "{0}.{1}.{2}.{3}",
         rr.ReadByte(),
         rr.ReadByte(),
         rr.ReadByte(),
         rr.ReadByte()), out this.m_address);
 }
Пример #13
0
 public RecordNULL(RecordReader rr)
 {
     rr.Position -= 2;
     // re-read length
     ushort RDLENGTH = rr.ReadUInt16();
     ANYTHING = new byte[RDLENGTH];
     ANYTHING = rr.ReadBytes(RDLENGTH);
 }
Пример #14
0
		public RecordA(RecordReader rr)
		{
			System.Net.IPAddress.TryParse(string.Format("{0}.{1}.{2}.{3}",
				rr.ReadByte(),
				rr.ReadByte(),
				rr.ReadByte(),
				rr.ReadByte()), out this.Address);
		}
Пример #15
0
 public RecordNAPTR(RecordReader rr)
 {
     ORDER = rr.ReadUInt16();
     PREFERENCE = rr.ReadUInt16();
     FLAGS = rr.ReadString();
     SERVICES = rr.ReadString();
     REGEXP = rr.ReadString();
     REPLACEMENT = rr.ReadDomainName();
 }
Пример #16
0
		public RecordA(RecordReader rr)
		{
			Address = new System.Net.IPAddress(rr.ReadBytes(4));
			//System.Net.IPAddress.TryParse(string.Format("{0}.{1}.{2}.{3}",
			//	rr.ReadByte(),
			//	rr.ReadByte(),
			//	rr.ReadByte(),
			//	rr.ReadByte()), out this.Address);
		}
Пример #17
0
 public RecordSOA(RecordReader rr)
 {
     MNAME   = rr.ReadDomainName();
     RNAME   = rr.ReadDomainName();
     SERIAL  = rr.ReadInt();
     REFRESH = rr.ReadInt();
     RETRY   = rr.ReadInt();
     EXPIRE  = rr.ReadInt();
     MINIMUM = rr.ReadInt();
 }
Пример #18
0
		public RecordSOA(RecordReader rr)
		{
			MNAME = rr.ReadDomainName();
			RNAME = rr.ReadDomainName();
			SERIAL = rr.ReadUInt32();
			REFRESH = rr.ReadUInt32();
			RETRY = rr.ReadUInt32();
			EXPIRE = rr.ReadUInt32();
			MINIMUM = rr.ReadUInt32();
		}
Пример #19
0
 public RecordLOC(RecordReader rr)
 {
     VERSION   = rr.ReadByte();           // must be 0!
     SIZE      = rr.ReadByte();
     HORIZPRE  = rr.ReadByte();
     VERTPRE   = rr.ReadByte();
     LATITUDE  = rr.ReadUInt32();
     LONGITUDE = rr.ReadUInt32();
     ALTITUDE  = rr.ReadUInt32();
 }
Пример #20
0
		public RecordDS(RecordReader rr)
		{
			ushort length = rr.ReadUInt16(-2);
			KEYTAG = rr.ReadUInt16();
			ALGORITHM = rr.ReadByte();
			DIGESTTYPE = rr.ReadByte();
			length -= 4;
			DIGEST = new byte[length];
			DIGEST = rr.ReadBytes(length);
		}
Пример #21
0
        public RecordTXT(RecordReader rr, int Length)
        {
            int pos = rr.Position;

            TXT = new List <string>();
            while ((rr.Position - pos) < Length)
            {
                TXT.Add(rr.ReadString());
            }
        }
Пример #22
0
        public RecordNAPTR(RecordReader rr)
        {
            Order = rr.ReadShort();
            Preference = rr.ReadShort();
            rr.ReadChar();                      // 1 byte needs to be skipped since for ENUM lookups the flag should be single char only. 
            Flag = rr.ReadChar();
            Service = rr.ReadString();
            Rule = rr.ReadString();
            Rule = (Rule != null) ? Rule.Replace(@"\\", @"\") : null;
            Replacement = rr.ReadDomainName();                  
 		}
Пример #23
0
 public RecordNAPTR(RecordReader rr)
 {
     Order      = rr.ReadShort();
     Preference = rr.ReadShort();
     rr.ReadChar();                      // 1 byte needs to be skipped since for ENUM lookups the flag should be single char only.
     Flag        = rr.ReadChar();
     Service     = rr.ReadString();
     Rule        = rr.ReadString();
     Rule        = (Rule != null) ? Rule.Replace(@"\\", @"\") : null;
     Replacement = rr.ReadDomainName();
 }
Пример #24
0
        public RecordDS(RecordReader rr)
        {
            ushort length = rr.ReadUInt16(-2);

            KEYTAG     = rr.ReadUInt16();
            ALGORITHM  = rr.ReadByte();
            DIGESTTYPE = rr.ReadByte();
            length    -= 4;
            DIGEST     = new byte[length];
            DIGEST     = rr.ReadBytes(length);
        }
Пример #25
0
 public RR(RecordReader rr)
 {
     TimeLived = 0;
     NAME      = rr.ReadDomainName();
     Type      = (Type)rr.ReadUInt16();
     Class     = (Class)rr.ReadUInt16();
     TTL       = rr.ReadUInt32();
     RDLENGTH  = rr.ReadUInt16();
     RECORD    = rr.ReadRecord(Type);
     RECORD.RR = this;
 }
Пример #26
0
 public RecordTKEY(RecordReader rr)
 {
     ALGORITHM  = rr.ReadDomainName();
     INCEPTION  = rr.ReadUInt32();
     EXPIRATION = rr.ReadUInt32();
     MODE       = rr.ReadUInt16();
     ERROR      = rr.ReadUInt16();
     KEYSIZE    = rr.ReadUInt16();
     KEYDATA    = rr.ReadBytes(KEYSIZE);
     OTHERSIZE  = rr.ReadUInt16();
     OTHERDATA  = rr.ReadBytes(OTHERSIZE);
 }
Пример #27
0
		public RecordTKEY(RecordReader rr)
		{
			ALGORITHM = rr.ReadDomainName();
			INCEPTION = rr.ReadUInt32();
			EXPIRATION = rr.ReadUInt32();
			MODE = rr.ReadUInt16();
			ERROR = rr.ReadUInt16();
			KEYSIZE = rr.ReadUInt16();
			KEYDATA = rr.ReadBytes(KEYSIZE);
			OTHERSIZE = rr.ReadUInt16();
			OTHERDATA = rr.ReadBytes(OTHERSIZE);
		}
Пример #28
0
 public RecordTSIG(RecordReader rr)
 {
     ALGORITHMNAME = rr.ReadDomainName();
     TIMESIGNED    = rr.ReadUInt32() << 32 | rr.ReadUInt32();
     FUDGE         = rr.ReadUInt16();
     MACSIZE       = rr.ReadUInt16();
     MAC           = rr.ReadBytes(MACSIZE);
     ORIGINALID    = rr.ReadUInt16();
     ERROR         = rr.ReadUInt16();
     OTHERLEN      = rr.ReadUInt16();
     OTHERDATA     = rr.ReadBytes(OTHERLEN);
 }
Пример #29
0
		public RecordAAAA(RecordReader rr)
		{
            Address = string.Format("{0:x}:{1:x}:{2:x}:{3:x}:{4:x}:{5:x}:{6:x}:{7:x}",
                rr.ReadUInt16(),
                rr.ReadUInt16(),
                rr.ReadUInt16(),
                rr.ReadUInt16(),
                rr.ReadUInt16(),
                rr.ReadUInt16(),
                rr.ReadUInt16(),
                rr.ReadUInt16());
		}
Пример #30
0
 public RecordTSIG(RecordReader rr)
 {
     ALGORITHMNAME = rr.ReadDomainName();
     TIMESIGNED = rr.ReadUInt32() << 32 | rr.ReadUInt32();
     FUDGE = rr.ReadUInt16();
     MACSIZE = rr.ReadUInt16();
     MAC = rr.ReadBytes(MACSIZE);
     ORIGINALID = rr.ReadUInt16();
     ERROR = rr.ReadUInt16();
     OTHERLEN = rr.ReadUInt16();
     OTHERDATA = rr.ReadBytes(OTHERLEN);
 }
Пример #31
0
 public RecordSIG(RecordReader rr)
 {
     TYPECOVERED         = rr.ReadUInt16();
     ALGORITHM           = rr.ReadByte();
     LABELS              = rr.ReadByte();
     ORIGINALTTL         = rr.ReadUInt32();
     SIGNATUREEXPIRATION = rr.ReadUInt32();
     SIGNATUREINCEPTION  = rr.ReadUInt32();
     KEYTAG              = rr.ReadUInt16();
     SIGNERSNAME         = rr.ReadDomainName();
     SIGNATURE           = rr.ReadString();
 }
Пример #32
0
 public RecordAAAA(RecordReader rr)
 {
     Address = string.Format("{0:x}:{1:x}:{2:x}:{3:x}:{4:x}:{5:x}:{6:x}:{7:x}",
                             rr.ReadUInt16(),
                             rr.ReadUInt16(),
                             rr.ReadUInt16(),
                             rr.ReadUInt16(),
                             rr.ReadUInt16(),
                             rr.ReadUInt16(),
                             rr.ReadUInt16(),
                             rr.ReadUInt16());
 }
Пример #33
0
		public RecordSIG(RecordReader rr)
		{
			TYPECOVERED = rr.ReadUInt16();
			ALGORITHM = rr.ReadByte();
			LABELS = rr.ReadByte();
			ORIGINALTTL = rr.ReadUInt32();
			SIGNATUREEXPIRATION = rr.ReadUInt32();
			SIGNATUREINCEPTION = rr.ReadUInt32();
			KEYTAG = rr.ReadUInt16();
			SIGNERSNAME = rr.ReadDomainName();
			SIGNATURE = rr.ReadString();
		}
Пример #34
0
		public RecordWKS(RecordReader rr)
		{
			ushort length = rr.ReadShort(-2);
			ADDRESS = string.Format("{0}.{1}.{2}.{3}",
				rr.ReadByte(),
				rr.ReadByte(),
				rr.ReadByte(),
				rr.ReadByte());
			PROTOCOL = (int)rr.ReadByte();
			length -= 5;
			BITMAP = new byte[length];
			BITMAP = rr.ReadBytes(length);
		}
Пример #35
0
		public RecordAAAA(RecordReader rr)
		{
			System.Net.IPAddress.TryParse(
				string.Format("{0:x}:{1:x}:{2:x}:{3:x}:{4:x}:{5:x}:{6:x}:{7:x}",
				rr.ReadUInt16(),
				rr.ReadUInt16(),
				rr.ReadUInt16(),
				rr.ReadUInt16(),
				rr.ReadUInt16(),
				rr.ReadUInt16(),
				rr.ReadUInt16(),
				rr.ReadUInt16()), out this.Address);
		}
Пример #36
0
 public RecordAAAA(RecordReader rr)
 {
     System.Net.IPAddress.TryParse(
         string.Format(CultureInfo.InvariantCulture, "{0:x}:{1:x}:{2:x}:{3:x}:{4:x}:{5:x}:{6:x}:{7:x}",
         rr.ReadUInt16(),
         rr.ReadUInt16(),
         rr.ReadUInt16(),
         rr.ReadUInt16(),
         rr.ReadUInt16(),
         rr.ReadUInt16(),
         rr.ReadUInt16(),
         rr.ReadUInt16()), out this.m_address);
 }
Пример #37
0
 public RecordAAAA(RecordReader rr)
 {
     System.Net.IPAddress.TryParse(
         string.Format(CultureInfo.InvariantCulture, "{0:x}:{1:x}:{2:x}:{3:x}:{4:x}:{5:x}:{6:x}:{7:x}",
                       rr.ReadUInt16(),
                       rr.ReadUInt16(),
                       rr.ReadUInt16(),
                       rr.ReadUInt16(),
                       rr.ReadUInt16(),
                       rr.ReadUInt16(),
                       rr.ReadUInt16(),
                       rr.ReadUInt16()), out this.m_address);
 }
Пример #38
0
 public RecordAAAA(RecordReader rr)
 {
     System.Net.IPAddress.TryParse(
         string.Format("{0:x}:{1:x}:{2:x}:{3:x}:{4:x}:{5:x}:{6:x}:{7:x}",
                       rr.ReadUInt16(),
                       rr.ReadUInt16(),
                       rr.ReadUInt16(),
                       rr.ReadUInt16(),
                       rr.ReadUInt16(),
                       rr.ReadUInt16(),
                       rr.ReadUInt16(),
                       rr.ReadUInt16()), out this.Address);
 }
Пример #39
0
        public RecordWKS(RecordReader rr)
        {
            ushort length = rr.ReadUInt16(-2);

            ADDRESS = string.Format(CultureInfo.InvariantCulture, "{0}.{1}.{2}.{3}",
                                    rr.ReadByte(),
                                    rr.ReadByte(),
                                    rr.ReadByte(),
                                    rr.ReadByte());
            PROTOCOL = (int)rr.ReadByte();
            length  -= 5;
            BITMAP   = new byte[length];
            BITMAP   = rr.ReadBytes(length);
        }
Пример #40
0
        public RecordWKS(RecordReader rr)
        {
            ushort length = rr.ReadShort(-2);

            ADDRESS = string.Format("{0}.{1}.{2}.{3}",
                                    rr.ReadByte(),
                                    rr.ReadByte(),
                                    rr.ReadByte(),
                                    rr.ReadByte());
            PROTOCOL = (int)rr.ReadByte();
            length  -= 5;
            BITMAP   = new byte[length];
            BITMAP   = rr.ReadBytes(length);
        }
Пример #41
0
        public RecordCERT(RecordReader rr)
        {
            // re-read length
            ushort RDLENGTH = rr.ReadUInt16(-2);

            //RDATA = rr.ReadBytes(RDLENGTH);

            TYPE      = rr.ReadUInt16();
            KEYTAG    = rr.ReadUInt16();
            ALGORITHM = rr.ReadByte();
            var length = RDLENGTH - 5;

            RAWKEY    = rr.ReadBytes(length);
            PUBLICKEY = Convert.ToBase64String(RAWKEY);
        }
Пример #42
0
        public RR(RecordReader rr)
        {
            TimeLived = 0;
            NAME      = rr.ReadDomainName();
            Type      = (DNSType)rr.ReadShort();
            Class     = (Class)rr.ReadShort();
            TTL       = rr.ReadInt();
            RDLENGTH  = rr.ReadShort();
            //Console.WriteLine("RDLENGTH : " + RDLENGTH.ToString());
            RECORD = rr.ReadRecord(Type);
            //Console.WriteLine("Type : " + Type.ToString());
            RECORD.RR = this;

            //Console.WriteLine("TTL=" + TTL + ".");

            if (TTL <= 0)
            {
                TTL = MIN_TTL;
            }
        }
Пример #43
0
        public DNSResponse(IPEndPoint iPEndPoint, byte[] data)
        {
            Server      = iPEndPoint;
            TimeStamp   = DateTime.Now;
            MessageSize = data.Length;
            RecordReader rr = new RecordReader(data);

            Questions   = new List <Question>();
            Answers     = new List <AnswerRR>();
            Authorities = new List <AuthorityRR>();
            Additionals = new List <AdditionalRR>();

            header = new Header(rr);

            for (int intI = 0; intI < header.QDCOUNT; intI++)
            {
                Questions.Add(new Question(rr));
            }

            for (int intI = 0; intI < header.ANCOUNT; intI++)
            {
                Answers.Add(new AnswerRR(rr));
            }

            for (int intI = 0; intI < header.NSCOUNT; intI++)
            {
                Authorities.Add(new AuthorityRR(rr));
            }

            for (int intI = 0; intI < header.ARCOUNT; intI++)
            {
                Additionals.Add(new AdditionalRR(rr));
            }

            if (header.RCODE != RCode.NOERROR)
            {
                Error = header.RCODE.ToString();
            }
        }
Пример #44
0
        public string ReadDomainName()
        {
            StringBuilder name   = new StringBuilder();
            int           length = 0;

            // get  the length of the first label
            while ((length = ReadByte()) != 0)
            {
                // top 2 bits set denotes domain name compression and to reference elsewhere
                if ((length & 0xc0) == 0xc0)
                {
                    // work out the existing domain name, copy this pointer
                    RecordReader newRecordReader = new RecordReader(m_Data, (length & 0x3f) << 8 | ReadByte());

                    name.Append(newRecordReader.ReadDomainName());
                    return(name.ToString());
                }

                // if not using compression, copy a char at a time to the domain name
                while (length > 0)
                {
                    name.Append(ReadChar());
                    length--;
                }

                name.Append('.');
            }

            if (name.Length == 0)
            {
                return(".");
            }
            else
            {
                return(name.ToString());
            }
        }
Пример #45
0
 public RecordMG(RecordReader rr)
 {
     MGMNAME = rr.ReadDomainName();
 }
Пример #46
0
		public RecordRP(RecordReader rr)
		{
			//MBOXDNAME = rr.ReadString();
			MBOXDNAME = rr.ReadDomainName();
			TXTDNAME = rr.ReadDomainName();
		}
Пример #47
0
 public RecordTXT(RecordReader rr)
 {
     TXT = rr.ReadString();
 }
Пример #48
0
		public RecordTXT(RecordReader rr)
		{
			TXT = rr.ReadString();
		}
Пример #49
0
 public RecordNSAP(RecordReader rr)
 {
     LENGTH      = rr.ReadUInt16();
     NSAPADDRESS = rr.ReadBytes(LENGTH);
 }
Пример #50
0
 public RecordMX(RecordReader rr)
 {
     PREFERENCE = rr.ReadShort();
     EXCHANGE   = rr.ReadDomainName();
 }
Пример #51
0
 public AdditionalRR(RecordReader br)
     : base(br)
 {
 }
Пример #52
0
 /// <summary>
 /// .ctor using record (from response)
 /// </summary>
 /// <param name="rr"></param>
 public Question(RecordReader rr)
 {
     QName  = rr.ReadDomainName();
     QType  = (QType)rr.ReadUInt16();
     QClass = (QClass)rr.ReadUInt16();
 }
Пример #53
0
 public RecordGPOS(RecordReader rr)
 {
     LONGITUDE = rr.ReadString();
     LATITUDE  = rr.ReadString();
     ALTITUDE  = rr.ReadString();
 }
Пример #54
0
 public AnswerRR(RecordReader br)
     : base(br)
 {
 }
Пример #55
0
 public RecordMB(RecordReader rr)
 {
     MADNAME = rr.ReadDomainName();
 }
Пример #56
0
 public RecordMINFO(RecordReader rr)
 {
     RMAILBX = rr.ReadDomainName();
     EMAILBX = rr.ReadDomainName();
 }
Пример #57
0
		public RecordLOC(RecordReader rr)
		{
			VERSION = rr.ReadByte(); // must be 0!
			SIZE = rr.ReadByte();
			HORIZPRE = rr.ReadByte();
			VERTPRE = rr.ReadByte();
			LATITUDE = rr.ReadUInt32();
			LONGITUDE = rr.ReadUInt32();
			ALTITUDE = rr.ReadUInt32();
		}
Пример #58
0
 public Question(RecordReader rr)
 {
     QName  = rr.ReadDomainName();
     QType  = (DNSQType)rr.ReadShort();
     QClass = (QClass)rr.ReadShort();
 }
Пример #59
0
 public RecordCNAME(RecordReader rr)
 {
     CNAME = rr.ReadDomainName();
 }
Пример #60
0
 public AuthorityRR(RecordReader br)
     : base(br)
 {
 }