Exemplo n.º 1
0
        public void Clean(string filename, string outputFilename)
        {
            var document = new RdgDocumentHandler(filename);

            Console.WriteLine("Removing all username and passwords from file");
            document.EnumerateUsernames((userNameElement) =>
            {
                var passwordNode = userNameElement.Parent?.Descendants("password").First();

                userNameElement.Value = string.Empty;
                if (passwordNode != null)
                {
                    passwordNode.Value = string.Empty;
                }
            });
            document.Save(outputFilename);
        }
Exemplo n.º 2
0
        public void RemoveAllUsersThatCannotBeDecrypted(string filename, string outputFilename)
        {
            var document = new RdgDocumentHandler(filename);

            Console.WriteLine("Removing usernames and passwords that cannot be decrypted");
            document.EnumerateUsernames((userNameElement) =>
            {
                try
                {
                    var passwordNode = userNameElement.Parent?.Descendants("password").First();
                    var domainNode   = userNameElement.Parent?.Descendants("domain").First();
                    if (passwordNode == null)
                    {
                        return;
                    }

                    if (CanDecrypt(passwordNode.Value))
                    {
                        return;
                    }

                    userNameElement.Value = string.Empty;
                    passwordNode.Value    = string.Empty;
                    if (domainNode != null)
                    {
                        domainNode.Value = string.Empty;
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                }
            });

            document.Save(outputFilename);
        }