我们的 postfix 服务器上有一个邮件用户,他使用公司邮件向我们的竞争对手发送入侵信息。
我被要求报告该用户上次的操作。
有像 pflogsumm 这样的工具可以提取统计数据,但到目前为止我还没有找到任何有用的东西来获取用户的所有信息,因为数据是多行的。
我想得到这样的东西:
对于发送的邮件
11/11/11 00:00:00 infractor@example.com -> user@anothercompany.com
11/11/11 00:00:01 infractor@example.com -> user2@anothercompany2.com
Run Code Online (Sandbox Code Playgroud)
对于收到的邮件
10/10/11 00:00:00 user@anothercompany.com -> infractor@example.com
10/10/11 00:00:01 user2@anothercompany2.com -> infractor@example.com
Run Code Online (Sandbox Code Playgroud)
我知道我可以自己做一个脚本,但是匹配每封邮件的后缀 ID 不是可以通过简单的 grep 来完成的,而且我有很多邮件历史记录,我必须重新检查分布在不同文件中的邮件等等在。
源日志是标准的后缀格式,例如这个...
Sep 13 16:15:57 server postfix/qmgr[18142]: B35CB5ED3D: from=<infractor@example.com, size=10755, nrcpt=1 (queue active)
Sep 13 16:15:57 server postfix/smtpd[32099]: disconnect from localhost[127.0.0.1]
Sep 13 16:15:57 server postfix/smtp[32420]: 58C3E5EC9C: to=<user@anothercompany.com>, relay=127.0.0.1[127.0.0.1]:10024, delay=1.4, delays=0.01/0/0/1.4, dsn=2.0.0, status=sent (250 2.0.0 Ok, id=32697-04, from MTA([127.0.0.1]:10025): 250 2.0.0 Ok: queued as B35CB5ED3D)
Sep 13 16:15:57 server postfix/qmgr[18142]: 58C3E5EC9C: removed
Sep 13 16:15:57 server postfix/smtp[32379]: B35CB5ED3D: to=<user@anothercompany.com>, relay=mail.anothercompany.com[123.123.123.163]:25, delay=0.06, delays=0.03/0/0.01/0.02, dsn=2.0.0, status=sent (250 2.0.0 Ok: queued as 77D0EB6C025)
Sep 13 16:15:57 server postfix/qmgr[18142]: B35CB5ED3D: removed
Run Code Online (Sandbox Code Playgroud)
下载 perl 脚本maillogconvert.pl并执行它:
perl maillogconvert.pl standard < /var/log/mail.log > result.log
Run Code Online (Sandbox Code Playgroud)
用法:
perl maillogconvert.pl [standard|vadmin] [year] < logfile > output
Run Code Online (Sandbox Code Playgroud)
第一个参数指定邮件日志文件的格式:标准 - 日志文件是标准 postfix、sendmail、qmail 或 mdaemon 日志格式 vadmin - 日志文件是带有 vadmin 多主机支持的 qmail 日志格式
如果当前年份不是正确的年份(即 2002),则第二个参数指定为日志文件添加时间戳的年份。始终使用 4 位数字。如果未指定,则使用当前年份。
如果没有指定输出,它会进入控制台 (stdout)。
归档时间: |
|
查看次数: |
11780 次 |
最近记录: |