forked from majal/maj-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvboxsign
More file actions
27 lines (22 loc) · 962 Bytes
/
vboxsign
File metadata and controls
27 lines (22 loc) · 962 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#!/bin/bash
# Sign and load VirtualBox modules
# Run as root
[ "`whoami`" = root ] || exec sudo "$0" "$@"
# Set working directory
dir=/home/directory/of/keys
cd $dir
# (Optional) Decrypt private key. To initially encrypt, run `gpg -c MOK.priv` then shred MOK.priv
echo
#gpg -d --passphrase-file /owned/by/root/.pass MOK.priv.gpg > MOK.priv
echo
# Sign and load modules
for module in vboxdrv vboxnetflt vboxnetadp vboxpci; do
[ "`hexdump -e '"%_p"' $(modinfo -n $module) | tail | grep signature`" ] && echo -e "\e[93mModule $module is already signed. Skipping.\e[0m" || /usr/src/linux-headers-$(uname -r)/scripts/sign-file sha256 ./MOK.priv ./MOK.der $(modinfo -n $module)
printf "$module: "
echo `hexdump -e '"%_p"' $(modinfo -n $module) | tail | grep signature`
modprobe $module && echo -e "\e[92m$module successfully loaded\e[0m" || echo -e "\e[91mFailed to load $module\e[0m"
done
# (Optional) Shred private key
echo
#shred -vfuz MOK.priv
echo