Logo

Stop Forum Spam

Forum



#1 2008-01-10 4:24 pm

Russ
Administrator
Registered: 2007-11-28
Posts: 120

Code Examples

Here's a little details on what I've been doing to automagically detect and report spammers. I do some mods on the registration page to detect first, by including some hidden form elements. They're usually hidden by HTML comments. This ensures they won't be seen in visual browsers but a dumb spambot that just sucks the HTML down and parses out fields can't tell the difference.

This is all done on PunBB, but it would be similar with other board software.

So in the HTML section of register.php I include this inside an HTML comment.

Code:

<!-- Spam control
<div class="inform">
    <fieldset class="profile-extra">
        <legend>Profile Info</legend>
        <div class="infldset">
        <label><strong>Real name</strong><br />
        <input type="text" name="realname" size="50" maxlength="50" /><br /></label>
        <label><strong>Interests</strong><br />
        <input type="text" name="interests" size="50" maxlength="50" /><br /></label>
            <label><strong>Website</strong><br />
        <input type="text" name="website" size="50" maxlength="50" /><br /></label>

</fieldset>
</div>
            
-->

They're also things that spammers typically can't resist filling out, too, especially website.

Now, when the form is posted I added a little bit to check if these fields are filled out. If they are, I know it can't be a legit registrant.

Code:

if($_POST['realname'] != '' || $_POST['website'] != '' || $_POST['interests'] != '')
{
        
    function PostToHost($host, $path, $data_to_send) {
    $fp = fsockopen($host,80);
    fputs($fp, "POST $path HTTP/1.1\n" );
    fputs($fp, "Host: $host\n" );
    fputs($fp, "Content-type: application/x-www-form-urlencoded\n" );
    fputs($fp, "Content-length: ".strlen($data_to_send)."\n" );
    fputs($fp, "Connection: close\n\n" );
    fputs($fp, $data_to_send);
    fclose($fp);
        }

    PostToHost("www.stopforumspam.com", "/post.php", "username=" . $_POST['req_username'] . "&ip_addr=" . $_SERVER['REMOTE_ADDR'] . "&email=" . $_POST['req_email1'] . "&api_key=ZZZZZZZZZZZZZZZ");
        
    echo "bye";
    die();
}

There's a little function in there that opens up a socket connection to the site on port 80 in order to post the form, obviously my API key isn't ZZZZZ but this is just an example. After that's done, the script is killed.

This is how 100% of my entries are handled. If you feel like modifying your own boards to do the same, feel free.

Offline

 

#2 2008-04-03 2:21 pm

the123king
Member
Registered: 2008-03-23
Posts: 33

Re: Code Examples

I've modified the Anti-Spam ACP for my forums to incorporate an easy-upload feature that inputs info coutesy of your little bit of PHP. All i have to do now is click "Report Spammers" and it sends all the entries to your database without any hassle from me big_smile

Thanks for that Russ

Offline

 

#3 2008-04-05 12:26 am

rtiredsarg
Member
Registered: 2008-04-04
Posts: 1

Re: Code Examples

I'll need to work on adding that to my site.

Your database has been very useful, I got about 50 bad new users in the last 3 days.

Sarg

Offline

 

#4 2008-04-06 2:48 am

kurtcobainvn
Member
Registered: 2008-02-14
Posts: 12

Re: Code Examples

Hi Rush and the123king, could you please see if you can give me some detail instruction how to make a 'button' that can automatically upload spammer details into this website data base?

Currently I have to copy and paste everything by hand. It is ok, I can overcome the tiredness to fight those moron spammers. But if there is a quicker way to do it, that would be so great.

I am using IPB forum. I know nearly nothing about coding stuffs but if you can give some easy instructions I am sure I can follow.

Offline

 

#5 2008-04-06 5:05 am

the123king
Member
Registered: 2008-03-23
Posts: 33

Re: Code Examples

kurtcobainvn wrote:

Hi Rush and the123king, could you please see if you can give me some detail instruction how to make a 'button' that can automatically upload spammer details into this website data base?

Currently I have to copy and paste everything by hand. It is ok, I can overcome the tiredness to fight those moron spammers. But if there is a quicker way to do it, that would be so great.

I am using IPB forum. I know nearly nothing about coding stuffs but if you can give some easy instructions I am sure I can follow.

I know absolutely nothing about the code of IPB, sorry.

Offline

 

#6 2008-04-06 8:51 am

UK Debate
Member
From: United Kingdom
Registered: 2008-04-04
Posts: 14
Website

Re: Code Examples

Just like to thank Russ for the function.

I run SMF forum software and have just added an include to the members profile page containing the (slightly modified) function in conjunction with a form for the necessary info and made accessable to Admins only.

I chose this method because I do not allow moderators to delete accounts, only to ban members.

Again, thanks Russ.

Offline

 

Board footer

Powered by PunBB
© Copyright 2002–2005 Rickard Andersson



Donate Valid XHTML 1.0 Transitional RSS 2.0 Feed