Advertisement
Guest User

Untitled

a guest
Mar 18th, 2019
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.16 KB | None | 0 0
  1. #!/bin/ksh
  2. #honeyd-syslogger.sh
  3. #
  4. # Parses honeyd logfiles to syslog and sends them to a SIEM.
  5. # This script is compatible with OpenBSD 6.4 and ksh. If
  6. # you're running in Linux/Bash, the commands below should help:
  7. #
  8. # YESTERDAY="$(date -u +"%Y-%m-%d" -d "yesterday")"
  9. #
  10. # Deploy: simply edit global variables according to your
  11. # environment, give this file 0755 permissions, and
  12. # edit crontab to run it periodicaly. Then, add these
  13. # lines to /etc/syslog.conf (change x.x.x.x for your
  14. # SIEM address):
  15. #
  16. # !!logger
  17. # *.* @tls://x.x.x.x
  18. # !*
  19. #
  20. # Author: Jose Lopes <joselopes@cemig.com.br>
  21. # License: MIT
  22. # Date: 2019-03-15
  23. ##
  24.  
  25.  
  26. INPATH="/path/to/log"
  27. OUTPATH="/path/to/aux/dir"
  28. YESTERDAY="$(date -r "$(expr $(date +%s) - 86400)" "+%Y-%m-%d")"
  29. YEAR="$(echo $YESTERDAY | cut -d"-" -f 1)"
  30.  
  31.  
  32. syslogger() {
  33. # $1: listener subdirectory
  34. # $2: listener prefix
  35. # $3: file filter
  36. in="$INPATH/$1/$YEAR/$2.$YESTERDAY"
  37. out="$OUTPATH/$2.$YESTERDAY"
  38. test -e "$in" && \
  39. egrep "$3" "$in" > "$out" && \
  40. logger -i -t logger -f "$out" && \
  41. rm -f "$out"
  42. }
  43.  
  44.  
  45. syslogger "directory_1" "file_prefix_a" ""
  46. syslogger "directory_2" "file_prefix_b" "(regex|optional)"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement