WD-Passport-Unlock-Linux
WD-Passport-Unlock-Linux copied to clipboard
Alternate way of getting the block device name
Here's the script I use to unlock my drive. Note how I get the device name without having to manually inspect dmesg by looking up the attached drives whose model is "My Passport".
It works like a charm in Ubuntu 22.04. However it will misbehave if more than one My Passport drives are plugged in at the same time. Not my case though.
I still have to investigate sg_raw's cmdline flags to see if I can feed the binary data from cookpw.py (maybe in hex form) through the command line to avoid creating the password.bin file for better security.
Hope it's useful to somebody!
#!/bin/bash
echo -n Drive password:
read -s password
echo
python3 cookpw.py $password > password.bin
dev=/dev/`lsblk --all -o NAME,MODEL | grep 'My Passport' | sed 's/ .*//'`
echo DEV IS $dev
sudo sg_raw -s 40 -i password.bin $dev c1 e1 00 00 00 00 00 00 28 00
rm password.bin