Esempio n. 1
0
 private void VerifyOnServers(BlacklistsToCheck _blacklistServers)
 {
     _blacklisted = null;
     if (_blacklistServers != null && _blacklistServers.blacklistCheck.Count > 0)
     {
         foreach (var item in _blacklistServers.blacklistCheck)
         {
             foreach (var i in item.dnsblList)
             {
                 if (VerifyOnServer(i.HostName))
                 {
                     _blacklisted = new BlackListed(true, i.HostName, item.Provider);
                     break;
                 }
             }
             if (_blacklisted == null)
             {
                 _blacklisted = new BlackListed(false, "");
             }
         }
     }
 }
Esempio n. 2
0
        static void Main(string[] args)
        {
            try
            {
                using (StreamReader r = new StreamReader(Path.Combine(currentDirectory, "Blacklists.json")))
                {
                    var json = r.ReadToEnd();

                    blacklistsToCheck = JsonConvert.DeserializeObject <BlacklistsToCheck>(json);
                }

                using (StreamReader r = new StreamReader(Path.Combine(currentDirectory, "IPs.json")))
                {
                    var json = r.ReadToEnd();

                    IPsToCheck items = JsonConvert.DeserializeObject <IPsToCheck>(json);

                    foreach (var provider in items.providerCheck)
                    {
                        Console.WriteLine("Querying ESP: " + provider.ESP);

                        foreach (var i in provider.ipList)
                        {
                            Console.WriteLine("Querying IP: " + i.IP);

                            VerifyIP IP = new VerifyIP(i.IP, blacklistsToCheck);

                            if (IP.IPAddr.Valid)
                            {
                                if (IP.BlackList.IsListed)
                                {
                                    BlacklistCollection bl = new BlacklistCollection
                                    {
                                        Provider  = provider.ESP,
                                        IPAddress = i.IP,
                                        Blacklist = IP.BlackList.Provider,
                                        Hostname  = IP.BlackList.VerifiedOnServer
                                    };

                                    blCollection.Add(bl);

                                    Console.WriteLine("IP {0} listed on {1} - {2}.", i.IP, IP.BlackList.Provider, IP.BlackList.VerifiedOnServer);
                                }
                            }
                        }
                        Console.WriteLine("------------------------------------------");
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                throw e;
            }
            finally
            {
                EndTime       = DateTime.Now;
                BatchDuration = (EndTime - StartTime);

                Console.WriteLine("App runtime: " + BatchDuration);
            }
        }
Esempio n. 3
0
 public VerifyIP(string address, BlacklistsToCheck blacklistServers)
 {
     _ip = new ExIPAddress(address);
     VerifyOnServers(blacklistServers);
 }