Esempio n. 1
0
		public void TestUuid()
		{
			var rfc4122Bytes = new byte[] {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf};
			UUID uuid = new UUID(rfc4122Bytes);
			Assert.AreEqual(rfc4122Bytes, uuid.GetBytes());

			Skin skin = new Skin {Slim = false, Texture = Encoding.Default.GetBytes(new string('Z', 8192))};
			var packet = new McpeLogin()
			{
				username = "******",
				protocol = 34,
				protocol2 = 34,
				clientId = new Random().Next(),
				clientUuid = new UUID(Guid.NewGuid().ToByteArray()),
				serverAddress = "83.249.65.92:19132",
				clientSecret = "iwmvi45hm85oncyo58",
				skin = skin,
			};

			var bytes = packet.Encode();
			Console.WriteLine(Package.HexDump(bytes, 16));

			UUID uuid2 = new UUID(rfc4122Bytes);

			Dictionary<UUID, string> uuiDictionary = new Dictionary<UUID, string>();
			uuiDictionary.Add(uuid, "test");

			Assert.AreEqual("test", uuiDictionary[uuid2]);
			
		}
Esempio n. 2
0
        public PlayerMob(string name, Level level)
            : base(63, level)
        {
            Width = 0.6;
            Length = 0.6;
            Height = 1.80;

            IsSpawned = false;

            Name = name;
            Skin = new Skin {Slim = false, Texture = Encoding.Default.GetBytes(new string('Z', 8192))};

            ItemInHand = new ItemStack();
        }
Esempio n. 3
0
        public PlayerMob(string name, Level level)
            : base(63, level)
        {
            Uuid = new UUID(Guid.NewGuid().ToByteArray());

            Width = 0.6;
            Length = 0.6;
            Height = 1.80;

            IsSpawned = false;

            Name = name;
            Skin = new Skin {Slim = false, Texture = Encoding.Default.GetBytes(new string('Z', 8192))};

            ItemInHand = new ItemAir();
        }
Esempio n. 4
0
        public void SendLogin(string username)
        {
            Skin skin = new Skin {Slim = false, Texture = Encoding.Default.GetBytes(new string('Z', 8192))};
            skin.SkinType = "Standard_Custom";
            //Skin skin = new Skin { Slim = false, Texture = Encoding.Default.GetBytes(new string('Z', 16384)) };
            var packet = new McpeLogin()
            {
                username = username,
                protocol = 39,
                protocol2 = 39,
                clientId = ClientId,
                clientUuid = new UUID(Guid.NewGuid().ToByteArray()),
                serverAddress = _serverEndpoint.Address + ":" + _serverEndpoint.Port,
                clientSecret = "iwmvi45hm85oncyo58",
                //clientSecret = Encoding.ASCII.GetString(MD5.Create().ComputeHash(Encoding.UTF8.GetBytes("" + ClientId + _serverEndpoint.Address + _serverEndpoint.Port))),
                skin = skin,
            };

            byte[] buffer = Player.CompressBytes(packet.Encode(), CompressionLevel.Fastest, true);

            McpeBatch batch = new McpeBatch();
            batch.payloadSize = buffer.Length;
            batch.payload = buffer;
            batch.Encode();

            SendPackage(batch);
            LoginSent = true;
        }
Esempio n. 5
0
        public void SendLogin(string username)
        {
            Skin skin = new Skin {Slim = false, Texture = Encoding.Default.GetBytes(new string('Z', 8192))};
            var packet = new McpeLogin()
            {
                clientId = 12345,
                username = username,
                protocol = 27,
                skin = skin
            };

            McpeBatch batch = new McpeBatch();
            byte[] buffer = CompressBytes(packet.Encode());

            batch.payloadSize = buffer.Length;
            batch.payload = buffer;

            SendPackage(batch);
        }
Esempio n. 6
0
        public static byte[] EncodeSkinJwt(CngKey newKey)
        {
            byte[] t = ImportECDsaCngKeyFromCngKey(newKey.Export(CngKeyBlobFormat.EccPrivateBlob));
            CngKey tk = CngKey.Import(t, CngKeyBlobFormat.EccPrivateBlob);

            ECDiffieHellmanCng ecKey = new ECDiffieHellmanCng(newKey);
            ecKey.HashAlgorithm = CngAlgorithm.Sha256;
            ecKey.KeyDerivationFunction = ECDiffieHellmanKeyDerivationFunction.Hash;

            var b64Key = Base64Url.Encode(ecKey.PublicKey.GetDerEncoded());

            Skin skin = new Skin
            {
                Slim = false, Texture = Encoding.Default.GetBytes(new string('Z', 8192)),
                SkinType = "Standard_Custom"
            };

            string skin64 = Convert.ToBase64String(skin.Texture);

            string skinData = $@"
            {{
            ""ClientRandomId"": {new Random().Next()},
            ""ServerAddress"": ""pe.mineplex.com:19132"",
            ""SkinData"": ""{skin64}"",
            ""SkinId"": ""{skin.SkinType}""
            }}";

            string val = JWT.Encode(skinData, tk, JwsAlgorithm.ES384, new Dictionary<string, object> { { "x5u", b64Key } });

            return Encoding.UTF8.GetBytes(val);
        }