Ejemplo n.º 1
0
        private void buttonMMF_Click(object sender, EventArgs e)
        {
            using (IPv4DataContext db = new IPv4DataContext())
            {
                var q = from item in db.gws
                        select item.Address;
                //q = q.Union(db.gws_Old.Select(f => f.Address));
                var list = from item in q.ToList()
                           orderby item
                           group item by string.Format("{0}/24", ((uint)item & 0xFFFFFF00).ToIPAddress());

                string filename = string.Format("{0}{1}.txt", Properties.Settings.Default.MMFPath, Path.GetFileNameWithoutExtension(Application.ExecutablePath));
                SaveFile(filename, list.Select(f => f.Key));
                var publicList = db.GoogleIPDuan.Select(f => f.IPBlock).Union(db.GoogleIPHunter.Select(f => f.IPBlock));
                if (publicList.Count() > 0)
                {
                    var p = from itemg in list
                            join itemp in publicList on itemg.Key equals itemp into g
                            from item in g.DefaultIfEmpty()
                            where string.IsNullOrWhiteSpace(item)
                            select itemg;
                    list     = p.ToList();
                    filename = string.Format("{0}{1}.Except.txt", Properties.Settings.Default.MMFPath, Path.GetFileNameWithoutExtension(Application.ExecutablePath));
                    SaveFile(filename, list.Select(f => f.Key));

                    list = from item in list.SelectMany(f => f)
                           orderby item
                           group item by string.Format("{0}/8", ((uint)item & 0xFF000000).ToIPAddress());

                    var ip = from item in list
                             select "\t\t\t" + string.Join(",", from a in item select string.Format(@"""{0}""", ((uint)a).ToIPAddress())) + ",";
                    SaveFile("gae.user.txt", ip);
                }
            }
        }
Ejemplo n.º 2
0
        void ExceptDB()
        {
            using (IPv4DataContext db = new IPv4DataContext())
            {
                var listDB = (from item in db.IPv4SSL
                              where item.Address >= IPSet.Min && item.Address <= IPSet.Max
                              select item.Address).ToList().Select(p => (uint)p);
                finishCount = IPSet.Count;
                IPSet.ExceptWith(listDB);
                finishCount -= IPSet.Count;
            }
            if (finishCount > 0)
            {
                CodeSite.Send("SkipCount", finishCount);
            }
            IPList.Clear();
            IPList.AddRange(IPSet);
            Random random = new Random();

            for (int i = 0; i < IPList.Count; i++)
            {
                int  j = random.Next(i, IPList.Count);
                uint t = IPList[i];
                IPList[i] = IPList[j];
                IPList[j] = t;
            }
        }
Ejemplo n.º 3
0
 public Task gwsAsync()
 {
     cts  = new CancellationTokenSource();
     task = Task.Factory.StartNew(() =>
     {
         while (!cts.IsCancellationRequested)
         {
             try
             {
                 using (IPv4DataContext db = new IPv4DataContext())
                 {
                     var q = db.gws_Old.Select(f => f.Address).Except(db.gws.Select(f => f.Address)).ToList();
                     for (int i = 0; i < q.Count - 1; i++)
                     {
                         if (cts.IsCancellationRequested)
                         {
                             break;
                         }
                         var gws = q[i];
                         //CodeSite.Send("gws.IP", gws.IP);
                         if (ProgressString != null)
                         {
                             ProgressString.Report(string.Format("{0}/{1}", i + 1, q.Count));
                         }
                         var ip = db.IPv4SSL.SingleOrDefault(f => f.Address == gws);
                         if (ip == null)
                         {
                             ip = new IPv4SSL((UInt32)gws);
                         }
                         else if (ip.Isgws)
                         {
                             //CodeSite.SendNote("跳过");
                             continue;
                         }
                         WebCheck(ip);
                         if (ip.RoundtripTime != -1 && db.IPv4SSL.SingleOrDefault(f => f.Address == gws) == null)
                         {
                             db.IPv4SSL.InsertOnSubmit(ip);
                         }
                         if (ip.Isgws)
                         {
                             if (ProgressIP != null)
                             {
                                 ProgressIP.Report(ip);
                             }
                             db.SubmitChanges();
                         }
                     }
                 }
             }
             catch (Exception ex)
             {
                 ex.SendCodeSite("gwsAsync");
                 Thread.Sleep(1000);
             }
         }
     }, cts.Token);
     return(task);
 }
Ejemplo n.º 4
0
 private bool SelectDB(IPAddress ip)
 {
     using (IPv4DataContext db = new IPv4DataContext())
     {
         listIPv4SSL = db.IPv4SSL
                       .Where(f => !f.IsSSL && f.Address >= ip.ToUInt32())
                       .OrderBy(f => f.Address)
                       .Take(200000)
                       .ToList();
         return(listIPv4SSL.Count > 0);
     }
 }
Ejemplo n.º 5
0
 private void buttonServernull_Click(object sender, EventArgs e)
 {
     using (IPv4DataContext db = new IPv4DataContext())
     {
         //var q = from g in db.Google
         //        join i in db.IPv4SSL on g.Address equals i.Address
         //        where i.Server == null
         //        select i.Address;
         foreach (var ip in db.IPv4SSL.Join(db.Google, i => i.Address, g => g.Address, (i, g) => i).Where(f => f.Server == null).OrderBy(f => f.Address))
         {
             CodeSite.Send("IP", ip.IP);
             Search.WebCheck(ip);
             Search.TcpCheck(ip);
             db.SubmitChanges();
         }
     }
 }
Ejemplo n.º 6
0
 void ExceptDB()
 {
     using (IPv4DataContext db = new IPv4DataContext())
     {
         var listDB = (from item in db.IPv4SSL
                       where item.Address >= listIP.First() && item.Address <= listIP.Last()
                       select item.Address).ToList().Select(f => (uint)f);
         progressCount  = listIP.Count;
         listIP         = listIP.Except(listDB).ToList();
         progressCount -= listIP.Count;
     }
     if (progressCount > 0)
     {
         CodeSite.Send("SkipCount", progressCount);
     }
     Shuffle();
 }
Ejemplo n.º 7
0
 static bool SaveDB(IEnumerable <IPv4SSL> ipa)
 {
     using (IPv4DataContext db = new IPv4DataContext())
     {
         try
         {
             db.IPv4SSL.InsertAllOnSubmit(ipa);
             db.SubmitChanges();
             return(true);
         }
         catch (Exception ex)
         {
             ex.SendCodeSite("SaveDB");
             CodeSite.Send("ipa.First().IP", ipa.First().IP);
         }
     }
     return(false);
 }
Ejemplo n.º 8
0
 protected override bool SaveDB(IEnumerable <IPv4SSL> ipa)
 {
     using (IPv4DataContext db = new IPv4DataContext())
     {
         try
         {
             db.IPv4SSL.InsertAllOnSubmit(ipa);
             db.SubmitChanges();
             return(true);
         }
         catch (Exception ex)
         {
             ex.SendCodeSite("SaveDB");
             CodeSite.Send("Count = {0}, FirstIP = {1}", ipa.Count(), ipa.First().IP);
         }
     }
     return(false);
 }
Ejemplo n.º 9
0
        private void buttonGoogleIPHunter_Click(object sender, EventArgs e)
        {
            var files = Directory.GetFiles(@"G:\DxgWork\GitHub\GoogleIPHunter\trunk", "*.txt", SearchOption.AllDirectories);

            using (IPv4DataContext db = new IPv4DataContext())
            {
                foreach (var file in files)
                {
                    foreach (var s in File.ReadAllLines(file))
                    {
                        try
                        {
                            IPNetwork network = IPNetwork.Parse(s);
                            if (network.ToString() == s)
                            {
                                uint address = network.Network.ToUInt32();
                                if (!db.GoogleIPHunter.Any(f => f.Address == (long)address))
                                {
                                    db.GoogleIPHunter.InsertOnSubmit(new GoogleIPHunter()
                                    {
                                        Address = address, IPBlock = s
                                    });
                                    db.SubmitChanges();
                                    CodeSite.SendNote("新增 = {0}", s);
                                }
                            }
                            else
                            {
                                CodeSite.SendError(s);
                            }
                        }
                        catch
                        {
                            //CodeSite.SendException(s, ex);
                        }
                    }
                }
            }
        }
Ejemplo n.º 10
0
 public MainForm()
 {
     InitializeComponent();
     search = new Search()
     {
         ProgressIP     = new Progress <IPv4SSL>(p => bindingSource1.Add(p)),
         ProgressString = new Progress <string>(p => labelCount.Text = p)
     };
     pingSniffer = new PingSniffer()
     {
         ProgressIPv4SSL = new Progress <IPv4SSL>(p => bindingSource1.Add(p)),
         ProgressString  = new Progress <string>(p => labelCount.Text = p)
     };
     sslSniffer = new SslSniffer()
     {
         ProgressIPv4SSL = new Progress <IPv4SSL>(p => bindingSource1.Add(p)),
         ProgressString  = new Progress <string>(p => labelCount.Text = p)
     };
     using (IPv4DataContext db = new IPv4DataContext())
     {
         IPNetworkSet.IPv4Assigned.Add(string.Join(Environment.NewLine, db.IPv4Assigned.Select(f => f.IPBlock)));
     }
 }
Ejemplo n.º 11
0
        private void buttonGoogleIP_Click(object sender, EventArgs e)
        {
            var sa = File.ReadAllLines("google ip duan.txt");

            using (IPv4DataContext db = new IPv4DataContext())
            {
                var list = db.GoogleIPDuan.ToList().Select(f => (uint)f.Address);
                foreach (var s in sa)
                {
                    try
                    {
                        IPNetwork network = IPNetwork.Parse(s);
                        if (network.ToString() == s)
                        {
                            uint address = network.Network.ToUInt32();
                            if (!list.Contains(address))
                            {
                                db.GoogleIPDuan.InsertOnSubmit(new GoogleIPDuan()
                                {
                                    Address = address, IPBlock = s
                                });
                                CodeSite.SendNote("新增 = {0}", s);
                            }
                        }
                        else
                        {
                            CodeSite.SendError(s);
                        }
                    }
                    catch (Exception ex)
                    {
                        CodeSite.SendException(s, ex);
                    }
                }
                db.SubmitChanges();
            }
        }
Ejemplo n.º 12
0
 protected override bool SaveDB(IEnumerable <IPv4SSL> ipa)
 {
     //CodeSite.Send("ipa.Count()", ipa.Count());
     using (IPv4DataContext db = new IPv4DataContext())
     {
         try
         {
             foreach (var ip in ipa)
             {
                 if (ip.Isgws && ProgressIPv4SSL != null)
                 {
                     ProgressIPv4SSL.Report(ip);
                 }
                 int i = listIPv4SSL.BinarySearch(ip);
                 if (i > -1)
                 {
                     //CodeSite.Send(listIPv4SSL[i].IP, listIPv4SSL[i]);
                     //CodeSite.Send(ip.IP, ip);
                     db.IPv4SSL.Attach(ip, listIPv4SSL[i]);
                 }
                 else
                 {
                     CodeSite.SendError(string.Format("{0}-{1}", i, ip.IP));
                 }
             }
             db.SubmitChanges();
             return(true);
         }
         catch (Exception ex)
         {
             ex.SendCodeSite("SaveDB");
             CodeSite.Send("ipa.First().IP", ipa.First().IP);
         }
     }
     return(false);
 }