This commit is contained in:
2021-02-07 23:19:03 -05:00

33
dislocker.sh Normal file
View File

@@ -0,0 +1,33 @@
#!/bin/bash
# Variables
bitlockerPartitionMountPoint="/mnt/bitlocker"
dislockerFileMountPoint="/mnt/bitlocker/dislocker-file"
unlockedBitlockerMountPoint="/mnt/unlockedBitlocker"
# get list of drives and find ones labeled with bitlocker
bitlockerPartition=`dislocker-find`
bitlockerRecoveryKeyID=`dislocker-metadata -V ${bitlockerPartition} | awk '/Recovery Key GUI:/ {print $10; exit}' | sed "s/'//g"`
# confirm drive
# make temp directories
mkdir ${bitlockerPartitionMountPoint}
mkdir ${unlockedBitlockerMountPoint}
# ask for the recovery key with dashses
# regex to match bitlocker key "^[0-9]{6}-[0-9]{6}-[0-9]{6}-[0-9]{6}-[0-9]{6}-[0-9]{6}-[0-9]{6}-[0-9]{6}$"
regex="^[0-9]{6}-[0-9]{6}-[0-9]{6}-[0-9]{6}-[0-9]{6}-[0-9]{6}-[0-9]{6}-[0-9]{6}$"
while : ; do
read -p "Enter recovery key with dashes for bitlocker recovery ID ${bitlockerRecoveryKeyID}: " bitlockerRecoveryKey
[[ ${bitlockerRecoveryKey} =~ ${regex} ]] || break
done
# try unlocking the drive
dislocker -v -V ${bitlockerPartition} -p${bitlockerRecoveryKey} -- ${bitlockerPartitionMountPoint}
# test if the dislockerFileMountPoint was created
if [ -f ${dislockerFileMountPoint} ]; then
# mount the file
mount -o loop,ro ${dislockerFileMountPoint} ${unlockedBitlockerMountPoint}
echo "The drive was unlocked and is availabe at ${unlockedBitlockerMountPoint}"
fi