Add a script to scrape all IP addresses and group and count them.
This commit is contained in:
commit
31d67ed735
2 changed files with 20 additions and 0 deletions
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
*~
|
19
mitigate-ddos/ddos-mitigator.sh
Executable file
19
mitigate-ddos/ddos-mitigator.sh
Executable file
|
@ -0,0 +1,19 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
input_files=/var/log/apache2/access_*.log
|
||||||
|
|
||||||
|
tmpdir=$(mktemp -d)
|
||||||
|
cd "${tmpdir}"
|
||||||
|
|
||||||
|
cut -d' ' -f1 ${input_files} | sort > all.txt
|
||||||
|
|
||||||
|
grep ':' all.txt > raw-ipv6.txt
|
||||||
|
grep -v ':' all.txt > raw-ipv4.txt
|
||||||
|
|
||||||
|
uniq -c raw-ipv6.txt | sort -n > sorted-ipv6.txt
|
||||||
|
uniq -c raw-ipv4.txt | sort -n > sorted-ipv4-32.txt
|
||||||
|
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
|
||||||
|
|
||||||
|
echo "Have fun in ${tmpdir}!"
|
Loading…
Reference in a new issue