Пример #1
0
        private void addWebsiteToListView(KP2faC_Website website)
        {
            ListViewItem lvi = new ListViewItem(website.name);

            if (website.is2faPosssible())
            {
                lvi.BackColor = Color.LightGreen;
                lvi.SubItems.Add("Yes - " + website.getTfa());
                lvi.ImageIndex  = (int)PwIcon.Checked;
                lvi.ToolTipText = "URL: " + website.url;

                if (!string.IsNullOrEmpty(website.exception))
                {
                    lvi.ImageIndex  = (int)PwIcon.Warning;
                    lvi.ToolTipText = lvi.ToolTipText + "\nException: " + website.exception;
                }
            }
            else
            {
                lvi.BackColor = Color.LightSalmon;
                lvi.SubItems.Add("No");
                lvi.ImageIndex  = (int)PwIcon.Expired;
                lvi.ToolTipText = "Tell them to support 2fa:\n (Double click)";
            }
            lvi.Tag = website;
            lv_Websites.Items.Add(lvi);
        }
Пример #2
0
        private void lv_Websites_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            var senderList = (ListView)sender;
            var item       = senderList.HitTest(e.Location).Item;

            if (item != null)
            {
                KP2faC_Website website = ((KP2faC_Website)item.Tag);
                if (website.is2faPosssible())
                {
                    if (website.doc != null)
                    {
                        System.Diagnostics.Process.Start(website.doc);
                    }
                    else
                    {
                        MessageBox.Show("Sorry, I cant help you. No Documentation found!", "KP2faChecker - " + website.name, MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
                else
                {
                    if (!string.IsNullOrEmpty(website.email_address))
                    {
                        DialogResult dialogResult = MessageBox.Show(website.name + " is not supporting 2fa.\n\nTell them to support 2fa on:\n    Twitter: " + website.twitter + "\n    Facebook: " + website.facebook + "\n    Email: " + website.email_address + "\n\nDo you want to send an email to " + website.name + "?", "KP2faChecker - " + website.name, MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation);
                        if (dialogResult == DialogResult.Yes)
                        {
                            System.Diagnostics.Process.Start(Uri.EscapeUriString(string.Format("mailto:{0}?Subject={1}&Body={2}", website.email_address, "Support Two Factor Authentication", "Security is important. We'd like it if you supported two factor auth.\r\n")));
                        }
                    }
                    else
                    {
                        DialogResult dialogResult = MessageBox.Show(website.name + " is not supporting 2fa.\n\nTell them to support 2fa on:\n    Twitter: " + website.twitter + "\n    Facebook: " + website.facebook, "KP2faChecker - " + website.name, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    }
                }
            }
        }
Пример #3
0
        public void InitEx(PwEntry pe)
        {
            btn_Reload.Enabled = false;
            btn_Reload.Visible = false;

            RichTextBuilder rb = new RichTextBuilder();

            string strItemSeperator = Environment.NewLine;

            EvAppendEntryFieldProtectedString(rb, strItemSeperator, "Title", PwDefs.TitleField, pe);
            EvAppendEntryFieldProtectedString(rb, strItemSeperator, "Username", PwDefs.UserNameField, pe);
            EvAppendEntryFieldProtectedString(rb, strItemSeperator, "URL", PwDefs.UrlField, pe);

            this.Text = this.Text + " - " + pe.Strings.ReadSafe(PwDefs.TitleField);


            string         r           = "";
            string         totpAlready = "No";
            KP2faC_Website curWebsite  = null;
            bool           bPossible   = false;

            if ((pe.Strings.Exists("otp") && pe.Strings.Get("otp") != null) ||
                (pe.Strings.Exists("TOTP Seed") && pe.Strings.Get("TOTP Seed") != null))
            {
                totpAlready = "Yes";
            }
            string url = pe.Strings.ReadSafe(PwDefs.UrlField);

            pb_trafficlight.Image = Properties.Resources.trafficlight_orange;
            if (String.IsNullOrEmpty(url))
            {
                r = "No Url set. A Url is needed to check for 2fa support";
            }
            else
            {
                if (KP2faCheckerExt.dictKp2fac_WebsiteByDomain.Count > 0)
                {
                    string   prettifiedUrl = KP2faCheckerExt.prettifyUrl(url, KP2faCheckerExt.prettifyMode.AllWithoutTld);
                    string[] domainArray   = prettifiedUrl.Split('.').Reverse().ToArray();

                    var curDict = KP2faCheckerExt.dictKp2fac_WebsiteByDomain;
                    for (int i = 0; i < domainArray.Length; i++)
                    {
                        if (curDict.ContainsKey(domainArray[i]))
                        {
                            if (curDict[domainArray[i]] is KP2faC_Website)
                            {
                                if (((KP2faC_Website)curDict[domainArray[i]]).is2faPosssible())
                                {
                                    if (i == domainArray.Length - 1)
                                    {
                                        r                     = "Yes" + r;
                                        bPossible             = true;
                                        pb_trafficlight.Image = Properties.Resources.trafficlight_green;
                                    }
                                }
                                else
                                {
                                    r = "No" + r;
                                    pb_trafficlight.Image = Properties.Resources.trafficlight_red;
                                }
                                curWebsite = (KP2faC_Website)curDict[domainArray[i]];
                            }
                            else
                            {
                                curDict = (Dictionary <string, object>)curDict[domainArray[i]];
                                if (i == domainArray.Length - 1)
                                {
                                    if (curDict.ContainsKey("*") && curDict["*"] is KP2faC_Website)
                                    {
                                        if (((KP2faC_Website)curDict["*"]).is2faPosssible())
                                        {
                                            r                     = "Yes" + r;
                                            bPossible             = true;
                                            pb_trafficlight.Image = Properties.Resources.trafficlight_green;
                                        }
                                        else
                                        {
                                            r = "No" + r;
                                            pb_trafficlight.Image = Properties.Resources.trafficlight_red;
                                        }
                                        curWebsite = (KP2faC_Website)curDict["*"];
                                    }
                                }
                            }
                        }
                        else if (curDict.ContainsKey("*"))
                        {
                            if (curDict["*"] is KP2faC_Website)
                            {
                                if (((KP2faC_Website)curDict["*"]).is2faPosssible())
                                {
                                    r                     = "Yes" + r;
                                    bPossible             = true;
                                    pb_trafficlight.Image = Properties.Resources.trafficlight_green;
                                }
                                else
                                {
                                    r = "No" + r;
                                    pb_trafficlight.Image = Properties.Resources.trafficlight_red;
                                }
                                curWebsite = (KP2faC_Website)curDict["*"];
                            }
                            break;
                        }
                    }
                }
                else
                {
                    r = "Unknown. API Error!";
                    btn_Reload.Enabled = true;
                    btn_Reload.Visible = true;
                    btn_Reload.Tag     = pe;
                }
                if (string.IsNullOrEmpty(r))
                {
                    r = "Dont know!";
                }
            }
            EvAppendEntryFieldString(rb, strItemSeperator, "2FA already configured", totpAlready);
            rb.Build(rtb_Entry);

            rb = new RichTextBuilder();
            EvAppendEntryFieldString(rb, strItemSeperator, "2FA supported", r);
            if (bPossible && curWebsite != null)
            {
                rb.AppendLine();
                EvAppendEntryFieldString(rb, strItemSeperator, "Websitename", curWebsite.name);
                EvAppendEntryFieldString(rb, strItemSeperator, "2FA Options", curWebsite.getTfa());
                EvAppendEntryFieldString(rb, strItemSeperator, "Documentation", curWebsite.doc);
                if (!String.IsNullOrEmpty(curWebsite.exception))
                {
                    EvAppendEntryFieldString(rb, strItemSeperator, "Exception", curWebsite.exception);
                }
            }
            else if (!bPossible && curWebsite != null)
            {
                EvAppendEntryFieldString(rb, strItemSeperator, "This is wrong?", "Give a hint! https://toasted.top/kp2fac/");
                rb.AppendLine();
                EvAppendEntryFieldString(rb, strItemSeperator, "Tell them to support 2FA!", " ");
                if (!String.IsNullOrEmpty(curWebsite.email_address))
                {
                    EvAppendEntryFieldString(rb, strItemSeperator, "Email address", curWebsite.email_address);
                }
                if (!String.IsNullOrEmpty(curWebsite.facebook))
                {
                    EvAppendEntryFieldString(rb, strItemSeperator, "Facebook", curWebsite.facebook);
                }
                if (!String.IsNullOrEmpty(curWebsite.twitter))
                {
                    EvAppendEntryFieldString(rb, strItemSeperator, "Twitter", curWebsite.twitter);
                }
            }
            else
            {
                rb.AppendLine();
                EvAppendEntryFieldString(rb, strItemSeperator, "Is 2fa supported?", "Give a hint! https://toasted.top/kp2fac/");
            }

            rb.Build(rtb_2FA);
        }