Guest User

Untitled

a guest
Jan 22nd, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.23 KB | None | 0 0
  1. #!/bin/sh
  2.  
  3. . /etc/asl/config
  4.  
  5. MYSQL="/usr/bin/mysql"
  6.  
  7. echo "Total events in last 24 hours:"
  8. $MYSQL -u$OSSEC_DATABASE_USERNAME -p$OSSEC_DATABASE_PASSWORD $OSSEC_DATABASE -B -e \
  9. "select count(*) from alert where timestamp > (UNIX_TIMESTAMP() - 86400);"
  10.  
  11.  
  12. echo
  13.  
  14.  
  15.  
  16. count=16
  17. while [ $count -gt 0 ]
  18. do
  19. count=`expr $count - 1`
  20. echo -n "Total Level $count events:"
  21.  
  22. $MYSQL -u$OSSEC_DATABASE_USERNAME -p$OSSEC_DATABASE_PASSWORD $OSSEC_DATABASE -B -e \
  23. "select count(alert.rule_id) from alert LEFT JOIN signature on alert.rule_id = signature.rule_id where signature.level = $count and alert.timestamp > (UNIX_TIMESTAMP() - 86400);"
  24. echo
  25. done # End of loop
  26.  
  27.  
  28.  
  29. # Web attacks: 60118
  30. echo -n "Web attacks: "
  31. $MYSQL -u$OSSEC_DATABASE_USERNAME -p$OSSEC_DATABASE_PASSWORD $OSSEC_DATABASE -B -e \
  32. "select count(rule_id) from alert where rule_id = '60118' and alert.timestamp > (UNIX_TIMESTAMP() - 86400);"
  33.  
  34. # Top 10 Web attackers
  35. ## select src_ip from alert where rule_id = '60118' and alert.timestamp > (UNIX_TIMESTAMP() - 86400);
  36. echo -n "Top 10 Attackers: "
  37. $MYSQL -u$OSSEC_DATABASE_USERNAME -p$OSSEC_DATABASE_PASSWORD $OSSEC_DATABASE -B -e \
  38. "select inet_ntoa(src_ip), count(*) as tmp from alert where rule_id = '60118' and alert.timestamp > (UNIX_TIMESTAMP() - 86400) group by rule_id, src_ip order by tmp desc limit 10;"
  39.  
  40. # Invalid user attempts
  41. echo -n "Top 10 Invalid User Attempt IP's in the last 24 hours: "
  42. $MYSQL -u$OSSEC_DATABASE_USERNAME -p$OSSEC_DATABASE_PASSWORD $OSSEC_DATABASE -B -e \
  43. "select inet_ntoa(src_ip), count(*) as tmp from alert where rule_id = '5712' and alert.timestamp > (UNIX_TIMESTAMP() - 86400) group by rule_id, src_ip order by tmp desc limit 10;"
  44.  
  45.  
  46. #
  47. echo -n "Top 10 Invalid User Attempt IP's in the last 72 hours: "
  48. $MYSQL -u$OSSEC_DATABASE_USERNAME -p$OSSEC_DATABASE_PASSWORD $OSSEC_DATABASE -B -e \
  49. "select inet_ntoa(src_ip), count(*) as tmp from alert where rule_id = '5712' and alert.timestamp > (UNIX_TIMESTAMP() - 259200) group by rule_id, src_ip order by tmp desc limit 10;"
  50.  
  51.  
  52. echo -n "Top 25 Invalid User Attempt IP's in the last 30 days: "
  53. $MYSQL -u$OSSEC_DATABASE_USERNAME -p$OSSEC_DATABASE_PASSWORD $OSSEC_DATABASE -B -e \
  54. "select inet_ntoa(src_ip), count(*) as tmp from alert where rule_id = '5712' and alert.timestamp > (UNIX_TIMESTAMP() - 2592000) group by rule_id, src_ip order by tmp desc limit 25;"
  55.  
  56.  
  57.  
  58.  
  59. echo -n "Top 10 Alerts in the last 24 hours:"
  60. $MYSQL -u$OSSEC_DATABASE_USERNAME -p$OSSEC_DATABASE_PASSWORD $OSSEC_DATABASE -B -e \
  61. "select alert.rule_id, count(*) as tmp from alert LEFT JOIN signature on alert.rule_id = signature.rule_id where signature.level > 6 and alert.timestamp > (UNIX_TIMESTAMP() - 86400) group by alert.rule_id order by tmp desc limit 10;"
  62.  
  63. echo -n "Top 10 Alerts in the DB "
  64. $MYSQL -u$OSSEC_DATABASE_USERNAME -p$OSSEC_DATABASE_PASSWORD $OSSEC_DATABASE -B -e \
  65. "select alert.rule_id, count(*) as tmp from alert LEFT JOIN signature on alert.rule_id = signature.rule_id where signature.level > 6 group by alert.rule_id order by tmp desc limit 10;";
  66.  
  67.  
  68. # 40113 is viruses detected.
  69.  
  70. # 4701 ssh protocol mismatch
  71.  
  72. # 50120 database shutdown
  73.  
  74. # 20100 IDS event
  75.  
  76. # 30051 squid
  77.  
  78. # 7204 changed ethernet
  79.  
  80. # 5104 promiscuous mode
Add Comment
Please, Sign In to add comment