Example #1
0
		protected Dictionary<string, string> DecodeHeaders(byte[] HeaderData)
		{
			var HeaderDataStream = new MemoryStream(HeaderData);
			var Headers = new Dictionary<string, string>();
			while (!HeaderDataStream.Eof())
			{
				var Key = HeaderDataStream.ReadStringz();
				var Value = HeaderDataStream.ReadStringz();
				Headers[Key] = Value;
			}
			return Headers;
		}
Example #2
0
		public async Task HandlePacketAsync()
		{
			var PacketHeader = new byte[4];
			await this.TcpClientStream.ReadAsync(PacketHeader, 0, 4);
			var Value = BitConverter.ToUInt32(PacketHeader, 0);
			uint PacketSize = Value & 0x7FFFFF;
			bool PacketFlag = ((Value >> 23) & 1) != 0;
			byte PacketSerial = (byte)(Value >> 24);
			var PacketData = new byte[PacketSize];
			await this.TcpClientStream.ReadAsync(PacketData, 0, PacketData.Length);
			var PacketDataStream = new MemoryStream(PacketData);
			var PacketDataBinaryReader = new BinaryReader(PacketDataStream);

			var Packet = default(HandshakeInitializationPacket);
			Packet.ProtocolVersion = PacketDataBinaryReader.ReadByte();
			Packet.ServerVersion = PacketDataStream.ReadStringz();
			Packet.ThreadNumber = PacketDataBinaryReader.ReadUInt32();
			Packet.ScrambleBuffer = PacketDataBinaryReader.ReadBytes(8);
			Packet.Filler1 = PacketDataBinaryReader.ReadByte();
			Packet.ServerCapablities = (ServerCapabilitiesSet)PacketDataBinaryReader.ReadUInt16();
			Packet.ServerLanguage = PacketDataBinaryReader.ReadByte();

			var Token = BitUtils.XorBytes(
				Sha1(Packet.ScrambleBuffer.Concat(stage1_hash)),
				stage1_hash
			);
			Console.WriteLine(Packet.ServerCapablities.ToStringDefault());
			//Console.WriteLine(Packet.ToStringDefault());
		}