コード例 #1
0
ファイル: Session.cs プロジェクト: andy012345/WoWServer
        public override Task OnActivateAsync()
        {
            N = new Shared.BigInteger("B79B3E2A87823CAB8F5EBFBF8EB10108535006298B5BADBD5B53E1895E644B89", 16);
            g = new Shared.BigInteger(7);
            s = new Shared.BigInteger(new Random(), 256);

            var streamProvider = base.GetStreamProvider("PacketStream");

            if (streamProvider == null)
            {
                throw new Exception("Session failed to initialise stream: GetStreamProvider failed");
            }

            _stream = new SessionStream();
            _stream.PacketStream  = streamProvider.GetStream <byte[]>(this.GetPrimaryKey(), "SessionPacketStream");
            _stream.CommandStream = streamProvider.GetStream <SocketCommand>(this.GetPrimaryKey(), "SessionCommandStream");

            if (_stream.PacketStream == null)
            {
                throw new Exception("Session failed to initialise stream: GetStream failed");
            }
            if (_stream.CommandStream == null)
            {
                throw new Exception("Session failed to initialise stream: GetStream failed");
            }

            DelayDeactivation(TimeSpan.FromDays(1)); //don't automatically gobble me up please!

            return(TaskDone.Done);
        }
コード例 #2
0
        public async Task OnLogonChallenge(AuthLogonChallenge challenge)
        {
            Account = GrainFactory.GetGrain <IAccount>(challenge.account);

            if (!(await Account.IsValid()))
            {
                await SendAuthError(AuthError.NoAccount);

                return;
            }


            string password = await Account.GetPassword();

            Shared.BigInteger pass = new Shared.BigInteger(password, 16);

            //test

            string passwordPlain = await Account.GetPasswordPlain();

            string SRPHash      = challenge.account.ToUpper() + ":" + passwordPlain.ToUpper();
            var    SRPHashBytes = Encoding.UTF8.GetBytes(SRPHash);
            var    SRPCreds     = BigInt.Hash(SRPHashBytes); //The bytes were g

            BigInteger x = BigInt.Hash(s, SRPCreds);

            v = g.ModPow(x, N);

            b = new Shared.BigInteger(new Random(), 160);

            Shared.BigInteger gmod = g.ModPow(b, N);

            if (gmod < 0)
            {
                gmod += N;
            }

            B = ((v * 3) + gmod) % N;

            if (B < 0)
            {
                B += N;
            }

            Shared.BigInteger unk = new Shared.BigInteger(new Random(), 128);
            //I'm sure this is used for matrix proofing (2 factor auth)

            PacketOut rtn = new PacketOut(AuthOp.AUTH_LOGON_CHALLENGE);

            rtn.Write((byte)AuthError.Success);
            rtn.Write((byte)0);  //unknown
            rtn.WriteBigInt(B, 32);
            rtn.WriteBigIntLength(g, 1);
            rtn.WriteBigIntLength(N, 32);
            rtn.WriteBigInt(s, 32);
            rtn.WriteBigInt(unk, 16);
            rtn.Write((byte)0);    //security flag
            await SendPacket(rtn); //test
        }
コード例 #3
0
        public async Task OnLogonChallenge(AuthLogonChallenge challenge)
        {
            Account = GrainFactory.GetGrain<IAccount>(challenge.account);

            if (!(await Account.IsValid()))
            {
                await SendAuthError(AuthError.NoAccount);
                return;
            }


            string password = await Account.GetPassword();

            Shared.BigInteger pass = new Shared.BigInteger(password, 16);

            //test

            string passwordPlain = await Account.GetPasswordPlain();
            string SRPHash = challenge.account.ToUpper() + ":" + passwordPlain.ToUpper();
            var SRPHashBytes = Encoding.UTF8.GetBytes(SRPHash);
            var SRPCreds = BigInt.Hash(SRPHashBytes); //The bytes were g

            BigInteger x = BigInt.Hash(s, SRPCreds);

            v = g.ModPow(x, N);

            b = new Shared.BigInteger(new Random(), 160);

            Shared.BigInteger gmod = g.ModPow(b, N);

            if (gmod < 0)
                gmod += N;

            B = ((v*3) + gmod)%N;

            if (B < 0)
                B += N;

            Shared.BigInteger unk = new Shared.BigInteger(new Random(), 128);
                //I'm sure this is used for matrix proofing (2 factor auth)

            PacketOut rtn = new PacketOut(AuthOp.AUTH_LOGON_CHALLENGE);
            rtn.Write((byte) AuthError.Success);
            rtn.Write((byte) 0); //unknown
            rtn.WriteBigInt(B, 32);
            rtn.WriteBigIntLength(g, 1);
            rtn.WriteBigIntLength(N, 32);
            rtn.WriteBigInt(s, 32);
            rtn.WriteBigInt(unk, 16);
            rtn.Write((byte) 0); //security flag
            await SendPacket(rtn); //test
        }
コード例 #4
0
ファイル: Session.cs プロジェクト: andy012345/WoWServer
        public async Task GetSessionKeyFromAuthAccount(string AccountName)
        {
            Account = GrainFactory.GetGrain <IAccount>(AccountName.ToUpper());

            if (Account == null)
            {
                return;
            }

            //get the auth session
            ISession auth_session = await Account.GetAuthSession();

            if (auth_session == null)
            {
                return;
            }

            SessionKey = await auth_session.GetSessionKey();
        }
コード例 #5
0
 public static object Deserializer(System.Type expected, global::Orleans.Serialization.BinaryTokenStreamReader stream)
 {
     Shared.BigInteger result = new Shared.BigInteger();
     object objResult = ((object)(result));
     object temp1 = ((uint[])(Orleans.Serialization.SerializationManager.DeserializeInner(typeof(uint[]), stream)));
     fieldInfo1.SetValue(objResult, temp1);
     object temp2 = ((int)(Orleans.Serialization.SerializationManager.DeserializeInner(typeof(int), stream)));
     fieldInfo2.SetValue(objResult, temp2);
     object temp3 = ((System.Runtime.Serialization.SerializationInfo)(Orleans.Serialization.SerializationManager.DeserializeInner(typeof(System.Runtime.Serialization.SerializationInfo), stream)));
     fieldInfo3.SetValue(objResult, temp3);
     return objResult;
 }
コード例 #6
0
 public static object DeepCopier(object original)
 {
     Shared.BigInteger input = ((Shared.BigInteger)(original));
     Shared.BigInteger result = new Shared.BigInteger();
     Orleans.Serialization.SerializationContext.Current.RecordObject(original, result);
     object objResult = ((object)(result));
     object temp1 = ((uint[])(Orleans.Serialization.SerializationManager.DeepCopyInner(fieldInfo1.GetValue(input))));
     fieldInfo1.SetValue(objResult, temp1);
     object temp2 = input.dataLength;
     fieldInfo2.SetValue(objResult, temp2);
     object temp3 = ((System.Runtime.Serialization.SerializationInfo)(Orleans.Serialization.SerializationManager.DeepCopyInner(fieldInfo3.GetValue(input))));
     fieldInfo3.SetValue(objResult, temp3);
     return objResult;
 }