Exemplo n.º 1
0
        public List <IssueScanResult> IssueScan(SPFDMARCRecord spfDMARCRecord, ParsedSPFRecord extendedSPF)
        {
            List <IssueScanResult> issueResults = new List <IssueScanResult>();

            issueResults.AddRange(SPFIssueScan(spfDMARCRecord.spfRecord, spfDMARCRecord.domainName, extendedSPF));
            if (issueResults.Count >= 1)
            {
                if (!issueResults[0].code.Equals(0) && !issueResults[0].code.Equals(11))
                {
                    issueResults = DMARCIssueScan(spfDMARCRecord.dmarcRecord, spfDMARCRecord.domainName, issueResults);
                }
            }
            else
            {
                issueResults = DMARCIssueScan(spfDMARCRecord.dmarcRecord, spfDMARCRecord.domainName, issueResults);
            }
            return(issueResults);
        }
Exemplo n.º 2
0
        public SPFDMARCRecord GetSPFDMARCRecord(string domainName)
        {
            bool           longSPF   = false;
            SPFDMARCRecord dnsRecord = new SPFDMARCRecord();

            dnsRecord.domainName = domainName;
            try
            {
                IDnsResolver     resolver   = new DnsStubResolver();
                List <TxtRecord> txtRecords = resolver.Resolve <TxtRecord>(domainName, RecordType.Txt);
                foreach (TxtRecord ip in Enumerable.Reverse(txtRecords))
                {
                    if (ip.TextData.Contains("v=spf1 "))
                    {
                        dnsRecord.spfRecord = ip.TextData;
                        if (!ip.TextData.Contains("+all") && !ip.TextData.Contains("~all") && !ip.TextData.Contains("-all") && !ip.TextData.Contains("?all"))
                        {
                            longSPF = true;
                        }
                    }
                    else if (longSPF)
                    {
                        if (ip.TextData.Contains("+all") || ip.TextData.Contains("~all") || ip.TextData.Contains("-all") || ip.TextData.Contains("?all"))
                        {
                            dnsRecord.spfRecord += ip.TextData;
                        }
                    }
                }
                try
                {
                    txtRecords = resolver.Resolve <TxtRecord>("_dmarc." + domainName, RecordType.Txt);
                    foreach (TxtRecord ip in txtRecords)
                    {
                        if (ip.TextData.Contains("v=DMARC1"))
                        {
                            dnsRecord.dmarcRecord = ip.TextData;
                        }
                    }
                    if (dnsRecord.dmarcRecord.IsNullOrWhiteSpace())
                    {
                        throw new Exception();
                    }
                }
                catch
                {
                    DomainParser domainParser = new DomainParser(new WebTldRuleProvider());
                    string       parentDomain = domainParser.Get(domainName).RegistrableDomain;

                    txtRecords = resolver.Resolve <TxtRecord>("_dmarc." + parentDomain, RecordType.Txt);
                    foreach (TxtRecord ip in txtRecords)
                    {
                        if (ip.TextData.Contains("v=DMARC1"))
                        {
                            dnsRecord.dmarcRecord = ip.TextData;
                        }
                    }
                }
            }
            catch
            {
                return(dnsRecord);
            }
            return(dnsRecord);
        }
Exemplo n.º 3
0
        private async void Process_OutputDataReceived(object sender, DataReceivedEventArgs e)
        {
            if (!e.Data.IsNullOrWhiteSpace())
            {
                if (e.Data.Contains(": ") && !e.Data.Contains("[!] Error") && !e.Data.Contains("[-] Total Unique") && !e.Data.Contains("DeprecationWarning:"))
                {
                    SubDomainOutput subdomain = new SubDomainOutput();
                    subdomain.SubDomain = e.Data.Split(':')[1].Trim();
                    Console.WriteLine(e.Data);
                    SPFParse       getSPFDMARC = new SPFParse();
                    SPFDMARCRecord spfDMARC    = getSPFDMARC.GetSPFDMARCRecord(subdomain.SubDomain);
                    Console.WriteLine("-------------------------");
                    ParsedSPFRecord spfParse = await new SPFParseScheduler().GetSPF(subdomain.SubDomain, 1);

                    List <IssueScanResult> issues = new IssueEngine().IssueScan(spfDMARC, spfParse);

                    string issueSeverity = "";
                    foreach (IssueScanResult issue in issues)
                    {
                        if (issue.severity == "Very High")
                        {
                            issueSeverity = issue.severity;
                        }
                        if (issueSeverity != "Very High")
                        {
                            if (issue.severity == "High")
                            {
                                issueSeverity = issue.severity;
                            }
                            if (issueSeverity != "High")
                            {
                                if (issue.severity == "Medium")
                                {
                                    issueSeverity = issue.severity;
                                }
                                if (issueSeverity != "Medium")
                                {
                                    if (issue.severity == "Low")
                                    {
                                        issueSeverity = issue.severity;
                                    }
                                }
                            }
                        }
                    }
                    subdomain.Spoofable = issueSeverity;
                    if (spfDMARC.spfRecord.IsNullOrWhiteSpace())
                    {
                        subdomain.SPFRecord = "-";
                    }
                    else
                    {
                        subdomain.SPFRecord = spfDMARC.spfRecord;
                    }
                    if (spfDMARC.dmarcRecord.IsNullOrWhiteSpace())
                    {
                        subdomain.DMARCRecord = "-";
                    }
                    else
                    {
                        if (spfDMARC.dmarcRecord.Contains("; p=none") || spfDMARC.dmarcRecord.Contains(";p=none"))
                        {
                            subdomain.DMARCRecord = "Audit";
                        }
                        else if (spfDMARC.dmarcRecord.Contains("; p=quarantine") || spfDMARC.dmarcRecord.Contains(";p=quarantine"))
                        {
                            subdomain.DMARCRecord = "Quarantine";
                        }
                        else if (spfDMARC.dmarcRecord.Contains("; p=reject") || spfDMARC.dmarcRecord.Contains(";p=reject"))
                        {
                            subdomain.DMARCRecord = "Reject";
                        }
                        else
                        {
                            subdomain.DMARCRecord = "-";
                        }
                    }
                    subdomain.searchEngine = engine;
                    subDomains.Add(subdomain);

                    Console.WriteLine(subdomain.Spoofable);
                    Console.WriteLine(subdomain.SubDomain);
                }
            }
        }