Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- PAST_TIMESTAMP="$(date +%s -d '5 min ago')000"
- mongoexport \
- --csv --quiet \
- --fields timestamp,source_ip,source_port,destination_ip,destination_port,honeypot \
- --db mnemosyne \
- --collection session \
- --query "{ timestamp: {\$gt: new Date($PAST_TIMESTAMP)}}" > /tmp/mhn-report.txt
- if cat /tmp/mhn-report.txt | grep 'dionaea'; # or snort for example
- then
- (
- cat /tmp/mhn-report.txt | tr ',' '\t' > /tmp/mhn-report2.txt;
- echo -e "Recent attack detected:\n" ;
- cat /tmp/mhn-report2.txt
- ) | mail -s "MHN Report: $(date -d '5 min ago')" -a "From: no-reply@mhn.mydomain.tld" user@company.com
- echo attacks detected;
- else
- echo no attacks detected;
- fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement