introduction to openwebmail - ilrc.edu.tw · •服務緣起 •openwebmail介紹...

81
張凱迪 [email protected] 2009/12/10 Introduction to OpenWebMail 國立宜蘭大學 電算中心 資訊網路組

Upload: others

Post on 12-Oct-2019

3 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Introduction to OpenWebMail - ilrc.edu.tw · •服務緣起 •OpenWebMail介紹 •OpenWebMail安裝 •資安小秘訣 •郵件分析統計 大綱 12/10/2009 3

張凱迪[email protected]

2009/12/10

Introduction to OpenWebMail

國立宜蘭大學 電算中心 資訊網路組

Page 2: Introduction to OpenWebMail - ilrc.edu.tw · •服務緣起 •OpenWebMail介紹 •OpenWebMail安裝 •資安小秘訣 •郵件分析統計 大綱 12/10/2009 3

本簡報內容與簡報使用圖形之著作權分屬國立宜蘭大學、OpenWebMail 與相關單位所有

簡報內容非經正式書面授權同意不得以任何形式更變、轉載、再製、

散佈、出版、展示或傳播

版權聲明

12/10/2009 2

Page 3: Introduction to OpenWebMail - ilrc.edu.tw · •服務緣起 •OpenWebMail介紹 •OpenWebMail安裝 •資安小秘訣 •郵件分析統計 大綱 12/10/2009 3

• 服務緣起• OpenWebMail介紹• OpenWebMail安裝• 資安小秘訣• 郵件分析統計

大綱

12/10/2009 3

Page 4: Introduction to OpenWebMail - ilrc.edu.tw · •服務緣起 •OpenWebMail介紹 •OpenWebMail安裝 •資安小秘訣 •郵件分析統計 大綱 12/10/2009 3

• 服務緣起• OpenWebMail介紹• OpenWebMail安裝• 資安小秘訣• 郵件分析統計

大綱

12/10/2009 4

Page 5: Introduction to OpenWebMail - ilrc.edu.tw · •服務緣起 •OpenWebMail介紹 •OpenWebMail安裝 •資安小秘訣 •郵件分析統計 大綱 12/10/2009 3

• 提供連線單位自行架設電子郵件系統

• 自行配置主機容量使用者權限

• 自行掌握資訊之機密性 / 完整性 / 可用性

• 節省系統購置經費

服務緣起

12/10/2009 5

Page 6: Introduction to OpenWebMail - ilrc.edu.tw · •服務緣起 •OpenWebMail介紹 •OpenWebMail安裝 •資安小秘訣 •郵件分析統計 大綱 12/10/2009 3

• 服務緣起• OpenWebMail介紹• OpenWebMail安裝• 資安小秘訣• 郵件分析統計

大綱

12/10/2009 6

Page 7: Introduction to OpenWebMail - ilrc.edu.tw · •服務緣起 •OpenWebMail介紹 •OpenWebMail安裝 •資安小秘訣 •郵件分析統計 大綱 12/10/2009 3

• 什麼是 Web Mail?

OpenWebMail介紹-什麼是 Web Mail

12/10/2009 7

郵件收發軟體

WebMail

Page 8: Introduction to OpenWebMail - ilrc.edu.tw · •服務緣起 •OpenWebMail介紹 •OpenWebMail安裝 •資安小秘訣 •郵件分析統計 大綱 12/10/2009 3

• WebMail 傳輸方式– 1. Through IMAP/POP3

OpenWebMail介紹-WebMail 傳輸方式

12/10/2009 8

Source: http://dslab.ee.ncku.edu.tw/~tung/openwebmail/webmail.html

Page 9: Introduction to OpenWebMail - ilrc.edu.tw · •服務緣起 •OpenWebMail介紹 •OpenWebMail安裝 •資安小秘訣 •郵件分析統計 大綱 12/10/2009 3

• WebMail 傳輸方式– 2. Direct Access

OpenWebMail介紹-WebMail 傳輸方式

12/10/2009 9

Source: http://dslab.ee.ncku.edu.tw/~tung/openwebmail/webmail.html

Page 10: Introduction to OpenWebMail - ilrc.edu.tw · •服務緣起 •OpenWebMail介紹 •OpenWebMail安裝 •資安小秘訣 •郵件分析統計 大綱 12/10/2009 3

• 官方網站 - http://openwebmail.org

• 主機位於– 美國 Spring Link 骨幹之機房

• 提供者– Daniel Pentecost– Norvasen &

Pentecost Inc.

OpenWebMail介紹

12/10/2009 10

Page 11: Introduction to OpenWebMail - ilrc.edu.tw · •服務緣起 •OpenWebMail介紹 •OpenWebMail安裝 •資安小秘訣 •郵件分析統計 大綱 12/10/2009 3

• 程式發展中心 - 成大電機分散式系統實驗室http://turtle.ee.ncku.edu.tw/openwebmail

• 最新程式碼測試完才對外公佈

• 提供大量鏡像下載

OpenWebMail介紹

12/10/2009 11

Page 12: Introduction to OpenWebMail - ilrc.edu.tw · •服務緣起 •OpenWebMail介紹 •OpenWebMail安裝 •資安小秘訣 •郵件分析統計 大綱 12/10/2009 3

• 歷史– 國立成功大學分散式系統實驗室

• 1998年使用Endymion 發展之 MailMan– 優點: 免費– 缺點: 原始碼經編碼處理增加中文處理能力吃足苦頭

• 2000年導入Ernie Miller 所發展之Neomail– 特點:不透過 POP3 直接處理 server 上之信件檔案– 缺點:速度慢、無法處理大量信件、不支援 HTML顯示– 缺乏功能: 收外部POP3 、無法檢索、不能拼字檢查

• 成大改寫NeoMail– OpenWebMail 於 2001年誕生

OpenWebMail介紹-歷史

12/10/2009 12

Page 13: Introduction to OpenWebMail - ilrc.edu.tw · •服務緣起 •OpenWebMail介紹 •OpenWebMail安裝 •資安小秘訣 •郵件分析統計 大綱 12/10/2009 3

• 特點– 系統

• 良好使用介面• 多國語言 (共支援超過 30 種語言)• 多組圖示、多組佈景、自訂背景• 世界時區切換、日光節約時間支援• 多種認證模組(unix, pop3, mysql, postgres, ldap)與PAM 支援• 使用者 quota 管理 (quota_unixfs, quota_du) , 可強制清除超過配額者過舊的信件或檔案

• 支援虛擬主機/使用者別名• 支援虛擬使用者帳號 (使用 pop3/webmail 無須建立 unix 帳號)• 支援多個網域, 各網域可做不同設定• 支援個別使用者權限設訂• 支援網頁壓縮傳送, 提高傳輸效率• 線上更改密碼• 使用者歷史記錄• 配合 SpeedyCGI, 可常駐於記憶體中執行

OpenWebMail介紹-特點

12/10/2009 13

Page 14: Introduction to OpenWebMail - ilrc.edu.tw · •服務緣起 •OpenWebMail介紹 •OpenWebMail安裝 •資安小秘訣 •郵件分析統計 大綱 12/10/2009 3

• 特點– 郵件列表

• 快速切換不同信件匣• 快速換頁功能• 可依信件狀態、信件日期、寄信人、信件標題、信件大小進行排序

• 可以設定過濾條件, 只列出符合條件之信件• 新信語音通知• 信匣變動通知, 顯示最近進入各信件匣的信件• 變更信件讀取狀態

OpenWebMail介紹-特點

12/10/2009 14

Page 15: Introduction to OpenWebMail - ilrc.edu.tw · •服務緣起 •OpenWebMail介紹 •OpenWebMail安裝 •資安小秘訣 •郵件分析統計 大綱 12/10/2009 3

• 特點– 郵件讀取

• 接近Outllook 的多媒體信件顯示能力• 字集內碼自動轉換 (如: 簡繁轉換, 日文 Shif-JIS/ISO-

2022-JP/EUC-JP, 各種字集/ UTF-8)• 可收取外部 POP3 郵件• 可關閉信件 CGI 連結, 避免Email 地址回傳給廣告商• 可關閉信件的 Javascript, 避免惡意 script 程式• 可將 HTML 信件轉換成純文字格式, 避免 HTML 病毒• 支援讀信回條• 支援自動回覆• 支援信件重組功能• 信件附件可被下載或儲存到網路硬碟

OpenWebMail介紹-特點

12/10/2009 15

Page 16: Introduction to OpenWebMail - ilrc.edu.tw · •服務緣起 •OpenWebMail介紹 •OpenWebMail安裝 •資安小秘訣 •郵件分析統計 大綱 12/10/2009 3

• 特點– 郵件撰寫

• 提供 HTML 信件編寫功能, 可內嵌圖片, 聲音, 表格, 同時支援 Windows IE 與所有平台的 Mozilla

• 支援多組發信地址• 支援寫信底稿• 支援草稿暫存• 支援個人通訊錄與公用通訊錄• 拼字檢查• 可動態切換寫信字集內碼• 可選擇送信字集內碼• 可透過本機或外部主機寄信• 郵件附件可由網路硬碟新增或使用者上傳

OpenWebMail介紹-特點

12/10/2009 16

Page 17: Introduction to OpenWebMail - ilrc.edu.tw · •服務緣起 •OpenWebMail介紹 •OpenWebMail安裝 •資安小秘訣 •郵件分析統計 大綱 12/10/2009 3

• 特點– 郵件過濾

• 可定義個人郵件規則與公用郵件規則• 可呼叫外部程式進行病毒掃描• 可呼叫外部程式進行垃圾信判讀• 支援過濾重複出現過多次信件• 支援過濾寄件人地址格式不正確信件• 支援過濾偽造來源IP位址信件• 支援過濾偽造發信人信件• 支援過濾偽造 EXE 附件型態信件

OpenWebMail介紹-特點

12/10/2009 17

Page 18: Introduction to OpenWebMail - ilrc.edu.tw · •服務緣起 •OpenWebMail介紹 •OpenWebMail安裝 •資安小秘訣 •郵件分析統計 大綱 12/10/2009 3

• 特點– 郵件搜尋

• 針對寄信人, 收信人, 信件檔頭, 信件標題, 信件內容, 附件檔名進行全文檢索

• 同時搜尋多個信件匣• 支援正規表示式 (Regular expression)• 搜尋時, 可自動進行內碼轉換再比對 (eg: 以簡體字搜尋繁體信件)

– 郵件管理• 信件匣建立/更名/刪除/下載• 信件複製/搬移/刪除/下載• 重建 / 修復信件匣索引• 自動清除垃圾桶 N天以上郵件

OpenWebMail介紹-特點

12/10/2009 18

Page 19: Introduction to OpenWebMail - ilrc.edu.tw · •服務緣起 •OpenWebMail介紹 •OpenWebMail安裝 •資安小秘訣 •郵件分析統計 大綱 12/10/2009 3

• 特點– 行事曆

• 年 / 月 / 週 / 日行事曆列表• 全年事件詳細列表• 支援個人行事曆與公用行事曆• 可設定週期性事件• 事件可標明色彩• 事件相關 link可是外部 URL或Open WebMail 中出現的任何 link, 如信件匣信件或是網路硬碟的檔案

• 與電子郵件列表主畫面整合, 提供事件提醒功能• 事件提醒可寄給外部郵件地址, 轉傳到其他裝置

OpenWebMail介紹-特點

12/10/2009 19

Page 20: Introduction to OpenWebMail - ilrc.edu.tw · •服務緣起 •OpenWebMail介紹 •OpenWebMail安裝 •資安小秘訣 •郵件分析統計 大綱 12/10/2009 3

• 特點– 網路硬碟

• 以使用者家目錄作為網路硬碟之Root• 基本目錄與檔案操作, 新增/複製/搬移/刪除 (包含子目錄)

• 檔案上傳與下傳• 多檔或目錄下傳 (即時編成壓縮檔傳回)• 文字檔線上編輯• HTML檔即時預覽 (檔案不必在 public_htm 下)• 壓縮檔建立/ 解壓縮 / 內容列表• 圖檔縮圖功能• 檔案搜尋, 可搜尋檔名或是文字內容• 郵件附件可由網路硬碟新增, 也可儲存到網路硬碟中

OpenWebMail介紹-特點

12/10/2009 20

Page 21: Introduction to OpenWebMail - ilrc.edu.tw · •服務緣起 •OpenWebMail介紹 •OpenWebMail安裝 •資安小秘訣 •郵件分析統計 大綱 12/10/2009 3

• Direct Access

OpenWebMail介紹-運作方式

12/10/2009 21

Source: http://dslab.ee.ncku.edu.tw/~tung/openwebmail/webmail.html

Page 22: Introduction to OpenWebMail - ilrc.edu.tw · •服務緣起 •OpenWebMail介紹 •OpenWebMail安裝 •資安小秘訣 •郵件分析統計 大綱 12/10/2009 3

• 服務緣起• OpenWebMail介紹• OpenWebMail安裝• 資安小秘訣• 郵件分析統計

大綱

12/10/2009 22

Page 23: Introduction to OpenWebMail - ilrc.edu.tw · •服務緣起 •OpenWebMail介紹 •OpenWebMail安裝 •資安小秘訣 •郵件分析統計 大綱 12/10/2009 3

• 需求– Apache web server with cgi enabled– Perl 5.005 or above

– CGI.pm-3.05.tar.gz (required)

– MIME-Base64-3.01.tar.gz (required)

– libnet-1.19.tar.gz (required)

– Digest-1.08.tar.gz (required)

– Digest-MD5-2.33.tar.gz (required)

– Text-Iconv-1.2.tar.gz (required)

– libiconv-1.9.1.tar.gz (required if system doesn't support iconv)

OpenWebMail安裝

12/10/2009 23

Page 24: Introduction to OpenWebMail - ilrc.edu.tw · •服務緣起 •OpenWebMail介紹 •OpenWebMail安裝 •資安小秘訣 •郵件分析統計 大綱 12/10/2009 3

• 需求– CGI-SpeedyCGI-2.22.tar.gz

(optional but highly recommended, for persistent running)

– Compress-Zlib-1.33.tar.gz (optional, for HTTP compression)

– ispell-3.1.20.tar.gz (optional, for spellcheck)

– Quota-1.4.10.tar.gz (optional, for unixfs quota support)

– Authen-PAM-0.14.tar.gz (optional, for auth_pam support)

– openssl-0.9.7d.tar.gz (optional, for pop3 over SSL support, required only if system doesn't support libssl)

– Net_SSLeay.pm-1.25.tar.gz (optional, for pop3 over SSL support)

– IO-Socket-SSL-0.96.tar.gz (optional, for pop3 over SSL support)

OpenWebMail安裝

12/10/2009 24

Page 25: Introduction to OpenWebMail - ilrc.edu.tw · •服務緣起 •OpenWebMail介紹 •OpenWebMail安裝 •資安小秘訣 •郵件分析統計 大綱 12/10/2009 3

• 需求– clamav-0.70.tar.gz

(optional, for viruscheck,available at http://www.clamav.net)– Mail-SpamAssassin-3.02.tar.gz

(optional, for spamcheck, available at http://www.spamassassin.org)– antiword-0.35.tar.gz (optional, for msword preview)– ImageMagick-5.5.3.tar.gz

(optional, for thumbnail support in webdisk)– tnef-1.2.3.1.tar.gz

(optional, tnef is used mostly by mails from MS Outlook and Exchange)– wget-1.9.1.tar.gz

(optional, for URL uploading support in webdisk & msg composing)– lsof_4.73A.freebsd.tar.bz2

(optional, for openwebmail-tool --unlock)

OpenWebMail安裝

12/10/2009 25

Page 26: Introduction to OpenWebMail - ilrc.edu.tw · •服務緣起 •OpenWebMail介紹 •OpenWebMail安裝 •資安小秘訣 •郵件分析統計 大綱 12/10/2009 3

• 建置範例解

– 從Virtual Box 全新安裝 CentOS 5.4

– 從無到有完整建置 Mail Server

– 從無到有完整建置OpenWebMail

– 點出系統預設安裝, 安裝OpenWebMail時缺少的套件

OpenWebMail安裝-建置範例

12/10/2009 26

Page 27: Introduction to OpenWebMail - ilrc.edu.tw · •服務緣起 •OpenWebMail介紹 •OpenWebMail安裝 •資安小秘訣 •郵件分析統計 大綱 12/10/2009 3

• 建置環境– IP Address

• 203.145.202.5

– Domain Name• mailtest.niu.edu.tw

– OS• In Virtual Box• CentOS 5.4

with kernel 2.6.18-164.el5

OpenWebMail安裝-建置範例主機配置

12/10/2009 27

Page 28: Introduction to OpenWebMail - ilrc.edu.tw · •服務緣起 •OpenWebMail介紹 •OpenWebMail安裝 •資安小秘訣 •郵件分析統計 大綱 12/10/2009 3

• 設定域名資訊– 正解

– MX

OpenWebMail安裝-建置範例前置工作

12/10/2009 28

Page 29: Introduction to OpenWebMail - ilrc.edu.tw · •服務緣起 •OpenWebMail介紹 •OpenWebMail安裝 •資安小秘訣 •郵件分析統計 大綱 12/10/2009 3

• 設定域名資訊– 反解

OpenWebMail安裝-建置範例前置工作

12/10/2009 29

Page 30: Introduction to OpenWebMail - ilrc.edu.tw · •服務緣起 •OpenWebMail介紹 •OpenWebMail安裝 •資安小秘訣 •郵件分析統計 大綱 12/10/2009 3

• DNS查詢設定是否正確

OpenWebMail安裝-建置範例前置工作

12/10/2009 30

Page 31: Introduction to OpenWebMail - ilrc.edu.tw · •服務緣起 •OpenWebMail介紹 •OpenWebMail安裝 •資安小秘訣 •郵件分析統計 大綱 12/10/2009 3

• 安裝完OS後補足必要函式庫– yum install compat* gcc*

OpenWebMail安裝-建置範例

12/10/2009 31

Page 32: Introduction to OpenWebMail - ilrc.edu.tw · •服務緣起 •OpenWebMail介紹 •OpenWebMail安裝 •資安小秘訣 •郵件分析統計 大綱 12/10/2009 3

• 停用Sendmail– service sendmail stop– chkconfig sendmail off

OpenWebMail安裝-建置範例

12/10/2009 32

Page 33: Introduction to OpenWebMail - ilrc.edu.tw · •服務緣起 •OpenWebMail介紹 •OpenWebMail安裝 •資安小秘訣 •郵件分析統計 大綱 12/10/2009 3

• 安裝Postix– yum install postfix

OpenWebMail安裝-建置範例

12/10/2009 33

Page 34: Introduction to OpenWebMail - ilrc.edu.tw · •服務緣起 •OpenWebMail介紹 •OpenWebMail安裝 •資安小秘訣 •郵件分析統計 大綱 12/10/2009 3

• 安裝Apache– yum install httpd

OpenWebMail安裝-建置範例

12/10/2009 34

Page 35: Introduction to OpenWebMail - ilrc.edu.tw · •服務緣起 •OpenWebMail介紹 •OpenWebMail安裝 •資安小秘訣 •郵件分析統計 大綱 12/10/2009 3

• 安裝Perl-SuidPerl– yum install perl-suidperl

OpenWebMail安裝-建置範例

12/10/2009 35

Page 36: Introduction to OpenWebMail - ilrc.edu.tw · •服務緣起 •OpenWebMail介紹 •OpenWebMail安裝 •資安小秘訣 •郵件分析統計 大綱 12/10/2009 3

• 安裝Perl-SuidPerl– yum install perl-suidperl

OpenWebMail安裝-建置範例

12/10/2009 36

Page 37: Introduction to OpenWebMail - ilrc.edu.tw · •服務緣起 •OpenWebMail介紹 •OpenWebMail安裝 •資安小秘訣 •郵件分析統計 大綱 12/10/2009 3

• 安裝Iconv

– wget http://openwebmail.org/openwebmail/download/packages/libiconv-1.9.1.tar.gz

– tar -zxvf libiconv-1.9.1.tar.gz– cd libiconv-1.9.1– ./configure– make– make install

– 可以安心裝完

OpenWebMail安裝-建置範例

12/10/2009 37

Page 38: Introduction to OpenWebMail - ilrc.edu.tw · •服務緣起 •OpenWebMail介紹 •OpenWebMail安裝 •資安小秘訣 •郵件分析統計 大綱 12/10/2009 3

• 安裝Text-Iconv

– wget http://openwebmail.org/openwebmail/download/packages/Text-Iconv-1.2.tar.gz

– tar -zxvf Text-Iconv-1.2.tar.gz– cd Text-Iconv-1.2

– 稍微麻煩一點點

OpenWebMail安裝-建置範例

12/10/2009 38

Page 39: Introduction to OpenWebMail - ilrc.edu.tw · •服務緣起 •OpenWebMail介紹 •OpenWebMail安裝 •資安小秘訣 •郵件分析統計 大綱 12/10/2009 3

• 安裝Text-Iconv

– 修改Makefile.PL

OpenWebMail安裝-建置範例

12/10/2009 39

Page 40: Introduction to OpenWebMail - ilrc.edu.tw · •服務緣起 •OpenWebMail介紹 •OpenWebMail安裝 •資安小秘訣 •郵件分析統計 大綱 12/10/2009 3

• 安裝Text-Iconv– perl Makefile.PL

– Make• 輕鬆愉快

OpenWebMail安裝-建置範例

12/10/2009 40

Page 41: Introduction to OpenWebMail - ilrc.edu.tw · •服務緣起 •OpenWebMail介紹 •OpenWebMail安裝 •資安小秘訣 •郵件分析統計 大綱 12/10/2009 3

• 安裝Text-Iconv– Make test

• 討人厭的小地方

OpenWebMail安裝-建置範例

12/10/2009 41

Page 42: Introduction to OpenWebMail - ilrc.edu.tw · •服務緣起 •OpenWebMail介紹 •OpenWebMail安裝 •資安小秘訣 •郵件分析統計 大綱 12/10/2009 3

• 安裝Text-Iconv– 建立link

• ln -s /usr/local/lib/libiconv.so.2 /usr/lib/libiconv.so.2

– make test• 正確無誤!!!

OpenWebMail安裝-建置範例

12/10/2009 42

Page 43: Introduction to OpenWebMail - ilrc.edu.tw · •服務緣起 •OpenWebMail介紹 •OpenWebMail安裝 •資安小秘訣 •郵件分析統計 大綱 12/10/2009 3

• 安裝Text-Iconv

– make install

OpenWebMail安裝-建置範例

12/10/2009 43

Page 44: Introduction to OpenWebMail - ilrc.edu.tw · •服務緣起 •OpenWebMail介紹 •OpenWebMail安裝 •資安小秘訣 •郵件分析統計 大綱 12/10/2009 3

• 主角 OpenWebMail• 取得最新版(2.53)主程式

– cd /var/www/– wget

http://openwebmail.org/openwebmail/download/release/openwebmail-2.53.tar.gz

OpenWebMail安裝-建置範例

12/10/2009 44

Page 45: Introduction to OpenWebMail - ilrc.edu.tw · •服務緣起 •OpenWebMail介紹 •OpenWebMail安裝 •資安小秘訣 •郵件分析統計 大綱 12/10/2009 3

• 解開OpenWebMail– tar zxvf openwebmail-2.53.tar.gz

• 移動檔案至正確路徑– mv data/openwebmail html/

• 刪除無用之資料夾– rmdir data

OpenWebMail安裝-建置範例

12/10/2009 45

Page 46: Introduction to OpenWebMail - ilrc.edu.tw · •服務緣起 •OpenWebMail介紹 •OpenWebMail安裝 •資安小秘訣 •郵件分析統計 大綱 12/10/2009 3

• 修改OpenWebMail組態檔案– cd /var/www/cgi-bin/openwebmail/etc– vim defaults/auth_unix.conf

• 原本– passwdfile_encrypted /etc/master.passwd– passwdmkdb /usr/sbin/pwd_mkdb

• 改成– passwdfile_encrypted /etc/shadow– passwdmkdb none

• 存檔離開

OpenWebMail安裝-建置範例

12/10/2009 46

Page 47: Introduction to OpenWebMail - ilrc.edu.tw · •服務緣起 •OpenWebMail介紹 •OpenWebMail安裝 •資安小秘訣 •郵件分析統計 大綱 12/10/2009 3

• 修改OpenWebMail組態檔案– vim openwebmail.conf

• 原本

OpenWebMail安裝-建置範例

12/10/2009 47

Page 48: Introduction to OpenWebMail - ilrc.edu.tw · •服務緣起 •OpenWebMail介紹 •OpenWebMail安裝 •資安小秘訣 •郵件分析統計 大綱 12/10/2009 3

• 修改OpenWebMail組態檔案– vim openwebmail.conf

• 按照主機配置修改

OpenWebMail安裝-建置範例

12/10/2009 48

Page 49: Introduction to OpenWebMail - ilrc.edu.tw · •服務緣起 •OpenWebMail介紹 •OpenWebMail安裝 •資安小秘訣 •郵件分析統計 大綱 12/10/2009 3

• 更改系統Log組態加入OpenWebMail Log– vim /etc/logrotate.d/syslog

/var/log/openwebmail.log {postrotate

/usr/bin/killall -HUP syslogdendscript

}

OpenWebMail安裝-建置範例

12/10/2009 49

Page 50: Introduction to OpenWebMail - ilrc.edu.tw · •服務緣起 •OpenWebMail介紹 •OpenWebMail安裝 •資安小秘訣 •郵件分析統計 大綱 12/10/2009 3

• 初始 OpenWebMail– /var/www/cgi-bin/openwebmail/openwebmail-tool.pl --

init

OpenWebMail安裝-建置範例

12/10/2009 50

Page 51: Introduction to OpenWebMail - ilrc.edu.tw · •服務緣起 •OpenWebMail介紹 •OpenWebMail安裝 •資安小秘訣 •郵件分析統計 大綱 12/10/2009 3

• 依照指示修改檔案– vim /var/www/cgi-bin/openwebmail/etc/dbm.conf

dbm_ext .dbdbmopen_ext .dbdbmopen_haslock no

OpenWebMail安裝-建置範例

12/10/2009 51

Page 52: Introduction to OpenWebMail - ilrc.edu.tw · •服務緣起 •OpenWebMail介紹 •OpenWebMail安裝 •資安小秘訣 •郵件分析統計 大綱 12/10/2009 3

• 再度執行初始 OpenWebMail– /var/www/cgi-bin/openwebmail/openwebmail-tool.pl --

init

OpenWebMail安裝-建置範例

12/10/2009 52

Page 53: Introduction to OpenWebMail - ilrc.edu.tw · •服務緣起 •OpenWebMail介紹 •OpenWebMail安裝 •資安小秘訣 •郵件分析統計 大綱 12/10/2009 3

• 窺探 OpenWebMail的面貌…

• 啟動postfix & httpd

– Service httpd start– Service postfix start

OpenWebMail安裝-建置範例

12/10/2009 53

Page 54: Introduction to OpenWebMail - ilrc.edu.tw · •服務緣起 •OpenWebMail介紹 •OpenWebMail安裝 •資安小秘訣 •郵件分析統計 大綱 12/10/2009 3

• 網址:• http://mailtest.niu.edu.tw/cgi-bin/openwebmail/openwebmail.pl

OpenWebMail安裝-建置範例

12/10/2009 54

Page 55: Introduction to OpenWebMail - ilrc.edu.tw · •服務緣起 •OpenWebMail介紹 •OpenWebMail安裝 •資安小秘訣 •郵件分析統計 大綱 12/10/2009 3

• 一登入就遇到Error!?

OpenWebMail安裝-建置範例

12/10/2009 55

Page 56: Introduction to OpenWebMail - ilrc.edu.tw · •服務緣起 •OpenWebMail介紹 •OpenWebMail安裝 •資安小秘訣 •郵件分析統計 大綱 12/10/2009 3

• 原來是SELinux惹的禍…

– Vim /etc/selinux/config

• Disabled SELinux再重開機

OpenWebMail安裝-建置範例

12/10/2009 56

Page 57: Introduction to OpenWebMail - ilrc.edu.tw · •服務緣起 •OpenWebMail介紹 •OpenWebMail安裝 •資安小秘訣 •郵件分析統計 大綱 12/10/2009 3

• 安全起見, root不能登入…

OpenWebMail安裝-建置範例

12/10/2009 57

Page 58: Introduction to OpenWebMail - ilrc.edu.tw · •服務緣起 •OpenWebMail介紹 •OpenWebMail安裝 •資安小秘訣 •郵件分析統計 大綱 12/10/2009 3

• 建個帳號再來一次!• Useradd kedy• Passwd kedy

OpenWebMail安裝-建置範例

12/10/2009 58

Page 59: Introduction to OpenWebMail - ilrc.edu.tw · •服務緣起 •OpenWebMail介紹 •OpenWebMail安裝 •資安小秘訣 •郵件分析統計 大綱 12/10/2009 3

• 怎麼不能收發信!?– 原來是Postfix還沒組態!– 編輯postfix組態檔案– vim /etc/postfix/main.cf

• myhostname = mailtest.niu.edu.tw• mydomain = niu.edu.tw• myorigin = $mydomain• inet_interfaces = $myhostname, localhost• mydestination = $myhostname, localhost.$mydomain,

localhost– 重新啟動postfix

OpenWebMail安裝-建置範例

12/10/2009 59

Page 60: Introduction to OpenWebMail - ilrc.edu.tw · •服務緣起 •OpenWebMail介紹 •OpenWebMail安裝 •資安小秘訣 •郵件分析統計 大綱 12/10/2009 3

• 大功告成

OpenWebMail安裝-建置範例

12/10/2009 60

Page 61: Introduction to OpenWebMail - ilrc.edu.tw · •服務緣起 •OpenWebMail介紹 •OpenWebMail安裝 •資安小秘訣 •郵件分析統計 大綱 12/10/2009 3

• 使用YUM 之 OpenWebMail 快速裝法

– 安裝perl-Text-Iconv• wget http://dag.wieers.com/rpm/packages/perl-Text-

Iconv/perl-Text-Iconv-1.4-1.2.el5.rf.i386.rpm• Rpm –ivh perl-Text-Iconv-1.4-1.2.el5.rf.i386.rpm

– 建立 libliconv連結• ln -s /usr/local/lib/libiconv.so.2 /usr/lib/libiconv.so.2

OpenWebMail安裝-YUM速解

12/10/2009 61

Page 62: Introduction to OpenWebMail - ilrc.edu.tw · •服務緣起 •OpenWebMail介紹 •OpenWebMail安裝 •資安小秘訣 •郵件分析統計 大綱 12/10/2009 3

• 增加yum來源, 使之連線至OpenWebMail尋找套建– cd /etc/yum.repos.d

– Lftpgethttp://openwebmail.org/openwebmail/download/redhat/rpm/release/openwebmail.repo

– yum install openwebmail

OpenWebMail安裝-YUM速解

12/10/2009 62

Page 63: Introduction to OpenWebMail - ilrc.edu.tw · •服務緣起 •OpenWebMail介紹 •OpenWebMail安裝 •資安小秘訣 •郵件分析統計 大綱 12/10/2009 3

• 安裝完畢後步驟同投影片47

OpenWebMail安裝-YUM速解

12/10/2009 63

Page 64: Introduction to OpenWebMail - ilrc.edu.tw · •服務緣起 •OpenWebMail介紹 •OpenWebMail安裝 •資安小秘訣 •郵件分析統計 大綱 12/10/2009 3

• 服務緣起• OpenWebMail介紹• OpenWebMail安裝• 資安小秘訣• 郵件分析統計

大綱

12/10/2009 64

Page 65: Introduction to OpenWebMail - ilrc.edu.tw · •服務緣起 •OpenWebMail介紹 •OpenWebMail安裝 •資安小秘訣 •郵件分析統計 大綱 12/10/2009 3

• 管控使用者空間限制

• 避免主機成為垃圾郵件跳板

• 找出帳號/通行碼相同使用者

• 帳號/通行碼不能相同

• 嚴格通行碼設定政策

資安小秘訣

12/10/2009 65

Page 66: Introduction to OpenWebMail - ilrc.edu.tw · •服務緣起 •OpenWebMail介紹 •OpenWebMail安裝 •資安小秘訣 •郵件分析統計 大綱 12/10/2009 3

• 導入Quota功能

– 啟動系統分割區支援quota之形式掛載– 建議使用者檔案分割區與系統分開

• 對使用者執行Quota之Soft & Hard Limit管控

– Edquota [username]– 使用者配額用盡後, 登入 OpenWebMail會顯示session不存在之Error訊息

資安小秘訣管控使用者空間限制

12/10/2009 66

Page 67: Introduction to OpenWebMail - ilrc.edu.tw · •服務緣起 •OpenWebMail介紹 •OpenWebMail安裝 •資安小秘訣 •郵件分析統計 大綱 12/10/2009 3

• 完整配置 Postfix 組態

• 避免信任所有來源做為發信主機– inet_interfaces mynetworks_style mynetworks

relay_domains

• 定期進行maillog檢視, 避免遭使用者誤用

• 宣導使用者通行碼定期更改, 避免遭入侵進行大量郵件散布

資安小秘訣避免主機成為垃圾郵件跳板

12/10/2009 67

Page 68: Introduction to OpenWebMail - ilrc.edu.tw · •服務緣起 •OpenWebMail介紹 •OpenWebMail安裝 •資安小秘訣 •郵件分析統計 大綱 12/10/2009 3

• 原理

– 利用/etc/passwd Dump出系統使用者清單

– 撰寫一支程式, 讀取使用者清單並送出FTP命令

– 抓取使用者家目錄下的檔案

– 若成功抓回檔案表示帳號通行碼相同

– 執行完畢後即可知道帳號通行碼相同的使用者

資安小秘訣找出帳號/通行碼相同使用者

12/10/2009 68

Page 69: Introduction to OpenWebMail - ilrc.edu.tw · •服務緣起 •OpenWebMail介紹 •OpenWebMail安裝 •資安小秘訣 •郵件分析統計 大綱 12/10/2009 3

• 程式碼#include <stdio.h>#include <string.h>int doGetFileSize(const char* filePath, const char* mode){

int fileLength = 0; FILE *fp; if(! (fp = fopen(filePath, mode))){//開啟檔案

return -1; //File Open Error}if(fseek(fp, 0, SEEK_END)) //移動指標到檔案的結尾

return -1; //File seek errorfileLength = ftell(fp) //取得檔案大小單位bytefclose(fp);return fileLength;

}

資安小秘訣找出帳號/通行碼相同使用者

12/10/2009 69

Page 70: Introduction to OpenWebMail - ilrc.edu.tw · •服務緣起 •OpenWebMail介紹 •OpenWebMail安裝 •資安小秘訣 •郵件分析統計 大綱 12/10/2009 3

• 程式碼int main(){

int getyou=0;char username[100]="r9643002";char command_h[2][100]={"wget

ftp://","@140.111.72.4/.bash_profile -O TMPFILE"};char command[256]="";FILE *userlist;if(! (userlist = fopen("userlist", "r")))

return -1; //File Open Error

資安小秘訣找出帳號/通行碼相同使用者

12/10/2009 70

Page 71: Introduction to OpenWebMail - ilrc.edu.tw · •服務緣起 •OpenWebMail介紹 •OpenWebMail安裝 •資安小秘訣 •郵件分析統計 大綱 12/10/2009 3

• 程式碼while(fscanf(userlist,"%s",username)!=EOF)

{//命令表頭char command_h[2][100]={"wget

ftp://","@140.111.72.4/.bash_profile -O TMPFILE"};char command[256]="";strcat(command,command_h[0]);//產生命令wget ftp://strcat(command,username);//wget ftp://[usernamestrcat(command,":");//wget ftp://[username]:strcat(command,username);//wget ftp://[username]:[username]strcat(command,command_h[1]);//wget

ftp://[username]:[username]@pws.niu.edu.tw/.bash_profile -O TMPFILEprintf("\nCommand: %s\n",command);//strcat(command,username);system(command);//Execute the command

資安小秘訣找出帳號/通行碼相同使用者

12/10/2009 71

Page 72: Introduction to OpenWebMail - ilrc.edu.tw · •服務緣起 •OpenWebMail介紹 •OpenWebMail安裝 •資安小秘訣 •郵件分析統計 大綱 12/10/2009 3

• 程式碼if(doGetFileSize("TMPFILE","r")>0)

{//有抓到檔案就改名,check the file size!getyou++;strcpy(command,"mv TMPFILE ");strcat(command, username);system(command);printf("Warning! The same username & password in

%s",username);}

}printf("\n There are %d user's password like their

username.\n",getyou);fclose(userlist);return 0;

}

資安小秘訣找出帳號/通行碼相同使用者

12/10/2009 72

Page 73: Introduction to OpenWebMail - ilrc.edu.tw · •服務緣起 •OpenWebMail介紹 •OpenWebMail安裝 •資安小秘訣 •郵件分析統計 大綱 12/10/2009 3

• /var/www/cgi-bin/openwebmail/openwebmail-prefs.pl

• sub changepassword { …} elsif ( $config{'enable_strictpwd'} &&($newpassword=~/^\d+$/ ||$newpassword=~/^[A-Za-z]+$/) ) {

• 上面程式修改為} elsif ( $config{'enable_strictpwd'} &&

(($newpassword eq $loginname) || $newpassword=~/^\d+$/ || $newpassword=~/^[A-Za-z]+$/) ) {

資安小秘訣帳號/通行碼不能相同

12/10/2009 73

Page 74: Introduction to OpenWebMail - ilrc.edu.tw · •服務緣起 •OpenWebMail介紹 •OpenWebMail安裝 •資安小秘訣 •郵件分析統計 大綱 12/10/2009 3

• 修改 /var/www/cgi-bin/openwebmail/etc/defaults/openwebmail.conf

– enable_changepwd yes• 讓使用者可以透過OpenWebMail更改通行碼

– enable_strictpwd yes • 嚴格通行碼政策 (須英數字混合)

– passwd_minlen 6• 通行碼最短長度,可自行變更(預設為6)

資安小秘訣嚴格通行碼設定政策

12/10/2009 74

Page 75: Introduction to OpenWebMail - ilrc.edu.tw · •服務緣起 •OpenWebMail介紹 •OpenWebMail安裝 •資安小秘訣 •郵件分析統計 大綱 12/10/2009 3

• 服務緣起• OpenWebMail介紹• OpenWebMail安裝• 資安小秘訣• 郵件分析統計

大綱

12/10/2009 75

Page 76: Introduction to OpenWebMail - ilrc.edu.tw · •服務緣起 •OpenWebMail介紹 •OpenWebMail安裝 •資安小秘訣 •郵件分析統計 大綱 12/10/2009 3

• AWStats is a free powerful and featureful tool that generates advanced web, streaming, ftp or mail server statistics, graphically.

• This log analyzer works as a CGI or from command lineand shows you all possible information your log contains, in few graphical web pages.

• It uses a partial information file to be able to process large log files, often and quickly.

– It can analyze log files from all major server tools like Apache log files (NCSA combined/XLF/ELF log format or common/CLF log format), WebStar, IIS (W3C log format) and a lot of other web, proxy, wap, streaming servers, mail servers and some ftp servers.

郵件分析統計 - AWStats

12/10/2009 76

Page 77: Introduction to OpenWebMail - ilrc.edu.tw · •服務緣起 •OpenWebMail介紹 •OpenWebMail安裝 •資安小秘訣 •郵件分析統計 大綱 12/10/2009 3

郵件分析統計 - AWStats

12/10/2009 77

Page 78: Introduction to OpenWebMail - ilrc.edu.tw · •服務緣起 •OpenWebMail介紹 •OpenWebMail安裝 •資安小秘訣 •郵件分析統計 大綱 12/10/2009 3

• 報表功能– 每月記錄– 每日記錄– 每個星期幾– 每小時– 國家– 主機– 發信人– 收信人– SMTP錯誤碼

郵件分析統計 - AWStats

12/10/2009 78

Page 79: Introduction to OpenWebMail - ilrc.edu.tw · •服務緣起 •OpenWebMail介紹 •OpenWebMail安裝 •資安小秘訣 •郵件分析統計 大綱 12/10/2009 3

• 報表功能– 每月記錄– 每日記錄– 每個星期幾– 每小時– 國家– 主機– 發信人– 收信人– SMTP錯誤碼

郵件分析統計 - AWStats

12/10/2009 79

Page 80: Introduction to OpenWebMail - ilrc.edu.tw · •服務緣起 •OpenWebMail介紹 •OpenWebMail安裝 •資安小秘訣 •郵件分析統計 大綱 12/10/2009 3

• 報表功能– 每月記錄– 每日記錄– 每個星期幾– 每小時– 國家– 主機– 發信人– 收信人– SMTP錯誤碼

郵件分析統計 - AWStats

12/10/2009 80

Page 81: Introduction to OpenWebMail - ilrc.edu.tw · •服務緣起 •OpenWebMail介紹 •OpenWebMail安裝 •資安小秘訣 •郵件分析統計 大綱 12/10/2009 3

Q&A

The END

12/10/2009 81