Preventing registration abuse on phpBB 31 July 2006
Good practise is to implement the MEMBERLIST mod as this ensures that only confirmed members appear on the list – so you will have a working email for the member.
Open your memberlist.php file, and go down to line 145. You will find a SQL query being built. We are going to modify this query the following one:
$sql = "SELECT username, user_id, user_viewemail, user_posts, user_regdate, user_from, user_website, user_email, user_icq, user_aim, user_yim, user_msnm, user_avatar, user_avatar_type, user_allowavatar FROM " . USERS_TABLE . " WHERE user_id <> " . ANONYMOUS . " AND user_active = 1 ORDER BY $order_by";
To maintain the correct count of members, edit the count query on line 278 as follows:
$sql = "SELECT count(*) AS total FROM " . USERS_TABLE . " WHERE user_id <> " . ANONYMOUS . " AND user_active = 1";
Next, we are working on the following assumptions.
- Spam bots know exactly what POST data to send your signup script to get themselves regsitered.
- Spam bots are capable of downloading your signup page and identifying what POSTDATA should be provided.
To work around this – we need to provide POST data that the Spam bot cannot predict. This is difficult because of assumption 2 – the Spam bot can look at your page and try to identify what it needs to provide. So you can’t just bung in hidden elements of your own and expect everything to be hunky dory.
We move forward on the assumption that the Spam bot probably wont be so sophisticated that it can analyse encrypted javascript includes. So we will dynamically add the hidden elements to the form using an encrypted javascript include.
we adjust the script profile.php as follows:- insert on line 95 after:
else if ( $mode == 'editprofile' || $mode == 'register' ) {
All we need to do now is to ensure that our signup page includes our hidden elements.
So we make a javascript include called botkiller_src.js
The src of the file should be as follows:
if(document.forms.length>0){ newField = document.createElement("input"); newField.type = "hidden"; newField.name = "iEatBotsForBreakfast"; newField.value = "yesIdo"; for(var j=0; j<document.forms.length; j++){ var frm = document.forms[j]; frm.appendChild(newField); } }
This is NOT the file to upload!..
Next we want to encrypt the src. So go to the following website: http://javascript.about.com/library/blenc1.htm
.. you can copy and paste your javascript src into the encrypter and encrypt it. Then copy the encrypted text and save the file as botkiller.js
This file you can upload to your website root.
Next, go to http://javascript.about.com/library/blenc.htm and obtain the custom decrypter. You will need to enter your sites domain name, hit the decrypter button and copy and paste the new lot of encrypted text into a new javascript file called decrypt.js
Upload this file too your site root as well.
Almost there!
Now you need to modify the registration script to include these includes as follows.
Open the following phpBB template files as follows: forum_dir/templates/template_name/overall_header.tpl
and add the following code to the end of the document
<script src="/decrypt.js" language="JavaScript1.2" type="text/javascript"></script>
Then open forum_dir/templates/template_name/overall_footer.tpl and add the following to the end:
<script src="/botkiller.js" language="JavaScript1.2" type="text/javascript"></script>
Thats it! from now on, any page with a form in will get the botkilling code in it. If you need to check submissions, you can add the same submission logic on the appropriate pages if your forum is getting Spam attacks to other POST scripts.