免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2969 | 回复: 1
打印 上一主题 下一主题

[Mail] 【急!有酬谢】关于Sendmail发件人与认证信息一致性问题 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2009-10-19 22:52 |只看该作者 |倒序浏览
环境:
CentOS/RedHat  sendmail 8.13

邮件架构:
总部有核心Sendmail,分公司有各自Sendmail。通过别名解析的方法,实现分公司邮件的路由。比如:abc在武汉,发abc@domain.com将在总部别名成abc@wh.domain.com,再发到武汉的sendmail。
发出邮件统一通过总部发出。
目前所有sendmail均没有认证功能。

目标:
为防止假冒发件人,比如abc冒充老总发邮件,要求实现
1、发邮件必须认证
2、认证信息与邮件头中的发件人信息必须一致,否则警告并通知系统管理员。

对于认证我很久前配置好了,并在网上指导过别人【以前网名叫笨人杨老大】。由于时间有点久了,技术实在有点荒疏了,现在居然搭建一个新环境,想先实现认证居然不能。同时查了很多资料,本论坛好像比较多,好像需要sendmail+cryussasl+MIMEdefang,但是我一直没有成功。

希望哪位大侠伸出友爱、温暖的大手,帮我尽快解决该问题。有酬谢。也可以帮我联系熟悉该技术的人。
只要帮我把道理讲清,帮我实现测试环境即可,其他的我可以自己搞定。

请直接发邮件 ppxwq@139.com
或qq: 10911617

先谢了。

[ 本帖最后由 ppxwq 于 2009-10-19 22:54 编辑 ]

论坛徽章:
1
荣誉会员
日期:2011-11-23 16:44:17
2 [报告]
发表于 2009-10-21 09:55 |只看该作者
目标:
为防止假冒发件人,比如abc冒充老总发邮件,要求实现
1、发邮件必须认证
2、认证信息与邮件头中的发件人信息必须一致,否则警告并通知系统管理员。

1. sasl 即可,有很多參考資料,可自己找
2. 思路:
* Envelope From  (Mail From: <>)
在 filter, filter_begin, filter_end 抓取 $Sender 變量即可得知


* Header From (From: <xxx@yy.com>
filter 參數解釋
For each leaf part of the mail message, filter is called with four arguments: entity, a MIME::Entity object; fname, the suggested filename taken from the MIME Content-Disposition header; ext, the file extension, and type, the MIME Content-Type value. For each non-leaf part of the mail message, filter_multipart is called with the same four arguments as filter. A non-leaf part of a message is a part that contains nested parts. Such a part has no useful body, but you should still perform filename checks to check for viruses that use malformed MIME to masquerade as non-leaf parts (like message/rfc822). In general, any action you perform in filter_multipart applies to the part itself and any contained parts.


  1. #/etc/mail/mimedefang
  2. sub filter {
  3.    my($entity, $fname, $ext, $type) = @_;
  4.    my $head = $entity->head;
  5.    my $from = $head->get('From);  # 取得郵件表頭中的 From
复制代码



* SMTP AUTH mech  (SMTP 認證部份)
這個部份在 mimedefang 較費事些,首先你的 mimedefang 啟動參數要有
-a auth_authen,auth_type 之類的參數


  1. if (defined($SendmailMacros{'auth_authen'})) {  # 如果有認證通過
  2.    # ...
复制代码


=======
所以,全部大意即為:

  1. sub filter {
  2.    my($entity, $fname, $ext, $type) = @_;
  3.    read_commands_file();  # 重要,如果要讀取 SendmailMacro 時需要
  4.    my $head = $entity->head;
  5.    my $from = $head->get('From);  # 取得郵件表頭中的 From
  6.    $from=~s/[<> ]//g;  # 去除 <> 和多餘的空白 (SPace)
  7.    $Sender=~s/[<> ]//g;
  8.    if ($Sender ne $from) {
  9.           md_syslog("info","$MsgID: Envelope From: $Sender != Header From: $from");

  10.           #return action_bouce();  # 退信
  11.           #return action_quarantine(); # 隔離
  12.           #add_recipient('me@mydomain.com'); # 問題郵件備到別的帳號一份
  13.    }
  14.    if ($Sender !~ /^$SendmailMacros{'auth_authen'}\@/i) { # 比對 Sender 的 username 部份是否和認證同
  15.           md_syslog('info',"MsgID:  Envelope From: $Sender != Auth Authen SendmailMacros{'auth_authen'}");
  16.    }  # md_syslog 是系統記錄的寫法,你要存資料庫的話自己寫個如 log_mysql  ...之類的 function 來處理

复制代码



大概是這樣的思路,其他的細節你自己處理,所有的 code 都是直接寫上來未經測試,可能少部份有語法上的錯誤

[ 本帖最后由 abel 于 2009-10-21 09:58 编辑 ]
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP