93,98 → 93,97 |
|
cat $MODEL_TABINFO | while read LINE_HTML |
do |
if [ "$(echo $LINE_HTML | grep 'XXORGXX' | wc -l)" -eq 1 ] |
then |
VALUE=$(grep ^ORGANISM= $CONF_FILE | cut -d'=' -f2-) |
echo ${LINE_HTML/XXORGXX/$VALUE} >> $HTML_REPORT |
|
if [ $(echo $LINE_HTML | grep 'XXORGXX' | wc -l) -eq 1 ] |
then |
VALUE=$(grep ^ORGANISM= $CONF_FILE | cut -d'=' -f2-) |
echo ${LINE_HTML/XXORGXX/$VALUE} >> $HTML_REPORT |
|
elif [ $(echo $LINE_HTML | grep 'XXINSTALLXX' | wc -l) -eq 1 ] |
then |
VALUE=$(grep ^INSTALL_DATE= $CONF_FILE | cut -d'=' -f2) |
echo ${LINE_HTML/XXINSTALLXX/$VALUE} >> $HTML_REPORT |
|
elif [ $(echo $LINE_HTML | grep 'XXAVERSIONXX' | wc -l) -eq 1 ] |
then |
VALUE=$(grep ^VERSION= $CONF_FILE | cut -d'=' -f2) |
echo ${LINE_HTML/XXAVERSIONXX/$VALUE} >> $HTML_REPORT |
|
elif [ $(echo $LINE_HTML | grep 'XXIP_PUBLICXX' | wc -l) -eq 1 ] |
then |
VALUE=$(grep ^PUBLIC_IP= $CONF_FILE | cut -d'=' -f2) |
echo ${LINE_HTML/XXIP_PUBLICXX/$VALUE} >> $HTML_REPORT |
|
elif [ $(echo $LINE_HTML | grep 'XXIP_PRIVEXX' | wc -l) -eq 1 ] |
then |
VALUE=$(grep ^PRIVATE_IP= $CONF_FILE | cut -d'=' -f2) |
echo ${LINE_HTML/XXIP_PRIVEXX/$VALUE} >> $HTML_REPORT |
|
elif [ $(echo $LINE_HTML | grep 'XXGWXX' | wc -l) -eq 1 ] |
then |
VALUE=$(grep ^GW= $CONF_FILE | cut -d'=' -f2) |
echo ${LINE_HTML/XXGWXX/$VALUE} >> $HTML_REPORT |
|
elif [ $(echo $LINE_HTML | grep 'XXDNS1XX' | wc -l) -eq 1 ] |
then |
VALUE=$(grep ^DNS1= $CONF_FILE | cut -d'=' -f2) |
echo ${LINE_HTML/XXDNS1XX/$VALUE} >> $HTML_REPORT |
|
elif [ $(echo $LINE_HTML | grep 'XXDNS2XX' | wc -l) -eq 1 ] |
then |
VALUE=$(grep ^DNS2= $CONF_FILE | cut -d'=' -f2) |
echo ${LINE_HTML/XXDNS2XX/$VALUE} >> $HTML_REPORT |
|
elif [ $(echo $LINE_HTML | grep 'XXHOSTXX' | wc -l) -eq 1 ] |
then |
VALUE=$(hostname) |
echo ${LINE_HTML/XXHOSTXX/$VALUE} >> $HTML_REPORT |
|
elif [ $(echo $LINE_HTML | grep 'XXOS_VERSIONXX' | wc -l) -eq 1 ] |
then |
VALUE=$( echo $(uname -r) [ $(uname -m) ] ) |
echo ${LINE_HTML/XXOS_VERSIONXX/$VALUE} >> $HTML_REPORT |
|
elif [ $(echo $LINE_HTML | grep 'XXREBOOTXX' | wc -l) -eq 1 ] |
then |
VALUE=$(echo $(who -b | cut -d' ' -f12-)) |
echo ${LINE_HTML/XXREBOOTXX/$VALUE} >> $HTML_REPORT |
|
elif [ $(echo $LINE_HTML | grep 'XXMAJCLAMAVXX' | wc -l) -eq 1 ] |
then |
VALUE=$(date -d @$(rpm -qa --queryformat "%{installtime} %{name}\n" | grep -E "clamav-db" | cut -d' ' -f1 ) "+%Y-%m-%d %H:%M:%S") |
echo ${LINE_HTML/XXMAJCLAMAVXX/$VALUE} >> $HTML_REPORT |
|
elif [ $(echo $LINE_HTML | grep 'XXMAJBLXX' | wc -l) -eq 1 ] |
then |
VALUE=$(cat /etc/e2guardian/lists/blacklists/README | grep 'Last version' | cut -d' ' -f4-6) |
echo ${LINE_HTML/XXMAJBLXX/$VALUE} >> $HTML_REPORT |
|
elif [ $(echo $LINE_HTML | grep 'XXRPMXX' | wc -l) -eq 1 ] |
then |
#show every ALCASAR RPM updated since X day ago |
#get timestamp of X day ago. Then we get every packets chich have been updated since this date. |
if [ $(rpm -qa --queryformat '%{installtime} %{name} %{version}\n' | awk -v seuil="$SECS_AGO" '$1 > seuil' | sort -n | grep -E "$PACKAGE" | wc -l) -gt 1 ] |
elif [ "$(echo $LINE_HTML | grep 'XXINSTALLXX' | wc -l)" -eq 1 ] |
then |
PACKAGE='php|lighttpd|iptables|dnsmasq|radius|tinyproxy|nfdump|e2guardian|clamav|ulogd|chilli|fail2ban|openssh|havp|ipt-netflow|wget' |
rpm -qa --queryformat '%{installtime} %{name} %{version}\n' | awk -v seuil="$SECS_AGO" '$1 > seuil' | sort -n | grep -E "$PACKAGE" | while read RPM_ALCASAR |
do |
RPM_TIMESTAMP=$(echo $RPM_ALCASAR | cut -d' ' -f1) |
RPM_DATE=$(date -d @$(echo $RPM_TIMESTAMP) "+%Y-%m-%d %H:%M:%S") |
RPM_NAME=$(echo $RPM_ALCASAR | cut -d' ' -f2) |
RPM_VERSION=$(echo $RPM_ALCASAR | cut -d' ' -f3) |
VALUE=$(grep ^INSTALL_DATE= $CONF_FILE | cut -d'=' -f2) |
echo ${LINE_HTML/XXINSTALLXX/$VALUE} >> $HTML_REPORT |
|
echo "<tr>" >> $HTML_REPORT |
echo "<td>$RPM_NAME</td>" >> $HTML_REPORT |
echo "<td>$RPM_DATE</td>" >> $HTML_REPORT |
echo "<td>$RPM_VERSION</td>" >> $HTML_REPORT |
echo "</tr>" >> $HTML_REPORT |
done |
elif [ "$(echo $LINE_HTML | grep 'XXAVERSIONXX' | wc -l)" -eq 1 ] |
then |
VALUE=$(grep ^VERSION= $CONF_FILE | cut -d'=' -f2) |
echo ${LINE_HTML/XXAVERSIONXX/$VALUE} >> $HTML_REPORT |
|
elif [ "$(echo $LINE_HTML | grep 'XXIP_PUBLICXX' | wc -l)" -eq 1 ] |
then |
VALUE=$(grep ^PUBLIC_IP= $CONF_FILE | cut -d'=' -f2) |
echo ${LINE_HTML/XXIP_PUBLICXX/$VALUE} >> $HTML_REPORT |
|
elif [ "$(echo $LINE_HTML | grep 'XXIP_PRIVEXX' | wc -l)" -eq 1 ] |
then |
VALUE=$(grep ^PRIVATE_IP= $CONF_FILE | cut -d'=' -f2) |
echo ${LINE_HTML/XXIP_PRIVEXX/$VALUE} >> $HTML_REPORT |
|
elif [ "$(echo $LINE_HTML | grep 'XXGWXX' | wc -l)" -eq 1 ] |
then |
VALUE=$(grep ^GW= $CONF_FILE | cut -d'=' -f2) |
echo ${LINE_HTML/XXGWXX/$VALUE} >> $HTML_REPORT |
|
elif [ "$(echo $LINE_HTML | grep 'XXDNS1XX' | wc -l)" -eq 1 ] |
then |
VALUE=$(grep ^DNS1= $CONF_FILE | cut -d'=' -f2) |
echo ${LINE_HTML/XXDNS1XX/$VALUE} >> $HTML_REPORT |
|
elif [ "$(echo $LINE_HTML | grep 'XXDNS2XX' | wc -l)" -eq 1 ] |
then |
VALUE=$(grep ^DNS2= $CONF_FILE | cut -d'=' -f2) |
echo ${LINE_HTML/XXDNS2XX/$VALUE} >> $HTML_REPORT |
|
elif [ "$(echo $LINE_HTML | grep 'XXHOSTXX' | wc -l)" -eq 1 ] |
then |
VALUE=$(hostname) |
echo ${LINE_HTML/XXHOSTXX/$VALUE} >> $HTML_REPORT |
|
elif [ "$(echo $LINE_HTML | grep 'XXOS_VERSIONXX' | wc -l)" -eq 1 ] |
then |
VALUE=$(echo "$(uname -r) [ $(uname -m) ]") |
echo ${LINE_HTML/XXOS_VERSIONXX/$VALUE} >> $HTML_REPORT |
|
elif [ "$(echo $LINE_HTML | grep 'XXREBOOTXX' | wc -l)" -eq 1 ] |
then |
VALUE=$(who -b | cut -d' ' -f12-) |
echo ${LINE_HTML/XXREBOOTXX/$VALUE} >> $HTML_REPORT |
|
elif [ "$(echo $LINE_HTML | grep 'XXMAJCLAMAVXX' | wc -l)" -eq 1 ] |
then |
VALUE=$(date -d "@$(rpm -qa --queryformat "%{installtime} %{name}\n" | grep -E "clamav-db" | cut -d' ' -f1 )" "+%Y-%m-%d %H:%M:%S") |
echo ${LINE_HTML/XXMAJCLAMAVXX/$VALUE} >> $HTML_REPORT |
|
elif [ "$(echo $LINE_HTML | grep 'XXMAJBLXX' | wc -l)" -eq 1 ] |
then |
VALUE=$(cat /etc/e2guardian/lists/blacklists/README | grep 'Last version' | cut -d' ' -f4-6) |
echo ${LINE_HTML/XXMAJBLXX/$VALUE} >> $HTML_REPORT |
|
elif [ "$(echo $LINE_HTML | grep 'XXRPMXX' | wc -l)" -eq 1 ] |
then |
#show every ALCASAR RPM updated since X day ago |
#get timestamp of X day ago. Then we get every packets chich have been updated since this date. |
if [ "$(rpm -qa --queryformat '%{installtime} %{name} %{version}\n' | awk -v seuil="$SECS_AGO" '$1 > seuil' | sort -n | grep -E "$PACKAGE" | wc -l)" -gt 1 ] |
then |
PACKAGE='php|lighttpd|iptables|dnsmasq|unbound|radius|tinyproxy|nfdump|e2guardian|clamav|ulogd|chilli|fail2ban|openssh|havp|ipt-netflow|wget' |
rpm -qa --queryformat '%{installtime} %{name} %{version}\n' | awk -v seuil="$SECS_AGO" '$1 > seuil' | sort -n | grep -E "$PACKAGE" | while read RPM_ALCASAR |
do |
RPM_TIMESTAMP=$(echo $RPM_ALCASAR | cut -d' ' -f1) |
RPM_DATE=$(date -d "@$(echo $RPM_TIMESTAMP)" "+%Y-%m-%d %H:%M:%S") |
RPM_NAME=$(echo $RPM_ALCASAR | cut -d' ' -f2) |
RPM_VERSION=$(echo $RPM_ALCASAR | cut -d' ' -f3) |
|
echo "<tr>" >> $HTML_REPORT |
echo "<td>$RPM_NAME</td>" >> $HTML_REPORT |
echo "<td>$RPM_DATE</td>" >> $HTML_REPORT |
echo "<td>$RPM_VERSION</td>" >> $HTML_REPORT |
echo "</tr>" >> $HTML_REPORT |
done |
else |
echo "<tr><td colspan=\"3\">Pas de RPM mis à jour cette semaine</td></tr>" >> $HTML_REPORT |
fi |
else |
echo "<tr><td colspan=\"3\">Pas de RPM mis à jour cette semaine</td></tr>" >> $HTML_REPORT |
echo $LINE_HTML >> $HTML_REPORT |
fi |
else |
echo $LINE_HTML >> $HTML_REPORT |
fi |
done |
|
######################BL WEBSITE SINCE INSTALLATION###################### |
192,45 → 191,36 |
#find data |
|
#decompress every logs |
if [ $(ls -1 /var/log/dnsmasq/dnsmasq-blacklist.log.*.gz 2>/dev/null | wc -l) -ge 1 ] |
if [ "$(ls -1 /var/log/unbound/unbound-blacklist.log.*.gz 2>/dev/null | wc -l)" -ge 1 ] |
then |
gunzip -d dnsmasq-blacklist.log.*.gz |
gunzip -d unbound-blacklist.log.*.gz |
fi |
|
#convert logs date in timestamp and find categories of blacklisted website |
for FILE in $(ls -1 /var/log/dnsmasq/ | grep 'dnsmasq-blacklist.log') |
tmp_log=$(mktemp) |
for FILE in /var/log/unbound/unbound-blacklist.log* |
do |
grep -E "info: [^ ]+ typetransparent $PRIVATE_IP" /var/log/unbound/unbound-blacklist.log > $tmp_log |
while read LOG_BL |
do |
if [ $(echo $LOG_BL | grep config | grep $PRIVATE_IP | wc -c) -ge 1 ] |
# find the current blacklisted category |
website_bl=$(echo $LOG_BL | cut -d' ' -f4) |
website_bl=${website_bl%?} # remove the last character |
|
#we convert www.test.co.uk => test.co.uk to find the category of this website |
if [ "$(grep -o '\.' <<< "$website_bl" | wc -l)" -ge "2" ] |
then |
#find the current blacklisted category |
website_bl=$(echo $LOG_BL | cut -d' ' -f6) |
|
#we convert www.test.co.uk => test.co.uk to find the category of this website |
if [ $(grep -o '\.' <<< "$website_bl" | wc -l) -ge "2" ] |
then |
website_bl=$(echo $website_bl | cut -d'.' -f2-) |
fi |
website_bl=$(echo $website_bl | cut -d'.' -f2-) |
fi |
|
#get BL category |
categorie_bl=$(grep -R "$website_bl/" /usr/local/share/dnsmasq-bl-enabled/ | cut -d':' -f1 | cut -d'/' -f6 | cut -d' ' -f1) |
if [ $(echo $categorie_bl | wc -w) -gt 1 ] |
then |
categorie_bl=$(grep -R "/$website_bl/" /usr/local/share/dnsmasq-bl-enabled/ | cut -d':' -f1 | cut -d'/' -f6 | cut -d' ' -f1 | head -1) |
fi |
|
#Calculate its timestamp |
Y=$(date -R | cut -d' ' -f4) |
M=$(echo $LOG_BL | cut -d' ' -f1) |
D=$(echo $LOG_BL | cut -d' ' -f2) |
H=$(echo $LOG_BL | cut -d' ' -f3) |
CURRENT_TS=$(date -d "$M $D $Y $H" +"%s") |
echo "$CURRENT_TS:$categorie_bl:" >> $TMP_BL |
fi |
|
done < /var/log/dnsmasq/$FILE |
#get BL category |
categorie_bl=$(grep -Rl "$website_bl" /usr/local/share/unbound-bl-enabled/ | cut -d'/' -f6 | head -1) |
|
CURRENT_TS=$(echo $LOG_BL | cut -d '[' -f2 | cut -d ']' -f1) |
echo "$CURRENT_TS:$categorie_bl:" >> $TMP_BL |
done < $tmp_log |
done |
rm $tmp_log |
|
#if data exists, create this section in html document |
if [ -e $TMP_BL ] |
244,19 → 234,18 |
do |
DATE_1=$TS |
DATE_2=$((TS-$STEP_TS)) |
COUNT_BL_INSTALLATION=0 |
|
COUNT_BL_INSTALLATION=0 |
|
for LINE in $(cat $TMP_BL) |
do |
TS_FILE=$(echo $LINE | cut -d':' -f1) |
|
if [ "$TS_FILE" -le "$DATE_1" -a "$TS_FILE" -ge "$DATE_2" ] |
|
if [ "$TS_FILE" -le "$DATE_1" ] && [ "$TS_FILE" -ge "$DATE_2" ] |
then |
COUNT_BL_INSTALLATION=$((COUNT_BL_INSTALLATION+1)) |
|
fi |
done |
|
|
VALUE_BL_INSTALLATION_LABEL="'$(date -d @$DATE_2 "+%Y-%m-%d" )', $VALUE_BL_INSTALLATION_LABEL" |
VALUE_BL_INSTALLATION_DATA="$COUNT_BL_INSTALLATION, $VALUE_BL_INSTALLATION_DATA" |
done |
273,41 → 262,41 |
cat $MODEL_CHARTJS | while read LINE_JS |
do |
#name of variable |
if [ $(echo $LINE_JS | grep 'XXCONFXX' | wc -l) -eq 1 ] |
if [ "$(echo $LINE_JS | grep 'XXCONFXX' | wc -l)" -eq 1 ] |
then |
echo ${LINE_JS/XXCONFXX/$CONF_BL_INSTALLATION} >> $HTML_REPORT |
#chart type |
elif [ $(echo $LINE_JS | grep 'XXTYPEXX' | wc -l) -eq 1 ] |
elif [ "$(echo $LINE_JS | grep 'XXTYPEXX' | wc -l)" -eq 1 ] |
then |
echo ${LINE_JS/XXTYPEXX/bar} >> $HTML_REPORT |
#chart title |
elif [ $(echo $LINE_JS | grep 'XXTITLEXX' | wc -l) -eq 1 ] |
elif [ "$(echo $LINE_JS | grep 'XXTITLEXX' | wc -l)" -eq 1 ] |
then |
echo ${LINE_JS/XXTITLEXX/"Sites bloqués au total"} >> $HTML_REPORT |
#chart data |
elif [ $(echo $LINE_JS | grep 'XXDATAXX' | wc -l) -eq 1 ] |
elif [ "$(echo $LINE_JS | grep 'XXDATAXX' | wc -l)" -eq 1 ] |
then |
echo ${LINE_JS/XXDATAXX/$VALUE_BL_INSTALLATION_DATA} >> $HTML_REPORT |
#color |
elif [ $(echo $LINE_JS | grep 'XXCOLORXX' | wc -l) -eq 1 ] |
elif [ "$(echo $LINE_JS | grep 'XXCOLORXX' | wc -l)" -eq 1 ] |
then |
echo ${LINE_JS/XXCOLORXX/$COLOR} >> $HTML_REPORT |
#labels |
elif [ $(echo $LINE_JS | grep 'XXLABELSXX' | wc -l) -eq 1 ] |
elif [ "$(echo $LINE_JS | grep 'XXLABELSXX' | wc -l)" -eq 1 ] |
then |
echo ${LINE_JS/XXLABELSXX/$VALUE_BL_INSTALLATION_LABEL} >> $HTML_REPORT |
elif [ $(echo $LINE_JS | grep 'XXLEGENDXX' | wc -l) -eq 1 ] |
elif [ "$(echo $LINE_JS | grep 'XXLEGENDXX' | wc -l)" -eq 1 ] |
then |
echo ${LINE_JS/XXLEGENDXX/false} >> $HTML_REPORT |
#display value of Y axis, only useful for chart bar |
elif [ $(echo $LINE_JS | grep 'XXCOMMENT-BEGINXX' | wc -l) -eq 1 ] |
elif [ "$(echo $LINE_JS | grep 'XXCOMMENT-BEGINXX' | wc -l)" -eq 1 ] |
then |
echo "" >> $HTML_REPORT |
#display value of Y axis, only useful for chart bar |
elif [ $(echo $LINE_JS | grep 'XXCOMMENT-ENDXX' | wc -l) -eq 1 ] |
elif [ "$(echo $LINE_JS | grep 'XXCOMMENT-ENDXX' | wc -l)" -eq 1 ] |
then |
echo "" >> $HTML_REPORT |
elif [ $(echo $LINE_JS | grep 'XXYLABELXX' | wc -l) -eq 1 ] |
elif [ "$(echo $LINE_JS | grep 'XXYLABELXX' | wc -l)" -eq 1 ] |
then |
echo "\"Nombre de site bloqué par la blacklist\"" >> $HTML_REPORT |
else |
321,7 → 310,7 |
|
|
|
######################DNSMASQ BLACKLIST###################### |
######################Unbound BLACKLIST###################### |
echo "Create BL website since $MAX_DAY_AGO days" |
|
#if data exists, create BL section in html document |
339,7 → 328,7 |
do |
TS_FILE=$(echo $LINE | cut -d':' -f1) |
#select only elements between DATE_1 and DATE_2 |
if [ "$TS_FILE" -le "$DATE_1" -a "$TS_FILE" -ge "$DATE_2" ] |
if [ "$TS_FILE" -le "$DATE_1" ] && [ "$TS_FILE" -ge "$DATE_2" ] |
then |
echo $LINE >> $TMP_BL_WEEK |
fi |
346,7 → 335,7 |
done |
|
#then we count every occurence for each category in TMP_BL_WEEK |
for CAT in $(ls /usr/local/share/dnsmasq-bl/ -1 | cut -d'.' -f1) |
for CAT in $(ls /usr/local/share/unbound-bl/ -1 | cut -d'.' -f1) |
do |
echo "$CAT:$(grep -o ":$CAT:" <<< "$(cat $TMP_BL_WEEK)" | wc -l):" >> $TMP_BL_WEEK_CAT |
done |
354,7 → 343,7 |
#we sort by number of occurence and we take the top 10 BL categories |
for LINE in $(sort -t':' -k2 -rn $TMP_BL_WEEK_CAT | head -n 10) |
do |
|
|
DATA=$(echo $LINE | cut -d':' -f2) |
LABEL=$(echo $LINE | cut -d':' -f1) |
if [ $DATA -ne 0 ] |
365,7 → 354,7 |
done |
|
#get other categories (sum them all) |
if [ $(cat $TMP_BL_WEEK_CAT | cut -d':' -f2 | sort -k1 -rn | tail -n+$(($(echo $VALUE_BL_DATA | wc -w)+1)) | paste -sd+ | bc) -gt 0 ] |
if [ "$(cat $TMP_BL_WEEK_CAT | cut -d':' -f2 | sort -k1 -rn | tail -n+$(($(echo $VALUE_BL_DATA | wc -w)+1)) | paste -sd+ | bc)" -gt 0 ] |
then |
VALUE_BL_DATA="$VALUE_BL_DATA $(cat $TMP_BL_WEEK_CAT | cut -d':' -f2 | sort -k1 -rn | tail -n+$(($(echo $VALUE_BL_DATA | wc -w)+1)) | paste -sd+ | bc)" |
VALUE_BL_LABEL="$VALUE_BL_LABEL 'autre ($(cat $TMP_BL_WEEK_CAT | cut -d':' -f2 | sort -k1 -rn | tail -n+$(($(echo $VALUE_BL_DATA | wc -w)+1)) | paste -sd+ | bc))'" |
382,39 → 371,39 |
cat $MODEL_CHARTJS | while read LINE_JS |
do |
#variable name |
if [ $(echo $LINE_JS | grep 'XXCONFXX' | wc -l) -eq 1 ] |
if [ "$(echo $LINE_JS | grep 'XXCONFXX' | wc -l)" -eq 1 ] |
then |
echo ${LINE_JS/XXCONFXX/$CONF_BL} >> $HTML_REPORT |
#chart type |
elif [ $(echo $LINE_JS | grep 'XXTYPEXX' | wc -l) -eq 1 ] |
elif [ "$(echo $LINE_JS | grep 'XXTYPEXX' | wc -l)" -eq 1 ] |
then |
echo ${LINE_JS/XXTYPEXX/pie} >> $HTML_REPORT |
#graph title |
elif [ $(echo $LINE_JS | grep 'XXTITLEXX' | wc -l) -eq 1 ] |
elif [ "$(echo $LINE_JS | grep 'XXTITLEXX' | wc -l)" -eq 1 ] |
then |
echo ${LINE_JS/XXTITLEXX/"Sites bloqués cette semaine"} >> $HTML_REPORT |
#chart data |
elif [ $(echo $LINE_JS | grep 'XXDATAXX' | wc -l) -eq 1 ] |
elif [ "$(echo $LINE_JS | grep 'XXDATAXX' | wc -l)" -eq 1 ] |
then |
echo ${LINE_JS/XXDATAXX/$VALUE_BL_DATA} >> $HTML_REPORT |
#color |
elif [ $(echo $LINE_JS | grep 'XXCOLORXX' | wc -l) -eq 1 ] |
elif [ "$(echo $LINE_JS | grep 'XXCOLORXX' | wc -l)" -eq 1 ] |
then |
echo ${LINE_JS/XXCOLORXX/$COLOR} >> $HTML_REPORT |
#labels |
elif [ $(echo $LINE_JS | grep 'XXLABELSXX' | wc -l) -eq 1 ] |
elif [ "$(echo $LINE_JS | grep 'XXLABELSXX' | wc -l)" -eq 1 ] |
then |
echo ${LINE_JS/XXLABELSXX/$VALUE_BL_LABEL} >> $HTML_REPORT |
#display legend, only useful for chart pie |
elif [ $(echo $LINE_JS | grep 'XXLEGENDXX' | wc -l) -eq 1 ] |
elif [ "$(echo $LINE_JS | grep 'XXLEGENDXX' | wc -l)" -eq 1 ] |
then |
echo ${LINE_JS/XXLEGENDXX/true} >> $HTML_REPORT |
#display value of Y axis, only useful for chart bar |
elif [ $(echo $LINE_JS | grep 'XXCOMMENT-BEGINXX' | wc -l) -eq 1 ] |
elif [ "$(echo $LINE_JS | grep 'XXCOMMENT-BEGINXX' | wc -l)" -eq 1 ] |
then |
echo "/*" >> $HTML_REPORT |
#display value of Y axis, only useful for chart bar |
elif [ $(echo $LINE_JS | grep 'XXCOMMENT-ENDXX' | wc -l) -eq 1 ] |
elif [ "$(echo $LINE_JS | grep 'XXCOMMENT-ENDXX' | wc -l)" -eq 1 ] |
then |
echo "*/" >> $HTML_REPORT |
else |
430,12 → 419,12 |
echo "Create AV logs since the installation of ALCASAR" |
|
#decompress every logs, if they exist |
if [ $(ls -1 /var/log/havp/access.log.*.gz 2>/dev/null | wc -l) -ge 1 ] |
if [ "$(ls -1 /var/log/havp/access.log.*.gz 2>/dev/null | wc -l)" -ge 1 ] |
then |
gunzip -d access.log.*.gz |
fi |
|
for FILE in $(ls -1 /var/log/havp/ | grep 'access.log') |
for FILE in /var/log/havp/access.log* |
do |
while read LINE_AV |
do |
445,8 → 434,7 |
H=$(echo $LINE_AV | cut -d' ' -f4) |
CURRENT_TS=$(date -d "$M $D $Y $H" +"%s") |
echo $CURRENT_TS >> $TMP_AV |
done < /var/log/havp/$FILE |
|
done < $FILE |
done |
|
if [ -e $TMP_AV ] |
461,7 → 449,7 |
|
for TS_FILE in $(cat $TMP_AV) |
do |
if [ "$TS_FILE" -le "$DATE_1" -a "$TS_FILE" -ge "$DATE_2" ] |
if [ "$TS_FILE" -le "$DATE_1" ] && [ "$TS_FILE" -ge "$DATE_2" ] |
then |
COUNT_AV=$((COUNT_AV+1)) |
fi |
470,7 → 458,7 |
VALUE_AV_LABEL="'$(date -d @$DATE_2 "+%Y-%m-%d" )', $VALUE_AV_LABEL" |
VALUE_AV_DATA="$COUNT_AV, $VALUE_AV_DATA" |
done |
|
|
#create Antivirus section in html document |
NAME_AV='chart_av' |
CONF_AV='config_av' |
484,41 → 472,41 |
cat $MODEL_CHARTJS | while read LINE_JS |
do |
#name of variable |
if [ $(echo $LINE_JS | grep 'XXCONFXX' | wc -l) -eq 1 ] |
if [ "$(echo $LINE_JS | grep 'XXCONFXX' | wc -l)" -eq 1 ] |
then |
echo ${LINE_JS/XXCONFXX/$CONF_AV} >> $HTML_REPORT |
#chart type |
elif [ $(echo $LINE_JS | grep 'XXTYPEXX' | wc -l) -eq 1 ] |
elif [ "$(echo $LINE_JS | grep 'XXTYPEXX' | wc -l)" -eq 1 ] |
then |
echo ${LINE_JS/XXTYPEXX/bar} >> $HTML_REPORT |
#graph title |
elif [ $(echo $LINE_JS | grep 'XXTITLEXX' | wc -l) -eq 1 ] |
elif [ "$(echo $LINE_JS | grep 'XXTITLEXX' | wc -l)" -eq 1 ] |
then |
echo ${LINE_JS/XXTITLEXX/"Menaces bloqués par l\'antivirus"} >> $HTML_REPORT |
#chart data |
elif [ $(echo $LINE_JS | grep 'XXDATAXX' | wc -l) -eq 1 ] |
elif [ "$(echo $LINE_JS | grep 'XXDATAXX' | wc -l)" -eq 1 ] |
then |
echo ${LINE_JS/XXDATAXX/$VALUE_AV_DATA} >> $HTML_REPORT |
#color |
elif [ $(echo $LINE_JS | grep 'XXCOLORXX' | wc -l) -eq 1 ] |
elif [ "$(echo $LINE_JS | grep 'XXCOLORXX' | wc -l)" -eq 1 ] |
then |
echo ${LINE_JS/XXCOLORXX/$COLOR} >> $HTML_REPORT |
#labels |
elif [ $(echo $LINE_JS | grep 'XXLABELSXX' | wc -l) -eq 1 ] |
elif [ "$(echo $LINE_JS | grep 'XXLABELSXX' | wc -l)" -eq 1 ] |
then |
echo ${LINE_JS/XXLABELSXX/$VALUE_AV_LABEL} >> $HTML_REPORT |
elif [ $(echo $LINE_JS | grep 'XXLEGENDXX' | wc -l) -eq 1 ] |
elif [ "$(echo $LINE_JS | grep 'XXLEGENDXX' | wc -l)" -eq 1 ] |
then |
echo ${LINE_JS/XXLEGENDXX/false} >> $HTML_REPORT |
#display value of Y axis, only useful for chart bar |
elif [ $(echo $LINE_JS | grep 'XXCOMMENT-BEGINXX' | wc -l) -eq 1 ] |
elif [ "$(echo $LINE_JS | grep 'XXCOMMENT-BEGINXX' | wc -l)" -eq 1 ] |
then |
echo "" >> $HTML_REPORT |
#display value of Y axis, only useful for chart bar |
elif [ $(echo $LINE_JS | grep 'XXCOMMENT-ENDXX' | wc -l) -eq 1 ] |
elif [ "$(echo $LINE_JS | grep 'XXCOMMENT-ENDXX' | wc -l)" -eq 1 ] |
then |
echo "" >> $HTML_REPORT |
elif [ $(echo $LINE_JS | grep 'XXYLABELXX' | wc -l) -eq 1 ] |
elif [ "$(echo $LINE_JS | grep 'XXYLABELXX' | wc -l)" -eq 1 ] |
then |
echo "\"Nombre de menaces virales bloqués par l'antivirus\"" >> $HTML_REPORT |
else |
538,7 → 526,7 |
|
#create new htdigest user to consult statistique of ACC |
#if user does not exist, we create him |
if [ $(grep "$tmp_account:" $DIR_KEY/key_only_manager | wc -l) -lt 1 ] |
if [ "$(grep "$tmp_account:" $DIR_KEY/key_only_manager | wc -l)" -lt 1 ] |
then |
(echo -n "$tmp_account:$realm:" && echo -n "$tmp_account:$realm:$password" | md5sum | awk '{print $1}' ) >> $DIR_KEY/key_only_manager |
(echo -n "$tmp_account:$realm:" && echo -n "$tmp_account:$realm:$password" | md5sum | awk '{print $1}' ) >> $DIR_KEY/key_manager |
557,7 → 545,7 |
cat $TMP_STATS_2 | sed -e 's:images/pixel.gif:../../manager/htdocs/images/pixel.gif:g' >> $HTML_REPORT |
|
#we delete our user if he still exists |
if [ $(grep "$tmp_account:" $DIR_KEY/key_only_manager | wc -l) -ge 1 ] |
if [ "$(grep "$tmp_account:" $DIR_KEY/key_only_manager | wc -l)" -ge 1 ] |
then |
$SED "/^$tmp_account:/d" $DIR_KEY/key_only_manager |
$SED "/^$tmp_account:/d" $DIR_KEY/key_manager |
595,7 → 583,7 |
echo "<h2>Connexion à l'ALCASAR Control Center (ACC)</h2>" >> $HTML_REPORT |
echo "<table class=\"table table-striped\">" >> $HTML_REPORT |
echo "<thead><tr><th>Date</th><th>Utilisateur</th><th>Adresse IP</th><th>Agent</th></tr></thead><tbody>" >> $HTML_REPORT |
echo $ROWS >> $HTML_REPORT |
echo "$ROWS" >> $HTML_REPORT |
echo "</tbody></table>" >> $HTML_REPORT |
|
|
640,7 → 628,7 |
echo "<h2>Trafic global</h2>" >> $HTML_REPORT |
echo "<table class=\"table table-striped\">" >> $HTML_REPORT |
echo "<thead><tr><th>Date</th><th>Entrant</th><th>Sortant</th><th>Total</th></tr></thead><tbody>" >> $HTML_REPORT |
echo $ROWS >> $HTML_REPORT |
echo "$ROWS" >> $HTML_REPORT |
echo "</tbody></table>" >> $HTML_REPORT |
|
|
698,21 → 686,21 |
echo "</html>" >> $HTML_REPORT |
|
#convert html document to PDF |
/usr/bin/wkhtmltopdf $HTML_REPORT $(echo $HTML_REPORT | cut -d'.' -f1).pdf |
chown apache:apache $(echo $HTML_REPORT | cut -d'.' -f1).pdf |
chmod 644 $(echo $HTML_REPORT | cut -d'.' -f1).pdf |
mv $(echo $HTML_REPORT | cut -d'.' -f1).pdf /var/Save/activity_report/ |
/usr/bin/wkhtmltopdf $HTML_REPORT "$(echo $HTML_REPORT | cut -d'.' -f1).pdf" |
chown apache:apache "$(echo $HTML_REPORT | cut -d'.' -f1).pdf" |
chmod 644 "$(echo $HTML_REPORT | cut -d'.' -f1).pdf" |
mv "$(echo $HTML_REPORT | cut -d'.' -f1).pdf" /var/Save/activity_report/ |
|
#compress every logs, if they exist |
if [ $(ls -1 /var/log/havp/access.log.* 2>/dev/null | wc -l) -ge 1 ] |
if [ "$(ls -1 /var/log/havp/access.log.* 2>/dev/null | wc -l)" -ge 1 ] |
then |
gzip /var/log/havp/access.log.* |
fi |
|
#compress every logs |
if [ $(ls -1 /var/log/dnsmasq/dnsmasq-blacklist.log.* 2>/dev/null | wc -l) -ge 1 ] |
if [ "$(ls -1 /var/log/unbound/unbound-blacklist.log.* 2>/dev/null | wc -l)" -ge 1 ] |
then |
gzip /var/log/dnsmasq/dnsmasq-blacklist.log.* |
gzip /var/log/unbound/unbound-blacklist.log.* |
fi |
|
#remove our files |