POP3 - Post Office Protocol - Version 3¶
pcapkit.protocols.application.pop3.protocol contains
POP3, which implements an
extractor for the Post Office Protocol - Version 3 (POP3) [RFC 1939] at TCP
port 110, with its extension mechanism [RFC 2449]. Its lines are read
through pcapkit.utilities.lines, which FTP and SMTP share.
Added in version 1.10.0.
- class pcapkit.protocols.application.pop3.protocol.POP3(file, length=None, /, *, layer=None, protocol=None, context=None)[source]¶
Bases:
Application[POP3,POP3]This class implements Post Office Protocol - Version 3.
One segment carries no session state, so it reads as the first of these that it is, whole:
a response: a status line of a status indicator and its text (RFC 1939 Section 3), alone, or followed by lines whose last, and only the last, holds a single period, which ends a multi-line response;
a server challenge of the
AUTHcommand (RFC 5034 Section 4);a command, one line of a keyword and its parameters (RFC 2449 Section 3);
the rest of a multi-line response, lines whose last, and only the last, holds a single period.
A multi-line response is read whole from one segment, or its end alone from the segment ending it, so the segments between, and one holding a status line and more lines but not that end, are refused: such a segment may as well hold several pipelined responses (RFC 2449 Section 6.6). Octets that are not whole lines, a status line of more than 512 octets and a command line of more than 255 (RFC 2449 Section 4) are refused too, so on a TCP port each such segment is kept as
Raw. A line of a response, or a client’s Base64 answer to a challenge, alone in a segment reads as a command if it can, since only the session marks either.Text is ASCII (RFC 1939 Section 3) or, after the
UTF8andLANGcommands, UTF-8 (RFC 6856 Section 2), so it is decoded as UTF-8 and octets that are not are refused. A parameter is ASCII, but for those ofUSER,PASSandAPOP, which may be UTF-8 too (RFC 6856 Section 2.2). A response code a response’s text opens with is read intoResponse.code(RFC 2449 Section 8), and any other text is free text, as RFC 1939 has it: thetextgrammar of RFC 2449 Section 3 admits no SP, so it would refuse that RFC’s own examples. The greeting’s timestamp (RFC 1939 Section 7) stays in its text, since only the session marks a greeting.Properties
- property length: NoReturn¶
Header length of current protocol.
- Raises:
UnsupportedCall – This protocol doesn’t support
length.
Methods
- read(length=None, **kwargs)[source]¶
Read Post Office Protocol - Version 3 (POP3).
- Parameters:
- Return type:
- Returns:
Parsed packet data.
- Raises:
ProtocolError – If the packet is no response, server challenge, command or end of a multi-line response.
- make(*, status=None, text=None, lines=None, challenge=None, cmmd=None, args=None, raw_cmmd=None, **kwargs)[source]¶
Make (construct) packet data.
A response takes
status,textandlines, a server challengechallengealone, a commandcmmd,argsandraw_cmmd, and the end of a multi-line responselinesalone. Each line is terminated with CRLF, and the octets are checked to read back as made.- Parameters:
status (
Status|str|None) – Status indicator, astr(aStatusmember is one).text (
str|bytes|bytearray|None) – Text of the status line, written after a single SP, a response code it opens with included;Nonewrites neither. Astris encoded as UTF-8;bytesare written verbatim.lines (
Iterable[bytes|bytearray] |None) – Lines of a multi-line response after its first, as sent, byte-stuffed (seestuff()); the line ending the response is written after them. Withstatus,Nonemakes a single-line response.challenge (
str|bytes|bytearray|None) – Challenge in Base64, written after+and a single SP; empty for an empty challenge.cmmd (
Command|str|None) – Command keyword, astr(aCommandmember is one).args (
str|bytes|bytearray|Iterable[str|bytes|bytearray] |None) – Parameters, each written after a single SP, or one parameter; astris encoded as UTF-8,bytesare written verbatim.raw_cmmd (
bytes|None) – Keyword as received, written in place ofcmmdwhen the two differ only in case (RFC 1939 Section 3).**kwargs (
Any) – Arbitrary keyword arguments.
- Return type:
- Returns:
Constructed packet data.
- Raises:
ProtocolError – If not exactly one of
status,challenge,cmmdandlinesalone is given, or with another’s keywords, or if the octets made would not read back as made.
Data Models
- classmethod __index__()[source]¶
Numeral registry index of the protocol.
- Return type:
- Returns:
Numeral registry index of the protocol in IANA service names and port numbers: TCP port 110, the port of
TCP.pop3as anint, whichTCP.__proto__dispatches here (The Registry Index).
Utilities
Auxiliary Data¶
- class pcapkit.protocols.application.pop3.protocol.Type(*values)[source]¶
Bases:
EnumLookup,StrEnumPOP3 packet type.
Built on
EnumLookup, the lookup contract shared by every non-registry enumeration (#877).- COMMAND = 'command'¶
Command packet.
- RESPONSE = 'response'¶
Response packet.
- CHALLENGE = 'challenge'¶
Server challenge packet.
- TAIL = 'tail'¶
Packet ending a multi-line response.
- class pcapkit.protocols.application.pop3.protocol.Status(*values)[source]¶
Bases:
EnumLookup,StrEnumPOP3 status indicator (RFC 1939 Section 3), sent in upper case.
Built on
EnumLookup, the lookup contract shared by every non-registry enumeration (#877).- OK = '+OK'¶
Positive status indicator.
- ERR = '-ERR'¶
Negative status indicator.
Header Schemas¶
Data Models¶
- class pcapkit.protocols.application.pop3.data.POP3(*args, **kwargs)[source]¶
Bases:
ProtocolData model for POP3 protocol.
- class pcapkit.protocols.application.pop3.data.Command(type, cmmd, args, raw_cmmd)[source]¶
Bases:
POP3Data model for a POP3 command (RFC 1939 Section 3).
- class pcapkit.protocols.application.pop3.data.Response(type, status, text, code, lines, body)[source]¶
Bases:
POP3Data model for a POP3 response, single-line or multi-line (RFC 1939 Section 3).
- text: str | None¶
Text after the status indicator and SP,
Nonewhere the line ends with the status indicator.
- code: ResponseCode | None¶
Response code
textopens with (RFC 2449 Section 8), if any.
- class pcapkit.protocols.application.pop3.data.Challenge(type, challenge)[source]¶
Bases:
POP3Data model for a server challenge of the
AUTHcommand (RFC 5034 Section 4).
- class pcapkit.protocols.application.pop3.data.Tail(type, lines, body)[source]¶
Bases:
POP3Data model for the rest of a multi-line response whose first line an earlier segment carried, up to and including the line ending it (RFC 1939 Section 3).
Constants¶
- pcapkit.protocols.application.pop3.const.POP3_COMMAND¶
A POP3 command line, CRLF excluded. A keyword of three or four printable ASCII characters, then each parameter after a single SP (RFC 2449 Section 3). A parameter is printable ASCII, or UTF-8 as well for the keywords of
POP3_UTF8_COMMANDS, which the reader checks.
- pcapkit.protocols.application.pop3.const.POP3_COMMAND_MAX = 255¶
The most octets a command line holds, CRLF included (RFC 2449 Section 4).
- pcapkit.protocols.application.pop3.const.POP3_UTF8_COMMANDS¶
The commands whose parameters may hold UTF-8 beyond ASCII (RFC 6856 Section 2.2).
- pcapkit.protocols.application.pop3.const.POP3_STATUS¶
The first line of a POP3 response, CRLF excluded. A status indicator, then SP and the text where any follows (RFC 1939 Section 3).
- pcapkit.protocols.application.pop3.const.POP3_STATUS_MAX = 512¶
The most octets the first line of a response holds, CRLF included (RFC 2449 Section 4).
- pcapkit.protocols.application.pop3.const.POP3_RESP_CODE¶
The response code a response’s text opens with (RFC 2449 Section 8), its levels separated by
/, as theresp-codegrammar of RFC 2449 Section 3 has them.
- pcapkit.protocols.application.pop3.const.POP3_CHALLENGE¶
A server challenge, CRLF excluded.
+, SP and the challenge in Base64, which is empty for an empty challenge (RFC 5034 Section 4), as thecontinue-reqgrammar of RFC 5034 Section 5 has it.