Esempio n. 1
0
        internal CompanyRoot GetFullCompany(string permalinkName, Dig digMgr)
        {
            CompanyRoot company = compManager.GetFullCompany(permalinkName);

            if (!Object.Equals(company, null) && !Object.Equals(null, company.homepage_url))
            {
                Records r = new Records();
                company.homepage_url = Utility.CleanUrl(company.homepage_url);
                IPAddress ip = digMgr.GetIPAddress(company.homepage_url);
                if (!Object.Equals(null, ip))
                {
                    company.ip_address = ip.ToString();
                }
                SSLCert cert = digMgr.GetSSLVerification(company.homepage_url);

                if (!Object.Equals(cert, null))
                {
                    r.SSLIssuer       = cert.FixedName;
                    r.CertificateType = cert.SubjectType;
                }
                r.WebHost   = digMgr.GetWebHostName(company.homepage_url);
                r.EmailHost = digMgr.GetEmailHostName(company.homepage_url);
                r.DNSHost   = digMgr.GetDNSHostName(company.homepage_url);
                r.Registrar = digMgr.GetRegistrar(company.homepage_url);

                company.records = r;
            }

            return(company);
        }
Esempio n. 2
0
        public void DigSSLCert()
        {
            Dig dig = new Dig();

            SSLCert cert = dig.GetSSLVerification("godaddy.com");

            Assert.IsNotNull(cert);
            Assert.IsNotNull(cert.IssuerName);
            Assert.IsNotNull(cert.SubjectType);
            Assert.AreEqual("www.godaddy.com", cert.SubjectType);

            cert = dig.GetSSLVerification("1footout.com");
            Assert.AreEqual(cert.FixedName, "None");
        }
Esempio n. 3
0
        /// <summary>
        /// Sends an HTTPRequest to the website on 443 to determine if there is a valid certificate
        /// </summary>
        /// <param name="domainName">any valid domain name without "www."</param>
        /// <returns>SSLCert object with Issuer and Subject (type)</returns>
        public SSLCert GetSSLVerification(string domainName)
        {
            SSLCert myCert = new SSLCert {
                Issuer = "None", Subject = "None", DomainToCheck = domainName
            };
            string       groupName = Guid.NewGuid().ToString();
            Uri          u         = new Uri(string.Format(@"https://www.{0}", domainName));
            ServicePoint sp        = ServicePointManager.FindServicePoint(u);

            if (string.IsNullOrEmpty(domainName))
            {
                return(myCert);
            }

            HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create(string.Format(@"https://www.{0}", domainName));

            try
            {
                req.Timeout             = 3000;
                req.Method              = "HEAD";
                req.ConnectionGroupName = groupName;

                using (WebResponse resp = req.GetResponse()) { }

                myCert = new SSLCert(sp.Certificate, domainName);
            }
            catch (WebException we)
            {
                if (!we.Message.Contains("timed out"))
                {
                    try
                    {
                        req = (HttpWebRequest)HttpWebRequest.Create(string.Format(@"https://{0}", domainName));
                        using (WebResponse resp = req.GetResponse()) { }
                        myCert = new SSLCert(sp.Certificate, domainName);
                    }
                    catch (Exception) { }
                }
            }
            catch (Exception) { }
            finally
            {
                sp.CloseConnectionGroup(groupName);
            }

            myCert.FixedName = GetCompanyFromRecordName(myCert.IssuerName, domainName, DigTypeEnum.SSL).TrimStart(new char[] { '"', '\\' });

            return(myCert);
        }
Esempio n. 4
0
        public void ProcessCrawledDomain(CrawlContext crawlContext)
        {
            SSLCert cert = null;

            try
            {
                cert = Dig.Instance.GetSSLVerification(crawlContext.RootUri.DnsSafeHost);
            }
            catch (Exception e)
            {
                _logger.ErrorFormat("Exception occurred getting ssl info for [{0}]", crawlContext.RootUri.DnsSafeHost, e);
            }

            if (cert != null)
            {
                if (cert.FixedName != "None")
                {
                    ProcessorResult result = new ProcessorResult {
                        UniqueAttributeId = 7
                    };
                    result.Attributes.Add("7", cert.FixedName);

                    DomainSave(crawlContext, result);
                }

                if (cert.SubjectType != "None")
                {
                    ProcessorResult result = new ProcessorResult {
                        UniqueAttributeId = 8
                    };
                    result.Attributes.Add("8", cert.SubjectType);

                    DomainSave(crawlContext, result);
                }
            }
        }
Esempio n. 5
0
        private void DoSSLCheck()
        {
            MarketShareDataSource mds = DroneDataSource as MarketShareDataSource;

            if (!Object.Equals(null, mds))
            {
                int maxParallel = XMLUtility.GetTextFromAccountNode(Xml, ProcessorName + "/maxparallel").ConvertStringToInt(1);
                Dig dig         = new Dig();

                Parallel.ForEach(mds.GetAllCompanies(MarketShareTypeBitMaskEnum.SSLIssuer, XMLUtility.GetIntFromAccountNode(Xml, ProcessorName + "/recordcount"))
                                 , new ParallelOptions {
                    MaxDegreeOfParallelism = maxParallel
                }
                                 , (company, state) =>
                {
                    try
                    {
                        if (Context.ShuttingDown)
                        {
                            state.Break();
                        }

                        MarketShareDataType marketType = new MarketShareDataType();
                        string url = Utility.CleanUrl(company.Uri.ToString());
                        WriteToUsageLogFile("Domain:" + url, string.Format("Executing {0}.{1}", ComponentTypeName, MethodInfo.GetCurrentMethod().Name), true);

                        if (!String.IsNullOrWhiteSpace(url))
                        {
                            SSLCert cert = dig.GetSSLVerification(url);
                            if (!Object.Equals(cert, null))
                            {
                                MarketShareDataComponent dc = new MarketShareDataComponent();

                                //Issuer
                                marketType.Value      = cert.FixedName;
                                marketType.DomainId   = company.DomainId;
                                marketType.SampleDate = company.DomainAttributes["SampleDate"];
                                marketType.TypeId     = (int)MarketShareDataTypeEnum.SSLIssuer;
                                marketType.BitMaskId  = (int)MarketShareTypeBitMaskEnum.SSLIssuer;
                                dc.MarketShareType    = marketType;
                                DroneDataSource.Process(dc);

                                //CertType
                                marketType.Value     = cert.SubjectType;
                                marketType.TypeId    = (int)MarketShareDataTypeEnum.CertificateType;
                                marketType.BitMaskId = (int)MarketShareTypeBitMaskEnum.CertificateType;
                                dc.MarketShareType   = marketType;
                                DroneDataSource.Process(dc);
                            }
                            else
                            {
                                Utility.WriteToLogFile(String.Format("SmallBiz_NoSSLInfo_{0:M_d_yyyy}", DateTime.Today) + ".log", string.Format("Domain: ,{0}", url));
                            }
                        }
                    }
                    catch (Exception e)
                    {
                        ExceptionExtensions.LogError(e, "SSLCheck.DoSSLCheck", "Domain: " + company.Uri.ToString());
                    }
                });
            }
        }