Fighting Comment Spam With Project Honey Pot (Posted on May 11th, 2013)

Early on when developing this blog my goal was to allow for a commenting system that didn't require login of my site or any other third party site to post. This has made me a huge target for spammers. In fact when my site first launched I didn't use recaptcha so I was getting thousands of comments per day and I didn't really have all that much content. However, a majority of these posts never saw the light of day thanks to Project Honey Pot's HTTP Blacklist. Taken from their site:

The HTTP Blacklist, or "http:BL", is a system that allows website administrators to take advantage of the data generated by Project Honey Pot in order to keep suspicious and malicious web robots off their sites. Project Honey Pot tracks harvesters, comment spammers, and other suspicious visitors to websites. Http:BL makes this data available to any member of Project Honey Pot in an easy and efficient way.

The service works by tracking the IPs of bad things and giving it a rating. With that rating you can choose how content gets marked as spam. So all I do is send the IP address of the poster to the service and then check to see what the odds are of it being a spammer.

Using HTTP Blacklist

The first step is registering for an API key which also requires an account on the site. Once you have that done using the service with Python (or any language really) is actually only a few lines of code which is pretty sweet. I've included some extra code for those using Django as well.

#Getting the users IP from a Django request
x_forwarded_for = request.META.get('HTTP_X_FORWARDED_FOR')
if x_forwarded_for:
    ip = x_forwarded_for.split(',')[0]
else:
    ip = request.META.get('REMOTE_ADDR')

#Step 1: Reverse the order of the IP address octets
iplist = ip.split('.')
iplist.reverse()

#Step 2: Build the query
query = YOUR_HTTP_BL_API_KEY + '.' + '.'.join(iplist) + '.' + 'dnsbl.httpbl.org'

#Step 3: Execute the query
from socket import gethostbyname
httpbl_result = gethostbyname(query)
httpbl_resultlist = httpbl_result.split('.')

From there it's up to you to interpret the data. The first item in the result list should be 127 signaling that the query was successful. The second item will be a value from 0-255 of when the last time that IP address was marked. The third item will be a threat score. I find this to be the most useful metric. From my experience anything above 45 is usually spam. The fourth and final item will be the type of user such as search engine, suspicious, harvester, or comment spammer. The API goes in to more detail for all of these fields. My code for marking comments as spam looks like this:

#Check if response is proper
if httpbl_resultlist[0] == "127":
    #Check threat level
    if httpbl_resultlist[2] > 45:
        comment.spam = True
    else:
        comment.spam = False
else:
    comment.spam = True

Overall I've found http:BL to be a super useful and FREE service to catch spammers. A lot of people also use Akismet so definitely check that out to see which fits your needs better. As of now I'm using recaptcha and http:BL to filter comments. I'd say about 10 comments get past recaptcha per day and about 5% of the comments that get past recaptcha also get past http:BL. So about 2-3 comments make it to the site every week which isn't bad for a userless commenting system. I'll definitely be looking to cut this number down with some more advanced filtering in the near future.

As always if you have any feedback or questions feel free to drop them in the comments below or contact me privately on my contact page. Thanks for reading!

Tags: Django, Python, Tools

Comments:

  • Jeni - 3 months, 3 weeks ago

    Our oracle database syllabus desined by oracle certified experts which includes basic and advanced level training. At the end of the oracle database course students can clear oracle global certification exams like OCA, OCP ,OCM.Trainingbangalore povides latest oracle version training like 10g,11g,11g R2.Our training center equiped with high level lab facilites.

    reply

  • showbiz news - 3 months, 2 weeks ago

    Just admiring your work and wondering how you managed this blog so well. It’s so remarkable that I can't afford to not go through this valuable information whenever I surf the internet!

    reply

  • pou hack - 3 months, 1 week ago

    Really a great addition. I have read this marvelous post. Thanks for sharing information about it. I really like that. Thanks so lot for your convene.

    reply

  • hill climb racing cheats - 3 months, 1 week ago

    Very good points you wrote here..Great stuff...I think you've made some truly interesting points.Keep up the good work.

    reply

  • Please Visit Tom Hardy Jacket - 2 months, 2 weeks ago

    Its fantastic comparison of the topic and able to study much more material here.

    reply

  • instagram get more followers - 1 month, 1 week ago

    Your blog provided us with valuable information to work with. Each & every tips of your post are awesome. Thanks a lot for sharing. Keep blogging..

    reply

  • get comments on instagram - 1 month, 1 week ago

    I am happy to find this post Very useful for me, as it contains lot of information. I Always prefer to read The Quality and glad I found this thing in you post. Thanks

    reply

  • facebook like hack - 1 week, 5 days ago

    I am very much pleased with the contents you have mentioned. I wanted to thank you for this great article.

    reply

  • Chris Pratt Vest Tedwed - 1 month, 1 week ago

    It’s very easy to understand! The involved analysis is very knowledgeable and a lot to know about this. Keep sharing here!

    reply

  • Governor Vest - 1 month, 1 week ago

    Just having read your article for a while now and impressed. Thanks for this great analysis. Outstanding assumptions

    reply

  • superiorpapers review - 1 month, 1 week ago

    I am using this superior papers reviews it is very motivating site for students it is very simply to understand and how to read and write simply. We are very happy with this superior papers making sites well.

    reply

  • gain twitter followers - 1 week, 5 days ago

    Thanks for the blog loaded with so many information. Stopping by your blog helped me to get what I was looking for.

    reply

  • Salesforce Training in Chennai - 1 month ago

    VEry informative article . Thanks.

    reply

  • David Beckham Jacket amazon - 4 weeks ago

    This post is a helpful overview of the particular topic and very actionable. Interesting approach!

    reply

  • amazon - 3 weeks, 5 days ago

    The provided resource of reading is best to gain lots of knowledge and build relevancy. Fastidious post

    reply

  • Credit Counseling - 3 weeks, 4 days ago

    Credit counseling agencies usually have a tie-up along with creditors and gives non-judgmental guidance. An professional guidance within the backdrop of the diminishing credibility allows you to negotiate restructuring better together with your creditors.

    reply

  • Depression - 3 weeks, 4 days ago

    Natural Remedy Of Depression is really a useful 1 whenever. Some occasion's depression might actually be triggered caused by insufficient nutrition within your body. Do you realize nicotine is really a crucial component to combat depression?

    reply

  • Debt - 3 weeks, 4 days ago

    Consolidating debts is really a debt administration strategy that must definitely be completely recognized before it's undertaken. Many individuals think this tactic is alone that can be obtained for their unique financial scenario.

    reply

  • Credit Counseling - 3 weeks, 4 days ago

    Debt administration and credit score counseling are extremely popular in the usa today. With the charge card crisis increasing, the credit score counseling services have become indispensable.

    reply

  • Debt Consolidation - 3 weeks, 4 days ago

    This debt consolidation reduction property enhance island the right way towards bring about anything formerly your financial situation.

    reply

  • best college paper writing service - 1 week, 6 days ago

    We are really interested to develop more articles and more online essay services for this kind of websites. These are all helps to improve more best college paper writing service books and content writing services.

    reply

  • how to get lots of followers on instagram - 1 week, 6 days ago

    Thanks for the post and great tips..even I also think that hard work is the most important aspect of getting success..

    reply

  • like instagram - 1 week, 6 days ago

    Excellent website you have here, so much cool information!..

    reply

  • Business Insurance - 1 week, 5 days ago

    Business insurance according to South Carolina of the islands a vast design as well as is going to extend a variety of aspects of SC businesses.

    reply

  • Business Insurance - 1 week, 5 days ago

    Insurance agent will usually provide the business owner those commercial insurance quotes that are extremely low hoping to obtain business from the owner

    reply

  • Accounting Services - 1 week, 5 days ago

    Outsourced accounting services provide quality financial information and genuine results that will help small, medium and large business enterprises make practical manoeuvres in conducting their operational strategies.

    reply

  • Business Travel - 1 week, 5 days ago

    If you have started your search for the best travel agent to get you to your business engagement with first class service, you have probably come across hundreds of corporate travel companies that claim to offer exactly that.

    reply

  • Debts Online - 1 week, 5 days ago

    When stuck up with multiple debts, debt consolidation may simplify their repayment a lot. You can search for some lenders that offer you to consolidate debt online, this is really easy and can be done in front of your computer at home.

    reply

  • fans facebook - 1 week, 5 days ago

    That is my own first-time all of us click here. I came across lots of pleasant points within your website, especially it is conversation. Within the lots of comments inside your posts, I guess I am not necessarily on it's own obtaining all the pleasurable the following! Carry on the actual outstanding perform.

    reply

  • 1000 followers - 1 week, 5 days ago

    Nevertheless this is our new we tend to hop on over. I stumbled upon a considerable amount of interesting important things ınside your blog, primarily its talk. In your a considerable amount of comments on your articles and reviews, Perhaps So i am never by themselves buying the different free time what follows! Remain typically the terrific characteristic.

    reply

  • twitter - 1 week, 4 days ago

    The on-line world might be bogged downwards with the help of counterfeit web logs without a proper personal message nonetheless put up was basically awesome not to mention value typically the read through. Regards for the purpose of showing this unique when camping.

    reply

  • Raleigh criminal lawyer - 1 week, 2 days ago

    This is usually a superb posting, With thanks to get allowing people this review. Continue to keep writing.

    reply

  • read more - 3 days, 11 hours ago

    Exceptional article, gone ahead of time along with added your blog. My spouse and i can’t delay you just read additional via anyone.

    reply

  • Pykazamberi28 - 1 day, 11 hours ago

    I'm curious to find out what blog system you are using? I'm experiencing some small security issues with my latest blog and I would like to find something more risk-free. Do you have any recommendations? A person necessarily lend a hand to make seriously posts I'd state. That is the very first time I frequented your website page and thus far? I amazed with the analysis you made to create this particular put up incredible. Excellent task!

    reply

  • Kesehatannya - 1 day, 11 hours ago

    I don't know whether it's just me or if perhaps everyone else encountering problems with your website. It appears like some of the text in your content are running off the screen. Can someone else please comment and let me know if this is happening to them too? This could be a problem with my web browser because I've had this happen previously. Appreciate it Your means of telling everything in this article is genuinely fastidious, all be capable of easily know it, Thanks a lot.

    reply

  • Sehat Sehat Hidupku - 1 day, 11 hours ago

    WOW just what I was searching for. Came here by searching for <Meta keyword of Target site we don't know yet> Thank you for sharing your info. I really appreciate your efforts and I am waiting for your further write ups thanks once again. Howdy! Do you know if they make any plugins to safeguard against hackers? I'm kinda paranoid about losing everything I've worked hard on. Any tips?

    reply

  • packers and movers mumbai - an hour ago

    http://www.youdial.in/packers-and-movers-mumbai

    reply

  • packers and movers mysore - an hour ago

    http://www.youdial.in/packers-and-movers-mysore

    reply

  • packers and movers nagpur - an hour ago

    http://www.youdial.in/packers-and-movers-nagpur

    reply

  • packers and movers nashik - an hour ago

    http://www.youdial.in/packers-and-movers-nashik

    reply