Skip to content

Instantly share code, notes, and snippets.

@ava1ar
Last active November 5, 2020 16:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ava1ar/eb5827158aa035c3e5ca2829dd083373 to your computer and use it in GitHub Desktop.
Save ava1ar/eb5827158aa035c3e5ca2829dd083373 to your computer and use it in GitHub Desktop.
Shell script to re-sign Windows boot efi files after windows update with custom Secure boot keys
#!/bin/bash -e
if [[ $EUID -ne 0 ]]; then
exec sudo /bin/bash "$0" "$@"
fi
CERTDIR=/boot/secureboot
BOOT_FILES_DIR=/boot/efi/EFI/Microsoft/Boot
echo "Validating files checksum..."
md5sum --quiet --check ${BOOT_FILES_DIR}/efi.md5
CODE=$?
if [[ $CODE -eq 0 ]]; then
echo "Checksum check PASSED!"
exit 0
else
echo "Checksum check FAILED, re-signing efi files!"
fi
for file in ${BOOT_FILES_DIR}/*.efi
do
echo "Found ${file}!"
mv ${file} ${file}.bak
/usr/bin/sbsign --key ${CERTDIR}/DB.key --cert ${CERTDIR}/DB.crt --output ${file} ${file}.bak
done
md5sum ${BOOT_FILES_DIR}/*.efi > ${BOOT_FILES_DIR}/efi.md5
echo "efi files were signed!"
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment