summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulien Voisin2015-04-15 11:27:47 +0200
committerJulien Voisin2015-04-15 11:40:09 +0200
commit91a4e5d3b154bd7207ab8482a5c0384c77815860 (patch)
treecc4b5cf508380b890e12f954e5c758914a29f769
parent2b2b35d4561a46ad03d15cd7b58f3d132a509faf (diff)
Ajout de l'option -s
Par default, ./scan.sh est silencieux
-rw-r--r--scan.sh15
1 files changed, 12 insertions, 3 deletions
diff --git a/scan.sh b/scan.sh
index f817866..3d48dc3 100644
--- a/scan.sh
+++ b/scan.sh
@@ -1,15 +1,17 @@
1#/bin/bash 1#/bin/bash
2 2
3diff_folder=false 3diff_folder='/var/log/phpmalwarefinder/'
4stdout=false
4 5
5SCAN_CMD='./yara -r ./malwares.yara -f' 6SCAN_CMD='./yara -r ./malwares.yara -f'
6 7
7show_help() { 8show_help() {
8 cat << EOF 9 cat << EOF
9Usage ${0##*/} [-dhw] 10Usage ${0##*/} [-dhw]
10 -d Path to the diff folder 11 -d Path to the diff folder (defaults to ${diff_folder})
11 -h Show this help message 12 -h Show this help message
12 -w Provide a whitelist file, containing one path per line 13 -w Provide a whitelist file, containing one path per line
14 -s Show diff on stdout
13EOF 15EOF
14} 16}
15 17
@@ -23,6 +25,9 @@ while getopts "hw:d:" opt; do
23 d) 25 d)
24 diff_folder="$OPTARG" 26 diff_folder="$OPTARG"
25 ;; 27 ;;
28 s)
29 stdout=true
30 ;;
26 '?') 31 '?')
27 show_help 32 show_help
28 exit 1 33 exit 1
@@ -43,6 +48,10 @@ if [ -z "$previous_scan" ]; then
43 exit 0 48 exit 0
44fi 49fi
45 50
46diff <($SCAN_CMD "$@" | sort | tee "$diff_folder/$(date +%s)") <(cat "$diff_folder"/"$previous_scan") 51if [ ${stdout} = true ]; then
52 diff <($SCAN_CMD "$@" | sort | tee "$diff_folder/$(date +%s)") <(cat "$diff_folder"/"$previous_scan")
53else
54 $SCAN_CMD "$@" | sort > "$diff_folder/$(date +%s)"
55fi
47 56
48exit 0 57exit 0