Beispiel #1
0
        public void AllStart(object RD)
        {
            info.DnsInfo ReqDns = RD as info.DnsInfo;

            //接口模式
            if (isServerapi)
            {
                lbl_state.BeginInvoke(new Action(() =>
                {
                    lbl_state.Text = "状态:正在运行服务接口模式获取子域名,请等待...";
                }));

                mode_serverapi Serverapi = new mode_serverapi(ReqDns);
                Serverapi.start();
            }

            //枚举模式
            if (isEnumerate)
            {
                F_main.handler = new CountdownEvent(F_main.handler.CurrentCount + diclist.Length);
                mode_enumerate enumerate = new mode_enumerate(ReqDns);
                enumerate.start();
            }
            if (handler != null)
            {
                handler.Wait();
            }

            lbl_state.BeginInvoke(new Action(() =>
            {
                bt_control.Text = "启 动";
                lbl_state.Text  = "状态:完成,共发现" + DomainList.Count + "个子域名";
            }));
        }
Beispiel #2
0
        private void bt_control_Click(object sender, EventArgs e)
        {
            if (txt_domain.Text.Trim() == "")
            {
                MessageBox.Show("请输入域名");
                return;
            }

            if (bt_control.Text != "启 动")
            {
                isrun           = false;
                bt_control.Text = "停止中";
                lbl_state.Text  = "状态:停止中";
                return;
            }

            bt_control.Text = "启动中";

            //初始化参数
            #region
            info.DnsInfo ReqDns = new info.DnsInfo();
            ReqDns.Domain  = txt_domain.Text.Trim();
            ReqDns.TimeOut = 2000;
            ReqDns.Ports   = txt_ports.Text.Trim();
            LV_result.Items.Clear();

            if (cmb_dns.SelectedItem != null && cmb_dns.SelectedItem.ToString().Contains("-"))
            {
                ReqDns.DnsServer = cmb_dns.SelectedItem.ToString().Trim().Split('-')[1];
            }
            else
            {
                if (Regex.IsMatch(cmb_dns.Text.Trim(), @"^\d+\.\d+\.\d+\.\d+$"))
                {
                    ReqDns.DnsServer = cmb_dns.Text.Trim();
                }
                else
                {
                    MessageBox.Show("请输入正确的DNS服务器地址");
                    bt_control.Text = "启 动";
                    return;
                }
            }

            if (chb_scanports.Checked)
            {
                isGetPorts = true;
            }
            else
            {
                isGetPorts = false;
            }

            if (chb_Enumerate.Checked)
            {
                isEnumerate = true;
            }
            else
            {
                isEnumerate = false;
            }

            if (chb_Serverapi.Checked)
            {
                isServerapi = true;
            }
            else
            {
                isServerapi = false;
            }


            //清空端口扫描缓存
            Tools.PortCache = new Dictionary <string, string>();
            DomainList      = new List <string>();


            #endregion

            if (isEnumerate)
            {
                if (File.Exists("dic.txt"))
                {
                    diclist = File.ReadAllLines("dic.txt");
                }
                else
                {
                    bt_control.Text = "启 动";
                    MessageBox.Show("字典文件dic.txt不存在,请放置在本程序同目录下");
                    return;
                }
                bool isgo = true;
                //重置线程池计数器
                handler = new CountdownEvent(1);
                ThreadPool.QueueUserWorkItem(_ =>
                {
                    try
                    {
                        if (Tools.checkAlwaysResolution(ReqDns))
                        {
                            string tmpblackip = string.Join(",", blackIp.ToArray());
                            if (System.Windows.Forms.DialogResult.No == MessageBox.Show("此域名泛解析到:" + tmpblackip + ",程序将自动略过解析到此IP的域名\n是否继续爆破?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Information))
                            {
                                bt_control.Text = "启 动";
                                isgo            = false;
                            }
                        }
                        handler.Signal();
                    }
                    catch (Exception)
                    {
                    }
                });
                //等待线程池结束
                handler.Wait();
                if (!isgo)
                {
                    return;
                }
            }

            //这里代表要真正开始启动了
            isrun           = true;
            bt_control.Text = "停 止";

            Th = new Thread(new ParameterizedThreadStart(AllStart));
            Th.Start(ReqDns);
        }