예제 #1
0
        public StringBuilder DecryptAllPasswords(StringBuilder stringBuilder)
        {
            Dictionary <string, StringTransform> replacements = new Dictionary <string, StringTransform>
            {
                {
                    "Source", new StringTransform
                    {
                        SearchRegex       = new Regex(@"<Source ID=""[a-fA-F0-9\-]+"" .*ConnectionString=""([^""]+)"" .*>"),
                        GroupNumbers      = new[] { 1 },
                        TransformFunction = DpapiWrapper.DecryptIfEncrypted
                    }
                },
                {
                    "DsfAbstractFileActivity", new StringTransform
                    {
                        SearchRegex       = new Regex(@"&lt;([a-zA-Z0-9]+:)?(DsfFileWrite|DsfFileRead|DsfFolderRead|DsfPathCopy|DsfPathCreate|DsfPathDelete|DsfPathMove|DsfPathRename|DsfZip|DsfUnzip) .*?Password=""([^""]+)"" .*?&gt;"),
                        GroupNumbers      = new[] { 3 },
                        TransformFunction = DpapiWrapper.DecryptIfEncrypted
                    }
                },
                {
                    "DsfAbstractMultipleFilesActivity", new StringTransform
                    {
                        SearchRegex       = new Regex(@"&lt;([a-zA-Z0-9]+:)?(DsfPathCopy|DsfPathMove|DsfPathRename|DsfZip|DsfUnzip) .*?DestinationPassword=""([^""]+)"" .*?&gt;"),
                        GroupNumbers      = new[] { 3 },
                        TransformFunction = DpapiWrapper.DecryptIfEncrypted
                    }
                },
                {
                    "Zip", new StringTransform
                    {
                        SearchRegex       = new Regex(@"&lt;([a-zA-Z0-9]+:)?(DsfZip|DsfUnzip) .*?ArchivePassword=""([^""]+)"" .*?&gt;"),
                        GroupNumbers      = new[] { 3 },
                        TransformFunction = DpapiWrapper.DecryptIfEncrypted
                    }
                }
            };
            string        xml    = stringBuilder.ToString();
            StringBuilder output = new StringBuilder();

            xml = StringTransform.TransformAllMatches(xml, replacements.Values.ToList());
            output.Append(xml);
            return(output);
        }
 public string EncryptDsfFileWritePasswords(string xml)
 {
     return(StringTransform.TransformAllMatches(xml, new List <StringTransform> {
         _replacements["DsfAbstractFileActivity"]
     }));
 }
 public string EncryptSourceConnectionStrings(string xml)
 {
     return(StringTransform.TransformAllMatches(xml, new List <StringTransform> {
         _replacements["Source"]
     }));
 }