diff --git a/modules/module-akkoma-accounts.sh b/modules/module-akkoma-accounts.sh index 3b628ae..add4c7a 100644 --- a/modules/module-akkoma-accounts.sh +++ b/modules/module-akkoma-accounts.sh @@ -3,9 +3,10 @@ FIREWALL="/opt/firewall/firewall.sh" NFT_CACHE='/tmp/nft.cache' ACCESS="/tmp/minute.log" ATTACK="module-akkoma-accounts" -SEARCH_SPAM=$(grep $2 $ACCESS | grep "api/v1/accounts" | grep $1 | wc -l) +COUNT_SPAM=$(grep $2 $ACCESS | grep "api/v1/accounts" | grep $1 | wc -l) +SEARCH_SPAM=$(($COUNT_SPAM)) CHECK=$(cat $NFT_CACHE | sort -u | grep $1) -if [[ "$SEARCH_SPAM" -gt 100 ]]; then +if [[ $SEARCH_SPAM -gt 100 ]]; then echo "$IP $CHECK $COUNT" if [ "$CHECK" = "" ]; then bash $FIREWALL ipBlockParser "$1" diff --git a/modules/module-akkoma-instance.sh b/modules/module-akkoma-instance.sh index 05e823e..373aec1 100644 --- a/modules/module-akkoma-instance.sh +++ b/modules/module-akkoma-instance.sh @@ -3,9 +3,10 @@ FIREWALL="/opt/firewall/firewall.sh" NFT_CACHE='/tmp/nft.cache' ACCESS="/tmp/minute.log" ATTACK="module-akkoma-instance" -SEARCH_SPAM=$(grep $2 $ACCESS | grep -E "api/v1/instance" | grep $1 | wc -l) +COUNT_SPAM=$(grep $2 $ACCESS | grep -E "api/v1/instance" | grep $1 | wc -l) +SEARCH_SPAM=$(($COUNT_SPAM)) CHECK=$(cat $NFT_CACHE | sort -u | grep $1) -if [[ "$SEARCH_SPAM" -gt 30 ]]; then +if [[ $SEARCH_SPAM -gt 30 ]]; then echo "$IP $CHECK $COUNT" if [ "$CHECK" = "" ]; then bash $FIREWALL ipBlockParser "$1" diff --git a/modules/module-akkoma-search.sh b/modules/module-akkoma-search.sh index 9ca226a..697b98b 100644 --- a/modules/module-akkoma-search.sh +++ b/modules/module-akkoma-search.sh @@ -3,9 +3,10 @@ FIREWALL="/opt/firewall/firewall.sh" NFT_CACHE='/tmp/nft.cache' ACCESS="/tmp/minute.log" ATTACK="module-akkoma-search" -SEARCH_SPAM=$(grep $2 $ACCESS | grep "api/v2/search" | grep $1 | wc -l) +COUNT_SPAM=$(grep $2 $ACCESS | grep "api/v2/search" | grep $1 | wc -l) +SEARCH_SPAM=$(($COUNT_SPAM)) CHECK=$(cat $NFT_CACHE | sort -u | grep $1) -if [[ "$SEARCH_SPAM" -gt 10 ]]; then +if [[ $SEARCH_SPAM -gt 10 ]]; then echo "$IP $CHECK $COUNT" if [ "$CHECK" = "" ]; then bash $FIREWALL ipBlockParser "$1" diff --git a/modules/module-akkoma-timeline-home.sh b/modules/module-akkoma-timeline-home.sh index 83e456d..15959d5 100644 --- a/modules/module-akkoma-timeline-home.sh +++ b/modules/module-akkoma-timeline-home.sh @@ -3,9 +3,10 @@ FIREWALL="/opt/firewall/firewall.sh" NFT_CACHE='/tmp/nft.cache' ACCESS="/tmp/minute.log" ATTACK="module-akkoma-timeline-home" -SEARCH_SPAM=$(grep $2 $ACCESS | grep -E "timelines/home" | grep $1 | wc -l) +COUNT_SPAM=$(grep $2 $ACCESS | grep -E "timelines/home" | grep $1 | wc -l) +SEARCH_SPAM=$(($COUNT_SPAM)) CHECK=$(cat $NFT_CACHE | sort -u | grep $1) -if [[ "$SEARCH_SPAM" -gt 30 ]]; then +if [[ $SEARCH_SPAM -gt 30 ]]; then echo "$IP $CHECK $COUNT" if [ "$CHECK" = "" ]; then bash $FIREWALL ipBlockParser "$1" diff --git a/modules/module-akkoma-timeline-public.sh b/modules/module-akkoma-timeline-public.sh index de44758..67dd29d 100644 --- a/modules/module-akkoma-timeline-public.sh +++ b/modules/module-akkoma-timeline-public.sh @@ -3,7 +3,8 @@ FIREWALL="/opt/firewall/firewall.sh" NFT_CACHE='/tmp/nft.cache' ACCESS="/tmp/minute.log" ATTACK="module-akkoma-timeline-public" -SEARCH_SPAM=$(grep $2 $ACCESS | grep "timelines/public" | grep $1 | wc -l) +COUNT_SPAM=$(grep $2 $ACCESS | grep "timelines/public" | grep $1 | wc -l) +SEARCH_SPAM=$(($COUNT_SPAM)) CHECK=$(cat $NFT_CACHE | sort -u | grep $1) if [[ "$SEARCH_SPAM" -gt 30 ]]; then echo "$IP $CHECK $COUNT" diff --git a/modules/module-get-spam.sh b/modules/module-get-spam.sh index ee80f24..b0d931e 100644 --- a/modules/module-get-spam.sh +++ b/modules/module-get-spam.sh @@ -2,8 +2,9 @@ FIREWALL="/opt/firewall/firewall.sh" ACCESS="/tmp/minute.log" ATTACK="module-get-spam" -GET_SPAM=$(grep $2 $ACCESS | grep -E "GET / HTTP" | wc -l) -if [[ "$GET_SPAM" -gt 20 ]]; then +COUNT_SPAM=$(grep $2 $ACCESS | grep -E "GET / HTTP" | wc -l) +SEARCH_SPAM=$(($COUNT_SPAM)) +if [[ $SEARCH_SPAM -gt 20 ]]; then bash $FIREWALL ipBlockParser "$1" bash $FIREWALL message "$ATTACK-$1" redis-cli SADD tmp_block $1 diff --git a/modules/module-go.sh b/modules/module-go.sh index ecd9614..203f928 100644 --- a/modules/module-go.sh +++ b/modules/module-go.sh @@ -2,8 +2,9 @@ FIREWALL="/opt/firewall/firewall.sh" ACCESS="/tmp/minute.log" ATTACK="module-go" -GO_SPAM=$(grep $2 $ACCESS | grep "Go-http-client" | grep $1 | wc -l) -if [[ "$GO_SPAM" -gt 10 ]]; then +COUNT_SPAM=$(grep $2 $ACCESS | grep "Go-http-client" | grep $1 | wc -l) +SEARCH_SPAM=$(($COUNT_SPAM)) +if [[ $SEARCH_SPAM -gt 10 ]]; then bash $FIREWALL ipBlockParser "$1" bash $FIREWALL message "$ATTACK-$1" redis-cli SADD tmp_block $1