Credit to sanciytinc for this.
Requirements
- CCcam Logfile (in this tutorial /var/log/cccam.log)
- root Access
- Cron Daemon
- iptables
Scripts
/root/BanUser.sh
Bash
#!/bin/bash
LOGFILE=/var/log/cccam.log
/sbin/iptables --flush
FILENAME=/root/baduser.db
touch $FILENAME
while read line
do
OUTPUT=`cat $LOGFILE | grep $line | awk '{printf "-A INPUT -s %s -j REJECT --reject-with icmp-host-unreachable\n", $10}' | awk 'x[$0]++ == 0' | tail --lines=1`
/sbin/iptables $OUTPUT
done < $FILENAME
FILENAME=/root/badhost.db
touch $FILENAME
while read line
do
OUTPUT="-A INPUT -s $line -j REJECT --reject-with icmp-host-unreachable"
/sbin/iptables $OUTPUT
done < $FILENAME
Display More
Database examples
/root/badhost.db
/root/baduser.db
Cronjob
/etc/cron.d/cccam-iptables
Fill into the file baduser.db deleted users, You can also use the badhost.db file to put the hostname or ip address. Already configured iptables rules will be deleted with this script so make attention.
Tested with ubuntu.
P.S: It's a good beginning to resolve the disconnecting client problems.