CIT 383 Administrative Scripting Electronic Mail Computer Security
- Slides: 11
CIT 383: Administrative Scripting Electronic Mail Computer Security: Art and Science 1
Topics 1. 2. 3. 4. MTAs SMTP Message Stores POP and IMAP CIT 383: Administrative Scripting
MTAs Mail Transport Agents use SMTP protocol § Receive mail from MUAs. § Route mail across internet. Examples § § § sendmail postfix qmail exim MS Exchange CIT 383: Administrative Scripting
SMTP Example 220 brahms. nku. edu ESMTP Sendmail 8. 13. 3; Wed, 12 Apr 2006 helo mydomain. com 250 brahms. nku. edu Hello mydomain. com, pleased to meet you mail from: me@mydomain. com 250 2. 1. 0 me@mydomain. com. . . Sender ok rcpt to: friend@nku. edu 250 2. 1. 5 friend@nku. edu. . . Recipient ok data 354 Enter mail, end with ". " on a line by itself Subject: Test From: me@mydomain. com To: friend@nku. edu This is a test. . 250 2. 0. 0 k 3 GIcr 001606 Message accepted for delivery quit 221 2. 0. 0 brahms. nku. edu closing connection CIT 383: Administrative Scripting
SMTP Commands HELO EHLO MAIL RCPT VRFY EXPN DATA QUIT RSET HELP hostname FROM: addr TO: addr CIT 383: Administrative Scripting
SMTP in Ruby require 'net/smtp' message = <<EOM From: #{from} To: #{to} Subject: smtp test This is a test message. EOM smtp = Net: : SMTP. new(server, 25) smtp. start do |smtp| smtp. send_message(message, to, from) end CIT 383: Administrative Scripting
Message Store Communication § Receives data from MDA (mail. local, procmail) § Provides data to MAA (IMAP, POP, NFS, web) Types of stores § Files (all messages for a user in one file) § Directories (directory per user) § Databases CIT 383: Administrative Scripting
POP and IMAP POP: Post Office Protocol – Simple download protocol for offline reading. IMAP: Internet Mail Access Protocol – Online and offline modes of reading. – Partial message fetch (headers, attachments, etc. ) – Message state stored on server, not client. – Multiple mailbox and multiple client support. CIT 383: Administrative Scripting
POP 3 Example S: +OK POP 3 server ready <1896. 697170952@dbc. mtview. ca. us> C: APOP mrose c 4 c 9334 bac 560 ecc 979 e 58001 b 3 e 22 fb S: +OK mrose's maildrop has 2 messages (320 octets) C: STAT S: +OK 2 320 C: LIST S: +OK 2 messages (320 octets) S: 1 120 S: 2 200 S: . C: RETR 1 S: +OK 120 octets S: <the POP 3 server sends message 1> S: . C: DELE 1 S: +OK message 1 deleted C: QUIT S: +OK dewey POP 3 server signing off (maildrop empty) CIT 383: Administrative Scripting
Accessing Mail in Ruby Files (mbox format) require ‘mailread’ mbox = Mail. new(fh) POP require ‘net/pop’ pop = Net: : POP 3. new(server) pop. start(user, pass) IMAP require ‘net/imap’ imap = Net: : IMAP. new(server) imap. login(user, pass) CIT 383: Administrative Scripting
References 1. Michael Fitzgerald, Learning Ruby, O’Reilly, 2008. 2. David Flanagan and Yukihiro Matsumoto, The Ruby Programming Language, O’Reilly, 2008. 3. Hal Fulton, The Ruby Way, 2 nd edition, Addison. Wesley, 2007. 4. Robert C. Martin, Clean Code, Prentice Hall, 2008. 5. Dave Thomas with Chad Fowler and Andy Hunt, Programming Ruby, 2 nd edition, Pragmatic Programmers, 2005. Computer Security: Art and Science 11