500 Internal Server Errors

Started by Randem, June 13, 2018, 01:12:28 AM

Previous topic - Next topic

Randem

If you get a 500 Internal Error after installing or uninstalling BotBanish, please contact us with your .htaccess file and we will correct the issue. It has been known that some other MOD's will change the BotBanish information in the .htaccess file and interfere with information BotBanish has placed there.

Randem

If you are running on a Centos Server with Linux with PHP 7, a PHP 7 handler will at some point be placed into your .htaccess file and cause a conflict with BotBanish because of specialNot a valid attachment ID. characters that the handler places into the commented text. To eliminate this issue find in the BotBanish_Subs.php file that is located at /BotBanish/bot/Subs/ the following routine:

function BotBanishHTACCESSReadFile($htaccess_name = BOTBANISH_HTACCESS_NAME) {

 $htaccess_data = '';
 $replace_char = '@^@';

 if (file_exists($htaccess_name)) {

 $htaccess_data = file_get_contents($htaccess_name);

 // Let's attempt to fix an improperly formatted file

 $temp_data = str_replace(array("\r\n", "\n", "\r"), $replace_char, $htaccess_data);
 $htaccess_data = str_replace($replace_char, PHP_EOL, $temp_data);
 }

 return $htaccess_data;
}

and replace it with the code in the attached file. The code cannot be placed into this message because the special characters will be replaced and that is not what we want.

Randem

Another source of 500 Internal Server Errors can be attributed to what is in your URL. if it contains any of these sequence of characters, a 500 series error will present:

md5|benchmark|union|select|insert|cast|declare|drop|alter|else|case|switch|require|include|isset|foreach|global

You can change this behavior by removing the sequence of characters from your .htaccess file from these lines or by changing the URL that uses these sequences of characters.

RewriteCond %{QUERY_STRING} ^.*(md5|benchmark|union|select|insert|cast|declare|drop|alter).* [NC]

RewriteCond %{QUERY_STRING} ^.*(else|case|switch|require|include|isset|foreach|global).* [NC]


Randem

500 errors are usually generated due to a .htaccess file formatting issue. One such issue to look for is an improper ipv4 / IPv6 address in the file. We have seen where the expected IP address should be written to the file but instead an improperly formatted IPv6 address is written causing the 500 error. Simply remove the improperly formatted IPv6 addresses and all should be fine. We have only seen one instance of this and will modify BotBanish to check first before recording this address. Bots do a lot of things to escape detection.

When BotBanish is installed it will make a backup copy of your .htaccess file just in case a problem arises after installation. The backup file has a numeric representation of the date appended to the end of the .htaccess name. If you have an issue with your .htaccess file after installing BotBanish, you can send the .htaccess file to us and we help you to correct the issue. Most systems will not experience an issue due to the complexity of their .htaccess files.

Randem

Some bots are on the rise that are using the User-Agent field to store code to inject onto hosted sites.

Please delete from your .htaccess files any entries that contain a question mark ("?"). It is the cause of the 500 Internal Server Errors.
Entries that will need to be removed will look like these examples:

SetEnvIfNoCase User-Agent "?php" bad_bot

SetEnvIfNoCase User-Agent "@" bad_bot

If you are downloading and editing the file on a PC or Mac please re-upload the file in binary format using the UTF-8 character set.
If not this may also cause an 500 Internal Server Error.

If you receive a 500 series error after installing BotBanish, do not fear a re-install of SMF is never needed. There is always a backup .htaccess file created for this very reason. Just rename the .htaccess file then rename the backup .htaccess file to the original name. That's it. You can now uninstall BotBanish. It would be helpful to allow us to see your .htaccess file to locate the issue. Most of the time it is a simple one line change or a missing CR/LF to get the site back up and running.