Exemplo n.º 1
0
        private static async Task <IEnumerable <WifiCredential> > GetOneXDatasInExportedDirectory(string dir)
        {
            List <WifiCredential> toret = new List <WifiCredential>();

            foreach (var file in Directory.GetFiles(dir, "*.wpei", SearchOption.TopDirectoryOnly))
            {
                string[] data = await Task.Run(() => File.ReadAllLines(file, Encoding.UTF8));

                if (data.Length != 3)
                {
                    continue;
                }
                var c = new WifiCredential(string.Empty, data[0], data[1], data[2]);
                c.GUID = Path.GetFileNameWithoutExtension(file);
                toret.Add(c);
            }

            RunAdministrativeProcessWithProxy(WifiPasswordExtractProxy.ExtractProxy.ExecutablePath, $"clean");

            return(toret);
        }
Exemplo n.º 2
0
        private static async Task <IEnumerable <WifiCredential> > ProcessNotEnterprisePasswords(List <WifiCredential> host)
        {
            List <WifiCredential> toret = host;

            List <WifiCredential> waitfordecrypt = new List <WifiCredential>();

            foreach (var profile in await GetWlanProfilesFromDirectoryAsync())
            {
                if (profile.MSM.security.authEncryption.useOneX)
                {
                    var guidcheck = toret.Where(v => v.GUID == profile.guid);
                    if (guidcheck.Any())
                    {
                        guidcheck.First().SSID = profile.SSIDConfig.SSID.name;
                    }
                    else
                    {
                        toret.Add(new WifiCredential(profile.SSIDConfig.SSID.name)
                        {
                            Open = false,
                            OneX = true,
                        });
                    }
                    continue;
                }

                if (profile.MSM.security.sharedKey != null && !profile.MSM.security.sharedKey.@protected)
                {
                    var c = new WifiCredential(profile.SSIDConfig.SSID.name, profile.MSM.security.sharedKey.keyMaterial);
                    c.GUID = profile.guid;
                    toret.Add(c);
                    continue;
                }
                else if (profile.MSM.security.authEncryption.authentication == "open")
                {
                    var c = new WifiCredential(profile.SSIDConfig.SSID.name);
                    c.GUID = profile.guid;
                    toret.Add(c);
                    continue;
                }

                if (profile.MSM.security.sharedKey != null && profile.MSM.security.sharedKey.@protected)
                {
                    if (UseLegacyNetshBasedPasswordExtract)
                    {
                        var dprofile = await GetWlanProfilesFromNetshWithProfileNameAsync(profile.name);

                        if (dprofile.Length > 0 && !dprofile[0].MSM.security.sharedKey.@protected)
                        {
                            var c = new WifiCredential(profile.SSIDConfig.SSID.name, dprofile[0].MSM.security.sharedKey.keyMaterial);
                            c.GUID = profile.guid;
                            toret.Add(c);
                            continue;
                        }
                    }
                    else
                    {
                        var b64km = KeyMaterialToBase64(profile.MSM.security.sharedKey.keyMaterial);
                        var c     = new WifiCredential(profile.SSIDConfig.SSID.name, b64km);
                        c.GUID = profile.guid;
                        waitfordecrypt.Add(c);
                    }
                }
            }

            if (!UseLegacyNetshBasedPasswordExtract)
            {
                var keys = await DecryptPasswordsBySYSTEMAccount(waitfordecrypt.Select(v => v.Password).ToArray());

                List <WifiCredential> newcred = new List <WifiCredential>();
                foreach (var key in keys)
                {
                    var searcher = waitfordecrypt.Where(v => v.Password == key.Key);
                    if (!searcher.Any())
                    {
                        continue;
                    }
                    var cred = searcher.First();
                    cred.Password = key.Value;
                    newcred.Add(cred);
                }
                toret.AddRange(newcred);
            }

            return(toret);
        }