Skip to content

Instantly share code, notes, and snippets.

@ProxiBlue
Created January 26, 2021 10:58
Show Gist options
  • Save ProxiBlue/0a575976285d6ce21a25e939f692be19 to your computer and use it in GitHub Desktop.
Save ProxiBlue/0a575976285d6ce21a25e939f692be19 to your computer and use it in GitHub Desktop.
Using maldet inside a pipeline deploy
#buddy starts in the working dir
SCANDIR=$(pwd)
wget http://www.rfxn.com/downloads/maldetect-current.tar.gz
tar -xzf maldetect-current.tar.gz
cd maldetect-1.6.4
/bin/bash ./install.sh
#make a fake vi to just echo out the report
echo '#!/bin/bash' >/usr/bin/vi
echo 'echo $1' >>/usr/bin/vi
chmod +x /usr/bin/vi
cat $maldetconf >/usr/local/maldetect/conf.maldet
chown nobody:nogroup /buddy/sitebuild -R
cd ../
rm -rf /buddy/sitebuild/maldetect*
maldet -d && maldet -u
maldet -verbose -a $SCANDIR
#trap the scan result so we can exit with it and trigger a fail if something was detected
RESULT=$?
maldet --report list
maldet -l
LOGLINE=$(maldet -l |grep "scan report saved, to view run:")
LOGNUMBER=${LOGLINE##* }
SESSIONLOG=$(maldet --report $LOGNUMBER | grep session)
cat $SESSIONLOG
exit $RESULT
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment