File: out_of_date_report_script

package info (click to toggle)
burp 3.1.4-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 3,684 kB
  • sloc: ansic: 50,989; sh: 3,612; cpp: 2,859; makefile: 868
file content (63 lines) | stat: -rw-r--r-- 1,788 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/usr/bin/env bash
#
# This script will generate list of outdated clients
# Create folders /usr/local/share/burp-custom and /var/log/burp-custom
# chmod +x the sh file
# Locate this file in  /usr/local/share/burp-custom/burp-custom-reports.sh
# link to if desired ln -s /usr/local/share/burp-custom/burp-custom-reports.sh /usr/local/bin/bur-custom-reports.sh

outdated=`date -d "1 days ago" +%F`
sendto=emailto@server.com
sendfrom=emailsender@from.com
timestamp=`date +%F-%H-%M`
logfolder=/var/log/burp-custom/


#Variable to use on outdated hosts function
repoutdfile=$logfolder/burp-outdated.$outdated.$timestamp.log
#Variable to use for not outdated hosts function
repokfile=$logfolder/burp-ok.$outdated.$timestamp.log

logsclean(){
    find $logfolder -name "*.log" -type f -mtime +30 -delete
}

make_dirs() {
    if [[ ! -d $1 ]] ; then  mkdir -p $1 ; fi
}

make_dirs "$logfolder"

report_outdated(){
    date_backup=`echo $1 | sed -e 's/\s\+/ /g' | cut -d' ' -f6`
    echo "line is $1"
    echo "date_backup is $date_backup"
    if [[ "$date_backup" < "$outdated" ]] ; then
        echo "$1" >> $repoutdfile
	else 
	    echo "$1" >> $repokfile
    fi
}


reports(){
    report_outdated "$1"
}

send_email_report(){
    cat $1 | mail -s "$2" $sendto -aFrom:$sendfrom
}


# example output line:
# hosname       idle           last backup: 0000023 2015-04-10 16:04:01
# read by line report from burp
burp -a S | grep -i "last backup" | while read -r line; do reports "$line" ; done

echo "finishing and sending email"
#Send email using function, parse file and then subject inside "subject line"
send_email_report $repoutdfile "Outdated hosts older than $outdated on $HOSTNAME"
send_email_report $repokfile "Burp Hosts ok newer than $outdated on $HOSTNAME"

#Clean old logs
logsclean