summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulien Voisin2015-03-10 13:59:34 +0100
committerJulien Voisin2015-03-10 13:59:34 +0100
commita113aa63fa45497b6393ed3cc87f6f1ef35c8e6e (patch)
tree2e87cd21828e7e12867a7df62594ec0ed7b2fab3
parentfb036bea2f4855ff65ed9c60f826b970218f19d5 (diff)
Add a scanner script
-rw-r--r--scan.sh48
1 files changed, 48 insertions, 0 deletions
diff --git a/scan.sh b/scan.sh
new file mode 100644
index 0000000..f817866
--- /dev/null
+++ b/scan.sh
@@ -0,0 +1,48 @@
1#/bin/bash
2
3diff_folder=false
4
5SCAN_CMD='./yara -r ./malwares.yara -f'
6
7show_help() {
8 cat << EOF
9Usage ${0##*/} [-dhw]
10 -d Path to the diff folder
11 -h Show this help message
12 -w Provide a whitelist file, containing one path per line
13EOF
14}
15
16OPTIND=1
17while getopts "hw:d:" opt; do
18 case "$opt" in
19 h)
20 show_help
21 exit 0
22 ;;
23 d)
24 diff_folder="$OPTARG"
25 ;;
26 '?')
27 show_help
28 exit 1
29 ;;
30 esac
31done
32shift "$((OPTIND-1))"
33
34if [ ! -d "$diff_folder" ]; then
35 echo "[-] Invalid previous_scan directory: " "$diff_folder"
36 exit 1
37fi
38
39previous_scan="$(ls -t "$diff_folder" | head -1)"
40if [ -z "$previous_scan" ]; then
41 echo "[*] No previous scan found: This will be the first one."
42 $SCAN_CMD "$@" | sort | tee > "$diff_folder/$(date +%s)"
43 exit 0
44fi
45
46diff <($SCAN_CMD "$@" | sort | tee "$diff_folder/$(date +%s)") <(cat "$diff_folder"/"$previous_scan")
47
48exit 0