Commits

Qaatloz  committed 54dd9ef

Added autotype of the password so disabling the ask password check is much more safe than before when it used the commandline to pass on the plaintext password

Changes the autotype sequence to {password} {enter} of the database entry by default because no username is used in truecrypt

Added functionality to enable autotype obfuscation by default because the truecrypt dialog supports it

  • Participants
  • Parent commits d97334f

Comments (0)

Files changed (3)

File src/KeepassTrueCryptMount/KeepassTrueCryptMountExt.cs

         private void OnTrueCryptMenuItemClicked(object sender, EventArgs e)
         {
             var entry = this.pluginHost.MainWindow.GetSelectedEntry(false);
+            var database = this.pluginHost.Database;
 
             if (entry == null)
             {
             }
 
             // do mount...
-            new ProcessStartInfo(this.pluginHost.GetTrueCryptExecutable())
-                .HideExecution()
-                .WithCommandLine(entry.ToTrueCryptArguments())
-                .Execute();
+            var truecryptProcessInfo = new ProcessStartInfo(this.pluginHost.GetTrueCryptExecutable(),entry.ToTrueCryptArguments());
+
+            var truecryptProcess = Process.Start(truecryptProcessInfo);
+            if(truecryptProcess != null){
+                if (truecryptProcess.WaitForInputIdle(3000))
+                {
+                    entry.PerformPasswordAutotype(database);
+                }
+            }
+
         }
 
         private void OnTrueCryptOptionsMenuItemClicked(object sender, EventArgs e)

File src/KeepassTrueCryptMount/PwEntryExtension.cs

     using System.Text;
 
     using KeePassLib;
+    using KeePass.Util;
 
     internal static class PwEntryExtension
     {
                 }
                
             }
-
-            // ask for password or set password directly
-            {
-                var askForPasswordString = entry.Strings.GetSafe(EntryStrings.AskForPassword).ReadString();
-                bool askForPassword;
-                bool.TryParse(askForPasswordString, out askForPassword);
-
-                if (!askForPassword)
-                {
-                    arguments.Append(" /p ");
-                    var pwd = entry.Strings.GetSafe("Password").ReadString();
-                    arguments.AppendFormat("\"{0}\"", pwd);
-                }
-            }
-
-            
             return arguments.ToString();
         }
 
 
             return bool.TrueString.Equals(entry.Strings.GetSafe(EntryStrings.Enabled).ReadString());
         }
+
+        public static void PerformPasswordAutotype(this PwEntry entry,PwDatabase database)
+        {
+            var askForPasswordString = entry.Strings.GetSafe(EntryStrings.AskForPassword).ReadString();
+            bool askForPassword;
+            bool.TryParse(askForPasswordString, out askForPassword);
+
+            if (!askForPassword)
+            {
+                AutoType.PerformIntoCurrentWindow(entry,database);
+            }
+        }
     }
 }

File src/KeepassTrueCryptMount/TrueCryptMountForm.cs

             entry.Strings.Set(EntryStrings.Beep, new ProtectedString(false, this.beepCheckBox.Checked.ToString()));
             entry.Strings.Set(EntryStrings.Explorer, new ProtectedString(false, this.explorerCheckBox.Checked.ToString()));
             entry.Strings.Set(EntryStrings.AskForPassword, new ProtectedString(false, this.askPasswordCheckBox.Checked.ToString()));
+            entry.AutoType.DefaultSequence = "{PASSWORD}{ENTER}";
+            entry.AutoType.ObfuscationOptions = KeePassLib.Collections.AutoTypeObfuscationOptions.UseClipboard;
 
             return this;
         }