From 172a8a92a474f39f22e87f238fb187376d6d036e Mon Sep 17 00:00:00 2001 From: Manuel Friedli Date: Tue, 16 Jun 2020 11:09:19 +0200 Subject: [PATCH] rename --- {mitigate-ddos => ddos-mitigator}/ddos-mitigator.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) rename {mitigate-ddos => ddos-mitigator}/ddos-mitigator.sh (82%) 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}!"