0

Hello I'd like to permenently ban anything requesting the directory "/backups/" now how can I do that using a PHP script or mod_security?

I want to do this in a similar manner as iptables does this if possible.

FreakAnon
  • 399
  • 3
  • 4

1 Answers1

0

I figured out how to do this on my own.

create a script in /bin called "blockip" containing the following

if [ -z "$1" ]
  then
    echo "No argument supplied"
    exit 1
fi
echo "Blocking IP address $1"
iptables -A INPUT -s $1 -j DROP

then

chmod +x /bin/blockip

and now run

sudo visudo

add this:

nobody ALL = NOPASSWD: /your/script

make sure it is chmod 755

and add this code to index.php in the directory.

exec("sudo blockip ".escapeshellcmd($_SERVER['REMOTE_ADDR']));
FreakAnon
  • 399
  • 3
  • 4