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:
|
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):
|
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 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 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:
|
3. Create the user the scripts will run as:
|
||||||
|
|
||||||
useradd -s /sbin/nologin _forumspam
|
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:
|
Create appropriate permissions for the file:
|
||||||
|
|
||||||
@ -55,3 +63,6 @@ TODO:
|
|||||||
* also check against [botscout](http://botscout.com/api.htm)
|
* also check against [botscout](http://botscout.com/api.htm)
|
||||||
* give the scripts more sensible names
|
* give the scripts more sensible names
|
||||||
* also create an rc script
|
* also create an rc script
|
||||||
|
* support `iptables`
|
||||||
|
* create a Makefile
|
||||||
|
* merge the two scripts into one
|
||||||
|
@ -2,8 +2,8 @@
|
|||||||
Description=Forumspam Block Daemon
|
Description=Forumspam Block Daemon
|
||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
User=forumspam
|
User=_forumspam
|
||||||
Group=forumspam
|
Group=_forumspam
|
||||||
ExecStart=/usr/local/bin/q2a_usercheck.sh
|
ExecStart=/usr/local/bin/q2a_usercheck.sh
|
||||||
|
|
||||||
[Install]
|
[Install]
|
||||||
|
@ -26,7 +26,7 @@ abort() {
|
|||||||
block_ip() {
|
block_ip() {
|
||||||
case "$fw_cmd" in
|
case "$fw_cmd" in
|
||||||
ufw)
|
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
|
echo `date` blocked ip $ip with freq $freq >> $logf
|
||||||
else
|
else
|
||||||
abort "failed to block ip $ip"
|
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
|
tail -F $logf | while read line ; do
|
||||||
case $line in (*"POST"*)
|
case $line in (*"POST"*)
|
||||||
ip=`echo $line | awk '{print $1}'`
|
ip=`echo $line | awk '{print $1}'`
|
||||||
if ! grep -q $ip $cache; then
|
ip_regex=`echo $ip | sed 's/\./\\./g'`
|
||||||
echo $ip >> $cache
|
if ! grep -q $ip_regex $cache; then
|
||||||
/usr/local/bin/forumspam.sh "$ip"
|
/usr/local/bin/forumspam.sh "$ip" && echo $ip >> $cache
|
||||||
fi
|
fi
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
Reference in New Issue
Block a user