commit a22d813080e394efb9a041a9e81405c611d6e4d6 parent 3d073554f8ea59c8c99e37307dbacb0fbf4c70b9 Author: sin <sin@2f30.org> Date: Wed, 25 Dec 2013 12:00:49 +0000 Add simple IDS script Diffstat:
A | sids | | | 43 | +++++++++++++++++++++++++++++++++++++++++++ |
1 file changed, 43 insertions(+), 0 deletions(-)
diff --git a/sids b/sids @@ -0,0 +1,43 @@ +#!/bin/sh + +# path of the signature store +sigstore=$(test -n "$SIGSTORE" && echo "$SIGSTORE" || echo /sigstore) +# paths to be hashed +sigpath=$(test -n "$SIGPATH" && echo "$SIGPATH" || \ + echo /bin:/sbin:/usr) + +set -o noclobber + +usage() { + echo "usage: $(basename $0) [-gv]" 1>&2 + exit 1 +} + +if test $1; then + option=$1 +else + usage +fi + +mkdir -p "$sigstore" + +case $option in +-g) + echo "$sigpath" | awk -F: '{ for (i=1; i<=NF; i++) {print $i}}' | + while read path; do + mtree_path=mtree$(echo "$path" | sed 's/\//_/g') + mtree -c -K sha256digest -p "$path" > "$sigstore/$mtree_path" + done + chmod 600 $sigstore/* + ;; +-v) + echo "$sigpath" | awk -F: '{ for (i=1; i<=NF; i++) {print $i}}' | + while read path; do + mtree_path=mtree$(echo "$path" | sed 's/\//_/g') + mtree -p "$path" < "$sigstore/$mtree_path" + done + ;; +*) + usage + ;; +esac