Exemplo n.º 1
0
        internal void SslBlackList(FileInfo mfile)
        {
            string path = Common.GetPath();

            //FileUrl = Common.GetURL();// Creates a dictionary of Filename and URL from which it got downloaded
            using (var rd = new StreamReader(path + mfile.ToString()))
            {
                List <KeyValuePair <string, List <string> > > InfoList = new List <KeyValuePair <string, List <string> > >();
                string fieldC        = "category";
                string fieldD        = "description";
                string fieldU        = "url";
                string fieldT        = "date";
                string IP            = "";
                string IpDescription = "";
                string category      = "";
                string IpDate        = "";
                string URL           = "";
                string line1         = rd.ReadLine();
                string line2         = rd.ReadLine();
                string line3         = rd.ReadLine();
                while (!rd.EndOfStream)
                {
                    string   line = rd.ReadLine();
                    string[] info = line.Split(',');
                    IpDate = line3.Split(':')[1];
                    if (info.Count() == 3)
                    {
                        IP            = info[0];
                        IpDescription = info[2];
                        category      = "C & C";
                        URL           = "https://sslbl.abuse.ch";
                        DescriptionList.Add(IpDescription);
                        CategoryList.Add(category);
                        UrlList.Add(URL);
                        IpDateList.Add(IpDate);
                        InfoList.Add(new KeyValuePair <string, List <string> >(fieldC, CategoryList));
                        InfoList.Add(new KeyValuePair <string, List <string> >(fieldD, DescriptionList));
                        InfoList.Add(new KeyValuePair <string, List <string> >(fieldU, UrlList));
                        InfoList.Add(new KeyValuePair <string, List <string> >(fieldT, IpDateList));
                        if (!BlackListDB.ContainsKey(IP))
                        {
                            BlackListDB.Add(IP, InfoList);
                            totalip.Add(IP);
                        }
                        CategoryList    = new List <string>();
                        DescriptionList = new List <string>();
                        UrlList         = new List <string>();
                        InfoList        = new List <KeyValuePair <string, List <string> > >();
                        IpDateList      = new List <string>();
                    }
                }
            }
        }
Exemplo n.º 2
0
        public Dictionary <string, List <KeyValuePair <string, List <string> > > > BadIpMain()
        {
            List <string> AllIP = new List <string>();
            List <KeyValuePair <string, List <string> > > InfoList = new List <KeyValuePair <string, List <string> > >();
            string fieldC        = "category";
            string fieldD        = "description";
            string fieldU        = "url";
            string fieldT        = "date";
            string IP            = "";
            string IpDescription = "";
            string category      = "";
            string IpDate        = "";
            string URL           = "";
            Dictionary <string, string> CatDesc = new Dictionary <string, string>();

            CatDesc = GetCatDesc();
            foreach (string cat in CatDesc.Keys)
            {
                AllIP = Get("https://www.badips.com/get/list/" + cat + "/0");
                foreach (string ip in AllIP)
                {
                    IP            = ip;
                    category      = cat;
                    IpDescription = CatDesc[cat];
                    URL           = "https://www.badips.com/get/list/" + cat + "/0";
                    IpDate        = "No Date Provided";
                    DescriptionList.Add(IpDescription);
                    CategoryList.Add(category);
                    UrlList.Add(URL);
                    IpDateList.Add(IpDate);
                    InfoList.Add(new KeyValuePair <string, List <string> >(fieldC, CategoryList));
                    InfoList.Add(new KeyValuePair <string, List <string> >(fieldD, DescriptionList));
                    InfoList.Add(new KeyValuePair <string, List <string> >(fieldU, UrlList));
                    InfoList.Add(new KeyValuePair <string, List <string> >(fieldT, IpDateList));
                    if (IP != "")
                    {
                        if (!BlackListDB.ContainsKey(IP))
                        {
                            totalip.Add(IP);
                            BlackListDB.Add(IP, InfoList);
                        }
                    }
                    CategoryList    = new List <string>();
                    DescriptionList = new List <string>();
                    UrlList         = new List <string>();
                    InfoList        = new List <KeyValuePair <string, List <string> > >();
                    IpDateList      = new List <string>();
                }
            }
            return(BlackListDB);
        }
Exemplo n.º 3
0
        internal void blocklistDe(FileInfo mfile)
        {
            string path = Common.GetPath();

            //FileUrl = Common.GetURL();// Creates a dictionary of Filename and URL from which it got downloaded
            using (var rd = new StreamReader(path + mfile.ToString()))
            {
                List <KeyValuePair <string, List <string> > > InfoList = new List <KeyValuePair <string, List <string> > >();
                string fieldC        = "category";
                string fieldD        = "description";
                string fieldU        = "url";
                string fieldT        = "date";
                string IP            = "";
                string IpDescription = "";
                string category      = "";
                string IpDate        = "";
                string URL           = "";
                while (!rd.EndOfStream)
                {
                    string line = rd.ReadLine();
                    IP     = line.Trim();
                    IpDate = "Provider updates every 48hrs";
                    if (mfile.ToString() == "all.txt")
                    {
                        IpDescription = "All IP addresses that have attacked one of our customers/servers in the last 48 hours. ";
                        category      = "attacks";
                    }
                    if (mfile.ToString() == "ssh.txt")
                    {
                        IpDescription = "All IP addresses which have been reported within the last 48 hours as having run attacks on the service";
                        category      = "ssh attacks";
                    }
                    if (mfile.ToString() == "bots.txt")
                    {
                        IpDescription = "All IP addresses which have been reported within the last 48 hours as having run attacks attacks on the RFI-Attacks, REG-Bots, IRC-Bots or BadBots (BadBots = he has posted a Spam-Comment on a open Forum or Wiki). ";
                        category      = "bots";
                    }
                    if (mfile.ToString() == "ircbot.txt")
                    {
                        IpDescription = "Irc bots found in last 48 hours. ";
                        category      = "ircbot";
                    }
                    if (mfile.ToString() == "bruteforcelogin.txt")
                    {
                        IpDescription = "All IPs which attacks Joomlas, Wordpress and other Web-Logins with Brute-Force Logins. ";
                        category      = "bruteforcelogin";
                    }
                    URL = "http://www.blocklist.de/en/export.html";
                    DescriptionList.Add(IpDescription);
                    CategoryList.Add(category);
                    UrlList.Add(URL);
                    IpDateList.Add(IpDate);
                    InfoList.Add(new KeyValuePair <string, List <string> >(fieldC, CategoryList));
                    InfoList.Add(new KeyValuePair <string, List <string> >(fieldD, DescriptionList));
                    InfoList.Add(new KeyValuePair <string, List <string> >(fieldU, UrlList));
                    InfoList.Add(new KeyValuePair <string, List <string> >(fieldT, IpDateList));
                    if (!BlackListDB.ContainsKey(IP))
                    {
                        totalip.Add(IP);
                        BlackListDB.Add(IP, InfoList);
                    }
                    CategoryList    = new List <string>();
                    DescriptionList = new List <string>();
                    UrlList         = new List <string>();
                    InfoList        = new List <KeyValuePair <string, List <string> > >();
                    IpDateList      = new List <string>();
                }
            }
        }
Exemplo n.º 4
0
        internal void IPsetDB(FileInfo mfile)
        {
            string path = Common.GetPath();

            FileUrl = Common.GetURL();// Creates a dictionary of Filename and URL from which it got downloaded
            using (var rd = new StreamReader(path + mfile.ToString()))
            {
                List <KeyValuePair <string, List <string> > > InfoList = new List <KeyValuePair <string, List <string> > >();
                string        fieldC        = "category";
                string        fieldD        = "description";
                string        fieldU        = "url";
                string        fieldT        = "date";
                string        IP            = "";
                string        IpDescription = "";
                string        category      = "";
                string        IpDate        = "";
                string        url           = "";
                List <string> tempDesc      = new List <string>();
                int           i             = 1;
                string        t             = "";
                string        l             = "";
                int           k             = 0;
                while (!rd.EndOfStream)
                {
                    string x = rd.ReadLine();
                    if (i != k && k == 0)
                    {
                        if (i >= 6)
                        {
                            if (!x.Contains("Maintainer"))
                            {
                                tempDesc.Add(x);
                            }
                            else
                            {
                                k = i;
                                k++;
                                l             = string.Join(" ", tempDesc);
                                l             = l.Replace("#", " ");
                                IpDescription = l;
                            }
                        }
                    }
                    i++;
                    if (i == k)
                    {
                        k = 1;
                    }
                    category = x.Contains("Category") ? x.Split(':')[1].ToString().Trim() : category;
                    IpDate   = x.Contains("Source File Date") ? x.Split(':')[1].ToString().Trim() : IpDate;

                    url = x.Contains("List source URL") ? x.Split(new char[] { ':' }, 2, StringSplitOptions.RemoveEmptyEntries)[1].ToString().Trim() : url;
                    var match = Regex.Match(x, @"\b(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})\b");
                    if (match.ToString() != "")
                    {
                        IP = match.ToString().Trim();
                        DescriptionList.Add(IpDescription);
                        CategoryList.Add(category);
                        UrlList.Add(url);
                        IpDateList.Add(IpDate);
                        InfoList.Add(new KeyValuePair <string, List <string> >(fieldC, CategoryList));
                        InfoList.Add(new KeyValuePair <string, List <string> >(fieldD, DescriptionList));
                        InfoList.Add(new KeyValuePair <string, List <string> >(fieldU, UrlList));
                        InfoList.Add(new KeyValuePair <string, List <string> >(fieldT, IpDateList));

                        if (!BlackListDB.ContainsKey(IP))
                        {
                            totalip.Add(IP);
                            BlackListDB.Add(IP, InfoList);
                        }
                        else
                        {
                            InfoList = BlackListDB[IP];
                            foreach (KeyValuePair <string, List <string> > item in InfoList)
                            {
                                if (item.Key == "category")
                                {
                                    if (!item.Value.Contains(category))
                                    {
                                        item.Value.Add(category);
                                    }
                                }
                                if (item.Key == "url")
                                {
                                    if (!item.Value.Contains(FileUrl[mfile.ToString()]))
                                    {
                                        item.Value.Add(FileUrl[mfile.ToString()]);
                                    }
                                }
                            }
                        }
                        CategoryList    = new List <string>();
                        DescriptionList = new List <string>();
                        UrlList         = new List <string>();
                        InfoList        = new List <KeyValuePair <string, List <string> > >();
                        IpDateList      = new List <string>();
                    }
                }
            }
        }