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

Add option to brute force byte-keyfile within length #28

Closed milesflo closed 4 years ago

milesflo commented 4 years ago

According to this redhat tutorial it's a common practice to have file-based authentication for LUKS drives to allow for at-boot decryption.

However, they recommend a key length of only 32 bytes which feels like an achievable keyspace for brute forcing.

Guide:

Adding a key file to an existing LUKS volume:

  1. Prepare a key file, whether it is random data or something specific

Examples:

dd if=/dev/random bs=32 count=1 of=/root/random_data_keyfile1
printf "Simple passphrase which can also be used interactively" >/root/plaintext_passphrase_keyfile2
Take care to ensure the key file is hidden from and unreadable by all untrusted parties
  1. Add the key file to the encrypted device with the command: cryptsetup luksAddKey DEV /PATH/TO/KEYFILE

Example:

[root ~] cryptsetup luksAddKey /dev/sda3 /root/random_data_keyfile1
Enter any passphrase: Existing passphrase which can be used to open DEV
[root ~] 

Implementation

Add a flag to try key file based bf-ing, with a flag to determine the target length, or ≤ this max size

glv2 commented 4 years ago

A key of 32 bytes is a 256-bit key, and that is a way too big keyspace for bruteforcing if the key is random data.

If the key is not random data and you have some information on its format, you could generate the possibilities and write them to a file using a custom program, and then try them with the -f option of bruteforce-luks.