public ScanRiskFlag GetRisk(string plainPassword)
        {
            var strength = scanner.scanPassword(plainPassword);

            if (strength == PasswordScanner.Strength.WEAK)
            {
                return(ScanRiskFlag.Weak);
            }
            else
            {
                return(ScanRiskFlag.Insecure);
            }
        }
Exemple #2
0
        private List <SecurityScoreData> GetSecurityScoreItems(string type)
        {
            PasswordScanner scanner = new PasswordScanner();
            IPBData         pbData  = _resolver.GetInstanceOf <IPBData>();
            var             sites   = pbData.GetSecureItemsByItemType(SecurityItemsDefaultProperties.SecurityItemType_PasswordVault);

            sites = sites.Where(p => !p.SharedWithUser && p.Data != null).ToList();

            var weakPwdStrength = new List <PasswordScanner.Strength> {
                PasswordScanner.Strength.VERYWEAK, PasswordScanner.Strength.WEAK
            };

            if (type == SecurityScoreItemType.week)
            {
                return(sites.Where(p => weakPwdStrength.Contains(scanner.scanPassword(p.Data.password))).Select(s => new SecurityScoreData {
                    id = s.Id, siteName = s.Name, siteUri = s.LoginUrl, password = s.Data.password, userName = !string.IsNullOrWhiteSpace(s.Data.username) ? s.Data.username : s.Data.email, LastModifiedDate = s.LastModifiedDate, ReEnterPassword = s.Data.require_master_password
                }).ToList());
            }

            if (type == SecurityScoreItemType.duplicate)
            {
                var pwdList = sites.Where(p => !string.IsNullOrWhiteSpace(p.Data.password)).GroupBy(p => p.Data.password).Select(g => new { Key = g.Key, Count = g.Count() }).Where(o => o.Count > 1).Select(s => s.Key);
                return(sites.Where(p => pwdList.Contains(p.Data.password)).Select(s => new SecurityScoreData {
                    id = s.Id, siteName = s.Name, siteUri = s.LoginUrl, password = s.Data.password, userName = !string.IsNullOrWhiteSpace(s.Data.username) ? s.Data.username : s.Data.email, LastModifiedDate = s.LastModifiedDate, ReEnterPassword = s.Data.require_master_password
                }).ToList());
            }

            if (type == SecurityScoreItemType.old)
            {
                return(sites.Where(p => p.LastModifiedDate < DateTime.Today.AddMonths(-6)).Select(s => new SecurityScoreData {
                    id = s.Id, siteName = s.Name, siteUri = s.LoginUrl, password = s.Data.password, userName = !string.IsNullOrWhiteSpace(s.Data.username) ? s.Data.username : s.Data.email, LastModifiedDate = s.LastModifiedDate, ReEnterPassword = s.Data.require_master_password
                }).ToList());
            }

            if (type == SecurityScoreItemType.all)
            {
                return(sites.Select(s => new SecurityScoreData {
                    id = s.Id, siteName = s.Name, siteUri = s.LoginUrl, password = s.Data.password, userName = !string.IsNullOrWhiteSpace(s.Data.username) ? s.Data.username : s.Data.email, LastModifiedDate = s.LastModifiedDate, ReEnterPassword = s.Data.require_master_password
                }).ToList());
            }

            throw new InvalidOperationException(string.Format("Invalid imte type {0}", type));
        }
Exemple #3
0
        private void CreatePasswordClick(object sender)
        {
            GeneratedPassword = randomGenerator.generatePswd(PasswordLength, CapitalsCheck, NumbersCheck, SymbolsCheck, LettersCheck);

            Strength s = (Strength)scanner.scanPassword(GeneratedPassword);

            switch (s)
            {
            case (Strength.VERYWEAK):
                PasswordStrengthValue = 10;
                PasswordStrengthText  = (string)System.Windows.Application.Current.FindResource("VeryWeak");
                break;

            case (Strength.WEAK):
                PasswordStrengthValue = 25;
                PasswordStrengthText  = (string)System.Windows.Application.Current.FindResource("Weak");
                break;

            case (Strength.GOOD):
                PasswordStrengthValue = 50;
                PasswordStrengthText  = (string)System.Windows.Application.Current.FindResource("Good");
                break;

            case (Strength.STRONG):
                PasswordStrengthValue = 75;
                PasswordStrengthText  = (string)System.Windows.Application.Current.FindResource("Strong");
                break;

            case (Strength.VERY_STRONG):
                PasswordStrengthValue = 100;
                PasswordStrengthText  = (string)System.Windows.Application.Current.FindResource("VeryStrong");
                break;

            default:
                PasswordStrengthValue = 0;
                PasswordStrengthText  = string.Empty;
                break;
            }
            AllGeneratedPasswords.Add(GeneratedPassword);
            var an = inAppAnalyitics.Get <Events.GeneratedPassword, PasswordGeneratorItem>();

            an.Log(new PasswordGeneratorItem(PasswordGeneratorSource.MainUI));
        }
Exemple #4
0
        void UpdatePasswordMeter(string password)
        {
            if (string.IsNullOrEmpty(password))
            {
                progressBar.Value = 0;
                return;
            }

            PasswordScanner scanner = new PasswordScanner();

            PasswordBoss.PasswordScanner.Strength s = (PasswordBoss.PasswordScanner.Strength)scanner.scanPassword(password);
            switch (s)
            {
            case (PasswordBoss.PasswordScanner.Strength.VERYWEAK):
                progressBar.Value      = 10;
                progressBar.Foreground = Application.Current.Resources["passwordWeakColor"] as Brush;
                break;

            case (PasswordBoss.PasswordScanner.Strength.WEAK):
                progressBar.Value      = 30;
                progressBar.Foreground = Application.Current.Resources["passwordNormalColor"] as Brush;
                break;

            case (PasswordBoss.PasswordScanner.Strength.GOOD):
                progressBar.Value      = 50;
                progressBar.Foreground = Application.Current.Resources["passwordMediumColor"] as Brush;
                break;

            case (PasswordBoss.PasswordScanner.Strength.STRONG):
                progressBar.Value      = 75;
                progressBar.Foreground = Application.Current.Resources["passwordStrongColor"] as Brush;
                break;

            case (PasswordBoss.PasswordScanner.Strength.VERY_STRONG):
                progressBar.Value      = 100;
                progressBar.Foreground = Application.Current.Resources["passwordVeryStrongColor"] as Brush;
                break;

            default:
                progressBar.Value = 0;
                break;
            }
        }