Skip to content

Instantly share code, notes, and snippets.

@Raymo111
Last active October 31, 2023 12:33
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Raymo111/964f8c5943a64919a324b5f92ac5874b to your computer and use it in GitHub Desktop.
Save Raymo111/964f8c5943a64919a324b5f92ac5874b to your computer and use it in GitHub Desktop.
Automatic Dislocker

Automatic Dislocker

By Raymond Li (Raymo111), October 1st, 2019

You'll need to have Dislocker installed, obviously. You'll also need accessible folders at /media/bitlocker/dislocker-file and /media/bitlockermount

  1. Download the script

    mkdir -p ~/scripts && wget +x https://gist.github.com/Raymo111/964f8c5943a64919a324b5f92ac5874b/raw/72d3b9c23189e0e1a55de7aab22578773b8f133c/dislocker.sh ~/scripts/dislocker.sh
    
  2. Run ~/scripts/dislocker.sh

sudo umount /media/bitlockermount to unmount the dislocker drive.

#!/bin/bash
part=""
i=0
drives=( $(sudo blkid | awk '{print substr($1, 0, length($1) - 1)}') )
for drive in "${drives[@]}"; do
sudo dd if=$drive bs=128 count=1 status=none | hexdump -C | grep -q FVE-FS && bl[$i]=${drive} && ((i++))
done
if [[ ${#bl[@]} == 0 ]]; then
echo "Bitlocker drive not found."
exit
elif [[ ${#bl[@]} == 1 ]]; then
read -n 1 -p "Unlock ${bl[0]}? [Y/n] " conf
if [ "$conf" != "" ]; then echo; fi
if [ "$conf" = "${conf#[Nn]}" ]; then
part=${bl[0]}
fi
else
echo "Available drives:"
i=0
for d in "${bl[@]}"; do
echo "$((i+1)). $d"
((i++))
done
read -n 1 -p "Drive to unlock [1-${#bl[@]}] " ans
if [ "$ans" != "" ]; then echo; fi
part=${bl[$((ans-1))]}
fi
if [[ $part != "" ]]; then
echo -n "User password for $part:"
echo
read -s pass
sudo dislocker $part -u$pass -- /media/bitlocker
sudo mount -o loop /media/bitlocker/dislocker-file /media/bitlockermount
echo "$part unlocked."
xdg-open /media/bitlockermount
else
echo "Nothing done."
fi
@varistov
Copy link

I issue sudo ntfs-3g /media/bitlocker/dislocker-file /media/bitlockermount instead of sudo mount -o loop /media/bitlocker/dislocker-file /media/bitlockermount
I am on ChromeOS flex, so loop devices are not supported. Only Mounting with ntfs-3g works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment