Ejemplo n.º 1
0
        /// <summary>
        ///     Allows a plugin to add URLs to the project
        /// </summary>
        /// <param name="url"></param>
        private static void AddUrl(string url)
        {
            var uri    = new Uri(url);
            var domain = Program.data.GetDomain(uri.Host);

            if (domain == null)
            {
                Program.data.AddDomain(uri.Host, "Plugins", Program.cfgCurrent.MaxRecursion, Program.cfgCurrent);
            }
            else
            {
                domain = Program.data.GetDomain(uri.Host);
                // If URL could not be added, return
                if (domain == null)
                {
                    return;
                }
            }
            if (domain == null)
            {
                return;
            }
            domain.map.AddUrl(url);

            if (Program.data.relations.Items.Any(r => r.Domain.Domain == domain.Domain && r.Ip != null))
            {
                return;
            }
            var listIpsOfDomain = DNSUtil.GetHostAddresses(domain.Domain);

            foreach (var ip in listIpsOfDomain)
            {
                Program.data.AddResolution(domain.Domain, ip.ToString(), "Plugins", Program.cfgCurrent.MaxRecursion,
                                           Program.cfgCurrent, true);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Add domain if this not exist in the list.
        /// </summary>
        /// <param name="domain"></param>
        /// <param name="source"></param>
        /// <param name="maxRecursion"></param>
        /// <param name="cfgCurrent"></param>
        public void AddDomain(string domain, string source, int maxRecursion, Configuration cfgCurrent)
        {
            domain = domain.Trim();

            if (domains.Items.Any(S => S.Domain.ToLower() == domain.ToLower()))
            {
                return;
            }

            var dItem = new DomainsItem(domain, source);

            domains.Items.Add(dItem);
#if PLUGINS
            Thread tPluginOnDomain = new Thread(new ParameterizedThreadStart(Program.data.plugins.OnNewDomain));
            tPluginOnDomain.IsBackground = true;
            object[] oDomain = new object[] { new object[] { domain } };
            tPluginOnDomain.Start(oDomain);
#endif
            var domainParts   = domain.Split('.');
            var currentdomain = domainParts[domainParts.Length - 1];

            for (var i = 2; i < domainParts.Length; i++)
            {
                currentdomain = domainParts[domainParts.Length - i] + "." + currentdomain;

                AddDomain(currentdomain, string.Format("{0} > Inferred by {2} [{1}]", GetDomainSource(domain), currentdomain, domain), maxRecursion - 1, cfgCurrent);
            }

            if (maxRecursion <= 0)
            {
                OnChangeEvent(null);
                return;
            }

            //OnLog(null, new EventsThreads.ThreadStringEventArgs(string.Format("Resolving domain: {0}", domain)));

            var listIpsOfDomain = DNSUtil.GetHostAddresses(domain);

            if (listIpsOfDomain.Count == 0)
            {
                var computer = new ComputersItem();
                computer.type  = ComputersItem.Tipo.Server;
                computer.name  = domain;
                computer.NotOS = true;
                computer.os    = OperatingSystem.OS.Unknown;
                if (!computers.Items.Any(S => S.name == domain))
                {
                    computers.Items.Add(computer);
                }
            }

            foreach (var IP in listIpsOfDomain)
            {
                if (Program.data.IsMainDomainOrAlternative(domain))
                {
                    var limit = Program.data.GetLimitFromIp(IP.ToString());

                    if (limit == null)
                    {
                        Program.data.AddLimit(new Limits(IP.ToString()));
                    }
                    else
                    {
                        var lastOct = int.Parse(IP.ToString().Split(new char[] { '.' })[3]);

                        if (lastOct < limit.Lower)
                        {
                            limit.Lower = lastOct;
                        }
                        else if (lastOct > limit.Higher)
                        {
                            limit.Higher = lastOct;
                        }
                    }
                }

                AddResolution(domain, IP.ToString(), string.Format("{0} > DNS resolution [{1}]", GetDomainSource(domain), IP.ToString()), maxRecursion - 1, Program.cfgCurrent, false);
            }

            // Fingerprinting HTTP
            if (cfgCurrent.PassiveFingerPrintingHttp && cfgCurrent.FingerPrintingAllHttp)
            {
                if (NewDomainByHTTPServer != null)
                {
                    NewDomainByHTTPServer(dItem, null);
                }
            }
            else if ((cfgCurrent.PassiveFingerPrintingHttp) && (source.ToLower() == "documents search" || source.ToLower().Contains("websearch") || source.ToLower().Contains("bing ip search") || source.ToLower().Contains("technologyrecognition") || source.ToLower().Contains("fingerprinting") || source.ToLower().Contains("certificate fingerprinting")))
            {
                if (NewDomainByHTTPServer != null)
                {
                    NewDomainByHTTPServer(dItem, null);
                }
            }
            // Fingerprinting SMTP
            if (cfgCurrent.PasiveFingerPrintingSmtp && cfgCurrent.FingerPrintingAllSmtp)
            {
                if (NewDomainByMXServer != null)
                {
                    NewDomainByMXServer(dItem, null);
                }
            }

            else if ((cfgCurrent.PasiveFingerPrintingSmtp) && (source.ToLower().Contains("mx server")))
            {
                if (NewDomainByMXServer != null)
                {
                    NewDomainByMXServer(dItem, null);
                }
            }

            // Fingerprinting FTP
            if (cfgCurrent.FingerPrintingAllFtp)
            {
                if (NewDomainByFTPServer != null)
                {
                    NewDomainByFTPServer(dItem, null);
                }
            }

            OnChangeEvent(null);
        }