コード例 #1
0
ファイル: Program.cs プロジェクト: gabriel-ar/flash_air
 private static void NetChange(object sender, NetworkAvailabilityEventArgs e)
 {
     if (e.IsAvailable)
     {
         try {
             WebClient wc   = new WebClient();
             string    ssid = wc.DownloadString("http://flashair/command.cgi?op=104");
             if (bool.Parse(settings["sync_auto"]))
             {
                 StartSyncAuto();
                 icon.ShowBalloonTip(2000, "La SD " + ssid + " fue detectada",
                                     "Iniciando sincronización.", System.Windows.Forms.ToolTipIcon.Info);
             }
             else
             {
                 icon.ShowBalloonTip(10000, "La SD " + ssid + " fue detectada",
                                     "No se copiarán datos de la SD, la sincronización automática está desactivada.",
                                     System.Windows.Forms.ToolTipIcon.Warning);
             }
         } catch (WebException) {
         }
     }
     else
     {
         if (wlan_intr.InterfaceState == Wlan.WlanInterfaceState.Disconnected ||
             GetSsidString(wlan_intr.CurrentConnection.wlanAssociationAttributes.dot11Ssid) != settings["card_ssid"])
         {
             wlan_intr.Scan();
         }
     }
 }
コード例 #2
0
ファイル: Form1.cs プロジェクト: pcjiushizhu/Wifi-connector
 private void label3_Click(object sender, EventArgs e)
 {
     WlanIface.Scan();
     NetWorkList.Clear();
     listBox1.Items.Clear();
     LoadNetWork();
 }
コード例 #3
0
        private void ScanCurrentNetworkInterface()
        {
            if (currentScanRetries < maxScanRetries)
            {
                currentScanRetries++;

                currentState = DroneNetworkConnectionState.ScanningForNewNetworks;
                UpdateConnectionStatus();

                try
                {
                    currentWifiInterface.Scan();
                }
                catch (System.ComponentModel.Win32Exception)
                {
                    AddFailureReasonForCurrentInterface("Network error during scan ... Is your network adapter disabled?");
                    ScanNextNetworkInterface();
                }
            }
            else
            {
                AddFailureReasonForCurrentInterface("The network scan could not be completed");
                ScanNextNetworkInterface();
            }
        }
コード例 #4
0
 public Task <bool> Scan(CancellationToken token)
 {
     _wlanInterface.Scan();
     _scanTaskCompletionSource = new TaskCompletionSource <bool>();
     token.Register(() => _scanTaskCompletionSource.TrySetCanceled());
     return(_scanTaskCompletionSource.Task);
 }
コード例 #5
0
ファイル: Form1.cs プロジェクト: joetex/ARDroneRouter
        public void ScanNetworks()
        {
            networkClient = new WlanClient(new Wlan.WlanNotificationCallbackDelegate(this.OnWlanNotification));

            foreach (WlanClient.WlanInterface wlanIface in networkClient.Interfaces)
            {
                // Lists all available networks
                networkInterface = wlanIface;
                networkInterface.Scan();
            }
        }
コード例 #6
0
        static void CrackWiFiList()
        {
            Console.ForegroundColor = ConsoleColor.DarkYellow;
            Console.WriteLine("\r\nUnsecured networks & profiles will not be shown");
            Console.ForegroundColor = ConsoleColor.Yellow;
            Console.WriteLine("Available networks:");
            Console.ForegroundColor = ConsoleColor.Gray;
            Console.Write("Scanning");
            Interface.Scan();

            Thread.Sleep(500);
            Console.Write(".");
            Thread.Sleep(500);
            Console.Write(".");
            Thread.Sleep(500);
            Console.Write(".");
            Thread.Sleep(500);
            Console.SetCursorPosition(0, Console.CursorTop);
            Console.Write("                 ");
            Console.SetCursorPosition(0, Console.CursorTop);

            AvNetwork = Interface.GetAvailableNetworkList(Wlan.WlanGetAvailableNetworkFlags.IncludeAllManualHiddenProfiles);
            for (int i = 0; i < AvNetwork.Length; i++)
            {
                var network = AvNetwork[i];

                if (network.profileName.Length <= 0 && network.securityEnabled)
                {
                    Console.ForegroundColor = ConsoleColor.Gray;
                    Console.Write("[" + i);

                    Console.ForegroundColor = ConsoleColor.Gray;
                    Console.Write("] ");


                    // if (network.profileName.Length >= 1) { Console.ForegroundColor = ConsoleColor.DarkRed; Console.Write("saved "); }
                    //else { Console.ForegroundColor = ConsoleColor.DarkGreen;                               Console.Write("new   "); }


                    Console.ForegroundColor = ConsoleColor.White;
                    Console.Write(GetStringForSSID(network.dot11Ssid));

                    //if (network.securityEnabled) { Console.ForegroundColor = ConsoleColor.DarkGreen; Console.Write(" secured "); }
                    //else { Console.ForegroundColor = ConsoleColor.DarkRed; Console.Write(" unsecured "); }
                    Console.ForegroundColor = ConsoleColor.DarkGray;
                    Console.Write(" " + network.dot11DefaultCipherAlgorithm.ToString() + " " + network.dot11DefaultAuthAlgorithm.ToString() + " ");
                    Console.Write("signal: " + network.wlanSignalQuality);
                    Console.WriteLine();
                }
            }
            Console.ForegroundColor = ConsoleColor.Gray;
            // WlanAvailableNetwork a = new NativeWifi.Wlan.WlanAvailableNetwork();
            //Console.WriteLine(a.profileName);
        }
コード例 #7
0
ファイル: Main.cs プロジェクト: gabriel-ar/wifi_manager
        private void Scan(object sender, EventArgs e)
        {
            try {
                adapter.Scan();
            } catch (Exception) {
                SetEnabled(false);
                return;
            }

            btn_scan.Enabled = false;
        }
コード例 #8
0
        private void ScanCurrentNetworkInterface()
        {
            if (currentScanRetries < maxScanRetries)
            {
                currentScanRetries++;

                currentState = DroneNetworkConnectionState.ScanningForNewNetworks;
                UpdateConnectionStatus();

                currentWifiInterface.Scan();
            }
            else
            {
                AddFailureReasonForCurrentInterface("The network scan could not be completed");
                ScanNextNetworkInterface();
            }
        }
コード例 #9
0
        //timer循环
        private void timer_scan_Tick(object sender, EventArgs e)
        {
            //1,获取当前检测到的AP

            bssworks = wlanIface.GetNetworkBssList();


            Console.Out.WriteLine(bssworks.Length + " 个AP检测到。");

            //2,merge到当前list中

            //listView1.Items.Clear();

            String str = null;
            String mac = null;

            foreach (Wlan.WlanBssEntry bsswork in bssworks)
            {
                str = SsidToString(bsswork.dot11Ssid);
                mac = BitConverter.ToString(bsswork.dot11Bssid);
                //Console.WriteLine(str);
                //Console.WriteLine(mac);
                //Console.WriteLine(bsswork.rssi);
                //Console.WriteLine();


                int index = FindMacInItems(listView1, mac);
                //Console.Out.WriteLine("index is " + index);
                //没有的话才加入
                if (index == -1)
                {
                    ListViewItem lvi = new ListViewItem(str);
                    lvi.SubItems.Add(mac);
                    lvi.SubItems.Add(bsswork.rssi + "");
                    lvi.SubItems.Add("***");
                    listView1.Items.Add(lvi);
                }
            }

            //关键,没有这个的话,每次都是一样的
            wlanIface.Scan();
        }
コード例 #10
0
        public DataSets.WlanInfo getWlanInfo()
        {
            infoWlan.WLANS.Clear();
            lista_bss = INTERFAZ.GetNetworkBssList();
            INTERFAZ.Scan();
            lista_redes = INTERFAZ.GetAvailableNetworkList(0);
            Wlan.WlanAvailableNetwork WLAN = new Wlan.WlanAvailableNetwork();
            foreach (Wlan.WlanBssEntry redBSS in lista_bss)
            {
                DataSets.WlanInfo.WLANSRow row = infoWlan.WLANS.NewWLANSRow();

                WLAN         = devuelve_red(redBSS.dot11Ssid, lista_redes);
                row.ESSID    = Encoding.ASCII.GetString(redBSS.dot11Ssid.SSID, 0, (int)redBSS.dot11Ssid.SSIDLength);
                row.BSSID    = Utils.ByteArrayToString(redBSS.dot11Bssid);
                row.Auth     = WLAN.dot11DefaultAuthAlgorithm.ToString();
                row.Cipher   = WLAN.dot11DefaultCipherAlgorithm.ToString();
                row.PowerDbm = redBSS.rssi;
                infoWlan.WLANS.AddWLANSRow(row);
            }

            return(infoWlan);
        }
コード例 #11
0
ファイル: Form1.cs プロジェクト: IdivideBy0/WifiRandom
        public void GetWifiInfo()
        {
            using (var client = new WlanClient())
            {
                try
                {
                    StringBuilder sb = new StringBuilder();

                    WlanClient.WlanInterface wlanIface = client.Interfaces.FirstOrDefault();
                    wlanIface.Scan();

                    Wlan.WlanBssEntry[] wlanBssEntries = wlanIface.GetNetworkBssList();

                    int baseCount = wlanBssEntries.Length - 1;

                    Random rnd = new Random();

                    int rndSelectedBss = 0;

                    if (baseCount >= 0)
                    {
                        rndSelectedBss = rnd.Next(0, baseCount);

                        Wlan.WlanBssEntry network = wlanBssEntries[rndSelectedBss];

                        byte[] macAddr = network.dot11Bssid;

                        string tMac = "";

                        for (int i = 0; i < macAddr.Length; i++)
                        {
                            tMac += macAddr[i].ToString("x2").PadLeft(2, '0').ToUpper();
                        }


                        sb.Append("");

                        sb.AppendLine("Found network with SSID: " +
                                      System.Text.ASCIIEncoding.ASCII.GetString(network.dot11Ssid.SSID).ToString().Replace("\0", "")
                                      );

                        sb.AppendLine("Signal: " + network.linkQuality.ToString() + " percent.");

                        sb.AppendLine("BSS Type: " + network.dot11BssType.ToString());

                        sb.AppendLine("MAC: " + tMac.ToString());

                        sb.AppendLine("RSS: " + network.rssi.ToString());

                        sb.AppendLine("Random: " + SeedRandom(network.linkQuality, network.rssi));

                        sb.AppendLine();

                        textBox1.Text += sb.ToString();
                    }
                    else
                    {
                        GetWifiInfo(); // try again
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
        }
コード例 #12
0
        void WlanScanThread()
        {
            while (tourRecording)
            {
                if (!validGpsSignal)
                {
                    context.MainForm.SetStatusBar("Warte auf gültiges GPS Signal...");
                    while (!validGpsSignal)
                    {
                        Thread.Sleep(100);
                    }
                }
                double signalAge = (DateTime.Now - gpsLlTimestamp).TotalSeconds;
                while (signalAge > 10)
                {
                    context.MainForm.SetStatusBar(String.Format("Letztes GPS Signal ist {0} Sekunden her. Warte auf Erneuerung...", (int)signalAge));
                    Thread.Sleep(1000);
                    signalAge = (DateTime.Now - gpsLlTimestamp).TotalSeconds;
                }

                scanComplete = false;
                usableInterface.Scan();
                while (!scanComplete)
                {
                    Thread.Sleep(100);
                }

                Invoke((MethodInvoker) delegate { listView1.Items.Clear(); });
                int numAps = 0;
                Wlan.WlanAvailableNetwork[] networks = usableInterface.GetAvailableNetworkList(Wlan.WlanGetAvailableNetworkFlags.IncludeAllAdhocProfiles | Wlan.WlanGetAvailableNetworkFlags.IncludeAllManualHiddenProfiles);
                foreach (Wlan.WlanAvailableNetwork network in networks)
                {
                    Wlan.Dot11Ssid      ssid       = network.dot11Ssid;
                    Wlan.WlanBssEntry[] bssEntries = usableInterface.GetNetworkBssList(ssid, network.dot11BssType, network.securityEnabled);

                    foreach (Wlan.WlanBssEntry bss in bssEntries)
                    {
                        numAps++;
                        string bssid       = BitConverter.ToString(bss.dot11Bssid);
                        string ssidEncoded = BitConverter.ToString(network.dot11Ssid.SSID);
                        this.Invoke(wifiFoundDelegate, bssid, Encoding.UTF8.GetString(network.dot11Ssid.SSID, 0, (int)network.dot11Ssid.SSIDLength), bss.rssi, network.dot11BssType, network.dot11DefaultAuthAlgorithm);

                        lock (lockVictim)
                        {
                            tourStreamWriter.WriteLine("NETWORK;{0};{1};{2};{3};{4};{5};{6};{7};{8};{9};{10};{11};" +
                                                       "{12};{13};{14};{15};{16};{17};{18};{19};{20};{21};{22};{23};{24};{25};{26};{27}",
                                                       DateTime.Now.Ticks, DateTime.Now.ToString(), lon, lat, bssid, (int)network.dot11BssType,
                                                       (int)network.dot11DefaultAuthAlgorithm, (int)network.dot11DefaultCipherAlgorithm,
                                                       network.dot11Ssid.SSIDLength, ssidEncoded, (int)network.flags, network.morePhyTypes,
                                                       network.networkConnectable, network.securityEnabled, network.wlanSignalQuality,
                                                       bss.beaconPeriod, bss.capabilityInformation, bss.chCenterFrequency,
                                                       (int)bss.dot11BssPhyType, (int)bss.dot11BssType, bss.hostTimestamp, bss.ieOffset,
                                                       bss.ieSize, bss.inRegDomain, bss.phyId, bss.rssi, bss.timestamp, (int)bss.wlanRateSet.GetRateInMbps(0)
                                                       );
                        }
                    }
                }
                lock (lockVictim)
                {
                    tourStreamWriter.Flush();
                }
                context.MainForm.SetStatusBar(String.Format("{0} Services entdeckt.", numAps));
            }
            scanThreadEnded = true;
            context.MainForm.SetStatusBar("Scan angehalten!");
        }
コード例 #13
0
ファイル: AppViewModel.cs プロジェクト: rainowen/wifiscaner
        /// <summary>
        /// Using managedWifi APIs to scan Wi-Fi networks and their details
        /// </summary>
        /// <returns>Result of managedWifi APIs scaned - Wi-Fi networks</returns>
        public string StartWifiScanning()
        {
            WlanClient client = new WlanClient();

            WlanClient.WlanInterface wlanIface = client.Interfaces[0];
            wlanIface.Scan();
            Thread.Sleep(10000);
            Wlan.WlanBssEntry[]         WlanBssValues = wlanIface.GetNetworkBssList();
            Wlan.WlanAvailableNetwork[] networks      = wlanIface.GetAvailableNetworkList(0);
            String APList = "";

            APList += "Wireless Card : " + wlanIface.InterfaceDescription + "\r\n";
            APList += "接口名称 : " + wlanIface.InterfaceName + "\r\n";
            APList += "当前有 " + WlanBssValues.Length.ToString() + "网络可见" + "\r\n";
            APList += "\r\n";
            int i = 1;

            foreach (Wlan.WlanBssEntry WlanBssValue in WlanBssValues)
            {
                APList += "SSID " + i.ToString() + ":" + GetStringForSSID(WlanBssValue.dot11Ssid) + "\r\n";
                APList += "Network type                :  结构" + "\r\n";
                String channel       = Convert.ToString(((WlanBssValue.chCenterFrequency - 2412000) / 1000 / 5 + 1));
                String securetype    = "Unknow";
                String securety      = "Unknow";
                String SignalQuality = "Unknow";
                int    j             = 0;
                for (j = 0; j < networks.Length; j++)
                {
                    if (GetStringForSSID(WlanBssValue.dot11Ssid).Equals(GetStringForSSID(networks[j].dot11Ssid)))
                    {
                        switch (networks[j].dot11DefaultCipherAlgorithm)
                        {
                        case Wlan.Dot11CipherAlgorithm.WEP:
                        case Wlan.Dot11CipherAlgorithm.WEP104:
                        case Wlan.Dot11CipherAlgorithm.WEP40:
                            securety = "WEP";
                            break;

                        case Wlan.Dot11CipherAlgorithm.None:
                            securety = "开放";
                            break;

                        case Wlan.Dot11CipherAlgorithm.CCMP:
                            securety = "CCMP";
                            break;

                        case Wlan.Dot11CipherAlgorithm.TKIP:
                            securety = "TKIP";
                            break;

                        default:
                            securety = "unknow";
                            break;
                        }
                        switch (networks[j].dot11DefaultAuthAlgorithm)
                        {
                        case Wlan.Dot11AuthAlgorithm.RSNA:
                            securetype = "WPA2 - 企业";
                            break;

                        case Wlan.Dot11AuthAlgorithm.RSNA_PSK:
                            securetype = "WPA2 - 个人";
                            break;

                        case Wlan.Dot11AuthAlgorithm.IEEE80211_SharedKey:
                            securetype = "IEEE80211_SharedKey";
                            break;

                        case Wlan.Dot11AuthAlgorithm.IEEE80211_Open:
                            securetype = "开放";
                            break;

                        case Wlan.Dot11AuthAlgorithm.WPA:
                            securetype = "WPA";
                            break;

                        case Wlan.Dot11AuthAlgorithm.WPA_None:
                            securetype = "WPA_None";
                            break;

                        case Wlan.Dot11AuthAlgorithm.WPA_PSK:
                            securetype = "WPA - 个人";
                            break;

                        default:
                            securety = "unknow";
                            break;
                        }
                        SignalQuality = networks[j].wlanSignalQuality.ToString() + "%";
                        break;
                    }
                }
                APList += "身份验证                : " + securetype + "\r\n";
                APList += "加密                    : " + securety + "\r\n";
                APList += "BSSID 1                 : " + GetStringForBSSID(WlanBssValue) + "\r\n";
                APList += "信号                    : " + SignalQuality + "\r\n";
                APList += "无线电类型              :      802.11n\r\n";
                APList += "频道                    : " + channel + "\r\n";
                //StringBuilder sb = new StringBuilder();
                //foreach (ushort value in WlanBssValue.wlanRateSet.Rates)
                //sb.AppendFormat("{0:d}" + " ", value);
                APList += "基本速率(Mbps)          :          1 2 5.5 11\r\n";
                APList += "其他速率(Mbps)          :          28 24 36 48 54\r\n";
                APList += "RSSI                    : " + WlanBssValue.rssi.ToString() + "\r\n";
                APList += "\r\n";

                //System.IO.File.Delete("testlog.txt");
                //System.IO.File.AppendAllText("testlog.txt", APList);
            }

            return(APList);
        }