Software Secret Weapons™
|
Fighting spam with SEIG – Secure Email Image Generator by Pavel Simakov on 2007-09-10 17:42:36 under Spam & Bots, view comments |
|||
|
found 1 post(s) for this archive:
The Problem
Preventing spam from getting into the personal email inbox is the number one privacy concern of any conscious Internet user. Many large scale e-commerce sites have implemented various schemes to safeguard your email address. But smaller providers of forum and collaborative platform software lag behind. Internet forums software like PHPBB, collaborative software like Drupal and Joomla are very popular, but can lead to exposure of email address to spammers. PHPBB, for example, shows listing of all registered users with the email addresses printed in plain text form right behind the user names. Any spammer or bot can come to crawl the forum and harvest the email addresses. Even if listings of users is disabled, any email address included as the part of the forum message is in danger. The forum post, unless specifically protected, can now be harvested. The SolutionOne can convert email address from a plain text to another representation: obfuscated text, encrypted text, image, etc. {1, 2}. In this post I describe SEIG (Secure Email Image Generator) PHP library that can be added to PHPBB, Drupal, Joomla or any other PHP package of your choice. With less than 100 lines of PHP code, SEIG library simply converts email addresses from text to images on the fly. Let me show you how SEIG library can improve email address privacy by securing the members list and posts in PHPBB 2.0.22. Download SEIG PHP library, image generation script and monofont.ttf and place all three files into the root of your PHPBB installation. You can place it anywhere, but I chose this location to simplify the explanations; we also assume that PHPBB installed in "/forum" folder. Securing email addresses in memberlist.phpOpen and edit /forum/common.php; find a section of code where includes are done (around line 191); add a reference to SEIG library like this: include($phpbb_root_path . 'includes/constants.'.$phpEx); include($phpbb_root_path . 'includes/template.'.$phpEx); include($phpbb_root_path . 'includes/sessions.'.$phpEx); include($phpbb_root_path . 'includes/auth.'.$phpEx); include($phpbb_root_path . 'includes/functions.'.$phpEx); include($phpbb_root_path . 'includes/db.'.$phpEx); // new line is here require_once($phpbb_root_path . "oySeig.php"); Open and edit /forum/memberlist.php; find a section of code that renders email address (around line 184); edit this sections to read as follows:
if ( !empty($row['user_viewemail']) || $userdata['user_level'] == ADMIN )
{
// new lines are here
$em_secret = md5($userdata[session_start].$userdata[session_id]);
$seig = new OYSeig();
$email = $seig->encodeURL($row['user_email'], $em_secret);
$email_img = '<img src="/forum/emgif.php?'.$email.'">';
$email = $email_img;
}
else
{
$email_img = 'hidden ';
$email = ' ';
}
Securing email addresses in bbcode.phpOpen and edit /forum/includes/bbcode.php; find a section of code where includes are done (around line 635); replace these lines of the original code: // matches an email@domain type address at the start of a line, or after a space. // Note: Only the followed chars are valid; alphanums, "-", "_" and or ".". $ret = preg_replace( "#(^|[\n ])([a-z0-9&\-_.]+?)@([\w\-]+\.([\w\-\.]+\.)*[\w]+)#i", "\\1<a href=\"mailto:\\2@\\3\">\\2@\\3</a>", $ret ); // replace plain text email with image reference global $userdata; $em_secret = md5($userdata[session_start].$userdata[session_id]); $seig = new OYSeig(); $email = $seig->encodeURL($row['user_email'], $em_secret); $ret = preg_replace_callback( "#(^|[\n ])([a-z0-9&\-_.]+?)@([\w\-]+\.([\w\-\.]+\.)*[\w]+)#i", "mailToLambda", $ret );
function mailToLambda($matches){
global $userdata;
$em_secret = md5($userdata[session_start].$userdata[session_id]);
$seig = new OYSeig();
return
"<img src='/forum/emgif.php?".
$seig->encodeURL($matches[2]."@".$matches[3], $em_secret).
"'>";
}
How SEIG WorksWhat is going on in here? We simply convert a plain text of the email address into a reference to an email image. The SRC attribute of the IMG tag has email in the encrypted form (using MCRYPT_RIJNDAEL_256 method of mcrypt PHP library). The key for this encryption is unique in space-time to each user session and is composed of session start time (session_start) and session id (session_id).The image is generated by the image generation script /forum/emgif.php as presented below. It initializes forum objects, computes the encryption key, decodes the email from query string. If all went well, it then renders email address image, or shows "no spam" image otherwise.
<?php
// connect to forum
define('IN_PHPBB', true);
include_once('extension.inc');
include_once('common.'.$phpEx);
// load user data fro this session
$userdata = session_pagestart($user_ip, PAGE_INDEX);
// connect SEIG library
require_once 'oySeig.php';
// get current key
$em_secret = md5($userdata[session_start].$userdata[session_id]);
// decrypt
$seig = new OYSeig();
$text = $seig->decodeURL($em_secret, $_REQUEST);
if ($text === false){
// failure
$seig->renderGif("[no spam]", 255, 0, 0);
} else {
// success
$seig->renderGif($text, 0, 80, 160);
}
?>
References
Comments (32) Leave a comment |
|
|||
|
Copyright © 2004-2010 by Pavel Simakov any conclusions, recommendations, ideas, thoughts or the source code presented on this site are my own and do not reflect a official opinion of my current or past employers, partners or clients |
|
Comment by Web Toolz — September 20, 2007 @ 7:32 pm
Some online image generators on <a href=”http://www.customsigngenerator.com”>www.CustomSignGenerator.com</a>.
Comment by Brian — December 4, 2007 @ 1:58 am
The oySeig php library link is to a blank file. Am I missing something here?
Comment by zeno — February 3, 2008 @ 10:06 am
Very interesting. Does this work with phpBB3?
Thanks.
Comment by Pavel Simakov — February 3, 2008 @ 3:18 pm
Yes, it works in general with anything including phpBB3, but you have to patch phpBB3 code your self.
Comment by Pavel Simakov — February 3, 2008 @ 3:21 pm
I just received this cute email that is directly relevant to the article:
Hi!!! hope you are doing well. we the leading data processing company in Bangladesh. Currently we are providing 300000+ captcha entry per day by our 55 operators and this is increasing very soon. Now we want to do long term business. You are the creator of captcha and you can help us.
Please try us, we can give you the quick service.
Thank you very much,
Best Regards
%NAME%, Bangladesh
Comment by vbulletin — February 5, 2008 @ 9:33 am
how to make it work for vbulletin forum ?
Comment by Freddi — June 16, 2008 @ 8:47 am
http://www.reduser.net/forum/member.php?u=10958
Comment by Miranda — June 17, 2008 @ 2:54 am
http://pdonline.keypress.com/user/view.php?id=3438&course=1
Comment by Franko — June 18, 2008 @ 5:47 am
http://www.reduser.net/forum/member.php?u=11009
Comment by Firero — June 23, 2008 @ 2:56 am
http://issofty17.is.noda.tus.ac.jp/view_profile.php?userid=24147
Comment by Trecci — June 27, 2008 @ 3:17 pm
http://communities.justicetalking.org/forums/thread/8839.aspx
Comment by Diegos — June 30, 2008 @ 9:56 pm
http://boinc.gorlaeus.net/view_profile.php?userid=15640
Comment by Webmoney ?? sms — July 13, 2008 @ 3:38 pm
<a href=”http://mobilecash.ws” title=”??? ? ???, ??? ??????? ?????? ?? ????? ??????????”>??? ? ???, ??? ??????? ?????? ?? ????? ??????????</a>
Comment by Webmoney ?? sms — July 13, 2008 @ 3:40 pm
<a href=”http://mobilecash.ws” title=”??? ? ???, ??? ??????? ?????? ?? ????? ??????????”>??? ? ???, ??? ??????? ?????? ?? ????? ??????????</a>
Comment by Anjelika — July 13, 2008 @ 10:36 pm
http://bbs.flashget.com/en/viewtopic.php?f=13&t=12511
Comment by Marisobel — July 22, 2008 @ 1:17 am
http://www.cgchannel.com/forum/viewthread?thread=32098
Comment by Brenden — July 24, 2008 @ 4:36 pm
http://www.gradschoolforum.com/t742-bathroom-cabinet.html
Comment by Harrisson — July 25, 2008 @ 2:15 pm
http://www.rtm.gov.my/html/forum/viewtopic.php?t=4428
Comment by Frensis — July 28, 2008 @ 3:55 am
http://fudforum.org/forum/index.php?t=msg&th=65021
Comment by Izabella — July 30, 2008 @ 3:51 am
http://enpf.chinabroadcast.cn/TalkChina/forums/thread/68718.aspx
Comment by Radrigez — August 4, 2008 @ 2:09 am
http://www.nme.com/boards/showthread.php?t=112703
Comment by Jenifer — August 6, 2008 @ 2:12 am
http://www.coachella.com/forum/showthread.php?t=21769
Comment by Bernik — August 8, 2008 @ 2:38 am
http://www.trackshark.com/forums/viewtopic.php?t=10290
Comment by Ruslan — August 11, 2008 @ 4:57 am
http://www.cilacapkab.go.id/webforum/index.php?showtopic=831
Comment by Saimon — August 18, 2008 @ 11:58 pm
http://bathroomvanities.hi5.com/
Comment by Sevastyn — August 25, 2008 @ 2:38 am
http://forums.forbes.com/forbes/board/message?board.id=fdchealth&thread.id=1626
Comment by Benjamin — August 26, 2008 @ 2:47 am
http://suprbay.org/member.php?u=50147
Comment by Kristi — August 28, 2008 @ 2:12 am
http://www.cable-modems.org/forum/read.php?1,27623
Comment by jozefina — August 30, 2008 @ 2:48 am
http://forums.elle.com/style/board/message?board.id=8&thread.id=1303
Comment by Jeferson — September 5, 2008 @ 3:59 am
http://www.unsysinst.org/forum/viewtopic.php?t=981
Comment by Suzana — September 10, 2008 @ 4:48 am
http://www.somalinet.com/forum/viewtopic.php?f=55&t=182049
Comment by blog — June 7, 2010 @ 10:00 pm
but you have to patch phpBB3 code your self.