Beispiel #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";
                }
            }
        }
Beispiel #2
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);
        }
Beispiel #3
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);
             }
         }
     }
 }
Beispiel #4
0
        public List <WiFi> GetWiFis()
        {
            var wiFis        = new List <WiFi>();
            var accessPoints = _wifi.GetAccessPoints();

            foreach (var accessPoint in accessPoints)
            {
                wiFis.Add(new WiFi(accessPoint.Name,
                                   accessPoint.SignalStrength.ToString() + "%",
                                   GetMAC(accessPoint),
                                   accessPoint.ToString().Split()[6],
                                   accessPoint.IsSecure,
                                   accessPoint.IsConnected)
                          );
            }
            return(wiFis);
        }
Beispiel #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());
        }
Beispiel #6
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;
                                }
                            }
                        }
                    }
                }
            }
        }