Пример #1
0
 private void DisplayText(object sender, EventArgs e)
 {
     if (type1.SelectedIndex == 0)
     {
         Display1.AppendText(RxString);
     }
     else if (type1.SelectedIndex == 1)
     {
         Display1.AppendText(DecWrite());
     }
     else
     {
         Display1.AppendText(HexWrite());
     }
 }
Пример #2
0
        private void UpdateDisplay(object sender, EventArgs e)
        {
            UpdateTimer.Tag = int.Parse(UpdateTimer.Tag.ToString()) + 1;
            try
            {
                if (!Program.Loading)
                {
                    if (!File.Exists(Program.userlog) || (!File.ReadAllText(Program.userlog).Contains(DateTime.Now.ToLongDateString()) && DateTime.Now.Hour == 7))
                    {
                        Program.Init();
                        File.AppendAllText(Program.userlog, DateTime.Now.ToLongDateString() + Environment.NewLine + Environment.NewLine);
                        while (!Program.IPlistfree)
                        {
                            Thread.Sleep(1);
                        }
                        Program.IPlistfree = false;
                        Program.UserList.Clear();
                        Program.IPlistfree = true;
                    }
                    if (int.Parse(UpdateTimer.Tag.ToString()) >= 100)
                    {
                        UpdateTimer.Tag = 0;
                        while (!Program.IPlistfree)
                        {
                            Thread.Sleep(1);
                        }
                        Program.IPlistfree = false;
                        List <string> temp1 = Program.RecentIPList.ToList();
                        List <string> temp2 = Program.BanList.ToList();
                        Program.IPlistfree = true;

                        foreach (string item in temp1)
                        {
                            if (!temp2.Contains(item) && temp1.Count(x => x == item) >= 100)
                            {
                                Program.BanList.Add(item);
                                //Credentials stored separately on a local machine for obvious reasons.
                                string email    = File.ReadAllText(@"C:\Users\alexf\Google Drive\Computer\Documents\emailcredentials.txt").Split('\t')[0];
                                string password = File.ReadAllText(@"C:\Users\alexf\Google Drive\Computer\Documents\emailcredentials.txt").Split('\t')[1];

                                SmtpClient client = new SmtpClient("smtp.gmail.com", 587)
                                {
                                    Credentials = new NetworkCredential(email, password), EnableSsl = true
                                };
                                MailMessage message = new MailMessage(email, email);
                                message.Subject = "Scraping Attempt Detected";
                                message.Body    = "IP: " + item + Environment.NewLine + "Blocked";
                                client.SendAsync(message, null);
                            }
                        }
                        while (!Program.IPlistfree)
                        {
                            Thread.Sleep(1);
                        }
                        Program.IPlistfree = false;
                        Program.RecentIPList.Clear();
                        Program.IPlistfree = true;
                    }


                    Display1.Clear();
                    Display1.AppendText("Server Version: " + Program.version + Environment.NewLine);
                    Display1.AppendText("Server URL: " + "http://" + Program.OwnIPAddress + ":" + Program.Port + "/" + Environment.NewLine);
                    TimeSpan uptime = DateTime.Now.Subtract(Program.starttime);
                    Display1.AppendText("Server Uptime: " + (uptime.Days == 1 ? uptime.Days + " day " : (uptime.Days > 1 ? uptime.Days + " days " : "")) + (uptime.Hours == 1 ? uptime.Hours + " hour " : (uptime.Hours > 1 ? uptime.Hours + " hours " : "")) + (uptime.Minutes == 1 ? uptime.Minutes + " minute " : (uptime.Minutes > 1 ? uptime.Minutes + " minutes " : "")) + (uptime.Seconds == 1 ? uptime.Seconds + " second " : (uptime.Seconds > 1 ? uptime.Seconds + " seconds " : "")) + Environment.NewLine);
                    Display1.AppendText("Total Connections: " + Program.totalconnections + Environment.NewLine);
                    Display1.AppendText("Unique Connections: " + Program.uniqueconnections + Environment.NewLine);
                    Display1.AppendText("Waiting for connections...");
                    while (!Program.IPlistfree)
                    {
                        Thread.Sleep(1);
                    }
                    Program.IPlistfree = false;
                    foreach (string line in Program.UserList.ToList())
                    {
                        if (Display2.Lines.Contains(line))
                        {
                            continue;
                        }
                        Display2.SelectionStart  = 0;
                        Display2.SelectionLength = 0;
                        Display2.SelectedText    = (line + '\n');
                        Display2.Update();
                    }
                    Program.IPlistfree = true;
                }
            }
            catch { }
        }