예제 #1
0
        private void H_DataToClient(object sender, DataToEventArgs e)
        {
            HSession HS = (HSession)sender;

            switch (e.Step)
            {
            case 1:
            {
                Program.Connections[HS].DoHandshake(e.Packet.ReadString(), e.Packet.ReadString());
                HS.SendToServer(3739, Program.Connections[HS].PublicKey);
                break;
            }

            case 2:
            {
                byte[] SharedKey = Program.Connections[HS].GetSharedKey(e.Packet.ReadString());
                HS.ClientEncrypt = new HRC4(SharedKey);
                HS.ServerDecrypt = new HRC4(SharedKey);

                HS.ReceiveData = false;
                HS.SendToServer(3709, 3937, HS.FlashClientURL, HS.GameData.Variables);
                HS.SendToServer(2828, HS.SSOTicket, -1);
                break;
            }
            }
        }
예제 #2
0
        public void OnLoginCallback(IAsyncResult iAr)
        {
            LoginAnimation.Stop();
            HSession HS = (HSession)iAr.AsyncState;

            if (HS.EndLogin(iAr))
            {
                Invoke(new Action(() =>
                {
                    LoginBtn.Text = "Login Successful!";
                    foreach (Control C in Controls)
                    {
                        C.Enabled = true;
                    }
                    Cursor          = Cursors.Default;
                    Program.Account = HS;
                    Close();
                }));
            }
            else
            {
                Invoke(new Action(() =>
                {
                    LoginBtn.Text = "Login Failed!";
                    foreach (Control C in Controls)
                    {
                        C.Enabled = true;
                    }
                    Cursor = Cursors.Default;
                    MessageBox.Show("Unable to authenticate the account, please try again.", "iKBenPeanut ~ Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    LoginBtn.Text = "Login/Connect";
                }));
            }
        }
예제 #3
0
파일: ServiceSm.cs 프로젝트: ANR2ME/Ryujinx
        public long GetService(ServiceCtx Context)
        {
            //Only for kernel version > 3.0.0.
            if (!Context.Session.IsInitialized)
            {
                //return SmNotInitialized;
            }

            string Name = string.Empty;

            for (int Index = 0; Index < 8 &&
                 Context.RequestData.BaseStream.Position <
                 Context.RequestData.BaseStream.Length; Index++)
            {
                byte Chr = Context.RequestData.ReadByte();

                if (Chr >= 0x20 && Chr < 0x7f)
                {
                    Name += (char)Chr;
                }
            }

            if (Name == string.Empty)
            {
                return(0);
            }

            HSession Session = new HSession(ServiceFactory.MakeService(Name));

            int Handle = Context.Ns.Os.Handles.GenerateId(Session);

            Context.Response.HandleDesc = IpcHandleDesc.MakeMove(Handle);

            return(0);
        }
예제 #4
0
        private void H_OnConnected(object sender, EventArgs e)
        {
            HSession H = (HSession)sender;

            Program.Connections[H] = new HKeyExchange(3, "90e0d43db75b5b8ffc8a77e31cc9758fa43fe69f14184bef64e61574beb18fac32520566f6483b246ddc3c991cb366bae975a6f6b733fd9570e8e72efc1e511ff6e2bcac49bf9237222d7c2bf306300d4dfc37113bcc84fa4401c9e4f2b4c41ade9654ef00bd592944838fae21a05ea59fecc961766740c82d84f4299dfb33dd");
            OnBotLoaded(H);

            H.SendToServer(4000, H.FlashClientRevision);
            H.SendToServer(3061);
        }
예제 #5
0
파일: Login.cs 프로젝트: Kennoz/iKBenPeanut
        private void LoginBtn_Click(object sender, EventArgs e)
        {
            HSession HS = new HSession(EmailTxt.Text, PasswordTxt.Text, HotelTxt.Text.ToHotel());
            HS.BeginLogin(LoginCB, HS);

            Cursor = Cursors.WaitCursor;
            LoginAnimation.Start();
            foreach (Control C in Controls)
                C.Enabled = false;
        }
예제 #6
0
        private static IpcMessage IpcConvertSessionToDomain(
            Switch Ns,
            HSession Session,
            IpcMessage Response,
            int HndId)
        {
            HDomain Dom = new HDomain(Session);

            Ns.Os.Handles.ReplaceData(HndId, Dom);

            return(FillResponse(Response, 0, Dom.GenerateObjectId(Dom)));
        }
예제 #7
0
        private void LoginBtn_Click(object sender, EventArgs e)
        {
            HSession HS = new HSession(EmailTxt.Text, PasswordTxt.Text, HotelTxt.Text.ToHotel());

            HS.BeginLogin(LoginCB, HS);

            Cursor = Cursors.WaitCursor;
            LoginAnimation.Start();
            foreach (Control C in Controls)
            {
                C.Enabled = false;
            }
        }
예제 #8
0
        private static IpcMessage IpcDuplicateSessionEx(
            Switch Ns,
            HSession Session,
            IpcMessage Response,
            BinaryReader ReqReader)
        {
            int Unknown = ReqReader.ReadInt32();

            int Handle = Ns.Os.Handles.GenerateId(Session);

            Response.HandleDesc = IpcHandleDesc.MakeMove(Handle);

            return(FillResponse(Response, 0));
        }
예제 #9
0
        private void SvcConnectToNamedPort(AThreadState ThreadState)
        {
            long StackPtr = (long)ThreadState.X0;
            long NamePtr  = (long)ThreadState.X1;

            string Name = AMemoryHelper.ReadAsciiString(Memory, NamePtr, 8);

            //TODO: Validate that app has perms to access the service, and that the service
            //actually exists, return error codes otherwise.

            HSession Session = new HSession(Name);

            ThreadState.X1 = (ulong)Ns.Os.Handles.GenerateId(Session);
            ThreadState.X0 = (int)SvcResult.Success;
        }
예제 #10
0
 public ServiceCtx(
     Switch Ns,
     AMemory Memory,
     HSession Session,
     IpcMessage Request,
     IpcMessage Response,
     BinaryReader RequestData,
     BinaryWriter ResponseData)
 {
     this.Ns           = Ns;
     this.Memory       = Memory;
     this.Session      = Session;
     this.Request      = Request;
     this.Response     = Response;
     this.RequestData  = RequestData;
     this.ResponseData = ResponseData;
 }
예제 #11
0
        private void SendSyncRequest(AThreadState ThreadState, bool UserBuffer)
        {
            long CmdPtr = ThreadState.Tpidr;
            long Size   = 0x100;
            int  Handle = 0;

            if (UserBuffer)
            {
                CmdPtr = (long)ThreadState.X0;
                Size   = (long)ThreadState.X1;
                Handle = (int)ThreadState.X2;
            }
            else
            {
                Handle = (int)ThreadState.X0;
            }

            HThread CurrThread = Process.GetThread(ThreadState.Tpidr);

            Process.Scheduler.Suspend(CurrThread.ProcessorId);

            byte[] CmdData = AMemoryHelper.ReadBytes(Memory, CmdPtr, (int)Size);

            HSession Session = Ns.Os.Handles.GetData <HSession>(Handle);

            IpcMessage Cmd = new IpcMessage(CmdData, CmdPtr, Session is HDomain);

            if (Session != null)
            {
                IpcHandler.IpcCall(Ns, Memory, Session, Cmd, CmdPtr, Handle);

                byte[] Response = AMemoryHelper.ReadBytes(Memory, CmdPtr, (int)Size);

                ThreadState.X0 = (int)SvcResult.Success;
            }
            else
            {
                ThreadState.X0 = (int)SvcResult.ErrBadIpcReq;
            }

            Thread.Yield();

            Process.Scheduler.Resume(CurrThread);
        }
예제 #12
0
 private void OnBotLoaded(HSession HS)
 {
     if (ConnectingBot)
     {
         AnimationDisplay = string.Format("Connecting% | ({0}/{1})", ++BotsLoaded, BotsExpected);
         if (BotsLoaded == BotsExpected)
         {
             ConnectingBot = false;
             foreach (HSession H in Program.Connections.Keys)
             {
                 if (!H.IsConnected)
                 {
                     H.Disconnect();
                 }
             }
             NavAmountNud.Maximum = Program.Connections.Count;
             DisplayFinish(string.Format("Connected! | ({0}/{1})", BotsLoaded, BotsExpected));
         }
         Invoke(new Action(() => { Text = string.Format("Kendax ~ {0}[Connected]", Program.Connections.Count); }));
     }
 }
예제 #13
0
        private void Main_DragDrop(object sender, DragEventArgs e)
        {
            if (e.Effect != DragDropEffects.Copy)
            {
                return;
            }
            int LoadedAccs = 0;

            HSession[] HSs = HSession.Extract(((string[])(e.Data.GetData(DataFormats.FileDrop)))[0]);
            foreach (HSession HS in HSs)
            {
                if (HS != null && !Program.Emails.ContainsKey(HS.Email))
                {
                    Program.Emails[HS.Email] = HS;
                    AccountTxt.Items.Add(HS.Email);
                    if (AccountTxt.Items.Count == 1)
                    {
                        AccountTxt.SelectedIndex = 0;
                    }
                    if (!AccountTxt.Enabled)
                    {
                        AccountTxt.Enabled = true;
                    }
                    if (!LoginBtn.Enabled)
                    {
                        LoginBtn.Enabled = true;
                    }
                    if (AccountTxt.Items.Count > 1)
                    {
                        AllAccountsChckbx.Enabled = true;
                    }
                    LoadedAccs++;
                }
            }
            AccountsGrpbx.Text    = string.Format("Account(s) - Total: {0} | Connected:", AccountTxt.Items.Count);
            ConnectedLbl.Location = new Point(TextRenderer.MeasureText(AccountsGrpbx.Text, AccountsGrpbx.Font).Width + 1, 0);
            StatusTxt.Text        = string.Format("Accounts Loaded! - ({0}/{1})", LoadedAccs, HSs.Length);
        }
예제 #14
0
        private void SendSyncRequest(ARegisters Registers, bool UserBuffer)
        {
            long CmdPtr = Registers.Tpidr;
            long Size   = 0x100;
            int  Handle = 0;

            if (UserBuffer)
            {
                CmdPtr = (long)Registers.X0;
                Size   = (long)Registers.X1;
                Handle = (int)Registers.X2;
            }
            else
            {
                Handle = (int)Registers.X0;
            }

            byte[] CmdData = AMemoryHelper.ReadBytes(Memory, CmdPtr, (int)Size);

            HSession Session = Ns.Os.Handles.GetData <HSession>(Handle);

            IpcMessage Cmd = new IpcMessage(CmdData, CmdPtr, Session is HDomain);

            if (Session != null)
            {
                IpcHandler.IpcCall(Ns, Memory, Session, Cmd, CmdPtr, Handle);

                byte[] Response = AMemoryHelper.ReadBytes(Memory, CmdPtr, (int)Size);

                Registers.X0 = (int)SvcResult.Success;
            }
            else
            {
                Registers.X0 = (int)SvcResult.ErrBadIpcReq;
            }
        }
예제 #15
0
 public HSessionObj(HSession Session, object Obj) : base(Session)
 {
     this.Obj = Obj;
 }
예제 #16
0
        private void LoginBtn_Click(object sender, EventArgs e)
        {
            LoggingIn = true;
            UpdateAccountUI(false);
            UpdateConnectionFeats(false);

            if (AllAccountsChckbx.Checked)
            {
                #region Account Login: Multiple
                int      LoginCount = 0;
                int      LoginFails = AccountTxt.Items.Count;
                string[] Accounts   = AccountTxt.Items.Cast <object>().Select(i => i.ToString()).ToArray();
                AnimationDisplay = string.Format("Logging In% | (1/{0})", Accounts.Length);
                AnimationTmr.Start();
                foreach (string Account in Accounts)
                {
                    if (Account.Contains('@'))
                    {
                        Program.Emails[Account].BeginLogin(new AsyncCallback((iAr) =>
                        {
                            HSession HS = (HSession)iAr.AsyncState;
                            if (HS.EndLogin(iAr))
                            {
                                LoginFails--;
                                Program.Accounts[HS.PlayerName] = HS;
                                Invoke(new Action(() =>
                                {
                                    AccountTxt.Items.Remove(HS.Email);
                                    AccountTxt.Items.Add(HS.PlayerName);
                                    AccountTxt.SelectedIndex = AccountTxt.Items.IndexOf(HS.PlayerName);
                                }));
                            }
                            AnimationDisplay = string.Format("Logging In% | ({0}/{1})", LoginCount + 2, Accounts.Length);
                            if (++LoginCount == Accounts.Length)
                            {
                                DisplayFinish(string.Format("Login(s) Succeeded! | ({0}/{1})", Accounts.Length - LoginFails, Accounts.Length));
                            }
                        }), Program.Emails[Account]);
                    }
                    else
                    {
                        Program.Accounts[Account].BeginLogin(new AsyncCallback((iAr) =>
                        {
                            if ((iAr.AsyncState as HSession).EndLogin(iAr))
                            {
                                LoginFails--;
                            }
                            AnimationDisplay = string.Format("Logging In% | ({0}/{1})", LoginCount + 2, Accounts.Length);
                            if (++LoginCount == Accounts.Length)
                            {
                                DisplayFinish(string.Format("Login(s) Succeeded! | ({0}/{1})", Accounts.Length - LoginFails, Accounts.Length));
                            }
                        }), Program.Accounts[Account]);
                    }
                }
                #endregion
            }
            else
            {
                #region Account Login: Single
                string AN = AccountTxt.Text;
                AnimationDisplay = string.Format("Logging In% | {0}", AN);
                AnimationTmr.Start();
                if (AN.Contains("@"))
                {
                    Program.Emails[AN].BeginLogin(new AsyncCallback((iAr) =>
                    {
                        HSession HS = (HSession)iAr.AsyncState;
                        if (HS.EndLogin(iAr))
                        {
                            Program.Accounts[HS.PlayerName] = HS;
                            Invoke(new Action(() =>
                            {
                                AccountTxt.Items.Remove(HS.Email);
                                AccountTxt.Items.Add(HS.PlayerName);
                                AccountTxt.SelectedIndex = AccountTxt.Items.IndexOf(HS.PlayerName);
                            }));
                            DisplayFinish("Login Success! | " + AN);
                        }
                        else
                        {
                            DisplayFinish("Login Failed! | " + AN);
                        }
                    }), Program.Emails[AN]);
                }
                else
                {
                    Program.Accounts[AN].BeginLogin(new AsyncCallback((iAr) =>
                    {
                        DisplayFinish(string.Format("Login {0}! | {1}", (iAr.AsyncState as HSession).EndLogin(iAr) ? "Success" : "Failed", AN));
                    }), Program.Accounts[AN]);
                }
                #endregion
            }
        }
예제 #17
0
 public HSession(HSession Session)
 {
     ServiceName   = Session.ServiceName;
     IsInitialized = Session.IsInitialized;
 }
예제 #18
0
        public static void IpcCall(
            Switch Ns,
            AMemory Memory,
            HSession Session,
            IpcMessage Request,
            int ThreadId,
            long CmdPtr,
            int HndId)
        {
            IpcMessage Response = new IpcMessage(Request.IsDomain && Request.Type == IpcMessageType.Request);

            using (MemoryStream Raw = new MemoryStream(Request.RawData))
            {
                BinaryReader ReqReader = new BinaryReader(Raw);

                if (Request.Type == IpcMessageType.Request)
                {
                    string ServiceName = Session.Service.GetType().Name;

                    ServiceProcessRequest ProcReq = null;

                    bool IgnoreNullPR = false;

                    string DbgServiceName = string.Empty;

                    if (Session is HDomain Dom)
                    {
                        if (Request.DomCmd == IpcDomCmd.SendMsg)
                        {
                            long Magic = ReqReader.ReadInt64();
                            int  CmdId = (int)ReqReader.ReadInt64();

                            object Obj = Dom.GetObject(Request.DomObjId);

                            if (Obj is HDomain)
                            {
                                Session.Service.Commands.TryGetValue(CmdId, out ProcReq);

                                DbgServiceName = $"{ProcReq?.Method.Name ?? CmdId.ToString()}";
                            }
                            else if (Obj != null)
                            {
                                ((IIpcService)Obj).Commands.TryGetValue(CmdId, out ProcReq);

                                DbgServiceName = $"{Obj.GetType().Name} {ProcReq?.Method.Name ?? CmdId.ToString()}";
                            }
                        }
                        else if (Request.DomCmd == IpcDomCmd.DeleteObj)
                        {
                            Dom.DeleteObject(Request.DomObjId);

                            Response = FillResponse(Response, 0);

                            IgnoreNullPR = true;
                        }
                    }
                    else
                    {
                        long Magic = ReqReader.ReadInt64();
                        int  CmdId = (int)ReqReader.ReadInt64();

                        if (Session is HSessionObj)
                        {
                            object Obj = ((HSessionObj)Session).Obj;

                            ((IIpcService)Obj).Commands.TryGetValue(CmdId, out ProcReq);

                            DbgServiceName = $"{Obj.GetType().Name} {ProcReq?.Method.Name ?? CmdId.ToString()}";
                        }
                        else
                        {
                            Session.Service.Commands.TryGetValue(CmdId, out ProcReq);

                            DbgServiceName = $"{ProcReq?.Method.Name ?? CmdId.ToString()}";
                        }
                    }

                    DbgServiceName = $"Tid {ThreadId} {ServiceName} {DbgServiceName}";

                    Logging.Debug($"IpcMessage: {DbgServiceName}");

                    if (ProcReq != null)
                    {
                        using (MemoryStream ResMS = new MemoryStream())
                        {
                            BinaryWriter ResWriter = new BinaryWriter(ResMS);

                            ServiceCtx Context = new ServiceCtx(
                                Ns,
                                Memory,
                                Session,
                                Request,
                                Response,
                                ReqReader,
                                ResWriter);

                            long Result = ProcReq(Context);

                            Response = FillResponse(Response, Result, ResMS.ToArray());
                        }
                    }
                    else if (!IgnoreNullPR)
                    {
                        throw new NotImplementedException(DbgServiceName);
                    }
                }
                else if (Request.Type == IpcMessageType.Control)
                {
                    long Magic = ReqReader.ReadInt64();
                    long CmdId = ReqReader.ReadInt64();

                    switch (CmdId)
                    {
                    case 0: Request = IpcConvertSessionToDomain(Ns, Session, Response, HndId); break;

                    case 3: Request = IpcQueryBufferPointerSize(Response);                     break;

                    case 2:     //IpcDuplicateSession, differences is unknown.
                    case 4: Request = IpcDuplicateSessionEx(Ns, Session, Response, ReqReader); break;

                    default: throw new NotImplementedException(CmdId.ToString());
                    }
                }
                else if (Request.Type == IpcMessageType.Unknown2)
                {
                    //TODO
                }
                else
                {
                    throw new NotImplementedException(Request.Type.ToString());
                }

                AMemoryHelper.WriteBytes(Memory, CmdPtr, Response.GetBytes(CmdPtr));
            }
        }