Linux cambridge2.uknoc5.com 4.18.0-553.27.1.lve.1.el8.x86_64 #1 SMP Wed Nov 20 15:58:00 UTC 2024 x86_64
LiteSpeed
Server IP : 92.48.92.37 & Your IP : 18.117.184.173
Domains :
Cant Read [ /etc/named.conf ]
User : drazizulhaq
Terminal
Auto Root
Create File
Create Folder
Localroot Suggester
Backdoor Destroyer
Readme
/
opt /
alt /
python35 /
lib64 /
python3.5 /
Delete
Unzip
Name
Size
Permission
Date
Action
__pycache__
[ DIR ]
drwxr-xr-x
2024-12-16 14:13
asyncio
[ DIR ]
drwxr-xr-x
2024-12-16 14:13
collections
[ DIR ]
drwxr-xr-x
2024-12-16 14:13
concurrent
[ DIR ]
drwxr-xr-x
2024-12-16 14:13
config-3.5m
[ DIR ]
drwxr-xr-x
2024-12-16 14:14
ctypes
[ DIR ]
drwxr-xr-x
2024-12-16 14:13
curses
[ DIR ]
drwxr-xr-x
2024-12-16 14:13
dbm
[ DIR ]
drwxr-xr-x
2024-12-16 14:13
distutils
[ DIR ]
drwxr-xr-x
2024-12-16 14:13
email
[ DIR ]
drwxr-xr-x
2024-12-16 14:13
encodings
[ DIR ]
drwxr-xr-x
2024-12-16 14:13
ensurepip
[ DIR ]
drwxr-xr-x
2024-12-16 14:13
html
[ DIR ]
drwxr-xr-x
2024-12-16 14:13
http
[ DIR ]
drwxr-xr-x
2024-12-16 14:13
idlelib
[ DIR ]
drwxr-xr-x
2024-12-16 14:13
importlib
[ DIR ]
drwxr-xr-x
2024-12-16 14:13
json
[ DIR ]
drwxr-xr-x
2024-12-16 14:13
lib-dynload
[ DIR ]
drwxr-xr-x
2024-12-16 14:13
lib2to3
[ DIR ]
drwxr-xr-x
2024-12-16 14:13
logging
[ DIR ]
drwxr-xr-x
2024-12-16 14:13
multiprocessing
[ DIR ]
drwxr-xr-x
2024-12-16 14:13
plat-linux
[ DIR ]
drwxr-xr-x
2024-12-16 14:13
pydoc_data
[ DIR ]
drwxr-xr-x
2024-12-16 14:13
site-packages
[ DIR ]
drwxr-xr-x
2024-12-16 14:13
sqlite3
[ DIR ]
drwxr-xr-x
2024-12-16 14:13
test
[ DIR ]
drwxr-xr-x
2024-12-16 14:13
unittest
[ DIR ]
drwxr-xr-x
2024-12-16 14:13
urllib
[ DIR ]
drwxr-xr-x
2024-12-16 14:13
venv
[ DIR ]
drwxr-xr-x
2024-12-16 14:13
wsgiref
[ DIR ]
drwxr-xr-x
2024-12-16 14:13
xml
[ DIR ]
drwxr-xr-x
2024-12-16 14:13
xmlrpc
[ DIR ]
drwxr-xr-x
2024-12-16 14:13
__future__.py
4.73
KB
-rw-r--r--
2024-05-31 13:51
__phello__.foo.py
64
B
-rw-r--r--
2024-05-31 13:51
_bootlocale.py
1.27
KB
-rw-r--r--
2024-05-31 13:51
_collections_abc.py
24.21
KB
-rw-r--r--
2024-05-31 13:51
_compat_pickle.py
8.36
KB
-rw-r--r--
2024-05-31 13:51
_compression.py
5.21
KB
-rw-r--r--
2024-05-31 13:51
_dummy_thread.py
5
KB
-rw-r--r--
2024-05-31 13:51
_markupbase.py
14.26
KB
-rw-r--r--
2024-05-31 13:51
_osx_support.py
18.67
KB
-rw-r--r--
2024-05-31 13:51
_pydecimal.py
223.27
KB
-rw-r--r--
2024-05-31 13:51
_pyio.py
85.91
KB
-rw-r--r--
2024-05-31 13:51
_sitebuiltins.py
3.04
KB
-rw-r--r--
2024-05-31 13:51
_strptime.py
21.67
KB
-rw-r--r--
2024-05-31 13:51
_sysconfigdata.py
26.32
KB
-rw-r--r--
2024-05-31 13:51
_threading_local.py
7.24
KB
-rw-r--r--
2024-05-31 13:51
_weakrefset.py
5.57
KB
-rw-r--r--
2024-05-31 13:51
abc.py
8.43
KB
-rw-r--r--
2024-05-31 13:51
aifc.py
31.22
KB
-rw-r--r--
2024-05-31 13:51
antigravity.py
476
B
-rw-r--r--
2024-05-31 13:51
argparse.py
88.03
KB
-rw-r--r--
2024-05-31 13:51
ast.py
11.72
KB
-rw-r--r--
2024-05-31 13:51
asynchat.py
11.69
KB
-rw-r--r--
2024-05-31 13:51
asyncore.py
19.63
KB
-rw-r--r--
2024-05-31 13:51
base64.py
20.04
KB
-rwxr-xr-x
2024-05-31 13:51
bdb.py
22.81
KB
-rw-r--r--
2024-05-31 13:51
binhex.py
13.63
KB
-rw-r--r--
2024-05-31 13:51
bisect.py
2.53
KB
-rw-r--r--
2024-05-31 13:51
bz2.py
12.13
KB
-rw-r--r--
2024-05-31 13:51
cProfile.py
5.2
KB
-rwxr-xr-x
2024-05-31 13:51
calendar.py
22.46
KB
-rw-r--r--
2024-05-31 13:51
cgi.py
35.2
KB
-rwxr-xr-x
2024-05-31 13:51
cgitb.py
11.74
KB
-rw-r--r--
2024-05-31 13:51
chunk.py
5.3
KB
-rw-r--r--
2024-05-31 13:51
cmd.py
14.51
KB
-rw-r--r--
2024-05-31 13:51
code.py
9.88
KB
-rw-r--r--
2024-05-31 13:51
codecs.py
35.38
KB
-rw-r--r--
2024-05-31 13:51
codeop.py
5.85
KB
-rw-r--r--
2024-05-31 13:51
colorsys.py
3.97
KB
-rw-r--r--
2024-05-31 13:51
compileall.py
11.44
KB
-rw-r--r--
2024-05-31 13:51
configparser.py
52.2
KB
-rw-r--r--
2024-05-31 13:51
contextlib.py
12.16
KB
-rw-r--r--
2024-05-31 13:51
copy.py
8.74
KB
-rw-r--r--
2024-05-31 13:51
copyreg.py
6.67
KB
-rw-r--r--
2024-05-31 13:51
crypt.py
1.83
KB
-rw-r--r--
2024-05-31 13:51
csv.py
15.75
KB
-rw-r--r--
2024-05-31 13:51
datetime.py
74.12
KB
-rw-r--r--
2024-05-31 13:51
decimal.py
320
B
-rw-r--r--
2024-05-31 13:51
difflib.py
82.23
KB
-rw-r--r--
2024-05-31 13:51
dis.py
16.94
KB
-rw-r--r--
2024-05-31 13:51
doctest.py
101.6
KB
-rw-r--r--
2024-05-31 13:51
dummy_threading.py
2.75
KB
-rw-r--r--
2024-05-31 13:51
enum.py
21.71
KB
-rw-r--r--
2024-05-31 13:51
filecmp.py
9.6
KB
-rw-r--r--
2024-05-31 13:51
fileinput.py
13.92
KB
-rw-r--r--
2024-05-31 13:51
fnmatch.py
3.09
KB
-rw-r--r--
2024-05-31 13:51
formatter.py
14.79
KB
-rw-r--r--
2024-05-31 13:51
fractions.py
24.04
KB
-rw-r--r--
2024-05-31 13:51
ftplib.py
34.13
KB
-rw-r--r--
2024-05-31 13:51
functools.py
28.27
KB
-rw-r--r--
2024-05-31 13:51
genericpath.py
4.26
KB
-rw-r--r--
2024-05-31 13:51
getopt.py
7.31
KB
-rw-r--r--
2024-05-31 13:51
getpass.py
5.85
KB
-rw-r--r--
2024-05-31 13:51
gettext.py
21.03
KB
-rw-r--r--
2024-05-31 13:51
glob.py
4.95
KB
-rw-r--r--
2024-05-31 13:51
gzip.py
19.79
KB
-rw-r--r--
2024-05-31 13:51
hashlib.py
7.79
KB
-rw-r--r--
2024-05-31 13:51
heapq.py
22.39
KB
-rw-r--r--
2024-05-31 13:51
hmac.py
4.94
KB
-rw-r--r--
2024-05-31 13:51
imaplib.py
50.96
KB
-rw-r--r--
2024-05-31 13:51
imghdr.py
3.67
KB
-rw-r--r--
2024-05-31 13:51
imp.py
10.43
KB
-rw-r--r--
2024-05-31 13:51
inspect.py
111.52
KB
-rw-r--r--
2024-05-31 13:51
io.py
3.32
KB
-rw-r--r--
2024-05-31 13:51
ipaddress.py
73.96
KB
-rw-r--r--
2024-05-31 13:51
keyword.py
2.17
KB
-rwxr-xr-x
2024-05-31 13:51
linecache.py
5.19
KB
-rw-r--r--
2024-05-31 13:51
locale.py
72.96
KB
-rw-r--r--
2024-05-31 13:51
lzma.py
12.62
KB
-rw-r--r--
2024-05-31 13:51
macpath.py
5.77
KB
-rw-r--r--
2024-05-31 13:51
macurl2path.py
2.67
KB
-rw-r--r--
2024-05-31 13:51
mailbox.py
76.58
KB
-rw-r--r--
2024-05-31 13:51
mailcap.py
7.91
KB
-rw-r--r--
2024-05-31 13:51
mimetypes.py
20.36
KB
-rw-r--r--
2024-05-31 13:51
modulefinder.py
22.54
KB
-rw-r--r--
2024-05-31 13:51
netrc.py
5.61
KB
-rw-r--r--
2024-05-31 13:51
nntplib.py
42.07
KB
-rw-r--r--
2024-05-31 13:51
ntpath.py
22.26
KB
-rw-r--r--
2024-05-31 13:51
nturl2path.py
2.39
KB
-rw-r--r--
2024-05-31 13:51
numbers.py
10
KB
-rw-r--r--
2024-05-31 13:51
opcode.py
5.75
KB
-rw-r--r--
2024-05-31 13:51
operator.py
10.61
KB
-rw-r--r--
2024-05-31 13:51
optparse.py
58.93
KB
-rw-r--r--
2024-05-31 13:51
os.py
36.17
KB
-rw-r--r--
2024-05-31 13:51
pathlib.py
45.9
KB
-rw-r--r--
2024-05-31 13:51
pdb.py
59.72
KB
-rwxr-xr-x
2024-05-31 13:51
pickle.py
54.86
KB
-rw-r--r--
2024-05-31 13:51
pickletools.py
89.61
KB
-rw-r--r--
2024-05-31 13:51
pipes.py
8.71
KB
-rw-r--r--
2024-05-31 13:51
pkgutil.py
20.85
KB
-rw-r--r--
2024-05-31 13:51
platform.py
45.07
KB
-rwxr-xr-x
2024-05-31 13:51
plistlib.py
31.06
KB
-rw-r--r--
2024-05-31 13:51
poplib.py
14.37
KB
-rw-r--r--
2024-05-31 13:51
posixpath.py
14.56
KB
-rw-r--r--
2024-05-31 13:51
pprint.py
20.37
KB
-rw-r--r--
2024-05-31 13:51
profile.py
21.52
KB
-rwxr-xr-x
2024-05-31 13:51
pstats.py
25.94
KB
-rw-r--r--
2024-05-31 13:51
pty.py
4.65
KB
-rw-r--r--
2024-05-31 13:51
py_compile.py
7.01
KB
-rw-r--r--
2024-05-31 13:51
pyclbr.py
13.25
KB
-rw-r--r--
2024-05-31 13:51
pydoc.py
101.22
KB
-rwxr-xr-x
2024-05-31 13:51
queue.py
8.57
KB
-rw-r--r--
2024-05-31 13:51
quopri.py
7.09
KB
-rwxr-xr-x
2024-05-31 13:51
random.py
25.84
KB
-rw-r--r--
2024-05-31 13:51
re.py
15.14
KB
-rw-r--r--
2024-05-31 13:51
reprlib.py
5.21
KB
-rw-r--r--
2024-05-31 13:51
rlcompleter.py
6.16
KB
-rw-r--r--
2024-05-31 13:51
runpy.py
11.68
KB
-rw-r--r--
2024-05-31 13:51
sched.py
6.07
KB
-rw-r--r--
2024-05-31 13:51
selectors.py
18.98
KB
-rw-r--r--
2024-05-31 13:51
shelve.py
8.33
KB
-rw-r--r--
2024-05-31 13:51
shlex.py
11.18
KB
-rw-r--r--
2024-05-31 13:51
shutil.py
39.11
KB
-rw-r--r--
2024-05-31 13:51
signal.py
2.07
KB
-rw-r--r--
2024-05-31 13:51
site.py
21
KB
-rw-r--r--
2024-05-31 13:51
smtpd.py
34.54
KB
-rwxr-xr-x
2024-05-31 13:51
smtplib.py
42.61
KB
-rwxr-xr-x
2024-05-31 13:51
sndhdr.py
6.27
KB
-rw-r--r--
2024-05-31 13:51
socket.py
26.5
KB
-rw-r--r--
2024-05-31 13:51
socketserver.py
24.09
KB
-rw-r--r--
2024-05-31 13:51
sre_compile.py
17.98
KB
-rw-r--r--
2024-05-31 13:51
sre_constants.py
6.66
KB
-rw-r--r--
2024-05-31 13:51
sre_parse.py
34.29
KB
-rw-r--r--
2024-05-31 13:51
ssl.py
41.36
KB
-rw-r--r--
2024-05-31 13:51
stat.py
4.92
KB
-rw-r--r--
2024-05-31 13:51
statistics.py
19.08
KB
-rw-r--r--
2024-05-31 13:51
string.py
11.58
KB
-rw-r--r--
2024-05-31 13:51
stringprep.py
12.61
KB
-rw-r--r--
2024-05-31 13:51
struct.py
257
B
-rw-r--r--
2024-05-31 13:51
subprocess.py
57.53
KB
-rw-r--r--
2024-05-31 13:51
sunau.py
17.67
KB
-rw-r--r--
2024-05-31 13:51
symbol.py
2.06
KB
-rwxr-xr-x
2024-05-31 13:51
symtable.py
7.02
KB
-rw-r--r--
2024-05-31 13:51
sysconfig.py
23.89
KB
-rw-r--r--
2024-05-31 13:51
tabnanny.py
11.15
KB
-rwxr-xr-x
2024-05-31 13:51
tarfile.py
90.89
KB
-rwxr-xr-x
2024-05-31 13:51
telnetlib.py
22.48
KB
-rw-r--r--
2024-05-31 13:51
tempfile.py
26.01
KB
-rw-r--r--
2024-05-31 13:51
textwrap.py
19.1
KB
-rw-r--r--
2024-05-31 13:51
this.py
1003
B
-rw-r--r--
2024-05-31 13:51
threading.py
47.88
KB
-rw-r--r--
2024-05-31 13:51
timeit.py
12.11
KB
-rwxr-xr-x
2024-05-31 13:51
token.py
3
KB
-rw-r--r--
2024-05-31 13:51
tokenize.py
27.14
KB
-rw-r--r--
2024-05-31 13:51
trace.py
30.81
KB
-rwxr-xr-x
2024-05-31 13:51
traceback.py
21.66
KB
-rw-r--r--
2024-05-31 13:51
tracemalloc.py
15.27
KB
-rw-r--r--
2024-05-31 13:51
tty.py
879
B
-rw-r--r--
2024-05-31 13:51
types.py
8.59
KB
-rw-r--r--
2024-05-31 13:51
typing.py
78.26
KB
-rw-r--r--
2024-05-31 13:51
uu.py
6.61
KB
-rwxr-xr-x
2024-05-31 13:51
uuid.py
22.72
KB
-rw-r--r--
2024-05-31 13:51
warnings.py
15.48
KB
-rw-r--r--
2024-05-31 13:51
wave.py
17.27
KB
-rw-r--r--
2024-05-31 13:51
weakref.py
19.99
KB
-rw-r--r--
2024-05-31 13:51
webbrowser.py
21.32
KB
-rwxr-xr-x
2024-05-31 13:51
xdrlib.py
5.77
KB
-rw-r--r--
2024-05-31 13:51
zipapp.py
6.99
KB
-rw-r--r--
2024-05-31 13:51
zipfile.py
71.95
KB
-rw-r--r--
2024-05-31 13:51
Save
Rename
"""A POP3 client class. Based on the J. Myers POP3 draft, Jan. 96 """ # Author: David Ascher <david_ascher@brown.edu> # [heavily stealing from nntplib.py] # Updated: Piers Lauder <piers@cs.su.oz.au> [Jul '97] # String method conversion and test jig improvements by ESR, February 2001. # Added the POP3_SSL class. Methods loosely based on IMAP_SSL. Hector Urtubia <urtubia@mrbook.org> Aug 2003 # Example (see the test function at the end of this file) # Imports import errno import re import socket try: import ssl HAVE_SSL = True except ImportError: HAVE_SSL = False __all__ = ["POP3","error_proto"] # Exception raised when an error or invalid response is received: class error_proto(Exception): pass # Standard Port POP3_PORT = 110 # POP SSL PORT POP3_SSL_PORT = 995 # Line terminators (we always output CRLF, but accept any of CRLF, LFCR, LF) CR = b'\r' LF = b'\n' CRLF = CR+LF # maximal line length when calling readline(). This is to prevent # reading arbitrary length lines. RFC 1939 limits POP3 line length to # 512 characters, including CRLF. We have selected 2048 just to be on # the safe side. _MAXLINE = 2048 class POP3: """This class supports both the minimal and optional command sets. Arguments can be strings or integers (where appropriate) (e.g.: retr(1) and retr('1') both work equally well. Minimal Command Set: USER name user(name) PASS string pass_(string) STAT stat() LIST [msg] list(msg = None) RETR msg retr(msg) DELE msg dele(msg) NOOP noop() RSET rset() QUIT quit() Optional Commands (some servers support these): RPOP name rpop(name) APOP name digest apop(name, digest) TOP msg n top(msg, n) UIDL [msg] uidl(msg = None) CAPA capa() STLS stls() UTF8 utf8() Raises one exception: 'error_proto'. Instantiate with: POP3(hostname, port=110) NB: the POP protocol locks the mailbox from user authorization until QUIT, so be sure to get in, suck the messages, and quit, each time you access the mailbox. POP is a line-based protocol, which means large mail messages consume lots of python cycles reading them line-by-line. If it's available on your mail server, use IMAP4 instead, it doesn't suffer from the two problems above. """ encoding = 'UTF-8' def __init__(self, host, port=POP3_PORT, timeout=socket._GLOBAL_DEFAULT_TIMEOUT): self.host = host self.port = port self._tls_established = False self.sock = self._create_socket(timeout) self.file = self.sock.makefile('rb') self._debugging = 0 self.welcome = self._getresp() def _create_socket(self, timeout): return socket.create_connection((self.host, self.port), timeout) def _putline(self, line): if self._debugging > 1: print('*put*', repr(line)) self.sock.sendall(line + CRLF) # Internal: send one command to the server (through _putline()) def _putcmd(self, line): if self._debugging: print('*cmd*', repr(line)) line = bytes(line, self.encoding) self._putline(line) # Internal: return one line from the server, stripping CRLF. # This is where all the CPU time of this module is consumed. # Raise error_proto('-ERR EOF') if the connection is closed. def _getline(self): line = self.file.readline(_MAXLINE + 1) if len(line) > _MAXLINE: raise error_proto('line too long') if self._debugging > 1: print('*get*', repr(line)) if not line: raise error_proto('-ERR EOF') octets = len(line) # server can send any combination of CR & LF # however, 'readline()' returns lines ending in LF # so only possibilities are ...LF, ...CRLF, CR...LF if line[-2:] == CRLF: return line[:-2], octets if line[:1] == CR: return line[1:-1], octets return line[:-1], octets # Internal: get a response from the server. # Raise 'error_proto' if the response doesn't start with '+'. def _getresp(self): resp, o = self._getline() if self._debugging > 1: print('*resp*', repr(resp)) if not resp.startswith(b'+'): raise error_proto(resp) return resp # Internal: get a response plus following text from the server. def _getlongresp(self): resp = self._getresp() list = []; octets = 0 line, o = self._getline() while line != b'.': if line.startswith(b'..'): o = o-1 line = line[1:] octets = octets + o list.append(line) line, o = self._getline() return resp, list, octets # Internal: send a command and get the response def _shortcmd(self, line): self._putcmd(line) return self._getresp() # Internal: send a command and get the response plus following text def _longcmd(self, line): self._putcmd(line) return self._getlongresp() # These can be useful: def getwelcome(self): return self.welcome def set_debuglevel(self, level): self._debugging = level # Here are all the POP commands: def user(self, user): """Send user name, return response (should indicate password required). """ return self._shortcmd('USER %s' % user) def pass_(self, pswd): """Send password, return response (response includes message count, mailbox size). NB: mailbox is locked by server from here to 'quit()' """ return self._shortcmd('PASS %s' % pswd) def stat(self): """Get mailbox status. Result is tuple of 2 ints (message count, mailbox size) """ retval = self._shortcmd('STAT') rets = retval.split() if self._debugging: print('*stat*', repr(rets)) numMessages = int(rets[1]) sizeMessages = int(rets[2]) return (numMessages, sizeMessages) def list(self, which=None): """Request listing, return result. Result without a message number argument is in form ['response', ['mesg_num octets', ...], octets]. Result when a message number argument is given is a single response: the "scan listing" for that message. """ if which is not None: return self._shortcmd('LIST %s' % which) return self._longcmd('LIST') def retr(self, which): """Retrieve whole message number 'which'. Result is in form ['response', ['line', ...], octets]. """ return self._longcmd('RETR %s' % which) def dele(self, which): """Delete message number 'which'. Result is 'response'. """ return self._shortcmd('DELE %s' % which) def noop(self): """Does nothing. One supposes the response indicates the server is alive. """ return self._shortcmd('NOOP') def rset(self): """Unmark all messages marked for deletion.""" return self._shortcmd('RSET') def quit(self): """Signoff: commit changes on server, unlock mailbox, close connection.""" resp = self._shortcmd('QUIT') self.close() return resp def close(self): """Close the connection without assuming anything about it.""" try: file = self.file self.file = None if file is not None: file.close() finally: sock = self.sock self.sock = None if sock is not None: try: sock.shutdown(socket.SHUT_RDWR) except OSError as exc: # The server might already have closed the connection. # On Windows, this may result in WSAEINVAL (error 10022): # An invalid operation was attempted. if (exc.errno != errno.ENOTCONN and getattr(exc, 'winerror', 0) != 10022): raise finally: sock.close() #__del__ = quit # optional commands: def rpop(self, user): """Not sure what this does.""" return self._shortcmd('RPOP %s' % user) timestamp = re.compile(br'\+OK.[^<]*(<.*>)') def apop(self, user, password): """Authorisation - only possible if server has supplied a timestamp in initial greeting. Args: user - mailbox user; password - mailbox password. NB: mailbox is locked by server from here to 'quit()' """ secret = bytes(password, self.encoding) m = self.timestamp.match(self.welcome) if not m: raise error_proto('-ERR APOP not supported by server') import hashlib digest = m.group(1)+secret digest = hashlib.md5(digest).hexdigest() return self._shortcmd('APOP %s %s' % (user, digest)) def top(self, which, howmuch): """Retrieve message header of message number 'which' and first 'howmuch' lines of message body. Result is in form ['response', ['line', ...], octets]. """ return self._longcmd('TOP %s %s' % (which, howmuch)) def uidl(self, which=None): """Return message digest (unique id) list. If 'which', result contains unique id for that message in the form 'response mesgnum uid', otherwise result is the list ['response', ['mesgnum uid', ...], octets] """ if which is not None: return self._shortcmd('UIDL %s' % which) return self._longcmd('UIDL') def utf8(self): """Try to enter UTF-8 mode (see RFC 6856). Returns server response. """ return self._shortcmd('UTF8') def capa(self): """Return server capabilities (RFC 2449) as a dictionary >>> c=poplib.POP3('localhost') >>> c.capa() {'IMPLEMENTATION': ['Cyrus', 'POP3', 'server', 'v2.2.12'], 'TOP': [], 'LOGIN-DELAY': ['0'], 'AUTH-RESP-CODE': [], 'EXPIRE': ['NEVER'], 'USER': [], 'STLS': [], 'PIPELINING': [], 'UIDL': [], 'RESP-CODES': []} >>> Really, according to RFC 2449, the cyrus folks should avoid having the implementation split into multiple arguments... """ def _parsecap(line): lst = line.decode('ascii').split() return lst[0], lst[1:] caps = {} try: resp = self._longcmd('CAPA') rawcaps = resp[1] for capline in rawcaps: capnm, capargs = _parsecap(capline) caps[capnm] = capargs except error_proto as _err: raise error_proto('-ERR CAPA not supported by server') return caps def stls(self, context=None): """Start a TLS session on the active connection as specified in RFC 2595. context - a ssl.SSLContext """ if not HAVE_SSL: raise error_proto('-ERR TLS support missing') if self._tls_established: raise error_proto('-ERR TLS session already established') caps = self.capa() if not 'STLS' in caps: raise error_proto('-ERR STLS not supported by server') if context is None: context = ssl._create_stdlib_context() resp = self._shortcmd('STLS') self.sock = context.wrap_socket(self.sock, server_hostname=self.host) self.file = self.sock.makefile('rb') self._tls_established = True return resp if HAVE_SSL: class POP3_SSL(POP3): """POP3 client class over SSL connection Instantiate with: POP3_SSL(hostname, port=995, keyfile=None, certfile=None, context=None) hostname - the hostname of the pop3 over ssl server port - port number keyfile - PEM formatted file that contains your private key certfile - PEM formatted certificate chain file context - a ssl.SSLContext See the methods of the parent class POP3 for more documentation. """ def __init__(self, host, port=POP3_SSL_PORT, keyfile=None, certfile=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT, context=None): if context is not None and keyfile is not None: raise ValueError("context and keyfile arguments are mutually " "exclusive") if context is not None and certfile is not None: raise ValueError("context and certfile arguments are mutually " "exclusive") self.keyfile = keyfile self.certfile = certfile if context is None: context = ssl._create_stdlib_context(certfile=certfile, keyfile=keyfile) self.context = context POP3.__init__(self, host, port, timeout) def _create_socket(self, timeout): sock = POP3._create_socket(self, timeout) sock = self.context.wrap_socket(sock, server_hostname=self.host) return sock def stls(self, keyfile=None, certfile=None, context=None): """The method unconditionally raises an exception since the STLS command doesn't make any sense on an already established SSL/TLS session. """ raise error_proto('-ERR TLS session already established') __all__.append("POP3_SSL") if __name__ == "__main__": import sys a = POP3(sys.argv[1]) print(a.getwelcome()) a.user(sys.argv[2]) a.pass_(sys.argv[3]) a.list() (numMsgs, totalSize) = a.stat() for i in range(1, numMsgs + 1): (header, msg, octets) = a.retr(i) print("Message %d:" % i) for line in msg: print(' ' + line) print('-----------------------') a.quit()