コード例 #1
0
        public Host(Dictionary <string, object> host, Boolean simple = false)
        {
            CultureInfo provider = CultureInfo.InvariantCulture;

            // Extract the info out of the host dictionary and put it in the local properties
            ip = IPAddress.Parse(host["ip"].ToString());

            // Hostnames
            ArrayList tmp = (ArrayList)host["hostnames"];

            hostnames = tmp.Cast <string>().ToList();

            // Banners
            banners = new List <ServiceBanner>();

            if (host["data"] is ArrayList)
            {
                tmp = (ArrayList)host["data"];
                foreach (Dictionary <string, object> data in tmp)
                {
                    DateTime timestamp = DateTime.ParseExact((string)data["timestamp"], "dd.MM.yyyy", provider);
                    banners.Add(new ServiceBanner((int)data["port"], (string)data["banner"], (DateTime)timestamp));
                }
            }
            else if (host["data"] is string)
            {
                DateTime timestamp = DateTime.ParseExact((string)host["updated"], "dd.MM.yyyy", provider);
                banners.Add(new ServiceBanner((int)host["port"], (string)host["data"], (DateTime)timestamp));
            }

            // Location
            location = new HostLocation(host);
        }
コード例 #2
0
ファイル: WebAPI.cs プロジェクト: achillean/Shodan.NET
        public Host(Dictionary<string, object> host, Boolean simple=false)
        {
            CultureInfo provider = CultureInfo.InvariantCulture;

            // Extract the info out of the host dictionary and put it in the local properties
            ip = IPAddress.Parse(host["ip"].ToString());

            // Hostnames
            ArrayList tmp = (ArrayList)host["hostnames"];
            hostnames = tmp.Cast<string>().ToList();

            // Banners
            banners = new List<ServiceBanner>();

            if (host["data"] is ArrayList)
            {
                tmp = (ArrayList)host["data"];
                foreach (Dictionary<string, object> data in tmp)
                {
                    DateTime timestamp = DateTime.ParseExact((string)data["timestamp"], "dd.MM.yyyy", provider);
                    banners.Add(new ServiceBanner((int)data["port"], (string)data["banner"], (DateTime)timestamp));
                }
            }
            else if (host["data"] is string)
            {
                DateTime timestamp = DateTime.ParseExact((string)host["updated"], "dd.MM.yyyy", provider);
                banners.Add(new ServiceBanner((int)host["port"], (string)host["data"], (DateTime)timestamp));
            }

            // Location
            location = new HostLocation(host);
        }