Exemple #1
0
        public void cracker(String domain, String user, String pass)
        {
            //跳过某些已经成功登陆了的。
            if (sucess_list.Contains(domain + "----" + user))
            {
                return;
            }
            //处理变化的密码
            pass = pass.Replace("%domain%", domain.Replace("http://", "").Replace("www.", ""));
            String reg = "\\.\\w+\\.";

            if (domain.LastIndexOf('.') == domain.IndexOf('.'))
            {
                reg = "\\w+\\.";
            }
            Match m = Regex.Match(domain, reg);

            if (m.Success)
            {
                pass = pass.Replace("%domain_center%", m.Groups[0].Value.Replace(".", ""));
            }

            pass = pass.Replace("%user%", user);

            String location = HttpTool.getLocationByPost(domain + "/wp-login.php", "log=" + HttpUtility.UrlEncode(user) + "&pwd=" + HttpUtility.UrlEncode(pass) + "&wp-submit=%E7%99%BB%E5%BD%95&redirect_to=" + domain + "%2Fwp-admin%2F&testcookie=1", timeout);

            if (location.IndexOf("wp-admin") != -1)
            {
                if (!sucess_list.Contains(domain + "----" + user))
                {
                    String successStr = domain + ":破解成功!账户:" + user + "----密码:" + pass;
                    this.txt_log.Invoke(new changeLog(updateLog), successStr);
                    FileTool.AppendLogToFile("/sucess.txt", successStr);
                    Interlocked.Increment(ref success);
                    this.lvw_result.Invoke(new delegateUpdateList(updateList), domain, user, pass);
                    sucess_list.Add(domain + "----" + user, pass);
                }
            }
            Interlocked.Increment(ref creakCount);
        }
Exemple #2
0
        public void ScanPort(string ip, string serviceName, int port)
        {
            //直接使用TcpClient类
            TcpClient tc = new TcpClient();

            //设置超时时间
            tc.SendTimeout = tc.ReceiveTimeout = 2000;

            try
            {
                //异步方法
                IAsyncResult oAsyncResult = tc.BeginConnect(ip, port, null, null);
                oAsyncResult.AsyncWaitHandle.WaitOne(2000, true);

                if (tc.Connected)
                {
                    lock (list_cracker)
                    {
                        list_cracker.Add(ip + ":" + port + ":" + serviceName);
                    }
                    tc.Close();
                    LogMessage(ip + " port " + port + " 开放!");
                    FileTool.AppendLogToFile(Directory.GetCurrentDirectory() + "/logs/portscan-" + DateTime.Now.ToString("yyyy-MM-dd") + ".log", ip + ":" + port + ":" + serviceName);
                }
                else
                {
                    //LogWarning(ip + " port " + port + " 连接超时!");
                }
            }
            catch (SocketException e)
            {
                LogWarning(ip + " port " + port + " 关闭!" + e.Message);
            }
            finally
            {
                tc.Close();
            }
            Interlocked.Decrement(ref scanPortsSumCount);
        }
Exemple #3
0
        private void crackerService(string crakerstring, string username, string password)
        {
            try
            {
                string[] crakers     = crakerstring.Split(':');
                string   ip          = crakers[0];
                int      port        = int.Parse(crakers[1]);
                string   serviceName = crakers[2];

                //跳过无法检查的IP列表,提高效率
                //多线程安全
                lock (list_ip_break)
                {
                    if (list_ip_break.Contains(ip + port))
                    {
                        //LogWarning(ip+"-"+port+"跳过检查!");
                        Interlocked.Increment(ref allCrackCount);
                        return;
                    }
                }
                //多线程安全
                lock (list_ip_user_break)
                {
                    //跳过已经检查的列表,提高效率
                    if (list_ip_user_break.Contains(ip + port + username))
                    {
                        LogWarning(ip + "-" + port + "-" + username + "跳过检查!");
                        Interlocked.Increment(ref allCrackCount);
                        return;
                    }
                }


                if (true)
                {
                    Object[] pramars = { ip, port, username, password, timeOut, retryCount };

                    int    count  = 0;
                    Server server = new Server();

                    while (count <= this.retryCount)
                    {
                        count++;
                        try
                        {     //跳过检查,多线程安全
                            bool cconce = false;
                            lock (list_success_username)
                            {
                                cconce = list_success_username.Contains(ip + serviceName + port);
                            }
                            if (this.crackerOneCount && cconce)
                            {
                                break;
                            }
                            Stopwatch sw = new Stopwatch();
                            sw.Start();
                            if (serviceName.Equals("RDP"))
                            {
                                server = creackRDP(ip, port, username, password, timeOut);
                            }
                            else
                            {
                                CrackService cs   = null;
                                Type         type = Type.GetType("SNETCracker.Model.Crack" + serviceName);
                                if (type != null)
                                {
                                    cs = (CrackService)Activator.CreateInstance(type);
                                }
                                server = cs.creack(ip, port, username, password, timeOut);
                            }
                            sw.Stop();
                            server.userTime = sw.ElapsedMilliseconds;
                        }
                        catch (IPBreakException ie)
                        {
                            string breakip = ie.Message;
                            lock (list_ip_break)
                            {
                                if (!list_ip_break.Contains(breakip))
                                {
                                    list_ip_break.Add(breakip);
                                }
                            }
                        }
                        catch (IPUserBreakException ie)
                        {
                            lock (list_ip_break)
                            {
                                string breakipuser = ie.Message;
                                if (!list_ip_break.Contains(breakipuser))
                                {
                                    list_ip_user_break.Add(breakipuser);
                                }
                            }
                        }
                        catch (TimeoutException te) {
                            continue;
                        }
                        catch (Exception e)
                        {
                            string logInfo = "检查" + ip + ":" + serviceName + "登录发生异常!" + e.Message;
                            LogWarning(logInfo);
                            FileTool.log(logInfo + e.StackTrace);
                        }
                        break;
                    }
                    if (server.isSuccess)
                    {
                        bool success = false;
                        lock (list_success_username)
                        {
                            success = list_success_username.Contains(ip + serviceName + port + username);
                        }
                        if (!success)
                        {
                            if (this.crackerOneCount)
                            {
                                //多线程安全
                                lock (list_success_username)
                                {
                                    success = list_success_username.Contains(ip + serviceName + port);
                                }
                            }
                            if (!success)
                            {
                                //多线程安全
                                lock (list_success_username)
                                {
                                    list_success_username.Add(ip + serviceName + port);
                                    list_success_username.Add(ip + serviceName + port + username);
                                }
                                Interlocked.Increment(ref successCount);
                                addItemToListView(successCount, ip, serviceName, port, username, password, server.banner, server.userTime);
                                String sinfo = ip + "-----" + serviceName + "----" + username + "----" + password + "----" + server.banner + "----成功!";
                                LogInfo(sinfo);
                                FileTool.AppendLogToFile(Directory.GetCurrentDirectory() + "/cracker_result.log", sinfo);
                            }
                        }
                    }
                    else
                    {
                        //LogWarning(ip + "-----" + serviceName + "----" + username + "----" + password + "失败!");
                    }
                }
            }
            catch (Exception e) {
                LogError(e.Message + e.StackTrace);
            }
            Interlocked.Increment(ref allCrackCount);
        }
Exemple #4
0
        public void getUserNames(String domain, int timeout)
        {
            //获得用户名
            if (!creaker_table.ContainsKey(domain))
            {
                if (domain.ToString().EndsWith("/"))
                {
                    domain = domain.ToString().Substring(0, domain.ToString().Length - 1);
                }

                HttpResult th = HttpTool.getHttpResult(domain + "/wp-login.php", timeout, false);
                if (!"".Equals(th.location))
                {
                    if (th.location.StartsWith("https"))
                    {
                        String ndomain = domain.Replace("http://", "https://");

                        this.txt_log.Invoke(new changeLog(updateLog), domain + "判断需要为https访问,已经自动修正为:" + ndomain);
                        domain = ndomain;
                    }
                    th = HttpTool.getHttpResult(domain + "/wp-login.php", timeout, false);
                }

                if (!"".Equals(th.html) && (th.html.IndexOf("wp-login.php?action=lostpassword") != -1 || th.html.IndexOf("/wp-includes/") != -1 || th.html.IndexOf("/wp-content/") != -1))
                {
                    //获取用户名
                    this.txt_log.Invoke(new changeLog(updateLog), domain + "判断为wordpress,正在自动收集用户名.....");
                    List <String> user_list = new List <String>();

                    int i          = 1;
                    int errorCount = 0;
                    while (user_list.Count <= 10 && errorCount < 3)
                    {
                        String     url = domain + "/?author=" + i;
                        HttpResult hr  = new HttpResult();
                        hr = HttpTool.getHttpResult(url, timeout, false);
                        String gusername = Tool.getUserName(hr);
                        if (!String.IsNullOrEmpty(gusername) && !user_list.Contains(gusername))
                        {
                            user_list.Add(gusername);
                        }
                        else
                        {
                            break;
                        }
                        i++;
                    }
                    if (user_list.Count <= 0)
                    {
                        String        feedurl = domain + "/?feed=rss2";
                        HttpResult    fhr     = HttpTool.getHttpResult(feedurl, timeout, true);
                        List <String> list    = Tool.getUserNameByFeed(fhr.html);
                        if (list.Count > 0)
                        {
                            user_list = list;
                            this.txt_log.Invoke(new changeLog(updateLog), domain + "自动获取到用户名:" + String.Join(",", user_list));
                        }
                    }
                    else
                    {
                        this.txt_log.Invoke(new changeLog(updateLog), domain + "自动获取到用户名:" + String.Join(",", user_list));
                    }
                    //没有获取到用户名,使用默认用户名
                    if (user_list.Count <= 0)
                    {
                        this.txt_log.Invoke(new changeLog(updateLog), domain + "没有获取到用户名,使用默认用户名字典!");
                        user_list = FileTool.readFileToList(AppDomain.CurrentDomain.BaseDirectory + "/dic/user.txt");
                        FileTool.AppendLogToFile("/logs/" + DateTime.Now.ToLongDateString() + ".wordpress.txt", domain + "----使用默认账号字典");
                    }
                    else
                    {
                        FileTool.AppendLogToFile("/logs/" + DateTime.Now.ToLongDateString() + ".wordpress.txt", domain + "----" + String.Join(",", user_list));
                    }
                    if (!creaker_table.ContainsKey(domain))
                    {
                        creaker_table.Add(domain, user_list);
                    }
                }
                else
                {
                    this.txt_log.Invoke(new changeLog(updateLog), "判断" + domain + "非wordpress,跳过....");
                    return;
                }
            }
            Interlocked.Increment(ref creakCount);
        }
Exemple #5
0
 public static void sysHTTPLog(String index, ServerInfo server)
 {
     FileTool.AppendLogToFile(httpLogPath + index + "-request.txt", server.request);
     FileTool.AppendLogToFile(httpLogPath + index + "-response.txt", server.header + "\r\n\r\n" + server.body);
 }
Exemple #6
0
 public static void SysLog(String log)
 {
     FileTool.AppendLogToFile("logs/" + DateTime.Now.ToLongDateString() + ".log.txt", log + "----" + DateTime.Now);
 }
Exemple #7
0
        public void AddItemToListView(ServerInfo svinfo)
        {
            //过滤类型不符合的
            if (!svinfo.contentType.StartsWith(config.contentType, StringComparison.OrdinalIgnoreCase))
            {
                return;
            }
            //过滤长度不符合的
            bool filter = false;

            if (config.contentLength > -2)
            {
                switch (config.contentSelect)
                {
                case 0:
                    if (svinfo.length < config.contentLength)
                    {
                        filter = true;
                    }

                    break;

                case 1:
                    if (svinfo.length == config.contentLength)
                    {
                        filter = true;
                    }

                    break;

                case 2:
                    if (svinfo.length > config.contentLength)
                    {
                        filter = true;
                    }
                    break;
                }
            }
            if (filter)
            {
                return;
            }
            ListViewItem lvi = new ListViewItem(svinfo.id + "");

            lvi.Tag = svinfo.type;
            lvi.SubItems.Add(svinfo.url);
            lvi.SubItems.Add(svinfo.code + "");
            lvi.SubItems.Add(svinfo.contentType + "");
            lvi.SubItems.Add(svinfo.length + "");
            lvi.SubItems.Add(svinfo.server + "");
            lvi.SubItems.Add(svinfo.powerBy + "");
            lvi.SubItems.Add(svinfo.runTime + "");
            lvi.SubItems.Add(svinfo.ip + "");
            String result = svinfo.url + "----" + svinfo.code;

            lvi.Tag = svinfo.type;
            if (svinfo.code.ToString().StartsWith("2"))
            {
                lvi.ForeColor = Color.Green;
            }
            else if (svinfo.code.ToString().StartsWith("3"))
            {
                lvi.ForeColor = Color.Blue;
            }
            else if (svinfo.code.ToString().StartsWith("4"))
            {
                lvi.ForeColor = Color.Gray;
            }
            else if (svinfo.code.ToString().StartsWith("5"))
            {
                lvi.ForeColor = Color.Red;
            }
            FileTool.AppendLogToFile("logs/scan_" + DateTime.Now.ToString("yyyy-MM-dd") + ".log", result);
            this.lvw_info.Items.Add(lvi);
        }