Exemple #1
0
        private void mainThreadForTelnetConnections(object target_routers)
        {
            List <Router> list_of_target_routers = (List <Router>)target_routers;

            foreach (Router router in list_of_target_routers)
            {
                ListViewItem router_item = null;
                foreach (ListViewItem item in listViewResults.Items)
                {
                    if (item.Tag == router)
                    {
                        router_item = item; item.BackColor = Color.Bisque; item.EnsureVisible(); break;
                    }
                }
                string router_ip = router_item.SubItems[0].Text;
                labelStatus.Text = "Trying to connect to: " + router_ip;
                Application.DoEvents();

                Telnet telnet = new Telnet(router.ip, 23, 5);

                if (telnet.Connect() == false)
                {
                    router_item.BackColor = Color.Red;
                    labelStatus.Text      = "Can't connect to: " + router_ip;
                    Application.DoEvents();
                }
                else
                {
                    try
                    {
                        telnet.WaitFor("Username:"******"Password:"******">");
                        connected = true;
                    }
                    catch (TimeoutException) { }
                    catch (Exception) { }

                    if (connected)
                    {
                        labelStatus.Text            = "Connected to: " + router_ip + "! Trying enable password...";
                        labelVulnerableRouters.Text = (Convert.ToInt32(labelVulnerableRouters.Text) + 1).ToString();
                        Application.DoEvents();

                        bool enable_password_works = false;
                        try
                        {
                            telnet.SendMessage("enable");
                            telnet.WaitFor("Password:"******"#");
                            enable_password_works = true;
                        }
                        catch (TimeoutException) { }
                        catch (Exception) { }

                        routerTelnetConnection(router, true, enable_password_works);
                    }
                    else
                    {
                        routerTelnetConnection(router, false, false);
                    }

                    telnet.Disconnect();
                    telnet = null;
                }

                Application.DoEvents();
                Thread.Sleep(100);
            }
            this.Cursor      = Cursors.Default;
            buttonRun.Text   = "Run";
            labelStatus.Text = "Work done, Master!";
        }
        private void mainThreadForTelnetConnections(object target_routers)
        {
            List<Router> list_of_target_routers = (List<Router>)target_routers;

            foreach (Router router in list_of_target_routers)
            {
                ListViewItem router_item = null;
                foreach (ListViewItem item in listViewResults.Items)
                {
                    if (item.Tag == router) { router_item = item; item.BackColor = Color.Bisque; item.EnsureVisible(); break; }
                }
                string router_ip = router_item.SubItems[0].Text;
                labelStatus.Text = "Trying to connect to: " + router_ip;
                Application.DoEvents();

                Telnet telnet = new Telnet(router.ip, 23, 5);

                if (telnet.Connect() == false)
                {
                    router_item.BackColor = Color.Red;
                    labelStatus.Text = "Can't connect to: " + router_ip;
                    Application.DoEvents();
                }
                else
                {
                    try
                    {
                        telnet.WaitFor("Username:"******"Password:"******">");
                        connected = true;
                    }
                    catch (TimeoutException) { }
                    catch (Exception) { }

                    if (connected)
                    {
                        labelStatus.Text = "Connected to: " + router_ip + "! Trying enable password...";
                        labelVulnerableRouters.Text = (Convert.ToInt32(labelVulnerableRouters.Text) + 1).ToString();
                        Application.DoEvents();

                        bool enable_password_works = false;
                        try
                        {
                            telnet.SendMessage("enable");
                            telnet.WaitFor("Password:"******"#");
                            enable_password_works = true;
                        }
                        catch (TimeoutException) { }
                        catch (Exception) { }

                        routerTelnetConnection(router, true, enable_password_works);
                    }
                    else
                    {
                        routerTelnetConnection(router, false, false);
                    }

                    telnet.Disconnect();
                    telnet = null;
                }

                Application.DoEvents();
                Thread.Sleep(100);
            }
            this.Cursor = Cursors.Default;
            buttonRun.Text = "Run";
            labelStatus.Text = "Work done, Master!";
        }