RoundCube Webmail Forum  

Go Back   RoundCube Webmail Forum > Third Party Contributions > Old Style Plug-Ins

For more information about the ads and why they're here, please see the FAQ
Reply
  #1  
Old 04-08-2009, 06:24 PM
rosali's Avatar
Super Moderator
 
Join Date: Dec 2007
Location: Germany
Posts: 1,428
Default Please test DNSBL Block function

I'm running a self-registration script for MyRoundCube and have trouble with spammers.

I have already disallowed SMTP connection others than established by Webmail. Also I have limited the Webmail to accept only 5 recipients per outgoing message. It seems still to be attractive for spammers.

I plan to code a plugin to deny sending out messages by webmail in case of a positive DNSBL result.

I have tested the following code on WINDOWS. Could you please be so kind and test the function if it works on UNIX systems aswell?

PHP Code:
<?php

//$check_ip = dnsbl_getVisitorIP();
$check_ip "217.20.240.19"// blacklisted IP

$dnsbl_lists = array("bl.spamcop.net""list.dsbl.org""sbl-xbl.spamhaus.org");

function 
dnsbl_blacklisted($ip) {
  global 
$dnsbl_lists;
  
$reverse_ip implode("."array_reverse(explode("."$ip))); 
  
$on_win substr(PHP_OS03) == "WIN" 0;
  foreach (
$dnsbl_lists as $dnsbl_list){
    if (
function_exists("checkdnsrr")) {
      if (
checkdnsrr($reverse_ip "." $dnsbl_list ".""A")) {
        return 
$reverse_ip "." $dnsbl_list;
      } 
    } else if (
$on_win == 1) {
      
$lookup "";
      @
exec("nslookup -type=A " $reverse_ip "." $dnsbl_list "."$lookup);
      foreach (
$lookup as $line) {
        if (
strstr($line$dnsbl_list)) {
           return 
$reverse_ip "." $dnsbl_list;
        }
      }
    } 
  }
  return 
false;
}

function 
dnsbl_getVisitorIP() { 
   
//Regular expression pattern for a valid IP address 
   
$ip_regexp "/^([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})/"

   
//Retrieve IP address from which the user is viewing the current page 
   
if (isset ($HTTP_SERVER_VARS["HTTP_X_FORWARDED_FOR"]) && !empty ($HTTP_SERVER_VARS["HTTP_X_FORWARDED_FOR"])) { 
      
$visitorIP = (!empty ($HTTP_SERVER_VARS["HTTP_X_FORWARDED_FOR"])) ? $HTTP_SERVER_VARS["HTTP_X_FORWARDED_FOR"] : ((!empty ($HTTP_ENV_VARS['HTTP_X_FORWARDED_FOR'])) ? $HTTP_ENV_VARS['HTTP_X_FORWARDED_FOR'] : @ getenv ('HTTP_X_FORWARDED_FOR')); 
   } 
   else { 
      
$visitorIP = (!empty ($HTTP_SERVER_VARS['REMOTE_ADDR'])) ? $HTTP_SERVER_VARS['REMOTE_ADDR'] : ((!empty ($HTTP_ENV_VARS['REMOTE_ADDR'])) ? $HTTP_ENV_VARS['REMOTE_ADDR'] : @ getenv ('REMOTE_ADDR')); 
   } 

   return 
$visitorIP
}


if(
dnsbl_blacklisted($check_ip))
  echo 
$check_ip ": banned";
else
  echo 
$check_ip ": pass";

?>
_____ EDIT _____
Outgoing messages are passed to SA aswell ... that's the final trap to catch them ...
How do you deal with an open back door (self-registration)
Any other recommendations are very appreciated !!!
__________________
Regards,
Rosali

__________________
MyRoundcube Project http://myroundcube.googlecode.com
MyRoundcube Forum http://http://www.roundcubeforum.net...45-myroundcube
MyRoundcube Online Demo http://mail4us.net
MyRoundcube Plugins Generic Installation Guide http://mail4us.net/myroundcube
Mailing List http://mail4us.net/?_action=plugin.nabble

Last edited by rosali; 04-08-2009 at 09:30 PM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2  
Old 04-09-2009, 08:23 AM
Super Moderator
 
Join Date: May 2007
Posts: 617
Default

i just tried it on my Debian Lenny box and it works fine, I tried a couple of good and bad IPs as well as the IP detection.
__________________
RoundCube Patches & Plugins: Managesieve, SpamAssassin Prefs, and more…
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3  
Old 04-09-2009, 09:18 AM
rosali's Avatar
Super Moderator
 
Join Date: Dec 2007
Location: Germany
Posts: 1,428
Default

Thanks - This function should be implemented into the forum code aswell. I've noticed that most of spam posts are submitted by blacklisted IP's.
__________________
Regards,
Rosali

__________________
MyRoundcube Project http://myroundcube.googlecode.com
MyRoundcube Forum http://http://www.roundcubeforum.net...45-myroundcube
MyRoundcube Online Demo http://mail4us.net
MyRoundcube Plugins Generic Installation Guide http://mail4us.net/myroundcube
Mailing List http://mail4us.net/?_action=plugin.nabble
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


For more information about the ads and why they're here, please see the FAQ

All times are GMT. The time now is 12:38 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0
Copyright © 2006-2008 RoundCube Webmail Community