Skip to content

Instantly share code, notes, and snippets.

@dnoliver
Last active December 9, 2020 18:41
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save dnoliver/a37b1953146ecd5d6568fc2ba1469007 to your computer and use it in GitHub Desktop.
Save dnoliver/a37b1953146ecd5d6568fc2ba1469007 to your computer and use it in GitHub Desktop.
Linux Integrity Measurement Architecture (IMA) Helpers

IMA Helper Scripts

#!/bin/bash
set -euo pipefail
cat /sys/kernel/security/ima/ascii_runtime_measurements | awk '{print $5}' | sort | uniq -c | sort -n -r
#!/bin/bash
set -euo pipefail
cat << EOF
dont_measure fsmagic=0x9fa0
dont_measure fsmagic=0x62656572
dont_measure fsmagic=0x64626720
dont_measure fsmagic=0x1021994
dont_measure fsmagic=0x1cd1
dont_measure fsmagic=0x42494e4d
dont_measure fsmagic=0x73636673
dont_measure fsmagic=0xf97cff8c
dont_measure fsmagic=0x43415d53
dont_measure fsmagic=0x27e0eb
dont_measure fsmagic=0x63677270
dont_measure fsmagic=0x6e736673
EOF
cat << EOF
dont_measure obj_type=container_share_t
dont_measure obj_type=container_var_lib_t
EOF
cat << EOF
measure func=MMAP_CHECK mask=MAY_EXEC
measure func=BPRM_CHECK mask=MAY_EXEC
measure func=FILE_CHECK euid=0 mask=MAY_EXEC
measure func=FILE_CHECK uid=0 mask=MAY_EXEC
measure func=MODULE_CHECK
measure func=FIRMWARE_CHECK
measure func=POLICY_CHECK
EOF
cat /etc/selinux/targeted/contexts/files/file_contexts | grep [A-Za-z0-9_]*unit_file_t --only-matching | sort | uniq | while read CONTEXT; do
echo "measure obj_type=${CONTEXT}"
done
cat /etc/selinux/targeted/contexts/files/file_contexts | grep [A-Za-z0-9_]*config_t --only-matching | sort | uniq | while read CONTEXT; do
echo "measure obj_type=${CONTEXT}"
done
cat /etc/selinux/targeted/contexts/files/file_contexts | grep [A-Za-z0-9_]*conf_t --only-matching | sort | uniq | while read CONTEXT; do
echo "measure obj_type=${CONTEXT}"
done
cat /etc/selinux/targeted/contexts/files/file_contexts | grep [A-Za-z0-9_]*cert_t --only-matching | sort | uniq | while read CONTEXT; do
echo "measure obj_type=${CONTEXT}"
done
cat /etc/selinux/targeted/contexts/files/file_contexts | grep [A-Za-z0-9_]*key_t --only-matching | sort | uniq | while read CONTEXT; do
echo "measure obj_type=${CONTEXT}"
done
cat /etc/selinux/targeted/contexts/files/file_contexts | grep [A-Za-z0-9_]*secret_t --only-matching | sort | uniq | while read CONTEXT; do
echo "measure obj_type=${CONTEXT}"
done
#!/bin/bash
set -euo pipefail
cat /sys/kernel/security/ima/ascii_runtime_measurements | awk '{print $5}' | sort | uniq | while read FILE; do
if [ ! -f ${FILE} ]; then echo ${FILE}; fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment