Skip to content

Instantly share code, notes, and snippets.

@ox0xo
Created August 1, 2021 15:30
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 ox0xo/f5ac0ff350b9afc7daff7265a8c2be24 to your computer and use it in GitHub Desktop.
Save ox0xo/f5ac0ff350b9afc7daff7265a8c2be24 to your computer and use it in GitHub Desktop.
Tripwire Alerting Script
#!/bin/bash
rm -f /etc/cron.daily/tripwire-check
LOCALPASS=TeamF!23
SITEPASS=TeamF!23
TRIPWIRE=/usr/sbin/tripwire
TWADMIN=/usr/sbin/twadmin
TWPRINT=/usr/sbin/twprint
TWLOG=/tmp/tripwire.log
cd /etc/tripwire
${TRIPWIRE} -m c -s -c tw.cfg > $TWLOG
if [ -s $TWLOG ]; then
if [ $(grep "Total violations found" $TWLOG | awk '{print $4}') -ne 0 ]; then
HOST=`hostname`
REPORT=`ls -dt /var/lib/tripwire/report/* | head -1`
LOG=`${TWPRINT} -m r --report-level 1 -c tw.cfg -r $REPORT | sed -e 's/"//g'`
CURL=`cat <<EOS
curl
-XPOST
'https://script.google.com/macros/s/*****/exec'
-H
'Content-Type: application/json'
-d
'{"host": "$HOST", "log": "tripwire", "message": "$LOG"}'
EOS`
eval ${CURL} &> /dev/null
${TWADMIN} -m p -c tw.cfg -p tw.pol -S site.key > twpol.txt
perl twpolmake.pl twpol.txt > twpol.txt.new
${TWADMIN} -m P -c tw.cfg -p tw.pol -S site.key -Q $SITEPASS twpol.txt.new > /dev/null
rm -f twpol.txt* *.bak
rm -f /var/lib/tripwire/*.twd.bak
${TRIPWIRE} -m i -s -c tw.cfg -P $LOCALPASS
fi
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment