A simple anti-spam system for question2answer, using the stopforumspam API and firewall rules (pf or ufw).
|
||
---|---|---|
forumspam.sh | ||
q2a_usercheck.sh | ||
README.md |
A simple anti-spam system for question2answer, using the stopforumspam API and system firewall (pf or ufw).
To deploy:
-
Modify the configuration variables in the scripts as neede.
-
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
-
Create the user the scripts will run as:
useradd -s /sbin/nologin _forumspam
-
If using
pf
:
Create appropriate permissions for the file:
install -m 640 -o _forumspam -g wheel /dev/null /etc/pf-forumspam.txt
Add the following to /etc/pf.conf
, preferably high up in the ruleset:
table <forumspam> persist file "/etc/pf-forumspam.txt"
block in quick on egress from <forumspam>
block out quick on egress to <forumspam>
- Give the
forumspam
user restrictive sudo or doas permissions:
If using doas, add the following to /etc/doas.conf
:
permit nopass _forumspam cmd pfctl args -nf /etc/pf.conf
permit nopass _forumspam cmd pfctl args -t forumspam -T replace -f /etc/pf-forumspam.txt
If using sudo, add to your sudo config file:
_forumspam ALL = NOPASSWD: /usr/sbin/ufw
Note: the path to ufw
may be different depending on your linux distribution.
- Register
q2a_usercheck.sh
as a systemd unit or rc script.
TODO:
- also check against botscout
- give the scripts more sensible names