Skip to content

Instantly share code, notes, and snippets.

@gzxu
Last active June 26, 2024 22:30
Show Gist options
  • Save gzxu/00121e79d6503892b29960e8985288e4 to your computer and use it in GitHub Desktop.
Save gzxu/00121e79d6503892b29960e8985288e4 to your computer and use it in GitHub Desktop.
Unlock an SED-supporting SSD with sedutil Hardware Encryption
device=sdb
serial="$(ls -la /dev/disk/by-id | grep "/$device\$" | sed 's/ /\n/g' | grep ata | sed 's/_/\n/g' | tail -n1)"
read -r -s password
hashed=$(SERIAL="$serial" PASSWORD="$password" python3 -c 'import hashlib, base64, os; print(base64.b64encode(hashlib.pbkdf2_hmac("sha1", os.environ["PASSWORD"].encode(), os.environ["SERIAL"].ljust(20, " ").encode(), 75000, 32)).decode())' | base64 -d)
sudo sedutil-cli -n --listLockingRanges "$hashed" /dev/$device
read -s -p Password: password && sudo sedutil-cli --setLockingRange 0 rw "$password" /dev/sda && sudo sedutil-cli --setMBRDone on "$password" /dev/sda
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment