Last active
May 31, 2017 06:09
-
-
Save hackers-terabit/6b3699ad53f89711bb343959ecfdc7bf to your computer and use it in GitHub Desktop.
Help measure/appraise(sign) system for immutability
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
whitelist="./whitelist" | |
verbose=1 | |
#generate unencrypted openssl pub/private rsa keypair | |
echo "generating signing key" | |
openssl genrsa -out /etc/rsa_private.pem 4096 | |
openssl rsa -pubout -in /etc/rsa_private.pem -out /etc/rsa_public.pem | |
#import public signing key | |
ima_id=`keyctl newring _ima @u` | |
evmctl import --rsa /etc/rsa_public.pem $ima_id | |
echo "Imported signing key" | |
echo "Measuring and signing files not found in whitelist" | |
echo "This will take a very long time, go watch a movie or something..." | |
find / \( -fstype rootfs -o -fstype ext4 \) -type f | grep -vf $whitelist | | |
while read filepath | |
do | |
#measure | |
evmctl ima_hash "$filepath" | |
#sign for appraisal excluding whitelist paths | |
evmctl sign --rsa -k /etc/rsa_private.pem --uuid --imasig "$filepath" | |
if [ $verbose -ge 1 ] | |
then | |
echo "Measured/Appraised:$filepath" | |
fi | |
done | |
echo "Done." | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Current "whitelist" file: