Skip to content

Instantly share code, notes, and snippets.

@LaurenceJJones
Last active May 25, 2023 09:46
Show Gist options
  • Save LaurenceJJones/4314730b47cad57bcc8ff576c87fa3ca to your computer and use it in GitHub Desktop.
Save LaurenceJJones/4314730b47cad57bcc8ff576c87fa3ca to your computer and use it in GitHub Desktop.
tmp_d=$(mktemp -d)
tmp_f="$tmp_d/crowdsec.csv"
curr_dec=$(cscli -ojson decisions list -a | jq '.[].decisions |.[] | select(.duration | contains("-") | not) | .value')
echo "duration,scope,value" > $tmp_f
while read -r -s i;
do
echo "$curr_dec" | grep -qw "$i"
if [ ! "$?" -eq 0 ]; then
echo "24h,ip,$i" >> $tmp_f
fi
done
cscli decisions import -i $tmp_f
rm -r $tmp_d
@LaurenceJJones
Copy link
Author

LaurenceJJones commented Sep 21, 2022

The script takes a list of IP's from stdin, checks if they are already imported + have an active decision if not imports them again

wget -qO- https://raw.githubusercontent.com/SecOps-Institute/Tor-IP-Addresses/master/tor-exit-nodes.lst | ./crowdsec_iplist_importer.sh

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment