prot.sh


SUBMITTED BY: Nosdam

DATE: June 26, 2023, 1:07 a.m.

UPDATED: June 26, 2023, 8:43 p.m.

FORMAT: Text only

SIZE: 695 Bytes

HITS: 35

  1. #!/bin/bash
  2. # Defina o limite de taxa em bps (bits por segundo)
  3. LIMITE_TAXA=10000000 # 1 Mbps
  4. # Defina o limite de pacotes por segundo
  5. LIMITE_PACOTES=$(($LIMITE_TAXA / 8 / 1500))
  6. # Limpe as regras existentes
  7. # Verificar o tráfego em tempo real para detecção de ataques DDoS
  8. tcpdump -i eth0 -n -s0 -c 1000 udp | awk '{print $3}' | cut -d. -f1-4 | sort | uniq -c | sort -nr | while read COUNT IP
  9. do
  10. if [ "$COUNT" -gt "$LIMITE_PACOTES" ]
  11. then
  12. echo "Bloqueando IP: $IP"
  13. # Bloquear tráfego UDP do IP detectado em todas as portas
  14. iptables -A INPUT -s $IP -j DROP
  15. fi
  16. done
  17. # Abrir script automaticamente após bloqueio de um IP
  18. bash prot.sh

comments powered by Disqus