Beispiel #1
0
        public void Decrypt(string filename)
        {
            var document = new RdgDocumentHandler(filename);

            Console.WriteLine("Decrypting passwords...");
            document.EnumerateUsernames((userNameElement) =>
            {
                var domainNode   = userNameElement.Parent?.Descendants("domain").First();
                var passwordNode = userNameElement.Parent?.Descendants("password").First();

                if (passwordNode == null)
                {
                    return;
                }

                try
                {
                    if (TryDecryptStringUsingLocalUser(passwordNode.Value, out string password))
                    {
                        Console.WriteLine($"{domainNode?.Value ?? "."}\\{userNameElement.Value}: {password}");
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                }
            });
        }
Beispiel #2
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);
        }
Beispiel #3
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);
        }