Compare commits

..

No commits in common. "bccf51d4a47a3ace3e35809ae57af804f7946f97" and "a512b79d5847b12c09126076078d453ad23e374e" have entirely different histories.

4 changed files with 8 additions and 19 deletions

View File

@ -6,26 +6,18 @@ stopforumspam API](https://www.stopforumspam.com/usage) and system firewall
To deploy:
1. Modify the configuration variables in the scripts as needed.
1. Modify the configuration variables in the scripts as neede.
2. Copy the scripts to `/usr/local/bin` (requires root):
install -m 755 -o root -g bin forumspam.sh /usr/local/bin/forumspam.sh
install -m 755 -o root -g bin q2a_usercheck.sh /usr/local/bin/q2a_usercheck.sh
install -m 640 -o _forumspam /dev/null /var/log/forumspam.log
3. Create the user the scripts will run as:
useradd -s /sbin/nologin _forumspam
4. Set up the firewall program
If using `ufw`, install it:
apt update
apt install ufw
If using `pf`:
4. If using `pf`:
Create appropriate permissions for the file:
@ -63,6 +55,3 @@ TODO:
* also check against [botscout](http://botscout.com/api.htm)
* give the scripts more sensible names
* also create an rc script
* support `iptables`
* create a Makefile
* merge the two scripts into one

View File

@ -2,8 +2,8 @@
Description=Forumspam Block Daemon
[Service]
User=_forumspam
Group=_forumspam
User=forumspam
Group=forumspam
ExecStart=/usr/local/bin/q2a_usercheck.sh
[Install]

View File

@ -26,7 +26,7 @@ abort() {
block_ip() {
case "$fw_cmd" in
ufw)
if "$getroot" ufw deny from $ip >/dev/null 2>>$logf; then
if [ "$getroot" ufw deny from $ip >/dev/null 2>>$logf ]; then
echo `date` blocked ip $ip with freq $freq >> $logf
else
abort "failed to block ip $ip"

View File

@ -8,9 +8,9 @@ test -f $cache || install -m 600 /dev/null $cache
tail -F $logf | while read line ; do
case $line in (*"POST"*)
ip=`echo $line | awk '{print $1}'`
ip_regex=`echo $ip | sed 's/\./\\./g'`
if ! grep -q $ip_regex $cache; then
/usr/local/bin/forumspam.sh "$ip" && echo $ip >> $cache
if ! grep -q $ip $cache; then
echo $ip >> $cache
/usr/local/bin/forumspam.sh "$ip"
fi
esac
done