Table of Contents

24.5.2 POP3 Console 2

An encrypted TCP connection to a POP3 server works reliably if you use the SSL client 'openssl', for example. You must use port 995 as the port number for POP3 via SSL.

24.5.2.1 Example

[1] hans@linux:~$ openssl s_client -quiet -connect mx.freenet.de:995
[2] depth=2 C = DE, O = Deutsche Telekom AG, OU = T-TeleSec Trust Center, CN = Deutsche Telekom Root CA 2
[3] verify error:num=19:self signed certificate in certificate chain verify return:0
[4] +OK <500.1448880155@mx.freenet.de>
[5] USER POP3USERNAME
[6] +OK user ok
[7] PASS POP3PASSWORT
[8] +OK 2 messages (5377 octets).
[9] LIST
[10] +OK
[11] 1 2572
[12] 2 2805
[13] .
[14] RETR 1
[15] +OK 2572 octets
[16] [ KOPFZEILEN – HEADER ]
[17]
[18] This is a MIME multipart/mixed message.
[19]
[20] --|1B031C1B1A9321EF01|
[21] Content-Type: text/plain;charset=UTF-8
[22] Content-Disposition: inline
[23] Content-Transfer-Encoding: quoted-printable
[24] Content-Length: 72
[25]
[26] Hallo!
[27] =
[28]
[29] Im Anhang liegt die Datei acht.png
[30] =
[31]
[32] Mit freundlichem Gru=C3=9F
[33] =
[34]
[35] Hans
[36]
[37] --|1B031C1B1A9321EF01|
[38] Content-Type: image/png; name="acht.png"
[39] Content-Disposition: attachment
[40] Content-Transfer-Encoding: base64
[41] Content-Length: 116
[42]
[43] iVBORw0KGgoAAAANSUhEUgAAAAgAAAAICAYAAADED76LAAAAO0lEQVQYlX2PyQ0AMAjDnKr7
[44] r5x+egvIEyxwZDBFOoASxJoAEWUB0J6Zhedi5QFSh/0lkDnAd/pWK2sORyMOEhaL7BAAAAAA
[45] SUVORK5CYII=
[46]
[47] --|1B031C1B1A9321EF01|--
[48]
[49] .
[50] NOOP
[51] +OK
[52] QUIT
[53] +OK
[54] hans@linux:~$

Comment:

This is quickly done to the console:

echo iVBORw0KGgoAAAANSUhEUgAAAAgAAAAICAYAAADED76LAAAAO0lEQVQYlX2PyQ0AMAjDnKr7r5x+egvIEyxwZDBFOoASxJoAE \
WUB0J6Zhedi5QFSh/0lkDnAd/pWK2sORyMOEhaL7BAAAAAASUVORK5CYII= | base64 --decode > acht.png

You will then see the image in your home directory:

B1
Figure 24.5.2.1.1: Tiny 8×8 pixel image

24.5.2.2 Authentication via APOP

If a POP3 server offers authentication via Authenticated Post Office Protocol (APOP), the POP3 user name is sent in plain text in the SSL tunnel, but the POP3 password is transmitted in encrypted form and this is what matters from a security point of view when authenticating to the POP3 server.

Authentication via APOP is based on the challenge-response method, which, according to a post on https://de.wikipedia.org/wiki/Challenge-Response-Authentifizierung, can be considered “a secure authentication method of a subscriber based on knowledge”.

[1] hans@linux:~$ openssl s_client -quiet -connect mx.freenet.de:995
[2] depth=2 C = DE, O = Deutsche Telekom AG, OU = T-TeleSec Trust Center, CN = Deutsche Telekom Root CA 2
[3] verify error:num=19:self signed certificate in certificate chain
[4] verify return:0
[5] +OK <31534.1448457450@mx.freenet.de>
[6] APOP User-Name Has-Wert
[7] +OK 3 messages (1147469 octets).
[8] LIST
[9] +OK
[10] 1 382310
[11] 2 382307
[12] 3 382852
[13] .
[14] QUIT
[15] +OK
[16] hans@linux:~$

Notes:

If a POP3 server responds with a welcome message (line 5) after the connection is established, following the syntax '+OK <process-id.timestamp@hostname>', then you can be sure that the POP3 server also allows authentication via APOP.The POP3 server also transmits the request 31534.1448457450@mx.freenet.de in the APOP welcome message after the +OK and a space.From this server request, the client must calculate a hash value as part of the response, including the POP3 user password. Later, the response is sent - without transmitting the password itself in it!The calculation of the hash value as part of the response is done, for example, in a (further) console with this instruction:

hans@linux:~$ echo -n "<31534.1448457450@mx.freenet.de>POP3-PASSWORD" | openssl md5

Subsequently, the complete response from 'User-Name<space>Hash-Value' can be sent to the POP3 server (line 6) after the APOP command:

APOP User-Name Hash-Wert

If the authentication was successful, then the POP3 server (line 7) sends the number of emails in the mailbox and their total size in bytes after the +OK.

If the authentication fails, then you receive this reply from the POP3 server:

-ERR premission denied