Exemplo n.º 1
0
        /// <summary>
        /// If we need to skip this Target
        /// </summary>
        /// <param name="target">The Target</param>
        /// <param name="agentTrigger">Agent trigger configuration</param>
        /// <returns>If we need to skip this Target</returns>
        private static bool SkipTarget(Target target, AgentTrigger agentTrigger)
        {
            if (agentTrigger.TargetHasBounty && (target == null || !target.HasBounty))
            {
                return(true);
            }

            if (!string.IsNullOrEmpty(agentTrigger.TargetIncExcName) && !string.IsNullOrEmpty(agentTrigger.TargetName))
            {
                if (INCLUDE.Equals(agentTrigger.TargetIncExcName, StringComparison.OrdinalIgnoreCase))
                {
                    var match = Regex.Match(target.Name, agentTrigger.TargetName);

                    // if match success dont skip this target
                    return(!match.Success);
                }
                else if (EXCLUDE.Equals(agentTrigger.TargetIncExcName, StringComparison.OrdinalIgnoreCase))
                {
                    var match = Regex.Match(target.Name, agentTrigger.TargetName);

                    // if match success skip this target
                    return(match.Success);
                }
            }

            return(false);
        }
Exemplo n.º 2
0
        /// <summary>
        /// If we need to skip this RootDomain
        /// </summary>
        /// <param name="rootDomain">The rootDomain</param>
        /// <param name="agentTrigger">Agent trigger configuration</param>
        /// <returns>If we need to skip this RootDomain</returns>
        private static bool SkipRootDomain(RootDomain rootDomain, AgentTrigger agentTrigger)
        {
            if (agentTrigger.RootdomainHasBounty && (rootDomain == null || !rootDomain.HasBounty))
            {
                return(true);
            }

            if (!string.IsNullOrEmpty(agentTrigger.RootdomainIncExcName) && !string.IsNullOrEmpty(agentTrigger.RootdomainName))
            {
                if (INCLUDE.Equals(agentTrigger.RootdomainIncExcName, StringComparison.OrdinalIgnoreCase))
                {
                    var match = Regex.Match(rootDomain.Name, agentTrigger.RootdomainName);

                    // if match success dont skip this rootdomain
                    return(!match.Success);
                }
                else if (EXCLUDE.Equals(agentTrigger.RootdomainIncExcName, StringComparison.OrdinalIgnoreCase))
                {
                    var match = Regex.Match(rootDomain.Name, agentTrigger.RootdomainName);

                    // if match success skip this rootdomain
                    return(match.Success);
                }
            }

            return(false);
        }
Exemplo n.º 3
0
        /// <summary>
        /// If we need to skip this Subdomain
        /// </summary>
        /// <param name="subdomain">The subdomain</param>
        /// <param name="agentTrigger">Agent trigger configuration</param>
        /// <returns>If we need to skip this Subdomain</returns>
        private static bool SkipSubdomain(Subdomain subdomain, AgentTrigger agentTrigger)
        {
            if (agentTrigger.SubdomainHasBounty && (subdomain == null || subdomain.HasBounty == null || !subdomain.HasBounty.Value))
            {
                return(true);
            }

            if (agentTrigger.SubdomainHasHttpOrHttpsOpen && (subdomain == null || subdomain.HasHttpOpen == null || !subdomain.HasHttpOpen.Value))
            {
                return(true);
            }

            if (agentTrigger.SubdomainIsAlive && (subdomain == null || subdomain.IsAlive == null || !subdomain.IsAlive.Value))
            {
                return(true);
            }

            if (agentTrigger.SubdomainIsMainPortal && (subdomain == null || subdomain.IsMainPortal == null || !subdomain.IsMainPortal.Value))
            {
                return(true);
            }

            if (!string.IsNullOrEmpty(agentTrigger.SubdomainIncExcName) && !string.IsNullOrEmpty(agentTrigger.SubdomainName))
            {
                if (INCLUDE.Equals(agentTrigger.SubdomainIncExcName, StringComparison.OrdinalIgnoreCase))
                {
                    var match = Regex.Match(subdomain.Name, agentTrigger.SubdomainName);

                    // if match success dont skip this subdomain
                    return(!match.Success);
                }
                else if (EXCLUDE.Equals(agentTrigger.SubdomainIncExcName, StringComparison.OrdinalIgnoreCase))
                {
                    var match = Regex.Match(subdomain.Name, agentTrigger.SubdomainName);

                    // if match success skip this subdomain
                    return(match.Success);
                }
            }

            if (!string.IsNullOrEmpty(agentTrigger.SubdomainIncExcServicePort) && !string.IsNullOrEmpty(agentTrigger.SubdomainServicePort))
            {
                if (INCLUDE.Equals(agentTrigger.SubdomainIncExcServicePort, StringComparison.OrdinalIgnoreCase))
                {
                    foreach (var service in subdomain.Services)
                    {
                        var matchService = Regex.Match(service.Name, agentTrigger.SubdomainServicePort);
                        var matchPort    = Regex.Match(service.Port.ToString(), agentTrigger.SubdomainServicePort);

                        // if match success service or port dont skip this subdomain
                        if (matchService.Success || matchPort.Success)
                        {
                            return(false);
                        }
                    }

                    return(true);
                }
                else if (EXCLUDE.Equals(agentTrigger.SubdomainIncExcServicePort, StringComparison.OrdinalIgnoreCase))
                {
                    foreach (var service in subdomain.Services)
                    {
                        var matchService = Regex.Match(service.Name, agentTrigger.SubdomainServicePort);
                        var matchPort    = Regex.Match(service.Port.ToString(), agentTrigger.SubdomainServicePort);

                        // if match success services or port skip this subdomain
                        if (matchService.Success || matchPort.Success)
                        {
                            return(true);
                        }
                    }
                }
            }

            if (!string.IsNullOrEmpty(agentTrigger.SubdomainIncExcIP) && !string.IsNullOrEmpty(agentTrigger.SubdomainIP))
            {
                if (INCLUDE.Equals(agentTrigger.SubdomainIncExcIP, StringComparison.OrdinalIgnoreCase))
                {
                    var match = Regex.Match(subdomain.IpAddress, agentTrigger.SubdomainIP);

                    // if match success dont skip this subdomain
                    return(!match.Success);
                }
                else if (EXCLUDE.Equals(agentTrigger.SubdomainIncExcIP, StringComparison.OrdinalIgnoreCase))
                {
                    var match = Regex.Match(subdomain.IpAddress, agentTrigger.SubdomainIP);

                    // if match success skip this subdomain
                    return(match.Success);
                }
            }

            if (!string.IsNullOrEmpty(agentTrigger.SubdomainIncExcTechnology) && !string.IsNullOrEmpty(agentTrigger.SubdomainTechnology))
            {
                if (INCLUDE.Equals(agentTrigger.SubdomainIncExcTechnology, StringComparison.OrdinalIgnoreCase))
                {
                    var match = Regex.Match(subdomain.Technology, agentTrigger.SubdomainTechnology);

                    // if match success dont skip this subdomain
                    return(!match.Success);
                }
                else if (EXCLUDE.Equals(agentTrigger.SubdomainIncExcTechnology, StringComparison.OrdinalIgnoreCase))
                {
                    var match = Regex.Match(subdomain.Technology, agentTrigger.SubdomainTechnology);

                    // if match success skip this subdomain
                    return(match.Success);
                }
            }

            if (!string.IsNullOrEmpty(agentTrigger.SubdomainIncExcLabel) && !string.IsNullOrEmpty(agentTrigger.SubdomainLabel))
            {
                if (INCLUDE.Equals(agentTrigger.SubdomainIncExcLabel, StringComparison.OrdinalIgnoreCase))
                {
                    foreach (var label in subdomain.Labels)
                    {
                        var match = Regex.Match(label.Label.Name, agentTrigger.SubdomainLabel);

                        // if match success label dont skip this subdomain
                        if (match.Success)
                        {
                            return(false);
                        }
                    }

                    return(true);
                }
                else if (EXCLUDE.Equals(agentTrigger.SubdomainIncExcLabel, StringComparison.OrdinalIgnoreCase))
                {
                    foreach (var label in subdomain.Labels)
                    {
                        var match = Regex.Match(label.Label.Name, agentTrigger.SubdomainLabel);

                        // if match success label skip this subdomain
                        if (match.Success)
                        {
                            return(true);
                        }
                    }
                    ;
                }
            }

            return(false);
        }