Ejemplo n.º 1
0
        private void accountsListView_ItemActivate(object sender, EventArgs e)
        {
            int index   = this.accountsListView.SelectedItems[0].Index;
            var records = this.db.FetchAccountRecords(this.accounts[index].Account.Id.Value);

            /* Display record list */
            this.recordsListView.Items.Clear();

            if (records == null || records.Count == 0)
            {
                this.recordsListView.Enabled = false;
            }
            else
            {
                this.recordsListView.Enabled = true;

                foreach (AccountRecord record in records)
                {
                    ListViewItem lvi = new ListViewItem();
                    lvi.SubItems.Add(new ListViewItem.ListViewSubItem(lvi, record.AccountName));
                    lvi.SubItems.Add(new ListViewItem.ListViewSubItem(lvi, record.Details.Enabled.ToString()));
                    lvi.SubItems.Add(new ListViewItem.ListViewSubItem(lvi, record.Details.Deleted.ToString()));
                    lvi.SubItems.Add(new ListViewItem.ListViewSubItem(lvi, Utility.GetTime(record.Details.Timestamp)));
                    lvi.SubItems.Add(new ListViewItem.ListViewSubItem(lvi, Utility.StringOrAlternative(record.Password.Plaintext)));
                    lvi.SubItems.Add(new ListViewItem.ListViewSubItem(lvi, Utility.FloatOrAlternative((record.Password = record.Password.SetStrength(PasswordStrength.EvaluatePassword(record.Password.Plaintext))).Strength)));
                    lvi.SubItems.Add(new ListViewItem.ListViewSubItem(lvi, Utility.ByteStringOrNull(record.Password.Nt)));
                    lvi.SubItems.Add(new ListViewItem.ListViewSubItem(lvi, Utility.ByteStringOrNull(record.Password.Lm)));

                    this.recordsListView.Items.Add(lvi);
                }

                /* Calculate statistics */
                var statistics = PasswordStatistics.Compute(records);

                this.statisticsListView.Items.Clear();

                if (statistics == null || statistics.Count == 0)
                {
                    this.statisticsListView.Enabled = false;
                }
                else
                {
                    this.statisticsListView.Enabled = true;

                    foreach (AccountStatistic statistic in statistics)
                    {
                        ListViewItem lvi = new ListViewItem();
                        lvi.SubItems.Add(new ListViewItem.ListViewSubItem(lvi, statistic.Description));
                        lvi.SubItems.Add(new ListViewItem.ListViewSubItem(lvi, Utility.DoubleOrAlternative(statistic.Value)));

                        this.statisticsListView.Items.Add(lvi);
                    }
                }

                /* Basic actions */
                this.Parent.Text = this.accounts[index].AccountNames + Form1.padding_spaces;
            }
        }
Ejemplo n.º 2
0
        private void AddGraphSeries_PasswordStrength(int index)
        {
            List <ValidEnvironment> timeline = null;

            if (index >= 0)
            {
                timeline = this.environments.GetRange(index, this.environments.Count - index);
                timeline.Reverse();

                var series_all      = AddGraphSeries("Password Strength (all)");
                var series_enabled  = AddGraphSeries("Password Strength (enabled)");
                var series_disabled = AddGraphSeries("Password Strength (disabled)");

                foreach (var environment in timeline)
                {
                    var records = this.db.FetchEnvironmentRecords(environment.Timestamp);

                    foreach (var record in records)
                    {
                        if (record.Password.Strength == 0.0f)
                        {
                            record.Password = record.Password.SetStrength(PasswordStrength.EvaluatePassword(record.Password.Plaintext));
                        }
                    }

                    var statistics = PasswordStatistics.Compute(records);

                    this.AddGraphPoint(series_all, statistics[1].All, Utility.GetDate(environment.Timestamp));
                    this.AddGraphPoint(series_enabled, statistics[1].Enabled, Utility.GetDate(environment.Timestamp));
                    this.AddGraphPoint(series_disabled, statistics[1].Disabled, Utility.GetDate(environment.Timestamp));
                }

                this.evolutionGraph.Series.Add(series_all);
                this.evolutionGraph.Series.Add(series_enabled);
                this.evolutionGraph.Series.Add(series_disabled);
            }
        }