glv2 / bruteforce-luks

Try to find the password of a LUKS encrypted volume.
GNU General Public License v3.0
238 stars 34 forks source link

TrueCrypt support #29

Open virtuald opened 3 years ago

virtuald commented 3 years ago

First, thanks for this tool, it's fantastic and enabled me to recover data from a volume that I mildly remembered the passphrase to (but I had to write a program to generate a bunch of permuations of that phrase to actually open it).

I suspect nobody actually wants to support truecrypt volumes... and so I don't really feel like cleaning it up to make it more general -- BUT, if someone else has a truecrypt volume they need to decrypt, applying this diff to a18694abcca8a310f18b7a842f5c48d6b21c064f allowed me to brute force a truecrypt volume that I had lying around.

diff --git a/src/bruteforce-luks.c b/src/bruteforce-luks.c
index 72649cf..a8db966 100644
--- a/src/bruteforce-luks.c
+++ b/src/bruteforce-luks.c
@@ -287,7 +287,7 @@ void * decryption_func(void *arg)

   /* Load the LUKS volume header */
   crypt_init(&cd, path);
-  crypt_load(cd, CRYPT_LUKS, NULL);
+  // crypt_load(cd, CRYPT_TCRYPT, NULL);
   crypt_set_log_callback(cd, &logger, &ret);

   do
@@ -299,8 +299,17 @@ void * decryption_func(void *arg)
     if(ret == 0)
       break;

+    struct crypt_params_tcrypt params = {0};
+    params.flags = CRYPT_TCRYPT_LEGACY_MODES;
+    params.keyfiles = NULL;
+    params.keyfiles_count = 0;
+    params.passphrase = pwd;
+    params.passphrase_size = pwd_len;
+
+    ret = crypt_load(cd, CRYPT_TCRYPT, &params);
+
     /* Decrypt the LUKS volume with the password */
-    ret = crypt_activate_by_passphrase(cd, NULL, CRYPT_ANY_SLOT, pwd, pwd_len, CRYPT_ACTIVATE_READONLY);
+    //ret = crypt_activate_by_passphrase(cd, NULL, CRYPT_ANY_SLOT, pwd, pwd_len, CRYPT_ACTIVATE_READONLY);
     if(ret >= 0)
     {
       /* We have a positive result */
@@ -525,22 +534,23 @@ void restore_state()

 int check_path(char *path)
 {
-  struct crypt_device *cd;
-  int ret;
-
-  ret = crypt_init(&cd, path);
-  if(ret < 0)
-    return(0);
-
-  ret = crypt_load(cd, CRYPT_LUKS, NULL);
-  if(ret < 0)
-  {
-    crypt_free(cd);
-    return(0);
-  }
-
-  crypt_free(cd);
-  return(1);
+  return 1;
+  // struct crypt_device *cd;
+  // int ret;
+
+  // ret = crypt_init(&cd, path);
+  // if(ret < 0)
+  //   return(0);
+
+  // ret = crypt_load(cd, CRYPT_LUKS, NULL);
+  // if(ret < 0)
+  // {
+  //   crypt_free(cd);
+  //   return(0);
+  // }
+
+  // crypt_free(cd);
+  // return(1);
 }

My hope is that either someone will adopt this into a PR or that someone searching the github issues will come across this and it will help them solve their problem. Feel free to close this if you don't wish to adopt it. Cheers!