Send Mail TransportSend Mail Transport
Protocol (SMTP)Protocol (SMTP)
➢ 1982 - RFC 8211982 - RFC 821
➢ 2008 - RFC 5321 (ESMTP)2008 - RFC 5321 (ESMTP)
➢ TCP ports 25 and 587TCP ports 25 and 587
➢ Mail User Agent(MUA)Mail User Agent(MUA)
➢ Mail Submission Agent(MSA)Mail Submission Agent(MSA)
➢ Mail Transfer Agent(MTA)Mail Transfer Agent(MTA)
➢ Mail Delivery Agent(MDA)Mail Delivery Agent(MDA)
MUA
MSAMSA
MTAMTA
MDAMDA
MTAMTA
mailmail
queuequeue
-mail1-mail1
-mail2-mail2
-mail3-mail3
mailboxmailbox
SMTP commandsSMTP commands
➢ HELOHELO
➢ EHLOEHLO
➢ MAIL FROM:MAIL FROM:
➢ RCPT TO:RCPT TO:
➢ DATADATA
➢ RSETRSET
➢ VRFYVRFY
➢ HELPHELP
➢ QUITQUIT
➢ Valid replies (2xx)Valid replies (2xx)
➢ Transient errors(4xx)Transient errors(4xx)
➢ Permanent errors(5xx)Permanent errors(5xx)
SMTP commandsSMTP commands
hackman@terion:~$ telnet yuhu.biz 25hackman@terion:~$ telnet yuhu.biz 25
Trying 85.14.7.4...Trying 85.14.7.4...
Connected to yuhu.biz.Connected to yuhu.biz.
Escape character is '^]'.Escape character is '^]'.
220 blackpearl.yuhu.biz ESMTP Postfix (2.1.1)220 blackpearl.yuhu.biz ESMTP Postfix (2.1.1)
HELOHELO
501 Syntax: HELO hostname501 Syntax: HELO hostname
HELO yuhu.bizHELO yuhu.biz
250 blackpearl.yuhu.biz250 blackpearl.yuhu.biz
SMTP commandsSMTP commands
hackman@terion:~$ telnet yuhu.biz 25hackman@terion:~$ telnet yuhu.biz 25
Trying 85.14.7.4...Trying 85.14.7.4...
Connected to yuhu.biz.Connected to yuhu.biz.
Escape character is '^]'.Escape character is '^]'.
220 blackpearl.yuhu.biz ESMTP Postfix (2.1.1)220 blackpearl.yuhu.biz ESMTP Postfix (2.1.1)
EHLO yuhu.bizEHLO yuhu.biz
250-blackpearl.yuhu.biz250-blackpearl.yuhu.biz
250-PIPELINING250-PIPELINING
250-SIZE 30720000250-SIZE 30720000
250-VRFY250-VRFY
250-ETRN250-ETRN
250-STARTTLS250-STARTTLS
250-AUTH CRAM-MD5 PLAIN LOGIN DIGEST-MD5250-AUTH CRAM-MD5 PLAIN LOGIN DIGEST-MD5
250-AUTH=CRAM-MD5 PLAIN LOGIN DIGEST-MD5250-AUTH=CRAM-MD5 PLAIN LOGIN DIGEST-MD5
250 8BITMIME250 8BITMIME
SMTP commandsSMTP commands
hackman@terion:~$ telnet yuhu.biz 25hackman@terion:~$ telnet yuhu.biz 25
Trying 85.14.7.4...Trying 85.14.7.4...
Connected to yuhu.biz.Connected to yuhu.biz.
Escape character is '^]'.Escape character is '^]'.
HELO yuhu.bizHELO yuhu.biz
250 blackpearl.yuhu.biz250 blackpearl.yuhu.biz
MAIL FROM: mm@yuhu.bizMAIL FROM: mm@yuhu.biz
250 Ok250 Ok
RCPT TO: mm@yuhu.bizRCPT TO: mm@yuhu.biz
250 Ok250 Ok
DATADATA
354 End data with <CR><LF>.<CR><LF>354 End data with <CR><LF>.<CR><LF>
Subject: testingSubject: testing
test 1test 1
..
250 Ok: queued as 450D1156263C250 Ok: queued as 450D1156263C
SMTP commandsSMTP commands
hackman@terion:~$ telnet yuhu.biz 25hackman@terion:~$ telnet yuhu.biz 25
Trying 85.14.7.4...Trying 85.14.7.4...
Connected to yuhu.biz.Connected to yuhu.biz.
Escape character is '^]'.Escape character is '^]'.
HELO yuhu.bizHELO yuhu.biz
250 blackpearl.yuhu.biz250 blackpearl.yuhu.biz
VRFY hackman@yuhu.bizVRFY hackman@yuhu.biz
252 hackman@yuhu.biz252 hackman@yuhu.biz
VRFY dsadas@yuhu.bizVRFY dsadas@yuhu.biz
550 <dsadas@yuhu.biz>: Recipient address550 <dsadas@yuhu.biz>: Recipient address
rejected: User unknown in virtual mailbox tablerejected: User unknown in virtual mailbox table
RSETRSET
250 Ok250 Ok
quitquit
221 Bye221 Bye
SMTPSMTP
➢ Retry interval, at least 30minRetry interval, at least 30min
➢ Give-up time, at least 4-5 daysGive-up time, at least 4-5 days
➢ Storage - either Mailbox or MaildirStorage - either Mailbox or Maildir
➢ Failover setupFailover setup
SMTPSMTP
Mailbox vs. MaildirMailbox vs. Maildir
mail# ls -1Amail# ls -1A
SpamSpam
mail-trashmail-trash
saved-draftssaved-drafts
saved-messagessaved-messages
sent-mailsent-mail
mail# ls -1Amail# ls -1A
camera/camera/
cur/cur/
new/new/
tmp/tmp/
mail# ls -1Amail# ls -1A
SpamSpam
mail-trashmail-trash
saved-draftssaved-drafts
saved-messagessaved-messages
sent-mailsent-mail
SMTP failoverSMTP failover
IN MX 10 mail.example.com.IN MX 10 mail.example.com.
IN MX 20 mail2.example.com.IN MX 20 mail2.example.com.
mailmail IN A 123.123.13.11IN A 123.123.13.11
mail2mail2 IN A 123.123.13.12IN A 123.123.13.12
.13.11.13.11
.13.12.13.12
SMTP failoverSMTP failover
IN MX 10 mail.example.com.IN MX 10 mail.example.com.
IN MX 20 mail2.example.com.IN MX 20 mail2.example.com.
mailmail IN A 123.123.13.11IN A 123.123.13.11
mail2mail2 IN A 123.123.13.12IN A 123.123.13.12
.13.11.13.11
.13.12.13.12
SMTP failoverSMTP failover
IN MX 10 mail.example.com.IN MX 10 mail.example.com.
IN MX 20 mail2.example.com.IN MX 20 mail2.example.com.
mailmail IN A 123.123.13.11IN A 123.123.13.11
mail2mail2 IN A 123.123.13.12IN A 123.123.13.12
.13.11.13.11
.13.12.13.12
Post Office Protocol - POPPost Office Protocol - POP
➢ 1984 – POP1984 – POP - RFC 918- RFC 918
➢ 1985 – POP21985 – POP2 - RFC 973- RFC 973
➢ 1988 – POP31988 – POP3 - RFC 1081- RFC 1081
➢ 1996 – POP31996 – POP3 - RFC 1939- RFC 1939
➢ TCP ports 110, 995(SSL)TCP ports 110, 995(SSL)
POP3 commandsPOP3 commands
➢ USERUSER
➢ PASSPASS
➢ LISTLIST
➢ STATSTAT
➢ UIDLUIDL
➢ RETRRETR
➢ DELEDELE
➢ QUITQUIT
➢ Valid replies (+OK)Valid replies (+OK)
➢ Negative replies(-ERR)Negative replies(-ERR)
➢ Single connectionSingle connection
POP3 commandsPOP3 commands
hackman@BlackPearl: ~$ telnet localhost 110hackman@BlackPearl: ~$ telnet localhost 110
Trying 127.0.0.1...Trying 127.0.0.1...
Connected to 127.0.0.1.Connected to 127.0.0.1.
Escape character is '^]'.Escape character is '^]'.
+OK+OK Dovecot ready.Dovecot ready.
USER userX@yuhu.bizUSER userX@yuhu.biz
+OK+OK
PASS Jer0n1m0!PASS Jer0n1m0!
+OK Logged in.+OK Logged in.
STATSTAT
+OK 1717 21744442+OK 1717 21744442
POP3 commandsPOP3 commands
LISTLIST
+OK 1717 messages:+OK 1717 messages:
1 84821 8482
2 808532 80853
3 330933 33093
4 55434 5543
..........
1715 80601715 8060
1716 65581716 6558
1717 46151717 4615
..
RETR 1717RETR 1717
___mail message here______mail message here___
..
DELE 1717DELE 1717
+OK Marked to be deleted.+OK Marked to be deleted.
Interactive Message AccessInteractive Message Access
Protocol - IMAPProtocol - IMAP
➢ 1988 – IMAP 21988 – IMAP 2 - RFC 1064- RFC 1064
➢ 1991 – IMAP 31991 – IMAP 3 - RFC 1203- RFC 1203
➢ 2003 – IMAP 42003 – IMAP 4 - RFC 3501- RFC 3501
➢ becomes INTERNET MESSAGE ACCESS PROTOCOLbecomes INTERNET MESSAGE ACCESS PROTOCOL
➢ 2011 – SRV records – RFC 61862011 – SRV records – RFC 6186
➢ 2013 – IMAP 42013 – IMAP 4 - RFC 6858- RFC 6858
➢ TCP port 143, 993(SSL)TCP port 143, 993(SSL)
Interactive Message AccessInteractive Message Access
Protocol - IMAPProtocol - IMAP
➢ Support multiple connectionsSupport multiple connections
➢ Supports foldersSupports folders
➢ Support pulling only the headers ofSupport pulling only the headers of
the e-mail, pull the data on demandthe e-mail, pull the data on demand
➢ Support mail PUSH(sending mail)Support mail PUSH(sending mail)
IMAP SRV records - RFC6186IMAP SRV records - RFC6186
_submission._tcp.example.com. SRV 0 1 587_submission._tcp.example.com. SRV 0 1 587
mail.example.com.mail.example.com.
_service._proto.name TTL class SRV priority weight port_service._proto.name TTL class SRV priority weight port
targettarget
- service: the symbolic name of the desired service.- service: the symbolic name of the desired service.
- proto: the transport protocol of the desired service; this is- proto: the transport protocol of the desired service; this is
usually either TCP or UDP.usually either TCP or UDP.
- name: the domain name for which this record is valid.- name: the domain name for which this record is valid.
- TTL: standard DNS time to live field.- TTL: standard DNS time to live field.
- class: standard DNS class field (this is always IN).- class: standard DNS class field (this is always IN).
- priority: the priority of the target host, lower value means- priority: the priority of the target host, lower value means
more preferred.more preferred.
- weight: A relative weight for records with the same priority.- weight: A relative weight for records with the same priority.
- port: the TCP or UDP port on which the service is to be- port: the TCP or UDP port on which the service is to be
found.found.
- target: the canonical hostname of the machine providing- target: the canonical hostname of the machine providing
the service.the service.
IMAP Basic commandsIMAP Basic commands
➢ a001 login USER PASSa001 login USER PASS
➢ a001 logouta001 logout
➢ a001 select FOLDERa001 select FOLDER
➢ a001 list "" *a001 list "" *
➢ a001 fetch PARAMa001 fetch PARAM
➢ ALL/HEADERS/BODYALL/HEADERS/BODY
➢ a001 delete "Message"a001 delete "Message"
➢ Valid replies - (a00x OK)Valid replies - (a00x OK)
➢ Negative replies - (a00x BAD or NO)Negative replies - (a00x BAD or NO)
IMAPIMAP
hackman@BlackPearl: ~$ telnet localhost 143hackman@BlackPearl: ~$ telnet localhost 143
Trying 127.0.0.1...Trying 127.0.0.1...
Connected to 127.0.0.1.Connected to 127.0.0.1.
Escape character is '^]'.Escape character is '^]'.
* OK* OK [CAPABILITY IMAP4rev1 LITERAL+ SASL-IR[CAPABILITY IMAP4rev1 LITERAL+ SASL-IR
LOGIN-REFERRALS ID ENABLE IDLE STARTTLSLOGIN-REFERRALS ID ENABLE IDLE STARTTLS
AUTH=PLAIN] Dovecot ready.AUTH=PLAIN] Dovecot ready.
a001 login userX@yuhu.biz Jer0n1m0!a001 login userX@yuhu.biz Jer0n1m0!
a001 OKa001 OK [CAPABILITY IMAP4rev1 LITERAL+ SASL-IR[CAPABILITY IMAP4rev1 LITERAL+ SASL-IR
LOGIN-REFERRALS ID ENABLE IDLE SORTLOGIN-REFERRALS ID ENABLE IDLE SORT
SORT=DISPLAY THREAD=REFERENCESSORT=DISPLAY THREAD=REFERENCES
THREAD=REFS MULTIAPPEND UNSELECT CHILDRENTHREAD=REFS MULTIAPPEND UNSELECT CHILDREN
NAMESPACE UIDPLUS LIST-EXTENDED I18NLEVEL=1NAMESPACE UIDPLUS LIST-EXTENDED I18NLEVEL=1
CONDSTORE QRESYNC ESEARCH ESORT SEARCHRESCONDSTORE QRESYNC ESEARCH ESORT SEARCHRES
WITHIN CONTEXT=SEARCH LIST-STATUS QUOTA]WITHIN CONTEXT=SEARCH LIST-STATUS QUOTA]
Logged inLogged in
IMAPIMAP
a002 lista002 list
a002 BADa002 BAD Error in IMAP command LIST: InvalidError in IMAP command LIST: Invalid
reference.reference.
a003 select inboxa003 select inbox
* FLAGS (Answered Flagged Deleted Seen Draft* FLAGS (Answered Flagged Deleted Seen Draft
$label2)$label2)
* OK [PERMANENTFLAGS (Answered Flagged* OK [PERMANENTFLAGS (Answered Flagged
Deleted Seen Draft $label2 *)] Flags permitted.Deleted Seen Draft $label2 *)] Flags permitted.
* 1714 EXISTS* 1714 EXISTS
* 0 RECENT* 0 RECENT
* OK [UIDVALIDITY 1330989345] UIDs valid* OK [UIDVALIDITY 1330989345] UIDs valid
* OK [UIDNEXT 59881] Predicted next UID* OK [UIDNEXT 59881] Predicted next UID
* OK [HIGHESTMODSEQ 1] Highest* OK [HIGHESTMODSEQ 1] Highest
a003 OKa003 OK [READ-WRITE] Select completed.[READ-WRITE] Select completed.
IMAPIMAP
a004 list "" *a004 list "" *
* LIST (HasNoChildren) "." "Spam"* LIST (HasNoChildren) "." "Spam"
* LIST (HasNoChildren) "." "INBOX"* LIST (HasNoChildren) "." "INBOX"
a004 OKa004 OK List completed.List completed.
a005 FETCH 1:15 ENVELOPEa005 FETCH 1:15 ENVELOPE
* 1 FETCH (ENVELOPE ("Thu, 23 May 2013 07:58:06* 1 FETCH (ENVELOPE ("Thu, 23 May 2013 07:58:06
+0000" "RE: svn commit: r1484852 - in+0000" "RE: svn commit: r1484852 - in
/httpd/httpd/trunk: CHANGES/httpd/httpd/trunk: CHANGES
modules/http/http_filters.c"modules/http/http_filters.c"
* 2 FETCH (ENVELOPE ("Thu, 23 May 2013 10:17:56* 2 FETCH (ENVELOPE ("Thu, 23 May 2013 10:17:56
+0200" {89}......+0200" {89}......
......
* 15 FETCH* 15 FETCH (ENVELOPE ..........(ENVELOPE ..........
a005 OKa005 OK Fetch completed.Fetch completed.
Hypertext Transfer ProtocolHypertext Transfer Protocol
HTTPHTTP
➢ 1995 – HTML 2.01995 – HTML 2.0 - RFC 1866- RFC 1866
➢ 1996 – HTTP/1.01996 – HTTP/1.0 - RFC 1945- RFC 1945
➢ 1997 – HTTP/1.11997 – HTTP/1.1 - RFC 2068- RFC 2068
➢ 1999 – HTTP/1.11999 – HTTP/1.1 - RFC 2616- RFC 2616
➢ 2012 – STATUS codes – RFC 65852012 – STATUS codes – RFC 6585
➢ 1995 – URI1995 – URI - RFC 1808- RFC 1808
➢ 2005 – URI2005 – URI - RFC 3986- RFC 3986
➢ Uniform Resource Identifier (URI)Uniform Resource Identifier (URI)
proto :// userinfo @ host : port / pathproto :// userinfo @ host : port / path
user : passuser : pass
useruser
Hypertext Transfer ProtocolHypertext Transfer Protocol
HTTPHTTP
➢ Absolute URI or PathAbsolute URI or Path
➢ http://x.com/images/srpr/logo4w.pnghttp://x.com/images/srpr/logo4w.png
➢ /images/srpr/logo4w.png/images/srpr/logo4w.png
➢ Request methodsRequest methods
➢ GETGET
➢ POSTPOST
➢ HEADHEAD
➢ OPTIONSOPTIONS
➢ CONNECTCONNECT
Hypertext Transfer ProtocolHypertext Transfer Protocol
HTTPHTTP
➢ Request methodsRequest methods
➢ GETGET
➢ POSTPOST
➢ HEADHEAD
➢ OPTIONSOPTIONS
➢ CONNECTCONNECT
HTTPHTTP
➢ Request HeadersRequest Headers
➢ HostHost
➢ Accept-CharsetAccept-Charset
➢ Accept-EncodingAccept-Encoding
➢ AuthorizationAuthorization
➢ RangeRange
➢ RefererReferer
➢ User-AgentUser-Agent
HTTP/1.0 vs. HTTP/1.1HTTP/1.0 vs. HTTP/1.1
➢ MethodsMethods
➢ GETGET
➢ HEADHEAD
➢ POSTPOST
➢ MethodsMethods
➢ GETGET
➢ HEADHEAD
➢ POSTPOST
➢ OPTIONSOPTIONS
➢ CONNECTCONNECT
➢ PUTPUT
➢ DELETEDELETE
HTTP/1.0 vs. HTTP/1.1HTTP/1.0 vs. HTTP/1.1
➢ HeadersHeaders
➢ AuthorizationAuthorization
➢ RefererReferer
➢ User-AgentUser-Agent
➢ HeadersHeaders
➢ HostHost
➢ Accept-CharsetAccept-Charset
➢ Accept-EncodingAccept-Encoding
➢ AuthorizationAuthorization
➢ RangeRange
➢ RefererReferer
➢ User-AgentUser-Agent
HTTP/1.0 vs. HTTP/1.1HTTP/1.0 vs. HTTP/1.1
hackman@terion:~$ telnet google.com 80hackman@terion:~$ telnet google.com 80
Trying 173.194.39.100...Trying 173.194.39.100...
Connected to google.com.Connected to google.com.
Escape character is '^]'.Escape character is '^]'.
GET / HTTP/1.0GET / HTTP/1.0
HTTP/1.0 302 FoundHTTP/1.0 302 Found
Location: http://www.google.bg/Location: http://www.google.bg/
Cache-Control: privateCache-Control: private
Content-Type: text/html; charset=UTF-8Content-Type: text/html; charset=UTF-8
Date: Thu, 06 Jun 2013 08:35:46 GMTDate: Thu, 06 Jun 2013 08:35:46 GMT
Server: gwsServer: gws
Content-Length: 218Content-Length: 218
Connection closed.Connection closed.
HTTP/1.0 vs. HTTP/1.1HTTP/1.0 vs. HTTP/1.1
hackman@terion:~$ telnet google.com 80hackman@terion:~$ telnet google.com 80
Trying 173.194.39.99...Trying 173.194.39.99...
Connected to google.com.Connected to google.com.
Escape character is '^]'.Escape character is '^]'.
GET / HTTP/1.1GET / HTTP/1.1
Host: google.comHost: google.com
HTTP/1.1 301 Moved PermanentlyHTTP/1.1 301 Moved Permanently
Location: http://www.google.com/Location: http://www.google.com/
Content-Type: text/html; charset=UTF-8Content-Type: text/html; charset=UTF-8
Date: Thu, 06 Jun 2013 08:36:01 GMTDate: Thu, 06 Jun 2013 08:36:01 GMT
Expires: Sat, 06 Jul 2013 08:36:01 GMTExpires: Sat, 06 Jul 2013 08:36:01 GMT
Cache-Control: public, max-age=2592000Cache-Control: public, max-age=2592000
Server: gwsServer: gws
Content-Length: 219Content-Length: 219
.......Connection still open............Connection still open.....
HTTP OPTIONSHTTP OPTIONS
hackman@terion:~$ telnet s1 81hackman@terion:~$ telnet s1 81
Trying 192.168.155.100...Trying 192.168.155.100...
Connected to s1.Connected to s1.
Escape character is '^]'.Escape character is '^]'.
OPTIONS / HTTP/1.0OPTIONS / HTTP/1.0
HTTP/1.1 200 OKHTTP/1.1 200 OK
Date: Thu, 06 Jun 2013 15:13:30 GMTDate: Thu, 06 Jun 2013 15:13:30 GMT
Server: ApacheServer: Apache
Allow: GET,HEAD,POST,OPTIONSAllow: GET,HEAD,POST,OPTIONS
Host-Header: 192fc2e7e50945beb8231a492d6a8024Host-Header: 192fc2e7e50945beb8231a492d6a8024
Content-Length: 0Content-Length: 0
Connection: closeConnection: close
Content-Type: text/htmlContent-Type: text/html
HTTP/1.0 requestHTTP/1.0 request
RequestRequest
Response and closeResponse and close
TimeoutTimeout
HTTP/1.1 requestHTTP/1.1 request
RequestRequest
ResponseResponse
RequestRequest
ResponseResponse
KeepAliveTimeoutKeepAliveTimeout
HTTPHTTP
➢ Request with headerRequest with header
➢ Request with cookieRequest with cookie
➢ Difference between normal and HEADDifference between normal and HEAD
requestsrequests

7.protocols 2

  • 1.
    Send Mail TransportSendMail Transport Protocol (SMTP)Protocol (SMTP) ➢ 1982 - RFC 8211982 - RFC 821 ➢ 2008 - RFC 5321 (ESMTP)2008 - RFC 5321 (ESMTP) ➢ TCP ports 25 and 587TCP ports 25 and 587 ➢ Mail User Agent(MUA)Mail User Agent(MUA) ➢ Mail Submission Agent(MSA)Mail Submission Agent(MSA) ➢ Mail Transfer Agent(MTA)Mail Transfer Agent(MTA) ➢ Mail Delivery Agent(MDA)Mail Delivery Agent(MDA)
  • 2.
  • 3.
    SMTP commandsSMTP commands ➢HELOHELO ➢ EHLOEHLO ➢ MAIL FROM:MAIL FROM: ➢ RCPT TO:RCPT TO: ➢ DATADATA ➢ RSETRSET ➢ VRFYVRFY ➢ HELPHELP ➢ QUITQUIT ➢ Valid replies (2xx)Valid replies (2xx) ➢ Transient errors(4xx)Transient errors(4xx) ➢ Permanent errors(5xx)Permanent errors(5xx)
  • 4.
    SMTP commandsSMTP commands hackman@terion:~$telnet yuhu.biz 25hackman@terion:~$ telnet yuhu.biz 25 Trying 85.14.7.4...Trying 85.14.7.4... Connected to yuhu.biz.Connected to yuhu.biz. Escape character is '^]'.Escape character is '^]'. 220 blackpearl.yuhu.biz ESMTP Postfix (2.1.1)220 blackpearl.yuhu.biz ESMTP Postfix (2.1.1) HELOHELO 501 Syntax: HELO hostname501 Syntax: HELO hostname HELO yuhu.bizHELO yuhu.biz 250 blackpearl.yuhu.biz250 blackpearl.yuhu.biz
  • 5.
    SMTP commandsSMTP commands hackman@terion:~$telnet yuhu.biz 25hackman@terion:~$ telnet yuhu.biz 25 Trying 85.14.7.4...Trying 85.14.7.4... Connected to yuhu.biz.Connected to yuhu.biz. Escape character is '^]'.Escape character is '^]'. 220 blackpearl.yuhu.biz ESMTP Postfix (2.1.1)220 blackpearl.yuhu.biz ESMTP Postfix (2.1.1) EHLO yuhu.bizEHLO yuhu.biz 250-blackpearl.yuhu.biz250-blackpearl.yuhu.biz 250-PIPELINING250-PIPELINING 250-SIZE 30720000250-SIZE 30720000 250-VRFY250-VRFY 250-ETRN250-ETRN 250-STARTTLS250-STARTTLS 250-AUTH CRAM-MD5 PLAIN LOGIN DIGEST-MD5250-AUTH CRAM-MD5 PLAIN LOGIN DIGEST-MD5 250-AUTH=CRAM-MD5 PLAIN LOGIN DIGEST-MD5250-AUTH=CRAM-MD5 PLAIN LOGIN DIGEST-MD5 250 8BITMIME250 8BITMIME
  • 6.
    SMTP commandsSMTP commands hackman@terion:~$telnet yuhu.biz 25hackman@terion:~$ telnet yuhu.biz 25 Trying 85.14.7.4...Trying 85.14.7.4... Connected to yuhu.biz.Connected to yuhu.biz. Escape character is '^]'.Escape character is '^]'. HELO yuhu.bizHELO yuhu.biz 250 blackpearl.yuhu.biz250 blackpearl.yuhu.biz MAIL FROM: mm@yuhu.bizMAIL FROM: mm@yuhu.biz 250 Ok250 Ok RCPT TO: mm@yuhu.bizRCPT TO: mm@yuhu.biz 250 Ok250 Ok DATADATA 354 End data with <CR><LF>.<CR><LF>354 End data with <CR><LF>.<CR><LF> Subject: testingSubject: testing test 1test 1 .. 250 Ok: queued as 450D1156263C250 Ok: queued as 450D1156263C
  • 7.
    SMTP commandsSMTP commands hackman@terion:~$telnet yuhu.biz 25hackman@terion:~$ telnet yuhu.biz 25 Trying 85.14.7.4...Trying 85.14.7.4... Connected to yuhu.biz.Connected to yuhu.biz. Escape character is '^]'.Escape character is '^]'. HELO yuhu.bizHELO yuhu.biz 250 blackpearl.yuhu.biz250 blackpearl.yuhu.biz VRFY hackman@yuhu.bizVRFY hackman@yuhu.biz 252 hackman@yuhu.biz252 hackman@yuhu.biz VRFY dsadas@yuhu.bizVRFY dsadas@yuhu.biz 550 <dsadas@yuhu.biz>: Recipient address550 <dsadas@yuhu.biz>: Recipient address rejected: User unknown in virtual mailbox tablerejected: User unknown in virtual mailbox table RSETRSET 250 Ok250 Ok quitquit 221 Bye221 Bye
  • 8.
    SMTPSMTP ➢ Retry interval,at least 30minRetry interval, at least 30min ➢ Give-up time, at least 4-5 daysGive-up time, at least 4-5 days ➢ Storage - either Mailbox or MaildirStorage - either Mailbox or Maildir ➢ Failover setupFailover setup
  • 9.
    SMTPSMTP Mailbox vs. MaildirMailboxvs. Maildir mail# ls -1Amail# ls -1A SpamSpam mail-trashmail-trash saved-draftssaved-drafts saved-messagessaved-messages sent-mailsent-mail mail# ls -1Amail# ls -1A camera/camera/ cur/cur/ new/new/ tmp/tmp/ mail# ls -1Amail# ls -1A SpamSpam mail-trashmail-trash saved-draftssaved-drafts saved-messagessaved-messages sent-mailsent-mail
  • 10.
    SMTP failoverSMTP failover INMX 10 mail.example.com.IN MX 10 mail.example.com. IN MX 20 mail2.example.com.IN MX 20 mail2.example.com. mailmail IN A 123.123.13.11IN A 123.123.13.11 mail2mail2 IN A 123.123.13.12IN A 123.123.13.12 .13.11.13.11 .13.12.13.12
  • 11.
    SMTP failoverSMTP failover INMX 10 mail.example.com.IN MX 10 mail.example.com. IN MX 20 mail2.example.com.IN MX 20 mail2.example.com. mailmail IN A 123.123.13.11IN A 123.123.13.11 mail2mail2 IN A 123.123.13.12IN A 123.123.13.12 .13.11.13.11 .13.12.13.12
  • 12.
    SMTP failoverSMTP failover INMX 10 mail.example.com.IN MX 10 mail.example.com. IN MX 20 mail2.example.com.IN MX 20 mail2.example.com. mailmail IN A 123.123.13.11IN A 123.123.13.11 mail2mail2 IN A 123.123.13.12IN A 123.123.13.12 .13.11.13.11 .13.12.13.12
  • 13.
    Post Office Protocol- POPPost Office Protocol - POP ➢ 1984 – POP1984 – POP - RFC 918- RFC 918 ➢ 1985 – POP21985 – POP2 - RFC 973- RFC 973 ➢ 1988 – POP31988 – POP3 - RFC 1081- RFC 1081 ➢ 1996 – POP31996 – POP3 - RFC 1939- RFC 1939 ➢ TCP ports 110, 995(SSL)TCP ports 110, 995(SSL)
  • 14.
    POP3 commandsPOP3 commands ➢USERUSER ➢ PASSPASS ➢ LISTLIST ➢ STATSTAT ➢ UIDLUIDL ➢ RETRRETR ➢ DELEDELE ➢ QUITQUIT ➢ Valid replies (+OK)Valid replies (+OK) ➢ Negative replies(-ERR)Negative replies(-ERR) ➢ Single connectionSingle connection
  • 15.
    POP3 commandsPOP3 commands hackman@BlackPearl:~$ telnet localhost 110hackman@BlackPearl: ~$ telnet localhost 110 Trying 127.0.0.1...Trying 127.0.0.1... Connected to 127.0.0.1.Connected to 127.0.0.1. Escape character is '^]'.Escape character is '^]'. +OK+OK Dovecot ready.Dovecot ready. USER userX@yuhu.bizUSER userX@yuhu.biz +OK+OK PASS Jer0n1m0!PASS Jer0n1m0! +OK Logged in.+OK Logged in. STATSTAT +OK 1717 21744442+OK 1717 21744442
  • 16.
    POP3 commandsPOP3 commands LISTLIST +OK1717 messages:+OK 1717 messages: 1 84821 8482 2 808532 80853 3 330933 33093 4 55434 5543 .......... 1715 80601715 8060 1716 65581716 6558 1717 46151717 4615 .. RETR 1717RETR 1717 ___mail message here______mail message here___ .. DELE 1717DELE 1717 +OK Marked to be deleted.+OK Marked to be deleted.
  • 17.
    Interactive Message AccessInteractiveMessage Access Protocol - IMAPProtocol - IMAP ➢ 1988 – IMAP 21988 – IMAP 2 - RFC 1064- RFC 1064 ➢ 1991 – IMAP 31991 – IMAP 3 - RFC 1203- RFC 1203 ➢ 2003 – IMAP 42003 – IMAP 4 - RFC 3501- RFC 3501 ➢ becomes INTERNET MESSAGE ACCESS PROTOCOLbecomes INTERNET MESSAGE ACCESS PROTOCOL ➢ 2011 – SRV records – RFC 61862011 – SRV records – RFC 6186 ➢ 2013 – IMAP 42013 – IMAP 4 - RFC 6858- RFC 6858 ➢ TCP port 143, 993(SSL)TCP port 143, 993(SSL)
  • 18.
    Interactive Message AccessInteractiveMessage Access Protocol - IMAPProtocol - IMAP ➢ Support multiple connectionsSupport multiple connections ➢ Supports foldersSupports folders ➢ Support pulling only the headers ofSupport pulling only the headers of the e-mail, pull the data on demandthe e-mail, pull the data on demand ➢ Support mail PUSH(sending mail)Support mail PUSH(sending mail)
  • 19.
    IMAP SRV records- RFC6186IMAP SRV records - RFC6186 _submission._tcp.example.com. SRV 0 1 587_submission._tcp.example.com. SRV 0 1 587 mail.example.com.mail.example.com. _service._proto.name TTL class SRV priority weight port_service._proto.name TTL class SRV priority weight port targettarget - service: the symbolic name of the desired service.- service: the symbolic name of the desired service. - proto: the transport protocol of the desired service; this is- proto: the transport protocol of the desired service; this is usually either TCP or UDP.usually either TCP or UDP. - name: the domain name for which this record is valid.- name: the domain name for which this record is valid. - TTL: standard DNS time to live field.- TTL: standard DNS time to live field. - class: standard DNS class field (this is always IN).- class: standard DNS class field (this is always IN). - priority: the priority of the target host, lower value means- priority: the priority of the target host, lower value means more preferred.more preferred. - weight: A relative weight for records with the same priority.- weight: A relative weight for records with the same priority. - port: the TCP or UDP port on which the service is to be- port: the TCP or UDP port on which the service is to be found.found. - target: the canonical hostname of the machine providing- target: the canonical hostname of the machine providing the service.the service.
  • 20.
    IMAP Basic commandsIMAPBasic commands ➢ a001 login USER PASSa001 login USER PASS ➢ a001 logouta001 logout ➢ a001 select FOLDERa001 select FOLDER ➢ a001 list "" *a001 list "" * ➢ a001 fetch PARAMa001 fetch PARAM ➢ ALL/HEADERS/BODYALL/HEADERS/BODY ➢ a001 delete "Message"a001 delete "Message" ➢ Valid replies - (a00x OK)Valid replies - (a00x OK) ➢ Negative replies - (a00x BAD or NO)Negative replies - (a00x BAD or NO)
  • 21.
    IMAPIMAP hackman@BlackPearl: ~$ telnetlocalhost 143hackman@BlackPearl: ~$ telnet localhost 143 Trying 127.0.0.1...Trying 127.0.0.1... Connected to 127.0.0.1.Connected to 127.0.0.1. Escape character is '^]'.Escape character is '^]'. * OK* OK [CAPABILITY IMAP4rev1 LITERAL+ SASL-IR[CAPABILITY IMAP4rev1 LITERAL+ SASL-IR LOGIN-REFERRALS ID ENABLE IDLE STARTTLSLOGIN-REFERRALS ID ENABLE IDLE STARTTLS AUTH=PLAIN] Dovecot ready.AUTH=PLAIN] Dovecot ready. a001 login userX@yuhu.biz Jer0n1m0!a001 login userX@yuhu.biz Jer0n1m0! a001 OKa001 OK [CAPABILITY IMAP4rev1 LITERAL+ SASL-IR[CAPABILITY IMAP4rev1 LITERAL+ SASL-IR LOGIN-REFERRALS ID ENABLE IDLE SORTLOGIN-REFERRALS ID ENABLE IDLE SORT SORT=DISPLAY THREAD=REFERENCESSORT=DISPLAY THREAD=REFERENCES THREAD=REFS MULTIAPPEND UNSELECT CHILDRENTHREAD=REFS MULTIAPPEND UNSELECT CHILDREN NAMESPACE UIDPLUS LIST-EXTENDED I18NLEVEL=1NAMESPACE UIDPLUS LIST-EXTENDED I18NLEVEL=1 CONDSTORE QRESYNC ESEARCH ESORT SEARCHRESCONDSTORE QRESYNC ESEARCH ESORT SEARCHRES WITHIN CONTEXT=SEARCH LIST-STATUS QUOTA]WITHIN CONTEXT=SEARCH LIST-STATUS QUOTA] Logged inLogged in
  • 22.
    IMAPIMAP a002 lista002 list a002BADa002 BAD Error in IMAP command LIST: InvalidError in IMAP command LIST: Invalid reference.reference. a003 select inboxa003 select inbox * FLAGS (Answered Flagged Deleted Seen Draft* FLAGS (Answered Flagged Deleted Seen Draft $label2)$label2) * OK [PERMANENTFLAGS (Answered Flagged* OK [PERMANENTFLAGS (Answered Flagged Deleted Seen Draft $label2 *)] Flags permitted.Deleted Seen Draft $label2 *)] Flags permitted. * 1714 EXISTS* 1714 EXISTS * 0 RECENT* 0 RECENT * OK [UIDVALIDITY 1330989345] UIDs valid* OK [UIDVALIDITY 1330989345] UIDs valid * OK [UIDNEXT 59881] Predicted next UID* OK [UIDNEXT 59881] Predicted next UID * OK [HIGHESTMODSEQ 1] Highest* OK [HIGHESTMODSEQ 1] Highest a003 OKa003 OK [READ-WRITE] Select completed.[READ-WRITE] Select completed.
  • 23.
    IMAPIMAP a004 list ""*a004 list "" * * LIST (HasNoChildren) "." "Spam"* LIST (HasNoChildren) "." "Spam" * LIST (HasNoChildren) "." "INBOX"* LIST (HasNoChildren) "." "INBOX" a004 OKa004 OK List completed.List completed. a005 FETCH 1:15 ENVELOPEa005 FETCH 1:15 ENVELOPE * 1 FETCH (ENVELOPE ("Thu, 23 May 2013 07:58:06* 1 FETCH (ENVELOPE ("Thu, 23 May 2013 07:58:06 +0000" "RE: svn commit: r1484852 - in+0000" "RE: svn commit: r1484852 - in /httpd/httpd/trunk: CHANGES/httpd/httpd/trunk: CHANGES modules/http/http_filters.c"modules/http/http_filters.c" * 2 FETCH (ENVELOPE ("Thu, 23 May 2013 10:17:56* 2 FETCH (ENVELOPE ("Thu, 23 May 2013 10:17:56 +0200" {89}......+0200" {89}...... ...... * 15 FETCH* 15 FETCH (ENVELOPE ..........(ENVELOPE .......... a005 OKa005 OK Fetch completed.Fetch completed.
  • 24.
    Hypertext Transfer ProtocolHypertextTransfer Protocol HTTPHTTP ➢ 1995 – HTML 2.01995 – HTML 2.0 - RFC 1866- RFC 1866 ➢ 1996 – HTTP/1.01996 – HTTP/1.0 - RFC 1945- RFC 1945 ➢ 1997 – HTTP/1.11997 – HTTP/1.1 - RFC 2068- RFC 2068 ➢ 1999 – HTTP/1.11999 – HTTP/1.1 - RFC 2616- RFC 2616 ➢ 2012 – STATUS codes – RFC 65852012 – STATUS codes – RFC 6585 ➢ 1995 – URI1995 – URI - RFC 1808- RFC 1808 ➢ 2005 – URI2005 – URI - RFC 3986- RFC 3986 ➢ Uniform Resource Identifier (URI)Uniform Resource Identifier (URI) proto :// userinfo @ host : port / pathproto :// userinfo @ host : port / path user : passuser : pass useruser
  • 25.
    Hypertext Transfer ProtocolHypertextTransfer Protocol HTTPHTTP ➢ Absolute URI or PathAbsolute URI or Path ➢ http://x.com/images/srpr/logo4w.pnghttp://x.com/images/srpr/logo4w.png ➢ /images/srpr/logo4w.png/images/srpr/logo4w.png ➢ Request methodsRequest methods ➢ GETGET ➢ POSTPOST ➢ HEADHEAD ➢ OPTIONSOPTIONS ➢ CONNECTCONNECT
  • 26.
    Hypertext Transfer ProtocolHypertextTransfer Protocol HTTPHTTP ➢ Request methodsRequest methods ➢ GETGET ➢ POSTPOST ➢ HEADHEAD ➢ OPTIONSOPTIONS ➢ CONNECTCONNECT
  • 27.
    HTTPHTTP ➢ Request HeadersRequestHeaders ➢ HostHost ➢ Accept-CharsetAccept-Charset ➢ Accept-EncodingAccept-Encoding ➢ AuthorizationAuthorization ➢ RangeRange ➢ RefererReferer ➢ User-AgentUser-Agent
  • 28.
    HTTP/1.0 vs. HTTP/1.1HTTP/1.0vs. HTTP/1.1 ➢ MethodsMethods ➢ GETGET ➢ HEADHEAD ➢ POSTPOST ➢ MethodsMethods ➢ GETGET ➢ HEADHEAD ➢ POSTPOST ➢ OPTIONSOPTIONS ➢ CONNECTCONNECT ➢ PUTPUT ➢ DELETEDELETE
  • 29.
    HTTP/1.0 vs. HTTP/1.1HTTP/1.0vs. HTTP/1.1 ➢ HeadersHeaders ➢ AuthorizationAuthorization ➢ RefererReferer ➢ User-AgentUser-Agent ➢ HeadersHeaders ➢ HostHost ➢ Accept-CharsetAccept-Charset ➢ Accept-EncodingAccept-Encoding ➢ AuthorizationAuthorization ➢ RangeRange ➢ RefererReferer ➢ User-AgentUser-Agent
  • 30.
    HTTP/1.0 vs. HTTP/1.1HTTP/1.0vs. HTTP/1.1 hackman@terion:~$ telnet google.com 80hackman@terion:~$ telnet google.com 80 Trying 173.194.39.100...Trying 173.194.39.100... Connected to google.com.Connected to google.com. Escape character is '^]'.Escape character is '^]'. GET / HTTP/1.0GET / HTTP/1.0 HTTP/1.0 302 FoundHTTP/1.0 302 Found Location: http://www.google.bg/Location: http://www.google.bg/ Cache-Control: privateCache-Control: private Content-Type: text/html; charset=UTF-8Content-Type: text/html; charset=UTF-8 Date: Thu, 06 Jun 2013 08:35:46 GMTDate: Thu, 06 Jun 2013 08:35:46 GMT Server: gwsServer: gws Content-Length: 218Content-Length: 218 Connection closed.Connection closed.
  • 31.
    HTTP/1.0 vs. HTTP/1.1HTTP/1.0vs. HTTP/1.1 hackman@terion:~$ telnet google.com 80hackman@terion:~$ telnet google.com 80 Trying 173.194.39.99...Trying 173.194.39.99... Connected to google.com.Connected to google.com. Escape character is '^]'.Escape character is '^]'. GET / HTTP/1.1GET / HTTP/1.1 Host: google.comHost: google.com HTTP/1.1 301 Moved PermanentlyHTTP/1.1 301 Moved Permanently Location: http://www.google.com/Location: http://www.google.com/ Content-Type: text/html; charset=UTF-8Content-Type: text/html; charset=UTF-8 Date: Thu, 06 Jun 2013 08:36:01 GMTDate: Thu, 06 Jun 2013 08:36:01 GMT Expires: Sat, 06 Jul 2013 08:36:01 GMTExpires: Sat, 06 Jul 2013 08:36:01 GMT Cache-Control: public, max-age=2592000Cache-Control: public, max-age=2592000 Server: gwsServer: gws Content-Length: 219Content-Length: 219 .......Connection still open............Connection still open.....
  • 32.
    HTTP OPTIONSHTTP OPTIONS hackman@terion:~$telnet s1 81hackman@terion:~$ telnet s1 81 Trying 192.168.155.100...Trying 192.168.155.100... Connected to s1.Connected to s1. Escape character is '^]'.Escape character is '^]'. OPTIONS / HTTP/1.0OPTIONS / HTTP/1.0 HTTP/1.1 200 OKHTTP/1.1 200 OK Date: Thu, 06 Jun 2013 15:13:30 GMTDate: Thu, 06 Jun 2013 15:13:30 GMT Server: ApacheServer: Apache Allow: GET,HEAD,POST,OPTIONSAllow: GET,HEAD,POST,OPTIONS Host-Header: 192fc2e7e50945beb8231a492d6a8024Host-Header: 192fc2e7e50945beb8231a492d6a8024 Content-Length: 0Content-Length: 0 Connection: closeConnection: close Content-Type: text/htmlContent-Type: text/html
  • 33.
    HTTP/1.0 requestHTTP/1.0 request RequestRequest Responseand closeResponse and close TimeoutTimeout
  • 34.
  • 35.
    HTTPHTTP ➢ Request withheaderRequest with header ➢ Request with cookieRequest with cookie ➢ Difference between normal and HEADDifference between normal and HEAD requestsrequests