Beispiel #1
0
        public void Run()
        {
            string[] lines = File.ReadAllLines("script.hbs", Encoding.UTF8);
            foreach (string line in lines)
            {
                if (line.Trim().StartsWith("#线程数"))
                {
                    int.TryParse(line.Replace("#线程数", "").Trim(), out threadCount);
                }
                if (line.Trim().StartsWith("#开启RGB"))
                {
                    rgb = true;
                }
                if (line.Trim().StartsWith("#关闭回显"))
                {
                    BomberUtils.showEcho = false;
                }
                script += line + "\r\n";
            }

            System.Net.ServicePointManager.DefaultConnectionLimit = threadCount;

            ScriptedBomber sb = new ScriptedBomber(script);

            sb.OnBomberComplete += Sb_OnBomberComplete;
            BomberPerformer bp = new BomberPerformer(sb);

            resultHandler = new showResult(delegate(int speed, string args) {
                monitorChart1.Value = speed;
                textBox1.Text       = args;
            });
            bp.ThreadCount = threadCount;
            bp.StartBomber();
        }
        public static void Run()
        {
            string[] lines = File.ReadAllLines("script.hbs", Encoding.UTF8);
            foreach (string line in lines)
            {
                if (line.Trim().StartsWith("#线程数"))
                {
                    int.TryParse(line.Replace("#线程数", "").Trim(), out threadCount);
                }
                if (line.Trim().StartsWith("#开启RGB"))
                {
                    rgb = true;
                }
                script += line + "\r\n";
            }

            System.Net.ServicePointManager.DefaultConnectionLimit = threadCount;

            ScriptedBomber sb = new ScriptedBomber(script);

            sb.OnBomberComplete += Sb_OnBomberComplete;
            BomberPerformer bp = new BomberPerformer(sb);

            bp.ThreadCount = threadCount;
            bp.StartBomber();
        }
Beispiel #3
0
 private void Button4_Click(object sender, EventArgs e)
 {
     if (listBox1.SelectedIndex < 0)
     {
         MessageBox.Show("没有选择任务", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
         return;
     }
     try
     {
         var             bomber    = list[listBox1.SelectedIndex];
         BomberPerformer performer = new BomberPerformer(bomber);//创建轰炸实例
         performer.ThreadCount    = Int32.Parse(textBox1.Text);
         bomber.OnBomberComplete += Bomber_OnBomberComplete;
         performer.StartBomber();
     } catch (Exception exp)
     {
         Console.WriteLine(exp.StackTrace);
     }
 }
        private void MainActivity_Click(object sender, EventArgs e)
        {
            if (null == performer)
            {
                String script = FindViewById <EditText>(Resource.Id.txtScript).Text;

                GetSharedPreferences("main", Android.Content.FileCreationMode.Private).Edit().PutString("script", script).Commit();

                int threadcount = 32;

                string[] lines = script.Split('\r', '\n');
                foreach (string line in lines)
                {
                    if (line.Trim().StartsWith("#线程数"))
                    {
                        int.TryParse(line.Replace("#线程数", "").Trim(), out threadcount);
                    }
                    if (line.Trim().StartsWith("#关闭回显"))
                    {
                        BomberUtils.showEcho = false;
                    }
                }

                System.Net.ServicePointManager.DefaultConnectionLimit = threadcount;
                System.Net.ServicePointManager.Expect100Continue      = false;

                ScriptedBomber bomber = new ScriptedBomber(script);
                performer = new BomberPerformer(bomber);
                bomber.OnBomberComplete += Bomber_OnBomberComplete;
                performer.ThreadCount    = threadcount;
                performer.StartBomber();
                ((Button)sender).Text = "停止并退出";
                successcount          = 0;
                failcount             = 0;
                last = DateTime.Now;
            }
            else
            {
                performer.StopBomber();
                Finish();
            }
        }