Advertisement
n4rf

Dislocker unlock script

Feb 19th, 2017
269
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.59 KB | None | 0 0
  1. #!/bin/bash
  2. #requirementes: dislocker,zenity
  3. DFILE_LOCATION="/tmp/DFILE"
  4. DRIVE_MOUNTPOINT="/mnt/UnlockedDrive"
  5.  
  6.  
  7. if ! type zenity > /dev/null; then
  8.   echo "Please install 'Zenity'";
  9.   exit;
  10. fi
  11.  
  12.  
  13. if ! type dislocker > /dev/null; then
  14.   zenity --error --tittle="Dislocker Not Found" --text="Dislocker has not been found on your system. Please install, and retry."
  15.   exit;
  16. fi
  17.  
  18. #If everythng seems to be OK, continue.
  19.  
  20. SUPASSWORD=$(zenity --password --title="Authenticate" --text="In order to continue, SuperUser Passwrod is required")
  21.  
  22.  
  23. #Check if exists, otherwise create a folder to mount dislocker-image
  24.  
  25. if [ ! -d $DFILE_LOCATION ]; then
  26.   # Control will enter here if $DIRECTORY doesn't exist.
  27.   echo $SUPASSWORD | sudo -S mkdir $DFILE_LOCATION
  28. fi
  29.  
  30. if [ ! -d $DRIVE_MOUNTPOINT ]; then
  31.   # Control will enter here if $DIRECTORY doesn't exist.
  32.   echo $SUPASSWORD | sudo -S mkdir $DRIVE_MOUNTPOINT
  33. fi
  34.  
  35.  
  36. lockedDrive=$(find /dev -mindepth 1 -maxdepth 1  -name "*[sh]d[a-z][0-9]"  | sort | awk '{ printf "FALSE""\0"$0"\0" }' | \
  37. xargs -0 zenity --list --title="Root Partition" --text="Select the locked partition to unlock." \
  38. --radiolist --multiple --column ' ' --column 'Partitions')
  39.  
  40. lockedDrivePSW=$(zenity --password --title="Locked Drive" --text="Please type Locked Drive Password")
  41.  
  42. if [ ! -f "$DFILE_LOCATION"/dislocker-file ]; then
  43.   # Control will enter here if file does not.
  44.   echo $SUPASSWORD | sudo -S dislocker -v -V $lockedDrive  -u$lockedDrivePSW -- $DFILE_LOCATION
  45.   echo $SUPASSWORD | sudo -S mount -o loop $DIRECTORY_DFILE_LOCATION/dislocker-file $DRIVE_MOUNTPOINT
  46. fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement