diff --git a/mitigate-ddos/ddos-mitigator.sh b/ddos-mitigator/ddos-mitigator.sh similarity index 82% rename from mitigate-ddos/ddos-mitigator.sh rename to ddos-mitigator/ddos-mitigator.sh index 8e8a1da..ff13568 100755 --- a/mitigate-ddos/ddos-mitigator.sh +++ b/ddos-mitigator/ddos-mitigator.sh @@ -1,11 +1,12 @@ #!/bin/sh input_files=/var/log/apache2/access_*.log - +date="14/Jun/2020:18:" tmpdir=$(mktemp -d) + cd "${tmpdir}" -cut -d' ' -f1 ${input_files} | sort > all.txt +grep -h "${date}" ${input_files} | cut -d' ' -f1 | sort > all.txt grep ':' all.txt > raw-ipv6.txt grep -v ':' all.txt > raw-ipv4.txt @@ -16,4 +17,5 @@ cut -d. -f1-3 raw-ipv4.txt | sort | uniq -c | sort -n > sorted-ipv4-24.txt cut -d. -f1-2 raw-ipv4.txt | sort | uniq -c | sort -n > sorted-ipv4-16.txt cut -d. -f1 raw-ipv4.txt | sort | uniq -c | sort -n > sorted-ipv4-8.txt +chmod o+rx "${tmpdir}" echo "Have fun in ${tmpdir}!"