コード例 #1
0
ファイル: LS2GC_LOGIN_SALT.cs プロジェクト: fiki574/egoAPB
            public override void HandlePacket(LobbyClient client, ServerPacket packet)
            {
                var reader = packet.Reader;

                var srpClient    = new WeakSrp6Client();
                var secureRandom = new SecureRandom();

                srpClient.Init(new BigInteger(Modulus), new BigInteger(Generator), new Sha1Digest(), secureRandom);

                uint accountId = reader.ReadUInt32();

                byte[] serverB    = reader.ReadBytes(64);
                ushort serverBLen = reader.ReadUInt16();

                byte[] salt = reader.ReadBytes(10);

                client.AccountID = accountId;

                BigInteger serverBInt = new BigInteger(1, serverB, 0, serverBLen);

                byte[] usernameBytes = Encoding.ASCII.GetBytes(accountId.ToString()), passwordBytes = Encoding.ASCII.GetBytes(client.Password);

                BigInteger clientPub = srpClient.GenerateClientCredentials(salt, usernameBytes, passwordBytes);

                srpClient.CalculateSecret(serverBInt);
                client.SrpKey = srpClient.CalculateSessionKey().ToByteArrayUnsigned();

                BigInteger proof      = srpClient.CalculateClientEvidenceMessage();
                var        loginProof = new GC2LS_LOGIN_PROOF(clientPub.ToByteArrayUnsigned(), proof.ToByteArrayUnsigned());

                client.SendPacket(loginProof);
            }
コード例 #2
0
ファイル: LS2GC_LOGIN_SALT.cs プロジェクト: McSimp/APBWatcher
            public override void HandlePacket(LobbyClient client, ServerPacket packet)
            {
                var reader = packet.Reader;

                // Initialise the SRP client
                var srpClient    = new WeakSrp6Client();
                var secureRandom = new SecureRandom();

                srpClient.Init(new BigInteger(Modulus), new BigInteger(Generator), new Sha1Digest(), secureRandom);

                // Read data from packet
                uint accountId = reader.ReadUInt32();

                byte[] serverB    = reader.ReadBytes(64);
                ushort serverBLen = reader.ReadUInt16();

                byte[] salt = reader.ReadBytes(10);

                Log.Info($"Account ID = 0x{accountId:X}");
                client._accountId = accountId;

                // Transform values into types the SRP client expects
                BigInteger serverBInt = new BigInteger(1, serverB, 0, serverBLen);

                byte[] usernameBytes = Encoding.ASCII.GetBytes(accountId.ToString());
                byte[] passwordBytes = Encoding.ASCII.GetBytes(client._password);

                // Calculate the client's public value
                BigInteger clientPub = srpClient.GenerateClientCredentials(salt, usernameBytes, passwordBytes);

                srpClient.CalculateSecret(serverBInt);
                client._srpKey = srpClient.CalculateSessionKey().ToByteArrayUnsigned();

                // Calculate the proof that the client knows the secret
                BigInteger proof = srpClient.CalculateClientEvidenceMessage();

                var loginProof = new GC2LS_LOGIN_PROOF(clientPub.ToByteArrayUnsigned(), proof.ToByteArrayUnsigned());

                client.SendPacket(loginProof);
            }