So in this tutorial, I will be teaching you how you can protect your website from being scanned by 3rd party people for vulnerabilities and how you can automatically ban them form doing it. This helps dramatically since there are chances that your website has some vulnerabilities which hackers might find and use to exploit your website. So hope you all enjoy this. If you find a mistake, please do write it down in the comments.
Please note that this will not work completely. This can still be bypassed. But more than 80% of the times, skids attempt to scan your site and they do not know how to bypass this restriction made by us.
1 - So first what you need is a directory to trap the scanner. So you must make a new directory named /trap/ or whatever you like in the root. So what we will do is when the scanner or the program scans your website and accesses this directory, they will be IP banned. So this will prevent further scanning of your website. Please keep in mind that even members, and not only guests will be banned by this method.
2 - Next thing we want to keep in mind is that we don't need to ban legit bots like the bots by search engines like google. So for that, we need to set access such that we do not allow these bots to enter the traps directory. For that, we add this piece of line to the robots.txt file.
So now these bots will ignore this directory and move on.
Now what you need to do is simple. Go and create a new index.php file in the new /trap/ directory and add this :
Make sure you CHMOD .htaccess to 666.
$file - you need to edit this depending on where you place your trap.
So now we have the trap setup, now we need to place the bait to lure the scanners to your trap. Now edit the index file in your root directory and add this piece of code at the bottom :
S
Since the bots or scanners checks for links while crawling, they will see this line of code and immediately travel to our /trap/ folder and get trapped in it. When a bot or scanner tries to access the directory, they would get an access denied message.You could also use this in various situations. You can use this in your admin directory where you have the ACP so that no one will access it.
Hope you like my tutorial
Thanks for reading.
Peace
Please note that this will not work completely. This can still be bypassed. But more than 80% of the times, skids attempt to scan your site and they do not know how to bypass this restriction made by us.
Setup
1 - So first what you need is a directory to trap the scanner. So you must make a new directory named /trap/ or whatever you like in the root. So what we will do is when the scanner or the program scans your website and accesses this directory, they will be IP banned. So this will prevent further scanning of your website. Please keep in mind that even members, and not only guests will be banned by this method.
2 - Next thing we want to keep in mind is that we don't need to ban legit bots like the bots by search engines like google. So for that, we need to set access such that we do not allow these bots to enter the traps directory. For that, we add this piece of line to the robots.txt file.
Code
]User-agent: *Disallow: /trap/Now what you need to do is simple. Go and create a new index.php file in the new /trap/ directory and add this :
Code
<?php
$agent = $_SERVER['$HTTP_USER_AGENT'];
$datum = date("Y-m-d (D) H:i:s",$tmestamp);
$ipad = $_SERVER['REMOTE_ADDR'];
$ban = "Deny from $ipad # /trap/ $agent - on $datum \r\n";
$file = "../.htaccess";
$search = file_get_contents($file);
$check = strpos($search, $ipad);
if ($check === FALSE) {
$open = @fopen($file, "a+");
$write = @fputs($open, $ban);
echo "The IP <b>".$ipad."</b> has been blocked for an invalid access attempt to a file, directory, or a scanning atempt.;
@fclose($open);
} else {
echo "The IP <b>".$ipad."</b> has been blocked for an invalid access attempt to a file, directory, or a scanning atempt.";
}
exit;
?>$file - you need to edit this depending on where you place your trap.
So now we have the trap setup, now we need to place the bait to lure the scanners to your trap. Now edit the index file in your root directory and add this piece of code at the bottom :
Code
<a href="/trap/"><img src="images/pix.JPG" border="0" alt=" " width="1" height="1"></a>Since the bots or scanners checks for links while crawling, they will see this line of code and immediately travel to our /trap/ folder and get trapped in it. When a bot or scanner tries to access the directory, they would get an access denied message.You could also use this in various situations. You can use this in your admin directory where you have the ACP so that no one will access it.
Hope you like my tutorial
Thanks for reading.
Peace



![[Image: Cx17p.png]](https://i.imgur.com/Cx17p.png)