Go Back   HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials > ISPConfig 3 > Feature Requests

Do you like HowtoForge? Please consider supporting us by becoming a subscriber.
Reply
 
Thread Tools Display Modes
  #1  
Old 2nd February 2014, 16:18
Quaxth Quaxth is offline
Senior Member
 
Join Date: Sep 2013
Location: Samut Prakan, Thailand
Posts: 440
Thanks: 48
Thanked 34 Times in 31 Posts
Send a message via Skype™ to Quaxth
Wink Import list of e-mail addresses to blacklist

As the title say's!

I was looking for to import, let say an CSV file to the E-Mail Blacklist and didn't find something! Maybe I'm blind?!

If not, if it could be done, How To.......?

Or could such feature added to ISPConfig? Same would be for export an already existing Blacklist in ISPConfig to an CSV File!

It's a lot of trouble to add address by address to the list!

Please advice.

Thanks.
__________________
*************
Have a nice day.
Reply With Quote
Sponsored Links
  #2  
Old 3rd February 2014, 15:57
sjau sjau is online now
Local Meanie
 
Join Date: Apr 2006
Location: Switzerland
Posts: 1,145
Thanks: 4
Thanked 55 Times in 51 Posts
Default

I made myself a little php script that I can run locally and that I use to create aliases and add stuff to the blacklist. It uses Curl to do the stuff. If you know some PHP you could alter it to go through the list...
__________________
"Common sense is not as common as commonly believed" by sjau

Auto-Install Script for ISPConfig and Horde on a Vanilla Debian Stable

Need more Repos for Ubuntu? Repository Generator
Need more Repos for Debian? Debian Repository Generator
Reply With Quote
  #3  
Old 3rd February 2014, 16:12
Quaxth Quaxth is offline
Senior Member
 
Join Date: Sep 2013
Location: Samut Prakan, Thailand
Posts: 440
Thanks: 48
Thanked 34 Times in 31 Posts
Send a message via Skype™ to Quaxth
Default

I wasn't think for my own only, even there'll a lot other looking for such feature of an high profile Control Panel! In reality. it's a pain in the ass for to key in the blacklist's entries one by one and that not once only, it need to done multiple times, for each Mail Domain! Most of the normal users as well as many system administrators didn't have the knowledge for to create such needed scripts. It would need a quite good knowledge of some program language for to to build those script's.
__________________
*************
Have a nice day.
Reply With Quote
  #4  
Old 4th February 2014, 08:47
sjau sjau is online now
Local Meanie
 
Join Date: Apr 2006
Location: Switzerland
Posts: 1,145
Thanks: 4
Thanked 55 Times in 51 Posts
Default

Well, I did alter my script but didn't test it yet:

That should add entries to the global blacklist.

Code:
<?php

# Define File containing Blacklist Entries
define('BLACKLIST_',             'blacklist.txt');

# Define Blacklist Settings
define('ACTIVE_',		'y');
define('BLACKLIST_TYPE_1_',	'sender');
define('BLACKLIST_TYPE_2_',	'client');
define('SERVER_ID_',		'1');
define('ACCESS_',		'REJECT');


# ISPConfig Login and URLs
define('USER_',			'admin');
define('PASSWD_',		'xxxx');
define('DOMAIN_',		'https://ispc.domain.com');
define('PORT_',                 '8080');
define('START_PAGE_',		DOMAIN_ . '/index.php');
define('LOGIN_PAGE_',		DOMAIN_ . '/content.php');
define('MAIL_BLACKLIST_EDIT_',	DOMAIN_ . '/mail/mail_blacklist_edit.php');


# Other Stuff
define('USERAGENT_', 		'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:11.0) Gecko/20100101 Firefox/11.0');
define('COOKIE_', 		'/tmp/ispc_user_cookie.txt');



/**************************************************************************************************************
*                                                                                                             *
*                                         HERE BE DRAGONS                                                     *
*                                                                                                             *
**************************************************************************************************************/


# Run the script to add sender and client blocklist entries
addBlock('1');
addBlock('2');


function addBlock ($type) {

        # Make Login
	$ch = ISPConfigLogin ();
    
        # Get the mail_alias_edit form to create necessary sessions vars
        curl_setopt($ch, CURLOPT_URL,                   MAIL_BLACKLIST_EDIT_);
        curl_setopt($ch, CURLOPT_PORT ,                     PORT_);
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER,    false);
        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST,    false);
        curl_setopt($ch, CURLOPT_USERAGENT,             USERAGENT_);
        curl_setopt($ch, CURLOPT_COOKIEFILE,            COOKIE_);
        curl_setopt($ch, CURLOPT_POST,                  false);
        curl_setopt($ch, CURLOPT_REFERER,               START_PAGE_);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER,        true);
        curl_setopt($ch, CURLOPT_HEADER,                true);
        curl_setopt($ch, CURLOPT_FOLLOWLOCATION,        true);
        curl_setopt($ch, CURLOPT_NOBODY,                false);
        $r = curl_exec($ch);

        # Read Blacklist file and loop through entries
	$entries = file(BLACKLIST_);
	foreach ($entries as $entry)
	{
            # Get entry and sanitize it
            trim($entry);

            # Build data array
            unset($data);
            if($type == 1) { $type_data = BLACKLIST_TYPE_1_; } else { $type_data = BLACKLIST_TYPE_2_; }
            $data = array(
                    'server_id'			=> SERVER_ID_,
                    'source'			=> $entry,
                    'type'			=> $type_data,
                    'active'			=> ACTIVE_,
                    'id'			=> '',
                    'access'			=> ACCESS_,
                    'next_tab'			=> '',
                    'phpsessid'			=> PHPSESSID_
            );

            # Transfer post data into url string
            unset($qstring);
            foreach ($data as $key => $val) {
                    $tmp = urlencode($key) . '=' . urlencode($val) . '&';
                    $qstring .= $tmp;
            }

            # Make Query
            curl_setopt($ch, CURLOPT_URL,		MAIL_BLACKLIST_EDIT_);
            curl_setopt($ch, CURLOPT_USERAGENT,		USERAGENT_);
            curl_setopt($ch, CURLOPT_COOKIEFILE,	COOKIE_);
            curl_setopt($ch, CURLOPT_POST,		true);
            curl_setopt($ch, CURLOPT_POSTFIELDS,	$qstring);
            curl_setopt($ch, CURLOPT_REFERER,		START_PAGE_);
            curl_setopt($ch, CURLOPT_RETURNTRANSFER,	true);
            curl_setopt($ch, CURLOPT_HEADER,		true);
            curl_setopt($ch, CURLOPT_FOLLOWLOCATION,	true);
            curl_setopt($ch, CURLOPT_NOBODY,		false);
            $r = curl_exec($ch);
        }

}





function ISPConfigLogin () {


	# Start Session Prefetching
	$ch = curl_init();
	curl_setopt($ch, CURLOPT_URL,                   START_PAGE_);
	curl_setopt($ch, CURLOPT_PORT ,			PORT_);
	curl_setopt($ch, CURLOPT_SSL_VERIFYPEER,	false);
	curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 	false);
	curl_setopt($ch, CURLOPT_USERAGENT,             USERAGENT_);
	curl_setopt($ch, CURLOPT_COOKIEJAR,             COOKIE_);
	curl_setopt($ch, CURLOPT_HEADER,                true);
	curl_setopt($ch, CURLOPT_RETURNTRANSFER,        true);
	curl_setopt($ch, CURLOPT_FOLLOWLOCATION,        true);
	curl_setopt($ch, CURLOPT_NOBODY,                false);
	$r = curl_exec($ch);


	# Build post data
	$data = array(
		'username'		=>	USER_,
		'passwort'		=>	PASSWD_,
		's_mod'			=>	'login',
		's_pg'			=>	'index'
	);


	# Transfer post data into url string
	foreach ($data as $key => $val) {
		$tmp = urlencode($key) . '=' . urlencode($val) . '&';
		$qstring .= $tmp;
	}

	# Make login
	curl_setopt($ch, CURLOPT_URL,                   LOGIN_PAGE_);
	curl_setopt($ch, CURLOPT_PORT ,			PORT_);
	curl_setopt($ch, CURLOPT_SSL_VERIFYPEER,	false);
	curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 	false);
	curl_setopt($ch, CURLOPT_USERAGENT,             USERAGENT_);
	curl_setopt($ch, CURLOPT_COOKIEFILE,            COOKIE_);
	curl_setopt($ch, CURLOPT_POST,                  true);
	curl_setopt($ch, CURLOPT_POSTFIELDS,            $qstring);
	curl_setopt($ch, CURLOPT_REFERER,               START_PAGE_);
	curl_setopt($ch, CURLOPT_RETURNTRANSFER,        true);
	curl_setopt($ch, CURLOPT_HEADER,                true);
	curl_setopt($ch, CURLOPT_FOLLOWLOCATION,        true);
	curl_setopt($ch, CURLOPT_NOBODY,                false);
	$r = curl_exec($ch);

	# Get the PHPSESSID from the cookie
	$filename = COOKIE_;
	$handle = fopen($filename, "r");
	$contents = fread($handle, filesize($filename));
	fclose($handle);
	$phpsessid = explode( 'PHPSESSID', $contents);
	define('PHPSESSID_',		trim($phpsessid[1]));

	return($ch);

}



?>
__________________
"Common sense is not as common as commonly believed" by sjau

Auto-Install Script for ISPConfig and Horde on a Vanilla Debian Stable

Need more Repos for Ubuntu? Repository Generator
Need more Repos for Debian? Debian Repository Generator
Reply With Quote
  #5  
Old 4th February 2014, 08:50
till till is offline
Super Moderator
 
Join Date: Apr 2005
Location: Lüneburg, Germany
Posts: 35,704
Thanks: 819
Thanked 5,321 Times in 4,174 Posts
Default

Hi Sjau, instead of using curl, you could have used the ispconfig remote api. Its easier to use
__________________
Till Brehm
--
Get ISPConfig support and the ISPConfig 3 manual from ispconfig.org.
Reply With Quote
  #6  
Old 4th February 2014, 08:51
sjau sjau is online now
Local Meanie
 
Join Date: Apr 2006
Location: Switzerland
Posts: 1,145
Thanks: 4
Thanked 55 Times in 51 Posts
Default

That's true... however mastering curl lets you automate just about every website - even those that don't have APIs

Also, in my script I do a bit more like adding entries to /etc/postfix/header_checks and testing those with:
Code:
header_checks = regexp:/etc/postfix/header_checks
in the main.cf
__________________
"Common sense is not as common as commonly believed" by sjau

Auto-Install Script for ISPConfig and Horde on a Vanilla Debian Stable

Need more Repos for Ubuntu? Repository Generator
Need more Repos for Debian? Debian Repository Generator

Last edited by sjau; 4th February 2014 at 08:55.
Reply With Quote
  #7  
Old 5th February 2014, 13:56
Quaxth Quaxth is offline
Senior Member
 
Join Date: Sep 2013
Location: Samut Prakan, Thailand
Posts: 440
Thanks: 48
Thanked 34 Times in 31 Posts
Send a message via Skype™ to Quaxth
Default Auto Bounce-Back

Just a question: Is there any way to do some Auto Bounce-Back of e-mails classified as Spam?

Thanks.
__________________
*************
Have a nice day.
Reply With Quote
  #8  
Old 5th February 2014, 13:58
till till is offline
Super Moderator
 
Join Date: Apr 2005
Location: Lüneburg, Germany
Posts: 35,704
Thanks: 819
Thanked 5,321 Times in 4,174 Posts
Default

Do you realy want to do that? You will get blacklistes by all major email providers for sending backscatter then.
__________________
Till Brehm
--
Get ISPConfig support and the ISPConfig 3 manual from ispconfig.org.
Reply With Quote
  #9  
Old 5th February 2014, 13:58
sjau sjau is online now
Local Meanie
 
Join Date: Apr 2006
Location: Switzerland
Posts: 1,145
Thanks: 4
Thanked 55 Times in 51 Posts
Default

depends on what you really mean.
__________________
"Common sense is not as common as commonly believed" by sjau

Auto-Install Script for ISPConfig and Horde on a Vanilla Debian Stable

Need more Repos for Ubuntu? Repository Generator
Need more Repos for Debian? Debian Repository Generator
Reply With Quote
  #10  
Old 5th February 2014, 14:08
Quaxth Quaxth is offline
Senior Member
 
Join Date: Sep 2013
Location: Samut Prakan, Thailand
Posts: 440
Thanks: 48
Thanked 34 Times in 31 Posts
Send a message via Skype™ to Quaxth
 
Default

The last 2 week I was getting a lot e-mails from bogus accounts of Yahoo!! That were around 1500!! Luckly only 2 mail addresses of mine were involved and I could easy just delete those e-mail's! I'm only afraid what'll happen if the other mails accounts get altered by that Spam mails too!

So, what do you thing would be the best solution for such "attacks"?

Thanks.
__________________
*************
Have a nice day.
Reply With Quote
Reply

Bookmarks

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

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Postfix Timeout after DATA from some emails treeman Server Operation 13 25th September 2013 12:51
Mail error , doesn't send externally. sharkutz Installation/Configuration 22 26th July 2013 15:09
Email from server driving me crazy chaloum General 29 13th April 2012 13:45
Email being accepted but not delivered punto Installation/Configuration 8 25th May 2011 00:13
ERROR: Connection dropped by IMAP server. [Centos 5.4, courier imap,squirrel, etc] darevil HOWTO-Related Questions 7 9th June 2010 14:49


All times are GMT +2. The time now is 22:45.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.