免费注册 查看新帖 |

Chinaunix

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

[Mail] postfix 如何避免发信人冒名!!!!!!!!!!!!!!!!!!! [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2007-11-21 12:30 |只看该作者 |倒序浏览
20可用积分
RFC882   DNS



最近在建立电邮系统时遇到了一点儿小问题,希望大家帮帮忙 ……

寄信时,怎样确定客户端使用的是真实的寄件人地址?比方说,以mailer的身份通过验证,但是却以test为发信人地址,
要如何避免这种冒名情况?


看了一下

Postfix: The Definitive Guide   

书上如是说:
12.3.2.2 Preventing sender spoofing
To make sure that clients use correct sender addresses when relaying, Postfix allows you to map sender addresses to SASL logins. For example, if you have an address kdent@example.com that should be used only by the SASL user kdent, you can create a file requiring the correct user for that address:

kdent@example.com        kdent
The file is a normal Postfix lookup table and allows regular expressions as well as local parts and domains (see Chapter 4 for information on Postfix lookup tables). Use the parameter smtpd_sender_login_maps in main.cf to indicate the table you create:

smtpd_sender_login_maps = hash:/etc/postfix/sasl_senders
You can list as many addresses as you need in the table. To reject messages from users attempting to use incorrect sender addresses or users who are not authenticated at all who attempt to use a specified address, include the restriction reject_sender_login_mismatch with your restriction parameters (see Chapter 11 for information on UBE restrictions).


我按其方法做了如下:


  1. smtpd_sasl_auth_enable=yes
  2. broken_sasl_auth_clients=yes
  3. smtpd_recipient_restrictions= reject_unknown_recipient_domain,
  4.                 reject_unauth_pipelining,reject_unauth_destination,
  5.         reject_sender_login_mismatch,permit_sasl_authenticated

  6. smtpd_sender_login_maps=mysql:/etc/postfix/mysql_sasl_senders.cf

  7. smtpd_sasl_local_domain=$myhostname,$mydomain,localhost.$mydomain
  8. smtpd_sasl_security_options=noanonymous
  9. smtpd_sasl_application_name=smtpd
  10. smtpd_banner=Welcome to  $myhostname ESMTP,adm:black! U can mail to me!
复制代码


数据库里面内容是:
mysql> select * from mailbox;
+-----------------+-------+----------+----------+---------+------+------+-------+
| name            | home  | username | password | maildir | uid  | gid  | quota |
+-----------------+-------+----------+----------+---------+------+------+-------+
| black@black.vnt | black | black    | black    | black/  | NULL | NULL |       |
| blue@black.vnt  | blue  | blue     | blue     | blue/   | NULL | NULL |       |
| jack@black.vnt  | jack  | jack     | jack     | jack/   |    0 |    0 |       |
| test@black.vnt   | test   | test      | test    | test/    | NULL | NULL |       |
+-----------------+-------+----------+----------+---------+------+------+-------+
4 rows in set (0.00 sec)


mysql_sasl_senders.cf表里面的内容是已经postmap过)
mail:/etc/postfix# less mysql_sasl_senders.cf
user = mail
password = mail
hosts = localhost
dbname = mail
table = mailbox
select_field = username
where_field = name


如果我把reject_sender_login_mismatch去除,正常发信但是没能 Preventing sender spoofing.
但是我加上这一次则出现

Nov 21 11:32:19 mail postfix/smtpd[2394]: NOQUEUE: reject: RCPT from host.black.vnt[200.0.10.1]: 553 5.7.1 <black@black.vnt>: Sender address rejected: not logged in; from=<black@black.vnt> to=<blue@black.vnt> proto=ESMTP helo=<blacklaptop>


正常用户也不能用了


各位可知道原因啊???谢谢

最佳答案

查看完整内容

我使用的方法基本是和你一样的,我不用milter,我的配置如下: (根据我的环境是成功的)main.cf里: 我的maps.cf放在/etc/postfix/mysql里的,别照搬哟mysql_virtual_alias_user_maps.cf内容:user = XXXXpassword = XXXXhosts = 127.0.0.1dbname = postfixtable = aliasselect_field = gotowhere_field = addressmysql_virtual_sender_maps.cf内容:user = XXXXpassword = XXXXhosts = 127.0.0.1dbname = postfixtable = mailbox ...

论坛徽章:
0
2 [报告]
发表于 2007-11-21 12:30 |只看该作者
原帖由 unixnovice 于 2007-11-28 21:34 发表
楼上的兄弟,您说的第二点正是我问题所在!发信验证可用Sasl做,但是第二点应该如何识现呢?望赐教!



我使用的方法基本是和你一样的,我不用milter,我的配置如下: (根据我的环境是成功的)

main.cf里:

  1. #### Preventing sender spoofing ####
  2. smtpd_sender_login_maps = mysql:/etc/postfix/mysql/mysql_virtual_alias_user_maps.cf, mysql:/etc/postfix/mysql/mysql_virtual_sender_maps.cf
  3. smtpd_reject_unlisted_sender = yes
  4. smtpd_sender_restrictions = permit_mynetworks, permit_sasl_authenticated, reject_sender_login_mismatch, reject_authenticated_sender_login_mismatch, reject_unauthenticated_sender_login_mismatch
复制代码


我的maps.cf放在/etc/postfix/mysql里的,别照搬哟

mysql_virtual_alias_user_maps.cf内容:

user = XXXX
password = XXXX
hosts = 127.0.0.1
dbname = postfix
table = alias
select_field = goto
where_field = address


mysql_virtual_sender_maps.cf内容:

user = XXXX
password = XXXX
hosts = 127.0.0.1
dbname = postfix
table = mailbox
select_field = username
where_field = username

我的mailbox表信息是:

  1. +--------------------------+------------+--------------------------+---------------------------+------------+-----------------+---------------------+---------------------+--------+
  2. | username                 | password   | name                     | maildir                   | quota      | domain          | created             | modified            | active |
  3. +--------------------------+------------+--------------------------+---------------------------+------------+-----------------+---------------------+---------------------+--------+
  4. | user@domain     | xxx     | user@domain     | domain.com/user/     | 1048576000 | domain.com     | 2006-09-20 16:55:05 | 2006-09-20 16:55:05 |      1 |
复制代码


我的sasl验证是用username字段里的信息作为user的,所以select_field = username,where_field = username.
你需要根据自己的表结构进行更改.

成功的话当你 telnet server 25假冒地址时会返回:
553 5.7.1 <xxx@xxx.com>: Sender address rejected: not logged in

[ 本帖最后由 恋夏寒 于 2007-12-17 11:41 编辑 ]

论坛徽章:
0
3 [报告]
发表于 2007-11-22 08:25 |只看该作者
提示不是说没有login吗?
要通过sasl验证

论坛徽章:
0
4 [报告]
发表于 2007-11-22 10:49 |只看该作者
写个milter就解决了,这问题我n年前见过,milter中看auth名字和from一致就通过。

论坛徽章:
0
5 [报告]
发表于 2007-11-22 23:47 |只看该作者
原帖由 meilinxiaoxue 于 2007-11-22 08:25 发表
提示不是说没有login吗?
要通过sasl验证



SASl验证没有问题的,因为这一步我调试成功过。只是加上Preventing sender spoofing.就出问题了
提示是说
Sender address rejected:再到 not logged


所以我认为问题出在reject_sender_login_mismatch上面。

论坛徽章:
0
6 [报告]
发表于 2007-11-22 23:54 |只看该作者
原帖由 刘五十三 于 2007-11-22 10:49 发表
写个milter就解决了,这问题我n年前见过,milter中看auth名字和from一致就通过。



那请问一下这个milter应怎么写呢?


权威指南上的方法应该行得通,但是为什么我的就不行呢?是不是我哪儿做错了?

请达人们给予指点……………………

论坛徽章:
0
7 [报告]
发表于 2007-11-23 01:32 |只看该作者
你为何要用sender_login_maps? 你的用户auth的时候,username是user@domain,还是仅仅是user呢?

权威指南的情况是,auth用户是user, mailfrom是user@domain,所以要一个map修正一下。如果你的auth已经是user@domain,被你map之后,反而不match咯。

论坛徽章:
0
8 [报告]
发表于 2007-11-24 21:39 |只看该作者
auth 用的是SASL认证,用的肯定是用户名了



所以这步我觉得我没有错啊

MYSQL_SERVER            localhost
MYSQL_USERNAME          mail
MYSQL_PASSWORD          mail
MYSQL_PORT       3306
MYSQL_SOCKET  /tmp/mysql.sock
MYSQL_DATABASE          mail
MYSQL_USER_TABLE        mailbox
MYSQL_CRYPE_PWFIELD     password
MYSQL_CLEAR_PWFIELD     password
MYSQL_UID_FIELD         "1006"
MYSQL_GID_FIELD         "1006"
MYSQL_LOGIN_FIELD       username
MYSQL_NAME_FIELD        name
MYSQL_HOME_FIELD        concat("/var/vmail/",maildir)
MYSQL_MAILDIR_FIELD     concat("/var/vmail/",maildir)

论坛徽章:
0
9 [报告]
发表于 2007-11-27 14:37 |只看该作者
原帖由 unixnovice 于 2007-11-22 23:54 发表



那请问一下这个milter应怎么写呢?


权威指南上的方法应该行得通,但是为什么我的就不行呢?是不是我哪儿做错了?

请达人们给予指点……………………

google一下milter,这条路肯定能通,而且极为灵活,改设置我觉得不一定能达到你的目的。

论坛徽章:
0
10 [报告]
发表于 2007-11-28 10:14 |只看该作者
这个问题有这么难么?还是大家的电邮服务器不怕地址伪造,一直用不上这功能?
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

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

清除 Cookies - ChinaUnix - Archiver - WAP - TOP