コード例 #1
0
ファイル: Main.cs プロジェクト: w7oami/SNETCracker
        private void cracker()
        {
            crakerKey();
            this.Invoke(new VoidDelegate(this.bt_timer.Start));
            this.runTime = 0;
            if (initDic())
            {
                //初始化检查次数
                initStatusCount();
                //清空检查列表
                this.list_cracker = new ConcurrentBag <string>();
                //清空跳过列表
                this.list_ip_break.Clear();
                this.list_ip_user_break.Clear();
                Boolean isScanport = this.chk_isScanPort.Checked;
                stp               = new SmartThreadPool();
                stp.MaxThreads    = maxThread;
                creackerSumCount  = 0;
                scanPortsSumCount = 0;


                //计算端口扫描总数
                if (isScanport)
                {
                    foreach (string serviceName in this.services_list.CheckedItems)
                    {
                        string[] ports = this.services[serviceName].Port.Split(',');
                        scanPortsSumCount += this.list_target.Count * ports.Length;
                    }
                }
                //更新状态
                this.Invoke(new update(updateStatus));

                foreach (string serviceName in this.services_list.CheckedItems)
                {
                    string[] ports = this.services[serviceName].Port.Split(',');
                    foreach (string sport in ports)
                    {
                        int port = int.Parse(sport);

                        foreach (string ip in list_target)
                        {
                            if (!isScanport)
                            {
                                list_cracker.Add(ip + ":" + port + ":" + serviceName);
                            }
                            else
                            {
                                stp.QueueWorkItem <string, string, int>(ScanPort, ip, serviceName, port);
                                stp.WaitFor(1000);
                            }
                        }
                    }
                }

                stp.WaitForIdle();
                if (isScanport)
                {
                    LogMessage("验证端口是否开放完成!");
                }
                int c = stp.CurrentWorkItemsCount;
                LogMessage("开始检查" + this.list_cracker.Count + "个目标," + services_list.CheckedItems.Count + "个服务.......");
                //计算检查总数
                if (this.notAutoSelectDic == false)
                {
                    foreach (string serviceName in this.services_list.CheckedItems)
                    {
                        creackerSumCount += list_cracker.Count * this.services[serviceName].ListUserName.Count * this.services[serviceName].ListPassword.Count;
                    }
                }
                else
                {
                    creackerSumCount += list_cracker.Count * this.list_username.Count * this.list_password.Count * this.services_list.CheckedItems.Count;
                }

                foreach (string serviceName in this.services_list.CheckedItems)
                {
                    HashSet <string> clist_username = null;
                    HashSet <string> clist_password = null;
                    if (this.notAutoSelectDic == false)
                    {
                        clist_username = this.services[serviceName].ListUserName;
                        clist_password = this.services[serviceName].ListPassword;
                    }
                    else
                    {
                        clist_username = this.list_username;
                        clist_password = this.list_password;
                    }

                    foreach (string user in clist_username)
                    {
                        //替换变量密码
                        string           username = user + this.txt_username_ext.Text;
                        HashSet <string> list_current_password = new HashSet <string>();
                        foreach (string cpass in clist_password)
                        {
                            string newpass = cpass.Replace("%user%", user);
                            if (!list_current_password.Contains(newpass))
                            {
                                list_current_password.Add(newpass);
                            }
                            else
                            {
                                //重复密码
                                creackerSumCount -= this.list_cracker.Count;
                            }
                        }
                        foreach (string pass in list_current_password)
                        {
                            foreach (string cracker in this.list_cracker)
                            {
                                if (cracker.EndsWith(serviceName))
                                {
                                    stp.QueueWorkItem <string, string, string>(crackerService, cracker, username, pass);
                                    stp.WaitFor(1000);
                                }
                            }
                        }
                    }
                }
                stp.WaitForIdle();
                stp.Shutdown();
                LogInfo("检查完成!");
            }
            //更新状态
            this.Invoke(new update(updateStatus));
            this.btn_cracker.Enabled   = true;
            this.services_list.Enabled = true;
            this.Invoke(new VoidDelegate(this.bt_timer.Stop));
        }
コード例 #2
0
ファイル: WPCreaker.cs プロジェクト: sry309/WPCracker
        public void crackerpass()
        {
            stp.MaxThreads = maxThread;
            stp.Start();
            int timeout = int.Parse(this.cmb_timeout.Text);

            taskCount += urls_list.Count;
            foreach (String domain in urls_list)
            {
                try
                {
                    String ndomain = Tool.updateTheDomain(domain);
                    //现获取用户名
                    stp.QueueWorkItem <String, int>(getUserNames, ndomain, timeout);
                    stp.WaitFor(1000);
                }
                catch (Exception e)
                {
                    Tool.SysLog("执行线程异常!" + domain + e.Message);
                    continue;
                }
            }
            stp.WaitForIdle();
            //stp.Start();
            this.txt_log.Invoke(new changeLog(updateLog), "获取用户名完成,正在开始尝试破解,请稍候.....");

            foreach (List <String> list in creaker_table.Values)
            {
                taskCount += pass_list.Count * list.Count;
            }

            foreach (String pass in this.pass_list)
            {
                IDictionaryEnumerator ide = null;
                lock (creaker_table)
                {
                    ide = creaker_table.GetEnumerator();
                }

                while (ide.MoveNext())
                {
                    String        ndomain  = Tool.updateTheDomain(ide.Key.ToString());
                    List <String> userlist = (List <String>)ide.Value;
                    if (userlist != null && userlist.Count > 0)
                    {
                        foreach (String user in userlist)
                        {
                            try
                            {
                                stp.QueueWorkItem <String, String, String>(cracker, ndomain, user, pass);
                                stp.WaitFor(1000);
                            }
                            catch (Exception e)
                            {
                                Tool.SysLog("执行线程异常!" + ndomain + e.Message);
                                continue;
                            }
                        }
                    }
                }
                this.txt_log.Invoke(new changeLog(updateLog), "正在尝试密码队列:" + pass);
            }
            stp.WaitForIdle();
            stopThread();
            MessageBox.Show("破解完成!");
        }