Compare commits
5 Commits
a512b79d58
...
bccf51d4a4
Author | SHA1 | Date | |
---|---|---|---|
|
bccf51d4a4 | ||
|
323f926e53 | ||
|
17751c93f3 | ||
|
a6fdf3921e | ||
|
e741dc37ee |
15
README.md
15
README.md
@ -6,18 +6,26 @@ stopforumspam API](https://www.stopforumspam.com/usage) and system firewall
|
||||
|
||||
To deploy:
|
||||
|
||||
1. Modify the configuration variables in the scripts as neede.
|
||||
1. Modify the configuration variables in the scripts as needed.
|
||||
|
||||
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. If using `pf`:
|
||||
4. Set up the firewall program
|
||||
|
||||
If using `ufw`, install it:
|
||||
|
||||
apt update
|
||||
apt install ufw
|
||||
|
||||
If using `pf`:
|
||||
|
||||
Create appropriate permissions for the file:
|
||||
|
||||
@ -55,3 +63,6 @@ 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
|
||||
|
@ -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]
|
||||
|
@ -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"
|
||||
|
@ -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}'`
|
||||
if ! grep -q $ip $cache; then
|
||||
echo $ip >> $cache
|
||||
/usr/local/bin/forumspam.sh "$ip"
|
||||
ip_regex=`echo $ip | sed 's/\./\\./g'`
|
||||
if ! grep -q $ip_regex $cache; then
|
||||
/usr/local/bin/forumspam.sh "$ip" && echo $ip >> $cache
|
||||
fi
|
||||
esac
|
||||
done
|
||||
|
Reference in New Issue
Block a user