18 Jul 2008

Project Honeybot

Twitter is a great platform for expressing ideas and keeping up with what is going on in the world, but there is also a downside and thats spam. There seems to be alot of twitter users which are just spam bots they just keep following people hopeing to sell you viagra. I think I have found away to name and shame them.

Enter Honeybot

Honeybot is my counter defense to this, what it does is constantly posts to the public time line a warning not to follow it. Now I believe that spambots constantly scrape the public timeline and follow whoevers on there. So they should in theory follow Honeybot automaticly.

The second thing it does is keeps a record of its followers, allowing me to create a public blacklist of it's followers.

Creating a Blacklist of Spambots

What I intend to do is post the list of followers on my website where people can see if they are being followed by spammers. It's basicly a copy of the xml file of followers you can obtain from the twitter API, but I am going to parse it into a more readable format.

Source Code

below is a copy of the source code so you can see how it works:

#!/usr/bin/perl -w
## Honeybot - This bot attempts to attract spam bots and creates a spambot blacklist
## James Januszka, 2008, http://blog.jamesjanuszka.com
##
use strict;
use LWP;
use LWP::Simple;
use URI;
my $agent ='Honeybot/0.1';my $statusurl = 'http://twitter.com/statuses/update.xml';
my $followerurl = 'http://twitter.com/statuses/followers.xml?lite=true';
my $server ='twitter.com:80';
my $realm ="Twitter API";
my $username = "enteryourusername";
my $password ="enteryourpassword";
my $file="followers.xml";
my $string ="Please do not follow this bot as any followers will be added to the blacklist. See http://tinyurl.com/5bomg4 for more details.".int(rand(100000));
my $browser = LWP::UserAgent->new(agent =>$agent);
$browser->credentials($server,$realm,$username=>$password);
print "Content-type: text/html\n\n";

&updatestatus();
&getfollowers();

sub updatestatus {
my $response =$browser->post($statusurl,['status'=>$string]);
die "OMG, WTF: ",$response->header('WWW-Authenticate'), $response->status_line unless $response->is_success;
}

sub getfollowers {
system("wget --http-user=$username --http-passwd=$password -O $file -U $agent $followerurl");
}

I hope that this will be a useful service for twitter users, if you have any comments about how I can improve Honeybot let me know.

3 comments:

  1. Spam moves to a new medium (well, it has been for some time on twitter I guess), and again someone has fallen for the same trap: filtering/blacklisting. Why don't you just report spammers to twitter? You yourself are now spamming the main timeline.

    Finally, get a good book on Perl, & in front of a sub is Perl4 style and instead of the -w switch I recommend to use: use warnings;

    ReplyDelete
  2. Thanks for your comments

    The overall goal of Honeybot is to attract spammers so I can report them to twitter.

    Putting & in front of a sub did seem a bit strange to me, but thats how I've seen it done before. The tip about use warnings; looks like a much better way if doing things.

    ReplyDelete
  3. I recently had a similar idea, and discovered your project when I found my first choice of name, "HoneyBot" was taken.

    My idea is to broadcast every word in an english dictionary, which includes a list of celebrity and brand names, and see who auto-follows.

    ReplyDelete