Exemple #1
35
        public void Topframe_Load(object sender, EventArgs e)
        {
            FormClosing += new FormClosingEventHandler(Topframe_Closing);
            notifyIcon1.ContextMenuStrip = contextMenuStrip1;
            save_Btn.Enabled = false;
            if (reg.GetValue("gateway") == null && reg.GetValue("ssid") == null)
            {
                NetworkInterface[] interfaces = NetworkInterface.GetAllNetworkInterfaces();
                for (int i = 0; i < interfaces.Length; i++)
                {
                    if (interfaces[i].NetworkInterfaceType == NetworkInterfaceType.Wireless80211)
                    {
                        IPInterfaceProperties gatewayip = interfaces[i].GetIPProperties();
                        if (gatewayip != null)
                        {
                            foreach (GatewayIPAddressInformation gw in gatewayip.GatewayAddresses)
                            {
                                gatewayIP_Textbox.Text = gw.Address.ToString();
                                reg.SetValue("gateway", gw.Address.ToString());
                                detector.GatewayAddr = gw.Address.ToString();
                            }
                        }
                    }
                }

                wifi = new Wifi();
                List<AccessPoint> aps = wifi.GetAccessPoints();
                ssid_Textbox.Text = aps[0].Name.ToString();
                reg.SetValue("ssid", aps[0].Name.ToString());
                detector.SSID = aps[0].Name.ToString();

                cycle_Textbox.Text = "5";
                reg.SetValue("cycletime", "5");
                detector.CycleTime = 5;


            }
            else
            {
                string gateway = (string)reg.GetValue("gateway");
                string ssid = (string)reg.GetValue("ssid");
                string cycletime = (string)reg.GetValue("cycletime");
                string autostart_reg = (string)reg.GetValue("onload");

                gatewayIP_Textbox.Text = gateway;
                ssid_Textbox.Text = ssid;
                cycle_Textbox.Text = cycletime;

                detector.SSID = ssid;
                detector.GatewayAddr = gateway;
                detector.CycleTime = Convert.ToInt32(cycletime);

                RegistryKey startupreg = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true);
                string val = (string)startupreg.GetValue("Wifi Observer");
                if (val == null)
                    windowsStartup_Chkbox.Checked = false;
                else
                    windowsStartup_Chkbox.Checked = true;

                bool autostart;
                autostart = Convert.ToBoolean(autostart_reg);
                
                if (autostart == true)
                {
                    autoStart_Chkbox.Checked = true;
                    detector.Start();

                    if (detector.thread.ThreadState == ThreadState.Background)
                    {
                        state_Label.Text = "Running...";
                        state_Label.ForeColor = Color.LawnGreen;
                        run_Btn.Text = "STOP";
                    }
                }
                else
                {
                    state_Label.Text = "STOPPED";
                    state_Label.ForeColor = Color.Red;
                    run_Btn.Text = "RUN";
                }
            }
        }
Exemple #2
1
        static void Main(string[] args)
        {
            // Init wifi object and event handlers
            wifi = new Wifi();
            wifi.ConnectionStatusChanged += wifi_ConnectionStatusChanged;

            if (wifi.NoWifiAvailable)
                Console.WriteLine("\r\n-- NO WIFI CARD WAS FOUND --");

            string command = "";
            do
            {
                Console.WriteLine("\r\n-- COMMAND LIST --");
                Console.WriteLine("L. List access points");
                Console.WriteLine("C. Connect");
                Console.WriteLine("D. Disconnect");
                Console.WriteLine("S. Status");
                Console.WriteLine("X. Print profile XML");
                Console.WriteLine("R. Remove profile");
                Console.WriteLine("I. Show access point information");
                Console.WriteLine("Q. Quit");

                command = Console.ReadLine().ToLower();

                Execute(command);

            } while (command != "q");
        }
Exemple #3
0
 public static void Main(string[] args)
 {
     SimpleWifi.Wifi wifi = new SimpleWifi.Wifi();
     WifiList();
     wifi.ConnectionStatusChanged += ChangeStatus;
     ConsoleAction();
 }
Exemple #4
0
        public bool Connect(string password)
        {
            var wifi        = new SimpleWifi.Wifi();
            var accessPoint = wifi.GetAccessPoints().FirstOrDefault(x => x.Name.Equals(Name));

            if (accessPoint != null)
            {
                var authRequest = new AuthRequest(accessPoint);
                authRequest.Password = password;
                return(accessPoint.Connect(authRequest));
            }
            return(false);
        }
Exemple #5
0
        private static string[] WifiChose()
        {
            List <string> arr = new List <string>();
            int           i   = 0;

            SimpleWifi.Wifi wifi = new SimpleWifi.Wifi();
            foreach (AccessPoint access in wifi.GetAccessPoints())
            {
                arr.Add(access.Name);
                int[] length = { i.ToString().Length, access.Name.Length };
                Console.WriteLine("+" + string.Join("+", MakeCase(length)) + "+");
                Console.WriteLine($"| {i} | {access.Name} |");
                Console.WriteLine("+" + string.Join("+", MakeCase(length)) + "+");
                i++;
            }
            return(arr.ToArray());
        }
Exemple #6
0
 private static void WifiList(string name = "")
 {
     SimpleWifi.Wifi wifi = new SimpleWifi.Wifi();
     Console.WriteLine("+------+--------+--------+-------+");
     Console.WriteLine("| Name | Status | Secure | Debit |");
     Console.WriteLine("+------+--------+--------+-------+");
     if (name == String.Empty)
     {
         foreach (AccessPoint access in wifi.GetAccessPoints())
         {
             LogAccessPoint(access);
         }
     }
     else
     {
         foreach (AccessPoint access in wifi.GetAccessPoints())
         {
             if (access.Name.Contains(name))
             {
                 LogAccessPoint(access);
             }
         }
     }
 }
Exemple #7
0
 public WiFiSearcher()
 {
     _wifi       = new SimpleWifi.Wifi();
     _wlanClient = new WlanClient();
 }
Exemple #8
0
        private static void ConsoleAction()
        {
            SimpleWifi.Wifi wifi = new SimpleWifi.Wifi();


            while (true)
            {
                if (Pass)
                {
                    if (WifiFocus != String.Empty)
                    {
                        Console.Write($"\n[@{WifiFocus}]>");
                    }
                    else
                    {
                        Console.Write("\n[@]>");
                    }
                }
                else if (Bf)
                {
                    if (WifiFocus != String.Empty)
                    {
                        Console.Write($"\n[#{WifiFocus}]>");
                    }
                    else
                    {
                        Console.Write("\n[#]>");
                    }
                }
                else
                {
                    Console.Write("\n[$]>");
                }
                string[] input = Console.ReadLine().Split(new char[0]);

                if (Pass)
                {
                    if (WifiFocus != String.Empty)
                    {
                        if (input[0] == "exit")
                        {
                            WifiFocus = String.Empty;
                        }
                        else
                        {
                            foreach (AccessPoint access in wifi.GetAccessPoints())
                            {
                                if (access.Name == WifiFocus)
                                {
                                    ;
                                    if (access.IsValidPassword(input[0]))
                                    {
                                        Console.WriteLine("\nValide Password !");
                                        if (access.Connect(new AuthRequest(access)))
                                        {
                                            Console.WriteLine("Connexion Success !");
                                        }
                                        else
                                        {
                                            Console.WriteLine("Connexion Failed !");
                                        }
                                        WifiFocus = String.Empty;
                                    }
                                    else
                                    {
                                        Console.WriteLine("\nInvalid Password !");
                                    }
                                }
                            }
                        }
                    }
                    else
                    {
                        switch (input[0])
                        {
                        case "exit":
                            WifiFocus = String.Empty;
                            Pass      = false;
                            break;

                        case "chose":
                        case "list":
                            string[] options = WifiChose();
                            Console.Write("\n[@Number]>");
                            string inpu = Console.ReadLine();
                            int    pos  = 0;
                            try
                            {
                                pos = int.Parse(inpu);
                                for (int i = 0; i < options.Length; i++)
                                {
                                    if (i == pos)
                                    {
                                        WifiFocus = options[i];
                                    }
                                }
                            }
                            catch { }
                            break;

                        case "help":
                            Console.WriteLine("\n list\n chose\n exit\n help");
                            break;
                        }
                    }
                }
                else if (Bf)
                {
                    if (WifiFocus != String.Empty)
                    {
                        if (input[0] == "exit")
                        {
                            WifiFocus = String.Empty;
                        }
                        else if (input[0] == "start")
                        {
                            foreach (AccessPoint access in wifi.GetAccessPoints())
                            {
                                if (access.Name == WifiFocus)
                                {
                                    BruteForce(access);
                                }
                            }
                        }
                    }
                    else
                    {
                        switch (input[0])
                        {
                        case "exit":
                            Bf = false;
                            break;

                        case "help":
                            Console.WriteLine("\n list\n help\n exit");
                            break;

                        case "list":
                            string[] options = WifiChose();
                            Console.Write("\n[#Number]>");
                            string inpu = Console.ReadLine();
                            int    pos  = 0;
                            try
                            {
                                pos = int.Parse(inpu);
                                for (int i = 0; i < options.Length; i++)
                                {
                                    if (i == pos)
                                    {
                                        WifiFocus = options[i];
                                    }
                                }
                            }
                            catch { }
                            break;
                        }
                    }
                }
                else
                {
                    if (input.Length == 1)
                    {
                        switch (input[0])
                        {
                        case "list":
                            WifiList();
                            break;

                        case "help":
                            Console.WriteLine("\n list [name]\n chose <action> (password,bf,bruteforce,disconnect)\n disconnect\n none\n default\n help\n exit");
                            break;

                        case "exit":
                            Environment.Exit(0);
                            break;

                        case "disconnect":
                            wifi.Disconnect();
                            break;

                        case "none":
                        case "default":
                            Pass = false;
                            Bf   = false;
                            break;
                        }
                    }
                    else
                    {
                        if (input.Length == 2)
                        {
                            if (input[0] == "list")
                            {
                                WifiList(input[1]);
                            }
                            else if (input[0] == "chose")
                            {
                                switch (input[1])
                                {
                                case "disconnect":
                                    wifi.Disconnect();
                                    break;

                                case "password":
                                    Pass = true;
                                    Bf   = false;
                                    break;

                                case "bf":
                                    Pass = false;
                                    Bf   = true;
                                    break;

                                case "bruteforce":
                                    Pass = false;
                                    Bf   = true;
                                    break;
                                }
                            }
                        }
                    }
                }
            }
        }
Exemple #9
-2
        /// <summary>
        /// Главная форма
        /// </summary>
        public MainForm()
        {
            InitializeComponent();

            // Считывание паролей
            try
            {
                sr = new StreamReader("pass.txt");
                passwords = sr.ReadToEnd().Split('\n');
                sr.Close();
                labelViewPassInDict.Text = passwords.Length.ToString();
                labelShowUsed.Text = "0";
                labelShowUnUsedPasswords.Text = "0";
                showRichTextBox2.Text += "-> Загрузка паролей прошла успешно\n";
                showRichTextBox2.Text += "-> Количество паролей = " + passwords.Length + "\n";

            }
            catch
            {
            }
            
            // инициализация вай-фай объекта
            try
            {
                wifi = new Wifi();
                wifi.ConnectionStatusChanged += wifi_ConnectionStatusChanged;
                if (wifi.NoWifiAvailable)
                    showRichTextBox2.Text += "\r\n-- Не найдено активных Wi-Fi точек --\n";

            }
            catch(Exception er)
            {
                MessageBox.Show(er.Message);

                SetLabelsToZeroState();
                // Обновить список сетей
                ReShow(null, null);  
            }

                      
        }