summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulien "shaddai" Reveret2016-01-29 10:55:32 +0100
committerJulien "shaddai" Reveret2016-01-29 10:55:54 +0100
commitd3e4592a03aad6303da38f2b6143b2c04c3a1073 (patch)
tree42e0c71c795380c8d78664b6f96b87e9539ab25f
parent539245a12a06763b5d77b9c01a9b3312b8d69f9f (diff)
add docroot-check.sh : check php files inside Apache DocumentRoot
-rw-r--r--php-malware-finder/docroot-check.sh21
1 files changed, 21 insertions, 0 deletions
diff --git a/php-malware-finder/docroot-check.sh b/php-malware-finder/docroot-check.sh
new file mode 100644
index 0000000..a5cce6e
--- /dev/null
+++ b/php-malware-finder/docroot-check.sh
@@ -0,0 +1,21 @@
1#!/usr/bin/env bash
2
3apache_confdir="/etc/apache2/sites-available"
4
5# grab the different document roots
6for docroot in $(grep -o 'DocumentRoot.*' $apache_confdir/* | \
7 awk '{if ($2 ~ "/data/www/*") print $2}') ; do
8
9 pmf_output_dir=$(echo $docroot |egrep -o '[^/]*/[^/]*$')
10 mkdir -p /tmp/$pmf_output_dir
11
12 SAVEIFS=$IFS
13 IFS=$(echo -en "\n\b")
14 find $docroot -type f -iname "*php" -exec yara /etc/phpmalwarefinder/malwares.yara {} > \
15 /tmp/$pmf_output_dir/cron.out 2>&1 \;
16
17 if [ -s /tmp/$pmf_output_dir/cron.out ]; then
18 cat /tmp/$pmf_output_dir/cron.out | \
19 mail -s "PMF REPORT:$(uname -n) DocumentRoot $docroot" jre@nbs-system.com
20 fi;
21done