akaaafk commited on
Commit
0e40cdc
·
verified ·
1 Parent(s): 4b5a57a

Add files using upload-large-folder tool

Browse files
Files changed (20) hide show
  1. benchmark/NYU_CTF_Bench/test/2019/CSAW-Quals/crypto/brillouin/lib/python2.7/site-packages/pytz/zoneinfo/America/Rainy_River +0 -0
  2. benchmark/NYU_CTF_Bench/test/2019/CSAW-Quals/crypto/brillouin/lib/python2.7/site-packages/pytz/zoneinfo/America/Rankin_Inlet +0 -0
  3. benchmark/NYU_CTF_Bench/test/2019/CSAW-Quals/crypto/brillouin/lib/python2.7/site-packages/pytz/zoneinfo/America/Thunder_Bay +0 -0
  4. benchmark/NYU_CTF_Bench/test/2019/CSAW-Quals/crypto/brillouin/lib/python2.7/site-packages/pytz/zoneinfo/America/Tijuana +0 -0
  5. benchmark/NYU_CTF_Bench/test/2019/CSAW-Quals/crypto/brillouin/lib/python2.7/site-packages/pytz/zoneinfo/America/Toronto +0 -0
  6. benchmark/NYU_CTF_Bench/test/2019/CSAW-Quals/crypto/brillouin/lib/python2.7/site-packages/pytz/zoneinfo/America/Tortola +0 -0
  7. benchmark/NYU_CTF_Bench/test/2019/CSAW-Quals/crypto/brillouin/lib/python2.7/site-packages/pytz/zoneinfo/America/Vancouver +0 -0
  8. benchmark/NYU_CTF_Bench/test/2019/CSAW-Quals/crypto/brillouin/lib/python2.7/site-packages/pytz/zoneinfo/America/Virgin +0 -0
  9. benchmark/NYU_CTF_Bench/test/2019/CSAW-Quals/crypto/brillouin/lib/python2.7/site-packages/pytz/zoneinfo/America/Whitehorse +0 -0
  10. benchmark/NYU_CTF_Bench/test/2019/CSAW-Quals/crypto/brillouin/lib/python2.7/site-packages/pytz/zoneinfo/America/Winnipeg +0 -0
  11. benchmark/NYU_CTF_Bench/test/2019/CSAW-Quals/crypto/brillouin/lib/python2.7/site-packages/urllib3/contrib/__init__.py +0 -0
  12. benchmark/NYU_CTF_Bench/test/2019/CSAW-Quals/crypto/brillouin/lib/python2.7/site-packages/urllib3/packages/__init__.py +5 -0
  13. benchmark/NYU_CTF_Bench/test/2019/CSAW-Quals/crypto/brillouin/lib/python2.7/site-packages/urllib3/packages/six.py +868 -0
  14. benchmark/NYU_CTF_Bench/test/2019/CSAW-Quals/crypto/brillouin/lib/python2.7/site-packages/urllib3/util/connection.py +134 -0
  15. benchmark/NYU_CTF_Bench/test/2019/CSAW-Quals/crypto/brillouin/lib/python2.7/site-packages/urllib3/util/queue.py +21 -0
  16. benchmark/NYU_CTF_Bench/test/2019/CSAW-Quals/crypto/brillouin/lib/python2.7/site-packages/urllib3/util/request.py +125 -0
  17. benchmark/NYU_CTF_Bench/test/2019/CSAW-Quals/crypto/brillouin/lib/python2.7/site-packages/urllib3/util/response.py +87 -0
  18. benchmark/NYU_CTF_Bench/test/2019/CSAW-Quals/crypto/brillouin/lib/python2.7/site-packages/urllib3/util/retry.py +412 -0
  19. benchmark/NYU_CTF_Bench/test/2019/CSAW-Quals/crypto/brillouin/lib/python2.7/site-packages/urllib3/util/ssl_.py +392 -0
  20. benchmark/NYU_CTF_Bench/test/2019/CSAW-Quals/crypto/brillouin/lib/python2.7/site-packages/urllib3/util/timeout.py +243 -0
benchmark/NYU_CTF_Bench/test/2019/CSAW-Quals/crypto/brillouin/lib/python2.7/site-packages/pytz/zoneinfo/America/Rainy_River ADDED
Binary file (2.12 kB). View file
 
benchmark/NYU_CTF_Bench/test/2019/CSAW-Quals/crypto/brillouin/lib/python2.7/site-packages/pytz/zoneinfo/America/Rankin_Inlet ADDED
Binary file (1.89 kB). View file
 
benchmark/NYU_CTF_Bench/test/2019/CSAW-Quals/crypto/brillouin/lib/python2.7/site-packages/pytz/zoneinfo/America/Thunder_Bay ADDED
Binary file (2.2 kB). View file
 
benchmark/NYU_CTF_Bench/test/2019/CSAW-Quals/crypto/brillouin/lib/python2.7/site-packages/pytz/zoneinfo/America/Tijuana ADDED
Binary file (2.34 kB). View file
 
benchmark/NYU_CTF_Bench/test/2019/CSAW-Quals/crypto/brillouin/lib/python2.7/site-packages/pytz/zoneinfo/America/Toronto ADDED
Binary file (3.49 kB). View file
 
benchmark/NYU_CTF_Bench/test/2019/CSAW-Quals/crypto/brillouin/lib/python2.7/site-packages/pytz/zoneinfo/America/Tortola ADDED
Binary file (148 Bytes). View file
 
benchmark/NYU_CTF_Bench/test/2019/CSAW-Quals/crypto/brillouin/lib/python2.7/site-packages/pytz/zoneinfo/America/Vancouver ADDED
Binary file (2.89 kB). View file
 
benchmark/NYU_CTF_Bench/test/2019/CSAW-Quals/crypto/brillouin/lib/python2.7/site-packages/pytz/zoneinfo/America/Virgin ADDED
Binary file (148 Bytes). View file
 
benchmark/NYU_CTF_Bench/test/2019/CSAW-Quals/crypto/brillouin/lib/python2.7/site-packages/pytz/zoneinfo/America/Whitehorse ADDED
Binary file (2.08 kB). View file
 
benchmark/NYU_CTF_Bench/test/2019/CSAW-Quals/crypto/brillouin/lib/python2.7/site-packages/pytz/zoneinfo/America/Winnipeg ADDED
Binary file (2.87 kB). View file
 
benchmark/NYU_CTF_Bench/test/2019/CSAW-Quals/crypto/brillouin/lib/python2.7/site-packages/urllib3/contrib/__init__.py ADDED
File without changes
benchmark/NYU_CTF_Bench/test/2019/CSAW-Quals/crypto/brillouin/lib/python2.7/site-packages/urllib3/packages/__init__.py ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ from __future__ import absolute_import
2
+
3
+ from . import ssl_match_hostname
4
+
5
+ __all__ = ('ssl_match_hostname', )
benchmark/NYU_CTF_Bench/test/2019/CSAW-Quals/crypto/brillouin/lib/python2.7/site-packages/urllib3/packages/six.py ADDED
@@ -0,0 +1,868 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Utilities for writing code that runs on Python 2 and 3"""
2
+
3
+ # Copyright (c) 2010-2015 Benjamin Peterson
4
+ #
5
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ # of this software and associated documentation files (the "Software"), to deal
7
+ # in the Software without restriction, including without limitation the rights
8
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ # copies of the Software, and to permit persons to whom the Software is
10
+ # furnished to do so, subject to the following conditions:
11
+ #
12
+ # The above copyright notice and this permission notice shall be included in all
13
+ # copies or substantial portions of the Software.
14
+ #
15
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ # SOFTWARE.
22
+
23
+ from __future__ import absolute_import
24
+
25
+ import functools
26
+ import itertools
27
+ import operator
28
+ import sys
29
+ import types
30
+
31
+ __author__ = "Benjamin Peterson <benjamin@python.org>"
32
+ __version__ = "1.10.0"
33
+
34
+
35
+ # Useful for very coarse version differentiation.
36
+ PY2 = sys.version_info[0] == 2
37
+ PY3 = sys.version_info[0] == 3
38
+ PY34 = sys.version_info[0:2] >= (3, 4)
39
+
40
+ if PY3:
41
+ string_types = str,
42
+ integer_types = int,
43
+ class_types = type,
44
+ text_type = str
45
+ binary_type = bytes
46
+
47
+ MAXSIZE = sys.maxsize
48
+ else:
49
+ string_types = basestring,
50
+ integer_types = (int, long)
51
+ class_types = (type, types.ClassType)
52
+ text_type = unicode
53
+ binary_type = str
54
+
55
+ if sys.platform.startswith("java"):
56
+ # Jython always uses 32 bits.
57
+ MAXSIZE = int((1 << 31) - 1)
58
+ else:
59
+ # It's possible to have sizeof(long) != sizeof(Py_ssize_t).
60
+ class X(object):
61
+
62
+ def __len__(self):
63
+ return 1 << 31
64
+ try:
65
+ len(X())
66
+ except OverflowError:
67
+ # 32-bit
68
+ MAXSIZE = int((1 << 31) - 1)
69
+ else:
70
+ # 64-bit
71
+ MAXSIZE = int((1 << 63) - 1)
72
+ del X
73
+
74
+
75
+ def _add_doc(func, doc):
76
+ """Add documentation to a function."""
77
+ func.__doc__ = doc
78
+
79
+
80
+ def _import_module(name):
81
+ """Import module, returning the module after the last dot."""
82
+ __import__(name)
83
+ return sys.modules[name]
84
+
85
+
86
+ class _LazyDescr(object):
87
+
88
+ def __init__(self, name):
89
+ self.name = name
90
+
91
+ def __get__(self, obj, tp):
92
+ result = self._resolve()
93
+ setattr(obj, self.name, result) # Invokes __set__.
94
+ try:
95
+ # This is a bit ugly, but it avoids running this again by
96
+ # removing this descriptor.
97
+ delattr(obj.__class__, self.name)
98
+ except AttributeError:
99
+ pass
100
+ return result
101
+
102
+
103
+ class MovedModule(_LazyDescr):
104
+
105
+ def __init__(self, name, old, new=None):
106
+ super(MovedModule, self).__init__(name)
107
+ if PY3:
108
+ if new is None:
109
+ new = name
110
+ self.mod = new
111
+ else:
112
+ self.mod = old
113
+
114
+ def _resolve(self):
115
+ return _import_module(self.mod)
116
+
117
+ def __getattr__(self, attr):
118
+ _module = self._resolve()
119
+ value = getattr(_module, attr)
120
+ setattr(self, attr, value)
121
+ return value
122
+
123
+
124
+ class _LazyModule(types.ModuleType):
125
+
126
+ def __init__(self, name):
127
+ super(_LazyModule, self).__init__(name)
128
+ self.__doc__ = self.__class__.__doc__
129
+
130
+ def __dir__(self):
131
+ attrs = ["__doc__", "__name__"]
132
+ attrs += [attr.name for attr in self._moved_attributes]
133
+ return attrs
134
+
135
+ # Subclasses should override this
136
+ _moved_attributes = []
137
+
138
+
139
+ class MovedAttribute(_LazyDescr):
140
+
141
+ def __init__(self, name, old_mod, new_mod, old_attr=None, new_attr=None):
142
+ super(MovedAttribute, self).__init__(name)
143
+ if PY3:
144
+ if new_mod is None:
145
+ new_mod = name
146
+ self.mod = new_mod
147
+ if new_attr is None:
148
+ if old_attr is None:
149
+ new_attr = name
150
+ else:
151
+ new_attr = old_attr
152
+ self.attr = new_attr
153
+ else:
154
+ self.mod = old_mod
155
+ if old_attr is None:
156
+ old_attr = name
157
+ self.attr = old_attr
158
+
159
+ def _resolve(self):
160
+ module = _import_module(self.mod)
161
+ return getattr(module, self.attr)
162
+
163
+
164
+ class _SixMetaPathImporter(object):
165
+
166
+ """
167
+ A meta path importer to import six.moves and its submodules.
168
+
169
+ This class implements a PEP302 finder and loader. It should be compatible
170
+ with Python 2.5 and all existing versions of Python3
171
+ """
172
+
173
+ def __init__(self, six_module_name):
174
+ self.name = six_module_name
175
+ self.known_modules = {}
176
+
177
+ def _add_module(self, mod, *fullnames):
178
+ for fullname in fullnames:
179
+ self.known_modules[self.name + "." + fullname] = mod
180
+
181
+ def _get_module(self, fullname):
182
+ return self.known_modules[self.name + "." + fullname]
183
+
184
+ def find_module(self, fullname, path=None):
185
+ if fullname in self.known_modules:
186
+ return self
187
+ return None
188
+
189
+ def __get_module(self, fullname):
190
+ try:
191
+ return self.known_modules[fullname]
192
+ except KeyError:
193
+ raise ImportError("This loader does not know module " + fullname)
194
+
195
+ def load_module(self, fullname):
196
+ try:
197
+ # in case of a reload
198
+ return sys.modules[fullname]
199
+ except KeyError:
200
+ pass
201
+ mod = self.__get_module(fullname)
202
+ if isinstance(mod, MovedModule):
203
+ mod = mod._resolve()
204
+ else:
205
+ mod.__loader__ = self
206
+ sys.modules[fullname] = mod
207
+ return mod
208
+
209
+ def is_package(self, fullname):
210
+ """
211
+ Return true, if the named module is a package.
212
+
213
+ We need this method to get correct spec objects with
214
+ Python 3.4 (see PEP451)
215
+ """
216
+ return hasattr(self.__get_module(fullname), "__path__")
217
+
218
+ def get_code(self, fullname):
219
+ """Return None
220
+
221
+ Required, if is_package is implemented"""
222
+ self.__get_module(fullname) # eventually raises ImportError
223
+ return None
224
+ get_source = get_code # same as get_code
225
+
226
+ _importer = _SixMetaPathImporter(__name__)
227
+
228
+
229
+ class _MovedItems(_LazyModule):
230
+
231
+ """Lazy loading of moved objects"""
232
+ __path__ = [] # mark as package
233
+
234
+
235
+ _moved_attributes = [
236
+ MovedAttribute("cStringIO", "cStringIO", "io", "StringIO"),
237
+ MovedAttribute("filter", "itertools", "builtins", "ifilter", "filter"),
238
+ MovedAttribute("filterfalse", "itertools", "itertools", "ifilterfalse", "filterfalse"),
239
+ MovedAttribute("input", "__builtin__", "builtins", "raw_input", "input"),
240
+ MovedAttribute("intern", "__builtin__", "sys"),
241
+ MovedAttribute("map", "itertools", "builtins", "imap", "map"),
242
+ MovedAttribute("getcwd", "os", "os", "getcwdu", "getcwd"),
243
+ MovedAttribute("getcwdb", "os", "os", "getcwd", "getcwdb"),
244
+ MovedAttribute("range", "__builtin__", "builtins", "xrange", "range"),
245
+ MovedAttribute("reload_module", "__builtin__", "importlib" if PY34 else "imp", "reload"),
246
+ MovedAttribute("reduce", "__builtin__", "functools"),
247
+ MovedAttribute("shlex_quote", "pipes", "shlex", "quote"),
248
+ MovedAttribute("StringIO", "StringIO", "io"),
249
+ MovedAttribute("UserDict", "UserDict", "collections"),
250
+ MovedAttribute("UserList", "UserList", "collections"),
251
+ MovedAttribute("UserString", "UserString", "collections"),
252
+ MovedAttribute("xrange", "__builtin__", "builtins", "xrange", "range"),
253
+ MovedAttribute("zip", "itertools", "builtins", "izip", "zip"),
254
+ MovedAttribute("zip_longest", "itertools", "itertools", "izip_longest", "zip_longest"),
255
+ MovedModule("builtins", "__builtin__"),
256
+ MovedModule("configparser", "ConfigParser"),
257
+ MovedModule("copyreg", "copy_reg"),
258
+ MovedModule("dbm_gnu", "gdbm", "dbm.gnu"),
259
+ MovedModule("_dummy_thread", "dummy_thread", "_dummy_thread"),
260
+ MovedModule("http_cookiejar", "cookielib", "http.cookiejar"),
261
+ MovedModule("http_cookies", "Cookie", "http.cookies"),
262
+ MovedModule("html_entities", "htmlentitydefs", "html.entities"),
263
+ MovedModule("html_parser", "HTMLParser", "html.parser"),
264
+ MovedModule("http_client", "httplib", "http.client"),
265
+ MovedModule("email_mime_multipart", "email.MIMEMultipart", "email.mime.multipart"),
266
+ MovedModule("email_mime_nonmultipart", "email.MIMENonMultipart", "email.mime.nonmultipart"),
267
+ MovedModule("email_mime_text", "email.MIMEText", "email.mime.text"),
268
+ MovedModule("email_mime_base", "email.MIMEBase", "email.mime.base"),
269
+ MovedModule("BaseHTTPServer", "BaseHTTPServer", "http.server"),
270
+ MovedModule("CGIHTTPServer", "CGIHTTPServer", "http.server"),
271
+ MovedModule("SimpleHTTPServer", "SimpleHTTPServer", "http.server"),
272
+ MovedModule("cPickle", "cPickle", "pickle"),
273
+ MovedModule("queue", "Queue"),
274
+ MovedModule("reprlib", "repr"),
275
+ MovedModule("socketserver", "SocketServer"),
276
+ MovedModule("_thread", "thread", "_thread"),
277
+ MovedModule("tkinter", "Tkinter"),
278
+ MovedModule("tkinter_dialog", "Dialog", "tkinter.dialog"),
279
+ MovedModule("tkinter_filedialog", "FileDialog", "tkinter.filedialog"),
280
+ MovedModule("tkinter_scrolledtext", "ScrolledText", "tkinter.scrolledtext"),
281
+ MovedModule("tkinter_simpledialog", "SimpleDialog", "tkinter.simpledialog"),
282
+ MovedModule("tkinter_tix", "Tix", "tkinter.tix"),
283
+ MovedModule("tkinter_ttk", "ttk", "tkinter.ttk"),
284
+ MovedModule("tkinter_constants", "Tkconstants", "tkinter.constants"),
285
+ MovedModule("tkinter_dnd", "Tkdnd", "tkinter.dnd"),
286
+ MovedModule("tkinter_colorchooser", "tkColorChooser",
287
+ "tkinter.colorchooser"),
288
+ MovedModule("tkinter_commondialog", "tkCommonDialog",
289
+ "tkinter.commondialog"),
290
+ MovedModule("tkinter_tkfiledialog", "tkFileDialog", "tkinter.filedialog"),
291
+ MovedModule("tkinter_font", "tkFont", "tkinter.font"),
292
+ MovedModule("tkinter_messagebox", "tkMessageBox", "tkinter.messagebox"),
293
+ MovedModule("tkinter_tksimpledialog", "tkSimpleDialog",
294
+ "tkinter.simpledialog"),
295
+ MovedModule("urllib_parse", __name__ + ".moves.urllib_parse", "urllib.parse"),
296
+ MovedModule("urllib_error", __name__ + ".moves.urllib_error", "urllib.error"),
297
+ MovedModule("urllib", __name__ + ".moves.urllib", __name__ + ".moves.urllib"),
298
+ MovedModule("urllib_robotparser", "robotparser", "urllib.robotparser"),
299
+ MovedModule("xmlrpc_client", "xmlrpclib", "xmlrpc.client"),
300
+ MovedModule("xmlrpc_server", "SimpleXMLRPCServer", "xmlrpc.server"),
301
+ ]
302
+ # Add windows specific modules.
303
+ if sys.platform == "win32":
304
+ _moved_attributes += [
305
+ MovedModule("winreg", "_winreg"),
306
+ ]
307
+
308
+ for attr in _moved_attributes:
309
+ setattr(_MovedItems, attr.name, attr)
310
+ if isinstance(attr, MovedModule):
311
+ _importer._add_module(attr, "moves." + attr.name)
312
+ del attr
313
+
314
+ _MovedItems._moved_attributes = _moved_attributes
315
+
316
+ moves = _MovedItems(__name__ + ".moves")
317
+ _importer._add_module(moves, "moves")
318
+
319
+
320
+ class Module_six_moves_urllib_parse(_LazyModule):
321
+
322
+ """Lazy loading of moved objects in six.moves.urllib_parse"""
323
+
324
+
325
+ _urllib_parse_moved_attributes = [
326
+ MovedAttribute("ParseResult", "urlparse", "urllib.parse"),
327
+ MovedAttribute("SplitResult", "urlparse", "urllib.parse"),
328
+ MovedAttribute("parse_qs", "urlparse", "urllib.parse"),
329
+ MovedAttribute("parse_qsl", "urlparse", "urllib.parse"),
330
+ MovedAttribute("urldefrag", "urlparse", "urllib.parse"),
331
+ MovedAttribute("urljoin", "urlparse", "urllib.parse"),
332
+ MovedAttribute("urlparse", "urlparse", "urllib.parse"),
333
+ MovedAttribute("urlsplit", "urlparse", "urllib.parse"),
334
+ MovedAttribute("urlunparse", "urlparse", "urllib.parse"),
335
+ MovedAttribute("urlunsplit", "urlparse", "urllib.parse"),
336
+ MovedAttribute("quote", "urllib", "urllib.parse"),
337
+ MovedAttribute("quote_plus", "urllib", "urllib.parse"),
338
+ MovedAttribute("unquote", "urllib", "urllib.parse"),
339
+ MovedAttribute("unquote_plus", "urllib", "urllib.parse"),
340
+ MovedAttribute("urlencode", "urllib", "urllib.parse"),
341
+ MovedAttribute("splitquery", "urllib", "urllib.parse"),
342
+ MovedAttribute("splittag", "urllib", "urllib.parse"),
343
+ MovedAttribute("splituser", "urllib", "urllib.parse"),
344
+ MovedAttribute("uses_fragment", "urlparse", "urllib.parse"),
345
+ MovedAttribute("uses_netloc", "urlparse", "urllib.parse"),
346
+ MovedAttribute("uses_params", "urlparse", "urllib.parse"),
347
+ MovedAttribute("uses_query", "urlparse", "urllib.parse"),
348
+ MovedAttribute("uses_relative", "urlparse", "urllib.parse"),
349
+ ]
350
+ for attr in _urllib_parse_moved_attributes:
351
+ setattr(Module_six_moves_urllib_parse, attr.name, attr)
352
+ del attr
353
+
354
+ Module_six_moves_urllib_parse._moved_attributes = _urllib_parse_moved_attributes
355
+
356
+ _importer._add_module(Module_six_moves_urllib_parse(__name__ + ".moves.urllib_parse"),
357
+ "moves.urllib_parse", "moves.urllib.parse")
358
+
359
+
360
+ class Module_six_moves_urllib_error(_LazyModule):
361
+
362
+ """Lazy loading of moved objects in six.moves.urllib_error"""
363
+
364
+
365
+ _urllib_error_moved_attributes = [
366
+ MovedAttribute("URLError", "urllib2", "urllib.error"),
367
+ MovedAttribute("HTTPError", "urllib2", "urllib.error"),
368
+ MovedAttribute("ContentTooShortError", "urllib", "urllib.error"),
369
+ ]
370
+ for attr in _urllib_error_moved_attributes:
371
+ setattr(Module_six_moves_urllib_error, attr.name, attr)
372
+ del attr
373
+
374
+ Module_six_moves_urllib_error._moved_attributes = _urllib_error_moved_attributes
375
+
376
+ _importer._add_module(Module_six_moves_urllib_error(__name__ + ".moves.urllib.error"),
377
+ "moves.urllib_error", "moves.urllib.error")
378
+
379
+
380
+ class Module_six_moves_urllib_request(_LazyModule):
381
+
382
+ """Lazy loading of moved objects in six.moves.urllib_request"""
383
+
384
+
385
+ _urllib_request_moved_attributes = [
386
+ MovedAttribute("urlopen", "urllib2", "urllib.request"),
387
+ MovedAttribute("install_opener", "urllib2", "urllib.request"),
388
+ MovedAttribute("build_opener", "urllib2", "urllib.request"),
389
+ MovedAttribute("pathname2url", "urllib", "urllib.request"),
390
+ MovedAttribute("url2pathname", "urllib", "urllib.request"),
391
+ MovedAttribute("getproxies", "urllib", "urllib.request"),
392
+ MovedAttribute("Request", "urllib2", "urllib.request"),
393
+ MovedAttribute("OpenerDirector", "urllib2", "urllib.request"),
394
+ MovedAttribute("HTTPDefaultErrorHandler", "urllib2", "urllib.request"),
395
+ MovedAttribute("HTTPRedirectHandler", "urllib2", "urllib.request"),
396
+ MovedAttribute("HTTPCookieProcessor", "urllib2", "urllib.request"),
397
+ MovedAttribute("ProxyHandler", "urllib2", "urllib.request"),
398
+ MovedAttribute("BaseHandler", "urllib2", "urllib.request"),
399
+ MovedAttribute("HTTPPasswordMgr", "urllib2", "urllib.request"),
400
+ MovedAttribute("HTTPPasswordMgrWithDefaultRealm", "urllib2", "urllib.request"),
401
+ MovedAttribute("AbstractBasicAuthHandler", "urllib2", "urllib.request"),
402
+ MovedAttribute("HTTPBasicAuthHandler", "urllib2", "urllib.request"),
403
+ MovedAttribute("ProxyBasicAuthHandler", "urllib2", "urllib.request"),
404
+ MovedAttribute("AbstractDigestAuthHandler", "urllib2", "urllib.request"),
405
+ MovedAttribute("HTTPDigestAuthHandler", "urllib2", "urllib.request"),
406
+ MovedAttribute("ProxyDigestAuthHandler", "urllib2", "urllib.request"),
407
+ MovedAttribute("HTTPHandler", "urllib2", "urllib.request"),
408
+ MovedAttribute("HTTPSHandler", "urllib2", "urllib.request"),
409
+ MovedAttribute("FileHandler", "urllib2", "urllib.request"),
410
+ MovedAttribute("FTPHandler", "urllib2", "urllib.request"),
411
+ MovedAttribute("CacheFTPHandler", "urllib2", "urllib.request"),
412
+ MovedAttribute("UnknownHandler", "urllib2", "urllib.request"),
413
+ MovedAttribute("HTTPErrorProcessor", "urllib2", "urllib.request"),
414
+ MovedAttribute("urlretrieve", "urllib", "urllib.request"),
415
+ MovedAttribute("urlcleanup", "urllib", "urllib.request"),
416
+ MovedAttribute("URLopener", "urllib", "urllib.request"),
417
+ MovedAttribute("FancyURLopener", "urllib", "urllib.request"),
418
+ MovedAttribute("proxy_bypass", "urllib", "urllib.request"),
419
+ ]
420
+ for attr in _urllib_request_moved_attributes:
421
+ setattr(Module_six_moves_urllib_request, attr.name, attr)
422
+ del attr
423
+
424
+ Module_six_moves_urllib_request._moved_attributes = _urllib_request_moved_attributes
425
+
426
+ _importer._add_module(Module_six_moves_urllib_request(__name__ + ".moves.urllib.request"),
427
+ "moves.urllib_request", "moves.urllib.request")
428
+
429
+
430
+ class Module_six_moves_urllib_response(_LazyModule):
431
+
432
+ """Lazy loading of moved objects in six.moves.urllib_response"""
433
+
434
+
435
+ _urllib_response_moved_attributes = [
436
+ MovedAttribute("addbase", "urllib", "urllib.response"),
437
+ MovedAttribute("addclosehook", "urllib", "urllib.response"),
438
+ MovedAttribute("addinfo", "urllib", "urllib.response"),
439
+ MovedAttribute("addinfourl", "urllib", "urllib.response"),
440
+ ]
441
+ for attr in _urllib_response_moved_attributes:
442
+ setattr(Module_six_moves_urllib_response, attr.name, attr)
443
+ del attr
444
+
445
+ Module_six_moves_urllib_response._moved_attributes = _urllib_response_moved_attributes
446
+
447
+ _importer._add_module(Module_six_moves_urllib_response(__name__ + ".moves.urllib.response"),
448
+ "moves.urllib_response", "moves.urllib.response")
449
+
450
+
451
+ class Module_six_moves_urllib_robotparser(_LazyModule):
452
+
453
+ """Lazy loading of moved objects in six.moves.urllib_robotparser"""
454
+
455
+
456
+ _urllib_robotparser_moved_attributes = [
457
+ MovedAttribute("RobotFileParser", "robotparser", "urllib.robotparser"),
458
+ ]
459
+ for attr in _urllib_robotparser_moved_attributes:
460
+ setattr(Module_six_moves_urllib_robotparser, attr.name, attr)
461
+ del attr
462
+
463
+ Module_six_moves_urllib_robotparser._moved_attributes = _urllib_robotparser_moved_attributes
464
+
465
+ _importer._add_module(Module_six_moves_urllib_robotparser(__name__ + ".moves.urllib.robotparser"),
466
+ "moves.urllib_robotparser", "moves.urllib.robotparser")
467
+
468
+
469
+ class Module_six_moves_urllib(types.ModuleType):
470
+
471
+ """Create a six.moves.urllib namespace that resembles the Python 3 namespace"""
472
+ __path__ = [] # mark as package
473
+ parse = _importer._get_module("moves.urllib_parse")
474
+ error = _importer._get_module("moves.urllib_error")
475
+ request = _importer._get_module("moves.urllib_request")
476
+ response = _importer._get_module("moves.urllib_response")
477
+ robotparser = _importer._get_module("moves.urllib_robotparser")
478
+
479
+ def __dir__(self):
480
+ return ['parse', 'error', 'request', 'response', 'robotparser']
481
+
482
+ _importer._add_module(Module_six_moves_urllib(__name__ + ".moves.urllib"),
483
+ "moves.urllib")
484
+
485
+
486
+ def add_move(move):
487
+ """Add an item to six.moves."""
488
+ setattr(_MovedItems, move.name, move)
489
+
490
+
491
+ def remove_move(name):
492
+ """Remove item from six.moves."""
493
+ try:
494
+ delattr(_MovedItems, name)
495
+ except AttributeError:
496
+ try:
497
+ del moves.__dict__[name]
498
+ except KeyError:
499
+ raise AttributeError("no such move, %r" % (name,))
500
+
501
+
502
+ if PY3:
503
+ _meth_func = "__func__"
504
+ _meth_self = "__self__"
505
+
506
+ _func_closure = "__closure__"
507
+ _func_code = "__code__"
508
+ _func_defaults = "__defaults__"
509
+ _func_globals = "__globals__"
510
+ else:
511
+ _meth_func = "im_func"
512
+ _meth_self = "im_self"
513
+
514
+ _func_closure = "func_closure"
515
+ _func_code = "func_code"
516
+ _func_defaults = "func_defaults"
517
+ _func_globals = "func_globals"
518
+
519
+
520
+ try:
521
+ advance_iterator = next
522
+ except NameError:
523
+ def advance_iterator(it):
524
+ return it.next()
525
+ next = advance_iterator
526
+
527
+
528
+ try:
529
+ callable = callable
530
+ except NameError:
531
+ def callable(obj):
532
+ return any("__call__" in klass.__dict__ for klass in type(obj).__mro__)
533
+
534
+
535
+ if PY3:
536
+ def get_unbound_function(unbound):
537
+ return unbound
538
+
539
+ create_bound_method = types.MethodType
540
+
541
+ def create_unbound_method(func, cls):
542
+ return func
543
+
544
+ Iterator = object
545
+ else:
546
+ def get_unbound_function(unbound):
547
+ return unbound.im_func
548
+
549
+ def create_bound_method(func, obj):
550
+ return types.MethodType(func, obj, obj.__class__)
551
+
552
+ def create_unbound_method(func, cls):
553
+ return types.MethodType(func, None, cls)
554
+
555
+ class Iterator(object):
556
+
557
+ def next(self):
558
+ return type(self).__next__(self)
559
+
560
+ callable = callable
561
+ _add_doc(get_unbound_function,
562
+ """Get the function out of a possibly unbound function""")
563
+
564
+
565
+ get_method_function = operator.attrgetter(_meth_func)
566
+ get_method_self = operator.attrgetter(_meth_self)
567
+ get_function_closure = operator.attrgetter(_func_closure)
568
+ get_function_code = operator.attrgetter(_func_code)
569
+ get_function_defaults = operator.attrgetter(_func_defaults)
570
+ get_function_globals = operator.attrgetter(_func_globals)
571
+
572
+
573
+ if PY3:
574
+ def iterkeys(d, **kw):
575
+ return iter(d.keys(**kw))
576
+
577
+ def itervalues(d, **kw):
578
+ return iter(d.values(**kw))
579
+
580
+ def iteritems(d, **kw):
581
+ return iter(d.items(**kw))
582
+
583
+ def iterlists(d, **kw):
584
+ return iter(d.lists(**kw))
585
+
586
+ viewkeys = operator.methodcaller("keys")
587
+
588
+ viewvalues = operator.methodcaller("values")
589
+
590
+ viewitems = operator.methodcaller("items")
591
+ else:
592
+ def iterkeys(d, **kw):
593
+ return d.iterkeys(**kw)
594
+
595
+ def itervalues(d, **kw):
596
+ return d.itervalues(**kw)
597
+
598
+ def iteritems(d, **kw):
599
+ return d.iteritems(**kw)
600
+
601
+ def iterlists(d, **kw):
602
+ return d.iterlists(**kw)
603
+
604
+ viewkeys = operator.methodcaller("viewkeys")
605
+
606
+ viewvalues = operator.methodcaller("viewvalues")
607
+
608
+ viewitems = operator.methodcaller("viewitems")
609
+
610
+ _add_doc(iterkeys, "Return an iterator over the keys of a dictionary.")
611
+ _add_doc(itervalues, "Return an iterator over the values of a dictionary.")
612
+ _add_doc(iteritems,
613
+ "Return an iterator over the (key, value) pairs of a dictionary.")
614
+ _add_doc(iterlists,
615
+ "Return an iterator over the (key, [values]) pairs of a dictionary.")
616
+
617
+
618
+ if PY3:
619
+ def b(s):
620
+ return s.encode("latin-1")
621
+
622
+ def u(s):
623
+ return s
624
+ unichr = chr
625
+ import struct
626
+ int2byte = struct.Struct(">B").pack
627
+ del struct
628
+ byte2int = operator.itemgetter(0)
629
+ indexbytes = operator.getitem
630
+ iterbytes = iter
631
+ import io
632
+ StringIO = io.StringIO
633
+ BytesIO = io.BytesIO
634
+ _assertCountEqual = "assertCountEqual"
635
+ if sys.version_info[1] <= 1:
636
+ _assertRaisesRegex = "assertRaisesRegexp"
637
+ _assertRegex = "assertRegexpMatches"
638
+ else:
639
+ _assertRaisesRegex = "assertRaisesRegex"
640
+ _assertRegex = "assertRegex"
641
+ else:
642
+ def b(s):
643
+ return s
644
+ # Workaround for standalone backslash
645
+
646
+ def u(s):
647
+ return unicode(s.replace(r'\\', r'\\\\'), "unicode_escape")
648
+ unichr = unichr
649
+ int2byte = chr
650
+
651
+ def byte2int(bs):
652
+ return ord(bs[0])
653
+
654
+ def indexbytes(buf, i):
655
+ return ord(buf[i])
656
+ iterbytes = functools.partial(itertools.imap, ord)
657
+ import StringIO
658
+ StringIO = BytesIO = StringIO.StringIO
659
+ _assertCountEqual = "assertItemsEqual"
660
+ _assertRaisesRegex = "assertRaisesRegexp"
661
+ _assertRegex = "assertRegexpMatches"
662
+ _add_doc(b, """Byte literal""")
663
+ _add_doc(u, """Text literal""")
664
+
665
+
666
+ def assertCountEqual(self, *args, **kwargs):
667
+ return getattr(self, _assertCountEqual)(*args, **kwargs)
668
+
669
+
670
+ def assertRaisesRegex(self, *args, **kwargs):
671
+ return getattr(self, _assertRaisesRegex)(*args, **kwargs)
672
+
673
+
674
+ def assertRegex(self, *args, **kwargs):
675
+ return getattr(self, _assertRegex)(*args, **kwargs)
676
+
677
+
678
+ if PY3:
679
+ exec_ = getattr(moves.builtins, "exec")
680
+
681
+ def reraise(tp, value, tb=None):
682
+ if value is None:
683
+ value = tp()
684
+ if value.__traceback__ is not tb:
685
+ raise value.with_traceback(tb)
686
+ raise value
687
+
688
+ else:
689
+ def exec_(_code_, _globs_=None, _locs_=None):
690
+ """Execute code in a namespace."""
691
+ if _globs_ is None:
692
+ frame = sys._getframe(1)
693
+ _globs_ = frame.f_globals
694
+ if _locs_ is None:
695
+ _locs_ = frame.f_locals
696
+ del frame
697
+ elif _locs_ is None:
698
+ _locs_ = _globs_
699
+ exec("""exec _code_ in _globs_, _locs_""")
700
+
701
+ exec_("""def reraise(tp, value, tb=None):
702
+ raise tp, value, tb
703
+ """)
704
+
705
+
706
+ if sys.version_info[:2] == (3, 2):
707
+ exec_("""def raise_from(value, from_value):
708
+ if from_value is None:
709
+ raise value
710
+ raise value from from_value
711
+ """)
712
+ elif sys.version_info[:2] > (3, 2):
713
+ exec_("""def raise_from(value, from_value):
714
+ raise value from from_value
715
+ """)
716
+ else:
717
+ def raise_from(value, from_value):
718
+ raise value
719
+
720
+
721
+ print_ = getattr(moves.builtins, "print", None)
722
+ if print_ is None:
723
+ def print_(*args, **kwargs):
724
+ """The new-style print function for Python 2.4 and 2.5."""
725
+ fp = kwargs.pop("file", sys.stdout)
726
+ if fp is None:
727
+ return
728
+
729
+ def write(data):
730
+ if not isinstance(data, basestring):
731
+ data = str(data)
732
+ # If the file has an encoding, encode unicode with it.
733
+ if (isinstance(fp, file) and
734
+ isinstance(data, unicode) and
735
+ fp.encoding is not None):
736
+ errors = getattr(fp, "errors", None)
737
+ if errors is None:
738
+ errors = "strict"
739
+ data = data.encode(fp.encoding, errors)
740
+ fp.write(data)
741
+ want_unicode = False
742
+ sep = kwargs.pop("sep", None)
743
+ if sep is not None:
744
+ if isinstance(sep, unicode):
745
+ want_unicode = True
746
+ elif not isinstance(sep, str):
747
+ raise TypeError("sep must be None or a string")
748
+ end = kwargs.pop("end", None)
749
+ if end is not None:
750
+ if isinstance(end, unicode):
751
+ want_unicode = True
752
+ elif not isinstance(end, str):
753
+ raise TypeError("end must be None or a string")
754
+ if kwargs:
755
+ raise TypeError("invalid keyword arguments to print()")
756
+ if not want_unicode:
757
+ for arg in args:
758
+ if isinstance(arg, unicode):
759
+ want_unicode = True
760
+ break
761
+ if want_unicode:
762
+ newline = unicode("\n")
763
+ space = unicode(" ")
764
+ else:
765
+ newline = "\n"
766
+ space = " "
767
+ if sep is None:
768
+ sep = space
769
+ if end is None:
770
+ end = newline
771
+ for i, arg in enumerate(args):
772
+ if i:
773
+ write(sep)
774
+ write(arg)
775
+ write(end)
776
+ if sys.version_info[:2] < (3, 3):
777
+ _print = print_
778
+
779
+ def print_(*args, **kwargs):
780
+ fp = kwargs.get("file", sys.stdout)
781
+ flush = kwargs.pop("flush", False)
782
+ _print(*args, **kwargs)
783
+ if flush and fp is not None:
784
+ fp.flush()
785
+
786
+ _add_doc(reraise, """Reraise an exception.""")
787
+
788
+ if sys.version_info[0:2] < (3, 4):
789
+ def wraps(wrapped, assigned=functools.WRAPPER_ASSIGNMENTS,
790
+ updated=functools.WRAPPER_UPDATES):
791
+ def wrapper(f):
792
+ f = functools.wraps(wrapped, assigned, updated)(f)
793
+ f.__wrapped__ = wrapped
794
+ return f
795
+ return wrapper
796
+ else:
797
+ wraps = functools.wraps
798
+
799
+
800
+ def with_metaclass(meta, *bases):
801
+ """Create a base class with a metaclass."""
802
+ # This requires a bit of explanation: the basic idea is to make a dummy
803
+ # metaclass for one level of class instantiation that replaces itself with
804
+ # the actual metaclass.
805
+ class metaclass(meta):
806
+
807
+ def __new__(cls, name, this_bases, d):
808
+ return meta(name, bases, d)
809
+ return type.__new__(metaclass, 'temporary_class', (), {})
810
+
811
+
812
+ def add_metaclass(metaclass):
813
+ """Class decorator for creating a class with a metaclass."""
814
+ def wrapper(cls):
815
+ orig_vars = cls.__dict__.copy()
816
+ slots = orig_vars.get('__slots__')
817
+ if slots is not None:
818
+ if isinstance(slots, str):
819
+ slots = [slots]
820
+ for slots_var in slots:
821
+ orig_vars.pop(slots_var)
822
+ orig_vars.pop('__dict__', None)
823
+ orig_vars.pop('__weakref__', None)
824
+ return metaclass(cls.__name__, cls.__bases__, orig_vars)
825
+ return wrapper
826
+
827
+
828
+ def python_2_unicode_compatible(klass):
829
+ """
830
+ A decorator that defines __unicode__ and __str__ methods under Python 2.
831
+ Under Python 3 it does nothing.
832
+
833
+ To support Python 2 and 3 with a single code base, define a __str__ method
834
+ returning text and apply this decorator to the class.
835
+ """
836
+ if PY2:
837
+ if '__str__' not in klass.__dict__:
838
+ raise ValueError("@python_2_unicode_compatible cannot be applied "
839
+ "to %s because it doesn't define __str__()." %
840
+ klass.__name__)
841
+ klass.__unicode__ = klass.__str__
842
+ klass.__str__ = lambda self: self.__unicode__().encode('utf-8')
843
+ return klass
844
+
845
+
846
+ # Complete the moves implementation.
847
+ # This code is at the end of this module to speed up module loading.
848
+ # Turn this module into a package.
849
+ __path__ = [] # required for PEP 302 and PEP 451
850
+ __package__ = __name__ # see PEP 366 @ReservedAssignment
851
+ if globals().get("__spec__") is not None:
852
+ __spec__.submodule_search_locations = [] # PEP 451 @UndefinedVariable
853
+ # Remove other six meta path importers, since they cause problems. This can
854
+ # happen if six is removed from sys.modules and then reloaded. (Setuptools does
855
+ # this for some reason.)
856
+ if sys.meta_path:
857
+ for i, importer in enumerate(sys.meta_path):
858
+ # Here's some real nastiness: Another "instance" of the six module might
859
+ # be floating around. Therefore, we can't use isinstance() to check for
860
+ # the six meta path importer, since the other six instance will have
861
+ # inserted an importer with different class.
862
+ if (type(importer).__name__ == "_SixMetaPathImporter" and
863
+ importer.name == __name__):
864
+ del sys.meta_path[i]
865
+ break
866
+ del i, importer
867
+ # Finally, add the importer to the meta path import hook.
868
+ sys.meta_path.append(_importer)
benchmark/NYU_CTF_Bench/test/2019/CSAW-Quals/crypto/brillouin/lib/python2.7/site-packages/urllib3/util/connection.py ADDED
@@ -0,0 +1,134 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from __future__ import absolute_import
2
+ import socket
3
+ from .wait import NoWayToWaitForSocketError, wait_for_read
4
+ from ..contrib import _appengine_environ
5
+
6
+
7
+ def is_connection_dropped(conn): # Platform-specific
8
+ """
9
+ Returns True if the connection is dropped and should be closed.
10
+
11
+ :param conn:
12
+ :class:`httplib.HTTPConnection` object.
13
+
14
+ Note: For platforms like AppEngine, this will always return ``False`` to
15
+ let the platform handle connection recycling transparently for us.
16
+ """
17
+ sock = getattr(conn, 'sock', False)
18
+ if sock is False: # Platform-specific: AppEngine
19
+ return False
20
+ if sock is None: # Connection already closed (such as by httplib).
21
+ return True
22
+ try:
23
+ # Returns True if readable, which here means it's been dropped
24
+ return wait_for_read(sock, timeout=0.0)
25
+ except NoWayToWaitForSocketError: # Platform-specific: AppEngine
26
+ return False
27
+
28
+
29
+ # This function is copied from socket.py in the Python 2.7 standard
30
+ # library test suite. Added to its signature is only `socket_options`.
31
+ # One additional modification is that we avoid binding to IPv6 servers
32
+ # discovered in DNS if the system doesn't have IPv6 functionality.
33
+ def create_connection(address, timeout=socket._GLOBAL_DEFAULT_TIMEOUT,
34
+ source_address=None, socket_options=None):
35
+ """Connect to *address* and return the socket object.
36
+
37
+ Convenience function. Connect to *address* (a 2-tuple ``(host,
38
+ port)``) and return the socket object. Passing the optional
39
+ *timeout* parameter will set the timeout on the socket instance
40
+ before attempting to connect. If no *timeout* is supplied, the
41
+ global default timeout setting returned by :func:`getdefaulttimeout`
42
+ is used. If *source_address* is set it must be a tuple of (host, port)
43
+ for the socket to bind as a source address before making the connection.
44
+ An host of '' or port 0 tells the OS to use the default.
45
+ """
46
+
47
+ host, port = address
48
+ if host.startswith('['):
49
+ host = host.strip('[]')
50
+ err = None
51
+
52
+ # Using the value from allowed_gai_family() in the context of getaddrinfo lets
53
+ # us select whether to work with IPv4 DNS records, IPv6 records, or both.
54
+ # The original create_connection function always returns all records.
55
+ family = allowed_gai_family()
56
+
57
+ for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM):
58
+ af, socktype, proto, canonname, sa = res
59
+ sock = None
60
+ try:
61
+ sock = socket.socket(af, socktype, proto)
62
+
63
+ # If provided, set socket level options before connecting.
64
+ _set_socket_options(sock, socket_options)
65
+
66
+ if timeout is not socket._GLOBAL_DEFAULT_TIMEOUT:
67
+ sock.settimeout(timeout)
68
+ if source_address:
69
+ sock.bind(source_address)
70
+ sock.connect(sa)
71
+ return sock
72
+
73
+ except socket.error as e:
74
+ err = e
75
+ if sock is not None:
76
+ sock.close()
77
+ sock = None
78
+
79
+ if err is not None:
80
+ raise err
81
+
82
+ raise socket.error("getaddrinfo returns an empty list")
83
+
84
+
85
+ def _set_socket_options(sock, options):
86
+ if options is None:
87
+ return
88
+
89
+ for opt in options:
90
+ sock.setsockopt(*opt)
91
+
92
+
93
+ def allowed_gai_family():
94
+ """This function is designed to work in the context of
95
+ getaddrinfo, where family=socket.AF_UNSPEC is the default and
96
+ will perform a DNS search for both IPv6 and IPv4 records."""
97
+
98
+ family = socket.AF_INET
99
+ if HAS_IPV6:
100
+ family = socket.AF_UNSPEC
101
+ return family
102
+
103
+
104
+ def _has_ipv6(host):
105
+ """ Returns True if the system can bind an IPv6 address. """
106
+ sock = None
107
+ has_ipv6 = False
108
+
109
+ # App Engine doesn't support IPV6 sockets and actually has a quota on the
110
+ # number of sockets that can be used, so just early out here instead of
111
+ # creating a socket needlessly.
112
+ # See https://github.com/urllib3/urllib3/issues/1446
113
+ if _appengine_environ.is_appengine_sandbox():
114
+ return False
115
+
116
+ if socket.has_ipv6:
117
+ # has_ipv6 returns true if cPython was compiled with IPv6 support.
118
+ # It does not tell us if the system has IPv6 support enabled. To
119
+ # determine that we must bind to an IPv6 address.
120
+ # https://github.com/shazow/urllib3/pull/611
121
+ # https://bugs.python.org/issue658327
122
+ try:
123
+ sock = socket.socket(socket.AF_INET6)
124
+ sock.bind((host, 0))
125
+ has_ipv6 = True
126
+ except Exception:
127
+ pass
128
+
129
+ if sock:
130
+ sock.close()
131
+ return has_ipv6
132
+
133
+
134
+ HAS_IPV6 = _has_ipv6('::1')
benchmark/NYU_CTF_Bench/test/2019/CSAW-Quals/crypto/brillouin/lib/python2.7/site-packages/urllib3/util/queue.py ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import collections
2
+ from ..packages import six
3
+ from ..packages.six.moves import queue
4
+
5
+ if six.PY2:
6
+ # Queue is imported for side effects on MS Windows. See issue #229.
7
+ import Queue as _unused_module_Queue # noqa: F401
8
+
9
+
10
+ class LifoQueue(queue.Queue):
11
+ def _init(self, _):
12
+ self.queue = collections.deque()
13
+
14
+ def _qsize(self, len=len):
15
+ return len(self.queue)
16
+
17
+ def _put(self, item):
18
+ self.queue.append(item)
19
+
20
+ def _get(self):
21
+ return self.queue.pop()
benchmark/NYU_CTF_Bench/test/2019/CSAW-Quals/crypto/brillouin/lib/python2.7/site-packages/urllib3/util/request.py ADDED
@@ -0,0 +1,125 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from __future__ import absolute_import
2
+ from base64 import b64encode
3
+
4
+ from ..packages.six import b, integer_types
5
+ from ..exceptions import UnrewindableBodyError
6
+
7
+ ACCEPT_ENCODING = 'gzip,deflate'
8
+ try:
9
+ import brotli as _unused_module_brotli # noqa: F401
10
+ except ImportError:
11
+ pass
12
+ else:
13
+ ACCEPT_ENCODING += ',br'
14
+
15
+ _FAILEDTELL = object()
16
+
17
+
18
+ def make_headers(keep_alive=None, accept_encoding=None, user_agent=None,
19
+ basic_auth=None, proxy_basic_auth=None, disable_cache=None):
20
+ """
21
+ Shortcuts for generating request headers.
22
+
23
+ :param keep_alive:
24
+ If ``True``, adds 'connection: keep-alive' header.
25
+
26
+ :param accept_encoding:
27
+ Can be a boolean, list, or string.
28
+ ``True`` translates to 'gzip,deflate'.
29
+ List will get joined by comma.
30
+ String will be used as provided.
31
+
32
+ :param user_agent:
33
+ String representing the user-agent you want, such as
34
+ "python-urllib3/0.6"
35
+
36
+ :param basic_auth:
37
+ Colon-separated username:password string for 'authorization: basic ...'
38
+ auth header.
39
+
40
+ :param proxy_basic_auth:
41
+ Colon-separated username:password string for 'proxy-authorization: basic ...'
42
+ auth header.
43
+
44
+ :param disable_cache:
45
+ If ``True``, adds 'cache-control: no-cache' header.
46
+
47
+ Example::
48
+
49
+ >>> make_headers(keep_alive=True, user_agent="Batman/1.0")
50
+ {'connection': 'keep-alive', 'user-agent': 'Batman/1.0'}
51
+ >>> make_headers(accept_encoding=True)
52
+ {'accept-encoding': 'gzip,deflate'}
53
+ """
54
+ headers = {}
55
+ if accept_encoding:
56
+ if isinstance(accept_encoding, str):
57
+ pass
58
+ elif isinstance(accept_encoding, list):
59
+ accept_encoding = ','.join(accept_encoding)
60
+ else:
61
+ accept_encoding = ACCEPT_ENCODING
62
+ headers['accept-encoding'] = accept_encoding
63
+
64
+ if user_agent:
65
+ headers['user-agent'] = user_agent
66
+
67
+ if keep_alive:
68
+ headers['connection'] = 'keep-alive'
69
+
70
+ if basic_auth:
71
+ headers['authorization'] = 'Basic ' + \
72
+ b64encode(b(basic_auth)).decode('utf-8')
73
+
74
+ if proxy_basic_auth:
75
+ headers['proxy-authorization'] = 'Basic ' + \
76
+ b64encode(b(proxy_basic_auth)).decode('utf-8')
77
+
78
+ if disable_cache:
79
+ headers['cache-control'] = 'no-cache'
80
+
81
+ return headers
82
+
83
+
84
+ def set_file_position(body, pos):
85
+ """
86
+ If a position is provided, move file to that point.
87
+ Otherwise, we'll attempt to record a position for future use.
88
+ """
89
+ if pos is not None:
90
+ rewind_body(body, pos)
91
+ elif getattr(body, 'tell', None) is not None:
92
+ try:
93
+ pos = body.tell()
94
+ except (IOError, OSError):
95
+ # This differentiates from None, allowing us to catch
96
+ # a failed `tell()` later when trying to rewind the body.
97
+ pos = _FAILEDTELL
98
+
99
+ return pos
100
+
101
+
102
+ def rewind_body(body, body_pos):
103
+ """
104
+ Attempt to rewind body to a certain position.
105
+ Primarily used for request redirects and retries.
106
+
107
+ :param body:
108
+ File-like object that supports seek.
109
+
110
+ :param int pos:
111
+ Position to seek to in file.
112
+ """
113
+ body_seek = getattr(body, 'seek', None)
114
+ if body_seek is not None and isinstance(body_pos, integer_types):
115
+ try:
116
+ body_seek(body_pos)
117
+ except (IOError, OSError):
118
+ raise UnrewindableBodyError("An error occurred when rewinding request "
119
+ "body for redirect/retry.")
120
+ elif body_pos is _FAILEDTELL:
121
+ raise UnrewindableBodyError("Unable to record file position for rewinding "
122
+ "request body during a redirect/retry.")
123
+ else:
124
+ raise ValueError("body_pos must be of type integer, "
125
+ "instead it was %s." % type(body_pos))
benchmark/NYU_CTF_Bench/test/2019/CSAW-Quals/crypto/brillouin/lib/python2.7/site-packages/urllib3/util/response.py ADDED
@@ -0,0 +1,87 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from __future__ import absolute_import
2
+ from ..packages.six.moves import http_client as httplib
3
+
4
+ from ..exceptions import HeaderParsingError
5
+
6
+
7
+ def is_fp_closed(obj):
8
+ """
9
+ Checks whether a given file-like object is closed.
10
+
11
+ :param obj:
12
+ The file-like object to check.
13
+ """
14
+
15
+ try:
16
+ # Check `isclosed()` first, in case Python3 doesn't set `closed`.
17
+ # GH Issue #928
18
+ return obj.isclosed()
19
+ except AttributeError:
20
+ pass
21
+
22
+ try:
23
+ # Check via the official file-like-object way.
24
+ return obj.closed
25
+ except AttributeError:
26
+ pass
27
+
28
+ try:
29
+ # Check if the object is a container for another file-like object that
30
+ # gets released on exhaustion (e.g. HTTPResponse).
31
+ return obj.fp is None
32
+ except AttributeError:
33
+ pass
34
+
35
+ raise ValueError("Unable to determine whether fp is closed.")
36
+
37
+
38
+ def assert_header_parsing(headers):
39
+ """
40
+ Asserts whether all headers have been successfully parsed.
41
+ Extracts encountered errors from the result of parsing headers.
42
+
43
+ Only works on Python 3.
44
+
45
+ :param headers: Headers to verify.
46
+ :type headers: `httplib.HTTPMessage`.
47
+
48
+ :raises urllib3.exceptions.HeaderParsingError:
49
+ If parsing errors are found.
50
+ """
51
+
52
+ # This will fail silently if we pass in the wrong kind of parameter.
53
+ # To make debugging easier add an explicit check.
54
+ if not isinstance(headers, httplib.HTTPMessage):
55
+ raise TypeError('expected httplib.Message, got {0}.'.format(
56
+ type(headers)))
57
+
58
+ defects = getattr(headers, 'defects', None)
59
+ get_payload = getattr(headers, 'get_payload', None)
60
+
61
+ unparsed_data = None
62
+ if get_payload:
63
+ # get_payload is actually email.message.Message.get_payload;
64
+ # we're only interested in the result if it's not a multipart message
65
+ if not headers.is_multipart():
66
+ payload = get_payload()
67
+
68
+ if isinstance(payload, (bytes, str)):
69
+ unparsed_data = payload
70
+
71
+ if defects or unparsed_data:
72
+ raise HeaderParsingError(defects=defects, unparsed_data=unparsed_data)
73
+
74
+
75
+ def is_response_to_head(response):
76
+ """
77
+ Checks whether the request of a response has been a HEAD-request.
78
+ Handles the quirks of AppEngine.
79
+
80
+ :param conn:
81
+ :type conn: :class:`httplib.HTTPResponse`
82
+ """
83
+ # FIXME: Can we do this somehow without accessing private httplib _method?
84
+ method = response._method
85
+ if isinstance(method, int): # Platform-specific: Appengine
86
+ return method == 3
87
+ return method.upper() == 'HEAD'
benchmark/NYU_CTF_Bench/test/2019/CSAW-Quals/crypto/brillouin/lib/python2.7/site-packages/urllib3/util/retry.py ADDED
@@ -0,0 +1,412 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from __future__ import absolute_import
2
+ import time
3
+ import logging
4
+ from collections import namedtuple
5
+ from itertools import takewhile
6
+ import email
7
+ import re
8
+
9
+ from ..exceptions import (
10
+ ConnectTimeoutError,
11
+ MaxRetryError,
12
+ ProtocolError,
13
+ ReadTimeoutError,
14
+ ResponseError,
15
+ InvalidHeader,
16
+ )
17
+ from ..packages import six
18
+
19
+
20
+ log = logging.getLogger(__name__)
21
+
22
+
23
+ # Data structure for representing the metadata of requests that result in a retry.
24
+ RequestHistory = namedtuple('RequestHistory', ["method", "url", "error",
25
+ "status", "redirect_location"])
26
+
27
+
28
+ class Retry(object):
29
+ """ Retry configuration.
30
+
31
+ Each retry attempt will create a new Retry object with updated values, so
32
+ they can be safely reused.
33
+
34
+ Retries can be defined as a default for a pool::
35
+
36
+ retries = Retry(connect=5, read=2, redirect=5)
37
+ http = PoolManager(retries=retries)
38
+ response = http.request('GET', 'http://example.com/')
39
+
40
+ Or per-request (which overrides the default for the pool)::
41
+
42
+ response = http.request('GET', 'http://example.com/', retries=Retry(10))
43
+
44
+ Retries can be disabled by passing ``False``::
45
+
46
+ response = http.request('GET', 'http://example.com/', retries=False)
47
+
48
+ Errors will be wrapped in :class:`~urllib3.exceptions.MaxRetryError` unless
49
+ retries are disabled, in which case the causing exception will be raised.
50
+
51
+ :param int total:
52
+ Total number of retries to allow. Takes precedence over other counts.
53
+
54
+ Set to ``None`` to remove this constraint and fall back on other
55
+ counts. It's a good idea to set this to some sensibly-high value to
56
+ account for unexpected edge cases and avoid infinite retry loops.
57
+
58
+ Set to ``0`` to fail on the first retry.
59
+
60
+ Set to ``False`` to disable and imply ``raise_on_redirect=False``.
61
+
62
+ :param int connect:
63
+ How many connection-related errors to retry on.
64
+
65
+ These are errors raised before the request is sent to the remote server,
66
+ which we assume has not triggered the server to process the request.
67
+
68
+ Set to ``0`` to fail on the first retry of this type.
69
+
70
+ :param int read:
71
+ How many times to retry on read errors.
72
+
73
+ These errors are raised after the request was sent to the server, so the
74
+ request may have side-effects.
75
+
76
+ Set to ``0`` to fail on the first retry of this type.
77
+
78
+ :param int redirect:
79
+ How many redirects to perform. Limit this to avoid infinite redirect
80
+ loops.
81
+
82
+ A redirect is a HTTP response with a status code 301, 302, 303, 307 or
83
+ 308.
84
+
85
+ Set to ``0`` to fail on the first retry of this type.
86
+
87
+ Set to ``False`` to disable and imply ``raise_on_redirect=False``.
88
+
89
+ :param int status:
90
+ How many times to retry on bad status codes.
91
+
92
+ These are retries made on responses, where status code matches
93
+ ``status_forcelist``.
94
+
95
+ Set to ``0`` to fail on the first retry of this type.
96
+
97
+ :param iterable method_whitelist:
98
+ Set of uppercased HTTP method verbs that we should retry on.
99
+
100
+ By default, we only retry on methods which are considered to be
101
+ idempotent (multiple requests with the same parameters end with the
102
+ same state). See :attr:`Retry.DEFAULT_METHOD_WHITELIST`.
103
+
104
+ Set to a ``False`` value to retry on any verb.
105
+
106
+ :param iterable status_forcelist:
107
+ A set of integer HTTP status codes that we should force a retry on.
108
+ A retry is initiated if the request method is in ``method_whitelist``
109
+ and the response status code is in ``status_forcelist``.
110
+
111
+ By default, this is disabled with ``None``.
112
+
113
+ :param float backoff_factor:
114
+ A backoff factor to apply between attempts after the second try
115
+ (most errors are resolved immediately by a second try without a
116
+ delay). urllib3 will sleep for::
117
+
118
+ {backoff factor} * (2 ** ({number of total retries} - 1))
119
+
120
+ seconds. If the backoff_factor is 0.1, then :func:`.sleep` will sleep
121
+ for [0.0s, 0.2s, 0.4s, ...] between retries. It will never be longer
122
+ than :attr:`Retry.BACKOFF_MAX`.
123
+
124
+ By default, backoff is disabled (set to 0).
125
+
126
+ :param bool raise_on_redirect: Whether, if the number of redirects is
127
+ exhausted, to raise a MaxRetryError, or to return a response with a
128
+ response code in the 3xx range.
129
+
130
+ :param bool raise_on_status: Similar meaning to ``raise_on_redirect``:
131
+ whether we should raise an exception, or return a response,
132
+ if status falls in ``status_forcelist`` range and retries have
133
+ been exhausted.
134
+
135
+ :param tuple history: The history of the request encountered during
136
+ each call to :meth:`~Retry.increment`. The list is in the order
137
+ the requests occurred. Each list item is of class :class:`RequestHistory`.
138
+
139
+ :param bool respect_retry_after_header:
140
+ Whether to respect Retry-After header on status codes defined as
141
+ :attr:`Retry.RETRY_AFTER_STATUS_CODES` or not.
142
+
143
+ :param iterable remove_headers_on_redirect:
144
+ Sequence of headers to remove from the request when a response
145
+ indicating a redirect is returned before firing off the redirected
146
+ request.
147
+ """
148
+
149
+ DEFAULT_METHOD_WHITELIST = frozenset([
150
+ 'HEAD', 'GET', 'PUT', 'DELETE', 'OPTIONS', 'TRACE'])
151
+
152
+ RETRY_AFTER_STATUS_CODES = frozenset([413, 429, 503])
153
+
154
+ DEFAULT_REDIRECT_HEADERS_BLACKLIST = frozenset(['Authorization'])
155
+
156
+ #: Maximum backoff time.
157
+ BACKOFF_MAX = 120
158
+
159
+ def __init__(self, total=10, connect=None, read=None, redirect=None, status=None,
160
+ method_whitelist=DEFAULT_METHOD_WHITELIST, status_forcelist=None,
161
+ backoff_factor=0, raise_on_redirect=True, raise_on_status=True,
162
+ history=None, respect_retry_after_header=True,
163
+ remove_headers_on_redirect=DEFAULT_REDIRECT_HEADERS_BLACKLIST):
164
+
165
+ self.total = total
166
+ self.connect = connect
167
+ self.read = read
168
+ self.status = status
169
+
170
+ if redirect is False or total is False:
171
+ redirect = 0
172
+ raise_on_redirect = False
173
+
174
+ self.redirect = redirect
175
+ self.status_forcelist = status_forcelist or set()
176
+ self.method_whitelist = method_whitelist
177
+ self.backoff_factor = backoff_factor
178
+ self.raise_on_redirect = raise_on_redirect
179
+ self.raise_on_status = raise_on_status
180
+ self.history = history or tuple()
181
+ self.respect_retry_after_header = respect_retry_after_header
182
+ self.remove_headers_on_redirect = frozenset([
183
+ h.lower() for h in remove_headers_on_redirect])
184
+
185
+ def new(self, **kw):
186
+ params = dict(
187
+ total=self.total,
188
+ connect=self.connect, read=self.read, redirect=self.redirect, status=self.status,
189
+ method_whitelist=self.method_whitelist,
190
+ status_forcelist=self.status_forcelist,
191
+ backoff_factor=self.backoff_factor,
192
+ raise_on_redirect=self.raise_on_redirect,
193
+ raise_on_status=self.raise_on_status,
194
+ history=self.history,
195
+ remove_headers_on_redirect=self.remove_headers_on_redirect
196
+ )
197
+ params.update(kw)
198
+ return type(self)(**params)
199
+
200
+ @classmethod
201
+ def from_int(cls, retries, redirect=True, default=None):
202
+ """ Backwards-compatibility for the old retries format."""
203
+ if retries is None:
204
+ retries = default if default is not None else cls.DEFAULT
205
+
206
+ if isinstance(retries, Retry):
207
+ return retries
208
+
209
+ redirect = bool(redirect) and None
210
+ new_retries = cls(retries, redirect=redirect)
211
+ log.debug("Converted retries value: %r -> %r", retries, new_retries)
212
+ return new_retries
213
+
214
+ def get_backoff_time(self):
215
+ """ Formula for computing the current backoff
216
+
217
+ :rtype: float
218
+ """
219
+ # We want to consider only the last consecutive errors sequence (Ignore redirects).
220
+ consecutive_errors_len = len(list(takewhile(lambda x: x.redirect_location is None,
221
+ reversed(self.history))))
222
+ if consecutive_errors_len <= 1:
223
+ return 0
224
+
225
+ backoff_value = self.backoff_factor * (2 ** (consecutive_errors_len - 1))
226
+ return min(self.BACKOFF_MAX, backoff_value)
227
+
228
+ def parse_retry_after(self, retry_after):
229
+ # Whitespace: https://tools.ietf.org/html/rfc7230#section-3.2.4
230
+ if re.match(r"^\s*[0-9]+\s*$", retry_after):
231
+ seconds = int(retry_after)
232
+ else:
233
+ retry_date_tuple = email.utils.parsedate(retry_after)
234
+ if retry_date_tuple is None:
235
+ raise InvalidHeader("Invalid Retry-After header: %s" % retry_after)
236
+ retry_date = time.mktime(retry_date_tuple)
237
+ seconds = retry_date - time.time()
238
+
239
+ if seconds < 0:
240
+ seconds = 0
241
+
242
+ return seconds
243
+
244
+ def get_retry_after(self, response):
245
+ """ Get the value of Retry-After in seconds. """
246
+
247
+ retry_after = response.getheader("Retry-After")
248
+
249
+ if retry_after is None:
250
+ return None
251
+
252
+ return self.parse_retry_after(retry_after)
253
+
254
+ def sleep_for_retry(self, response=None):
255
+ retry_after = self.get_retry_after(response)
256
+ if retry_after:
257
+ time.sleep(retry_after)
258
+ return True
259
+
260
+ return False
261
+
262
+ def _sleep_backoff(self):
263
+ backoff = self.get_backoff_time()
264
+ if backoff <= 0:
265
+ return
266
+ time.sleep(backoff)
267
+
268
+ def sleep(self, response=None):
269
+ """ Sleep between retry attempts.
270
+
271
+ This method will respect a server's ``Retry-After`` response header
272
+ and sleep the duration of the time requested. If that is not present, it
273
+ will use an exponential backoff. By default, the backoff factor is 0 and
274
+ this method will return immediately.
275
+ """
276
+
277
+ if response:
278
+ slept = self.sleep_for_retry(response)
279
+ if slept:
280
+ return
281
+
282
+ self._sleep_backoff()
283
+
284
+ def _is_connection_error(self, err):
285
+ """ Errors when we're fairly sure that the server did not receive the
286
+ request, so it should be safe to retry.
287
+ """
288
+ return isinstance(err, ConnectTimeoutError)
289
+
290
+ def _is_read_error(self, err):
291
+ """ Errors that occur after the request has been started, so we should
292
+ assume that the server began processing it.
293
+ """
294
+ return isinstance(err, (ReadTimeoutError, ProtocolError))
295
+
296
+ def _is_method_retryable(self, method):
297
+ """ Checks if a given HTTP method should be retried upon, depending if
298
+ it is included on the method whitelist.
299
+ """
300
+ if self.method_whitelist and method.upper() not in self.method_whitelist:
301
+ return False
302
+
303
+ return True
304
+
305
+ def is_retry(self, method, status_code, has_retry_after=False):
306
+ """ Is this method/status code retryable? (Based on whitelists and control
307
+ variables such as the number of total retries to allow, whether to
308
+ respect the Retry-After header, whether this header is present, and
309
+ whether the returned status code is on the list of status codes to
310
+ be retried upon on the presence of the aforementioned header)
311
+ """
312
+ if not self._is_method_retryable(method):
313
+ return False
314
+
315
+ if self.status_forcelist and status_code in self.status_forcelist:
316
+ return True
317
+
318
+ return (self.total and self.respect_retry_after_header and
319
+ has_retry_after and (status_code in self.RETRY_AFTER_STATUS_CODES))
320
+
321
+ def is_exhausted(self):
322
+ """ Are we out of retries? """
323
+ retry_counts = (self.total, self.connect, self.read, self.redirect, self.status)
324
+ retry_counts = list(filter(None, retry_counts))
325
+ if not retry_counts:
326
+ return False
327
+
328
+ return min(retry_counts) < 0
329
+
330
+ def increment(self, method=None, url=None, response=None, error=None,
331
+ _pool=None, _stacktrace=None):
332
+ """ Return a new Retry object with incremented retry counters.
333
+
334
+ :param response: A response object, or None, if the server did not
335
+ return a response.
336
+ :type response: :class:`~urllib3.response.HTTPResponse`
337
+ :param Exception error: An error encountered during the request, or
338
+ None if the response was received successfully.
339
+
340
+ :return: A new ``Retry`` object.
341
+ """
342
+ if self.total is False and error:
343
+ # Disabled, indicate to re-raise the error.
344
+ raise six.reraise(type(error), error, _stacktrace)
345
+
346
+ total = self.total
347
+ if total is not None:
348
+ total -= 1
349
+
350
+ connect = self.connect
351
+ read = self.read
352
+ redirect = self.redirect
353
+ status_count = self.status
354
+ cause = 'unknown'
355
+ status = None
356
+ redirect_location = None
357
+
358
+ if error and self._is_connection_error(error):
359
+ # Connect retry?
360
+ if connect is False:
361
+ raise six.reraise(type(error), error, _stacktrace)
362
+ elif connect is not None:
363
+ connect -= 1
364
+
365
+ elif error and self._is_read_error(error):
366
+ # Read retry?
367
+ if read is False or not self._is_method_retryable(method):
368
+ raise six.reraise(type(error), error, _stacktrace)
369
+ elif read is not None:
370
+ read -= 1
371
+
372
+ elif response and response.get_redirect_location():
373
+ # Redirect retry?
374
+ if redirect is not None:
375
+ redirect -= 1
376
+ cause = 'too many redirects'
377
+ redirect_location = response.get_redirect_location()
378
+ status = response.status
379
+
380
+ else:
381
+ # Incrementing because of a server error like a 500 in
382
+ # status_forcelist and a the given method is in the whitelist
383
+ cause = ResponseError.GENERIC_ERROR
384
+ if response and response.status:
385
+ if status_count is not None:
386
+ status_count -= 1
387
+ cause = ResponseError.SPECIFIC_ERROR.format(
388
+ status_code=response.status)
389
+ status = response.status
390
+
391
+ history = self.history + (RequestHistory(method, url, error, status, redirect_location),)
392
+
393
+ new_retry = self.new(
394
+ total=total,
395
+ connect=connect, read=read, redirect=redirect, status=status_count,
396
+ history=history)
397
+
398
+ if new_retry.is_exhausted():
399
+ raise MaxRetryError(_pool, url, error or ResponseError(cause))
400
+
401
+ log.debug("Incremented Retry for (url='%s'): %r", url, new_retry)
402
+
403
+ return new_retry
404
+
405
+ def __repr__(self):
406
+ return ('{cls.__name__}(total={self.total}, connect={self.connect}, '
407
+ 'read={self.read}, redirect={self.redirect}, status={self.status})').format(
408
+ cls=type(self), self=self)
409
+
410
+
411
+ # For backwards compatibility (equivalent to pre-v1.9):
412
+ Retry.DEFAULT = Retry(3)
benchmark/NYU_CTF_Bench/test/2019/CSAW-Quals/crypto/brillouin/lib/python2.7/site-packages/urllib3/util/ssl_.py ADDED
@@ -0,0 +1,392 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from __future__ import absolute_import
2
+ import errno
3
+ import warnings
4
+ import hmac
5
+ import re
6
+
7
+ from binascii import hexlify, unhexlify
8
+ from hashlib import md5, sha1, sha256
9
+
10
+ from ..exceptions import SSLError, InsecurePlatformWarning, SNIMissingWarning
11
+ from ..packages import six
12
+ from ..packages.rfc3986 import abnf_regexp
13
+
14
+
15
+ SSLContext = None
16
+ HAS_SNI = False
17
+ IS_PYOPENSSL = False
18
+ IS_SECURETRANSPORT = False
19
+
20
+ # Maps the length of a digest to a possible hash function producing this digest
21
+ HASHFUNC_MAP = {
22
+ 32: md5,
23
+ 40: sha1,
24
+ 64: sha256,
25
+ }
26
+
27
+
28
+ def _const_compare_digest_backport(a, b):
29
+ """
30
+ Compare two digests of equal length in constant time.
31
+
32
+ The digests must be of type str/bytes.
33
+ Returns True if the digests match, and False otherwise.
34
+ """
35
+ result = abs(len(a) - len(b))
36
+ for l, r in zip(bytearray(a), bytearray(b)):
37
+ result |= l ^ r
38
+ return result == 0
39
+
40
+
41
+ _const_compare_digest = getattr(hmac, 'compare_digest',
42
+ _const_compare_digest_backport)
43
+
44
+ # Borrow rfc3986's regular expressions for IPv4
45
+ # and IPv6 addresses for use in is_ipaddress()
46
+ _IP_ADDRESS_REGEX = re.compile(
47
+ r'^(?:%s|%s|%s)$' % (
48
+ abnf_regexp.IPv4_RE,
49
+ abnf_regexp.IPv6_RE,
50
+ abnf_regexp.IPv6_ADDRZ_RFC4007_RE
51
+ )
52
+ )
53
+
54
+ try: # Test for SSL features
55
+ import ssl
56
+ from ssl import wrap_socket, CERT_REQUIRED
57
+ from ssl import HAS_SNI # Has SNI?
58
+ except ImportError:
59
+ pass
60
+
61
+ try: # Platform-specific: Python 3.6
62
+ from ssl import PROTOCOL_TLS
63
+ PROTOCOL_SSLv23 = PROTOCOL_TLS
64
+ except ImportError:
65
+ try:
66
+ from ssl import PROTOCOL_SSLv23 as PROTOCOL_TLS
67
+ PROTOCOL_SSLv23 = PROTOCOL_TLS
68
+ except ImportError:
69
+ PROTOCOL_SSLv23 = PROTOCOL_TLS = 2
70
+
71
+
72
+ try:
73
+ from ssl import OP_NO_SSLv2, OP_NO_SSLv3, OP_NO_COMPRESSION
74
+ except ImportError:
75
+ OP_NO_SSLv2, OP_NO_SSLv3 = 0x1000000, 0x2000000
76
+ OP_NO_COMPRESSION = 0x20000
77
+
78
+
79
+ # A secure default.
80
+ # Sources for more information on TLS ciphers:
81
+ #
82
+ # - https://wiki.mozilla.org/Security/Server_Side_TLS
83
+ # - https://www.ssllabs.com/projects/best-practices/index.html
84
+ # - https://hynek.me/articles/hardening-your-web-servers-ssl-ciphers/
85
+ #
86
+ # The general intent is:
87
+ # - prefer cipher suites that offer perfect forward secrecy (DHE/ECDHE),
88
+ # - prefer ECDHE over DHE for better performance,
89
+ # - prefer any AES-GCM and ChaCha20 over any AES-CBC for better performance and
90
+ # security,
91
+ # - prefer AES-GCM over ChaCha20 because hardware-accelerated AES is common,
92
+ # - disable NULL authentication, MD5 MACs, DSS, and other
93
+ # insecure ciphers for security reasons.
94
+ # - NOTE: TLS 1.3 cipher suites are managed through a different interface
95
+ # not exposed by CPython (yet!) and are enabled by default if they're available.
96
+ DEFAULT_CIPHERS = ':'.join([
97
+ 'ECDHE+AESGCM',
98
+ 'ECDHE+CHACHA20',
99
+ 'DHE+AESGCM',
100
+ 'DHE+CHACHA20',
101
+ 'ECDH+AESGCM',
102
+ 'DH+AESGCM',
103
+ 'ECDH+AES',
104
+ 'DH+AES',
105
+ 'RSA+AESGCM',
106
+ 'RSA+AES',
107
+ '!aNULL',
108
+ '!eNULL',
109
+ '!MD5',
110
+ '!DSS',
111
+ ])
112
+
113
+ try:
114
+ from ssl import SSLContext # Modern SSL?
115
+ except ImportError:
116
+ class SSLContext(object): # Platform-specific: Python 2
117
+ def __init__(self, protocol_version):
118
+ self.protocol = protocol_version
119
+ # Use default values from a real SSLContext
120
+ self.check_hostname = False
121
+ self.verify_mode = ssl.CERT_NONE
122
+ self.ca_certs = None
123
+ self.options = 0
124
+ self.certfile = None
125
+ self.keyfile = None
126
+ self.ciphers = None
127
+
128
+ def load_cert_chain(self, certfile, keyfile):
129
+ self.certfile = certfile
130
+ self.keyfile = keyfile
131
+
132
+ def load_verify_locations(self, cafile=None, capath=None):
133
+ self.ca_certs = cafile
134
+
135
+ if capath is not None:
136
+ raise SSLError("CA directories not supported in older Pythons")
137
+
138
+ def set_ciphers(self, cipher_suite):
139
+ self.ciphers = cipher_suite
140
+
141
+ def wrap_socket(self, socket, server_hostname=None, server_side=False):
142
+ warnings.warn(
143
+ 'A true SSLContext object is not available. This prevents '
144
+ 'urllib3 from configuring SSL appropriately and may cause '
145
+ 'certain SSL connections to fail. You can upgrade to a newer '
146
+ 'version of Python to solve this. For more information, see '
147
+ 'https://urllib3.readthedocs.io/en/latest/advanced-usage.html'
148
+ '#ssl-warnings',
149
+ InsecurePlatformWarning
150
+ )
151
+ kwargs = {
152
+ 'keyfile': self.keyfile,
153
+ 'certfile': self.certfile,
154
+ 'ca_certs': self.ca_certs,
155
+ 'cert_reqs': self.verify_mode,
156
+ 'ssl_version': self.protocol,
157
+ 'server_side': server_side,
158
+ }
159
+ return wrap_socket(socket, ciphers=self.ciphers, **kwargs)
160
+
161
+
162
+ def assert_fingerprint(cert, fingerprint):
163
+ """
164
+ Checks if given fingerprint matches the supplied certificate.
165
+
166
+ :param cert:
167
+ Certificate as bytes object.
168
+ :param fingerprint:
169
+ Fingerprint as string of hexdigits, can be interspersed by colons.
170
+ """
171
+
172
+ fingerprint = fingerprint.replace(':', '').lower()
173
+ digest_length = len(fingerprint)
174
+ hashfunc = HASHFUNC_MAP.get(digest_length)
175
+ if not hashfunc:
176
+ raise SSLError(
177
+ 'Fingerprint of invalid length: {0}'.format(fingerprint))
178
+
179
+ # We need encode() here for py32; works on py2 and p33.
180
+ fingerprint_bytes = unhexlify(fingerprint.encode())
181
+
182
+ cert_digest = hashfunc(cert).digest()
183
+
184
+ if not _const_compare_digest(cert_digest, fingerprint_bytes):
185
+ raise SSLError('Fingerprints did not match. Expected "{0}", got "{1}".'
186
+ .format(fingerprint, hexlify(cert_digest)))
187
+
188
+
189
+ def resolve_cert_reqs(candidate):
190
+ """
191
+ Resolves the argument to a numeric constant, which can be passed to
192
+ the wrap_socket function/method from the ssl module.
193
+ Defaults to :data:`ssl.CERT_NONE`.
194
+ If given a string it is assumed to be the name of the constant in the
195
+ :mod:`ssl` module or its abbreviation.
196
+ (So you can specify `REQUIRED` instead of `CERT_REQUIRED`.
197
+ If it's neither `None` nor a string we assume it is already the numeric
198
+ constant which can directly be passed to wrap_socket.
199
+ """
200
+ if candidate is None:
201
+ return CERT_REQUIRED
202
+
203
+ if isinstance(candidate, str):
204
+ res = getattr(ssl, candidate, None)
205
+ if res is None:
206
+ res = getattr(ssl, 'CERT_' + candidate)
207
+ return res
208
+
209
+ return candidate
210
+
211
+
212
+ def resolve_ssl_version(candidate):
213
+ """
214
+ like resolve_cert_reqs
215
+ """
216
+ if candidate is None:
217
+ return PROTOCOL_TLS
218
+
219
+ if isinstance(candidate, str):
220
+ res = getattr(ssl, candidate, None)
221
+ if res is None:
222
+ res = getattr(ssl, 'PROTOCOL_' + candidate)
223
+ return res
224
+
225
+ return candidate
226
+
227
+
228
+ def create_urllib3_context(ssl_version=None, cert_reqs=None,
229
+ options=None, ciphers=None):
230
+ """All arguments have the same meaning as ``ssl_wrap_socket``.
231
+
232
+ By default, this function does a lot of the same work that
233
+ ``ssl.create_default_context`` does on Python 3.4+. It:
234
+
235
+ - Disables SSLv2, SSLv3, and compression
236
+ - Sets a restricted set of server ciphers
237
+
238
+ If you wish to enable SSLv3, you can do::
239
+
240
+ from urllib3.util import ssl_
241
+ context = ssl_.create_urllib3_context()
242
+ context.options &= ~ssl_.OP_NO_SSLv3
243
+
244
+ You can do the same to enable compression (substituting ``COMPRESSION``
245
+ for ``SSLv3`` in the last line above).
246
+
247
+ :param ssl_version:
248
+ The desired protocol version to use. This will default to
249
+ PROTOCOL_SSLv23 which will negotiate the highest protocol that both
250
+ the server and your installation of OpenSSL support.
251
+ :param cert_reqs:
252
+ Whether to require the certificate verification. This defaults to
253
+ ``ssl.CERT_REQUIRED``.
254
+ :param options:
255
+ Specific OpenSSL options. These default to ``ssl.OP_NO_SSLv2``,
256
+ ``ssl.OP_NO_SSLv3``, ``ssl.OP_NO_COMPRESSION``.
257
+ :param ciphers:
258
+ Which cipher suites to allow the server to select.
259
+ :returns:
260
+ Constructed SSLContext object with specified options
261
+ :rtype: SSLContext
262
+ """
263
+ context = SSLContext(ssl_version or PROTOCOL_TLS)
264
+
265
+ context.set_ciphers(ciphers or DEFAULT_CIPHERS)
266
+
267
+ # Setting the default here, as we may have no ssl module on import
268
+ cert_reqs = ssl.CERT_REQUIRED if cert_reqs is None else cert_reqs
269
+
270
+ if options is None:
271
+ options = 0
272
+ # SSLv2 is easily broken and is considered harmful and dangerous
273
+ options |= OP_NO_SSLv2
274
+ # SSLv3 has several problems and is now dangerous
275
+ options |= OP_NO_SSLv3
276
+ # Disable compression to prevent CRIME attacks for OpenSSL 1.0+
277
+ # (issue #309)
278
+ options |= OP_NO_COMPRESSION
279
+
280
+ context.options |= options
281
+
282
+ context.verify_mode = cert_reqs
283
+ if getattr(context, 'check_hostname', None) is not None: # Platform-specific: Python 3.2
284
+ # We do our own verification, including fingerprints and alternative
285
+ # hostnames. So disable it here
286
+ context.check_hostname = False
287
+ return context
288
+
289
+
290
+ def ssl_wrap_socket(sock, keyfile=None, certfile=None, cert_reqs=None,
291
+ ca_certs=None, server_hostname=None,
292
+ ssl_version=None, ciphers=None, ssl_context=None,
293
+ ca_cert_dir=None, key_password=None):
294
+ """
295
+ All arguments except for server_hostname, ssl_context, and ca_cert_dir have
296
+ the same meaning as they do when using :func:`ssl.wrap_socket`.
297
+
298
+ :param server_hostname:
299
+ When SNI is supported, the expected hostname of the certificate
300
+ :param ssl_context:
301
+ A pre-made :class:`SSLContext` object. If none is provided, one will
302
+ be created using :func:`create_urllib3_context`.
303
+ :param ciphers:
304
+ A string of ciphers we wish the client to support.
305
+ :param ca_cert_dir:
306
+ A directory containing CA certificates in multiple separate files, as
307
+ supported by OpenSSL's -CApath flag or the capath argument to
308
+ SSLContext.load_verify_locations().
309
+ :param key_password:
310
+ Optional password if the keyfile is encrypted.
311
+ """
312
+ context = ssl_context
313
+ if context is None:
314
+ # Note: This branch of code and all the variables in it are no longer
315
+ # used by urllib3 itself. We should consider deprecating and removing
316
+ # this code.
317
+ context = create_urllib3_context(ssl_version, cert_reqs,
318
+ ciphers=ciphers)
319
+
320
+ if ca_certs or ca_cert_dir:
321
+ try:
322
+ context.load_verify_locations(ca_certs, ca_cert_dir)
323
+ except IOError as e: # Platform-specific: Python 2.7
324
+ raise SSLError(e)
325
+ # Py33 raises FileNotFoundError which subclasses OSError
326
+ # These are not equivalent unless we check the errno attribute
327
+ except OSError as e: # Platform-specific: Python 3.3 and beyond
328
+ if e.errno == errno.ENOENT:
329
+ raise SSLError(e)
330
+ raise
331
+
332
+ elif ssl_context is None and hasattr(context, 'load_default_certs'):
333
+ # try to load OS default certs; works well on Windows (require Python3.4+)
334
+ context.load_default_certs()
335
+
336
+ # Attempt to detect if we get the goofy behavior of the
337
+ # keyfile being encrypted and OpenSSL asking for the
338
+ # passphrase via the terminal and instead error out.
339
+ if keyfile and key_password is None and _is_key_file_encrypted(keyfile):
340
+ raise SSLError("Client private key is encrypted, password is required")
341
+
342
+ if certfile:
343
+ if key_password is None:
344
+ context.load_cert_chain(certfile, keyfile)
345
+ else:
346
+ context.load_cert_chain(certfile, keyfile, key_password)
347
+
348
+ # If we detect server_hostname is an IP address then the SNI
349
+ # extension should not be used according to RFC3546 Section 3.1
350
+ # We shouldn't warn the user if SNI isn't available but we would
351
+ # not be using SNI anyways due to IP address for server_hostname.
352
+ if ((server_hostname is not None and not is_ipaddress(server_hostname))
353
+ or IS_SECURETRANSPORT):
354
+ if HAS_SNI and server_hostname is not None:
355
+ return context.wrap_socket(sock, server_hostname=server_hostname)
356
+
357
+ warnings.warn(
358
+ 'An HTTPS request has been made, but the SNI (Server Name '
359
+ 'Indication) extension to TLS is not available on this platform. '
360
+ 'This may cause the server to present an incorrect TLS '
361
+ 'certificate, which can cause validation failures. You can upgrade to '
362
+ 'a newer version of Python to solve this. For more information, see '
363
+ 'https://urllib3.readthedocs.io/en/latest/advanced-usage.html'
364
+ '#ssl-warnings',
365
+ SNIMissingWarning
366
+ )
367
+
368
+ return context.wrap_socket(sock)
369
+
370
+
371
+ def is_ipaddress(hostname):
372
+ """Detects whether the hostname given is an IPv4 or IPv6 address.
373
+ Also detects IPv6 addresses with Zone IDs.
374
+
375
+ :param str hostname: Hostname to examine.
376
+ :return: True if the hostname is an IP address, False otherwise.
377
+ """
378
+ if six.PY3 and isinstance(hostname, bytes):
379
+ # IDN A-label bytes are ASCII compatible.
380
+ hostname = hostname.decode('ascii')
381
+ return _IP_ADDRESS_REGEX.match(hostname) is not None
382
+
383
+
384
+ def _is_key_file_encrypted(key_file):
385
+ """Detects if a key file is encrypted or not."""
386
+ with open(key_file, 'r') as f:
387
+ for line in f:
388
+ # Look for Proc-Type: 4,ENCRYPTED
389
+ if 'ENCRYPTED' in line:
390
+ return True
391
+
392
+ return False
benchmark/NYU_CTF_Bench/test/2019/CSAW-Quals/crypto/brillouin/lib/python2.7/site-packages/urllib3/util/timeout.py ADDED
@@ -0,0 +1,243 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from __future__ import absolute_import
2
+ # The default socket timeout, used by httplib to indicate that no timeout was
3
+ # specified by the user
4
+ from socket import _GLOBAL_DEFAULT_TIMEOUT
5
+ import time
6
+
7
+ from ..exceptions import TimeoutStateError
8
+
9
+ # A sentinel value to indicate that no timeout was specified by the user in
10
+ # urllib3
11
+ _Default = object()
12
+
13
+
14
+ # Use time.monotonic if available.
15
+ current_time = getattr(time, "monotonic", time.time)
16
+
17
+
18
+ class Timeout(object):
19
+ """ Timeout configuration.
20
+
21
+ Timeouts can be defined as a default for a pool::
22
+
23
+ timeout = Timeout(connect=2.0, read=7.0)
24
+ http = PoolManager(timeout=timeout)
25
+ response = http.request('GET', 'http://example.com/')
26
+
27
+ Or per-request (which overrides the default for the pool)::
28
+
29
+ response = http.request('GET', 'http://example.com/', timeout=Timeout(10))
30
+
31
+ Timeouts can be disabled by setting all the parameters to ``None``::
32
+
33
+ no_timeout = Timeout(connect=None, read=None)
34
+ response = http.request('GET', 'http://example.com/, timeout=no_timeout)
35
+
36
+
37
+ :param total:
38
+ This combines the connect and read timeouts into one; the read timeout
39
+ will be set to the time leftover from the connect attempt. In the
40
+ event that both a connect timeout and a total are specified, or a read
41
+ timeout and a total are specified, the shorter timeout will be applied.
42
+
43
+ Defaults to None.
44
+
45
+ :type total: integer, float, or None
46
+
47
+ :param connect:
48
+ The maximum amount of time to wait for a connection attempt to a server
49
+ to succeed. Omitting the parameter will default the connect timeout to
50
+ the system default, probably `the global default timeout in socket.py
51
+ <http://hg.python.org/cpython/file/603b4d593758/Lib/socket.py#l535>`_.
52
+ None will set an infinite timeout for connection attempts.
53
+
54
+ :type connect: integer, float, or None
55
+
56
+ :param read:
57
+ The maximum amount of time to wait between consecutive
58
+ read operations for a response from the server. Omitting
59
+ the parameter will default the read timeout to the system
60
+ default, probably `the global default timeout in socket.py
61
+ <http://hg.python.org/cpython/file/603b4d593758/Lib/socket.py#l535>`_.
62
+ None will set an infinite timeout.
63
+
64
+ :type read: integer, float, or None
65
+
66
+ .. note::
67
+
68
+ Many factors can affect the total amount of time for urllib3 to return
69
+ an HTTP response.
70
+
71
+ For example, Python's DNS resolver does not obey the timeout specified
72
+ on the socket. Other factors that can affect total request time include
73
+ high CPU load, high swap, the program running at a low priority level,
74
+ or other behaviors.
75
+
76
+ In addition, the read and total timeouts only measure the time between
77
+ read operations on the socket connecting the client and the server,
78
+ not the total amount of time for the request to return a complete
79
+ response. For most requests, the timeout is raised because the server
80
+ has not sent the first byte in the specified time. This is not always
81
+ the case; if a server streams one byte every fifteen seconds, a timeout
82
+ of 20 seconds will not trigger, even though the request will take
83
+ several minutes to complete.
84
+
85
+ If your goal is to cut off any request after a set amount of wall clock
86
+ time, consider having a second "watcher" thread to cut off a slow
87
+ request.
88
+ """
89
+
90
+ #: A sentinel object representing the default timeout value
91
+ DEFAULT_TIMEOUT = _GLOBAL_DEFAULT_TIMEOUT
92
+
93
+ def __init__(self, total=None, connect=_Default, read=_Default):
94
+ self._connect = self._validate_timeout(connect, 'connect')
95
+ self._read = self._validate_timeout(read, 'read')
96
+ self.total = self._validate_timeout(total, 'total')
97
+ self._start_connect = None
98
+
99
+ def __str__(self):
100
+ return '%s(connect=%r, read=%r, total=%r)' % (
101
+ type(self).__name__, self._connect, self._read, self.total)
102
+
103
+ @classmethod
104
+ def _validate_timeout(cls, value, name):
105
+ """ Check that a timeout attribute is valid.
106
+
107
+ :param value: The timeout value to validate
108
+ :param name: The name of the timeout attribute to validate. This is
109
+ used to specify in error messages.
110
+ :return: The validated and casted version of the given value.
111
+ :raises ValueError: If it is a numeric value less than or equal to
112
+ zero, or the type is not an integer, float, or None.
113
+ """
114
+ if value is _Default:
115
+ return cls.DEFAULT_TIMEOUT
116
+
117
+ if value is None or value is cls.DEFAULT_TIMEOUT:
118
+ return value
119
+
120
+ if isinstance(value, bool):
121
+ raise ValueError("Timeout cannot be a boolean value. It must "
122
+ "be an int, float or None.")
123
+ try:
124
+ float(value)
125
+ except (TypeError, ValueError):
126
+ raise ValueError("Timeout value %s was %s, but it must be an "
127
+ "int, float or None." % (name, value))
128
+
129
+ try:
130
+ if value <= 0:
131
+ raise ValueError("Attempted to set %s timeout to %s, but the "
132
+ "timeout cannot be set to a value less "
133
+ "than or equal to 0." % (name, value))
134
+ except TypeError:
135
+ # Python 3
136
+ raise ValueError("Timeout value %s was %s, but it must be an "
137
+ "int, float or None." % (name, value))
138
+
139
+ return value
140
+
141
+ @classmethod
142
+ def from_float(cls, timeout):
143
+ """ Create a new Timeout from a legacy timeout value.
144
+
145
+ The timeout value used by httplib.py sets the same timeout on the
146
+ connect(), and recv() socket requests. This creates a :class:`Timeout`
147
+ object that sets the individual timeouts to the ``timeout`` value
148
+ passed to this function.
149
+
150
+ :param timeout: The legacy timeout value.
151
+ :type timeout: integer, float, sentinel default object, or None
152
+ :return: Timeout object
153
+ :rtype: :class:`Timeout`
154
+ """
155
+ return Timeout(read=timeout, connect=timeout)
156
+
157
+ def clone(self):
158
+ """ Create a copy of the timeout object
159
+
160
+ Timeout properties are stored per-pool but each request needs a fresh
161
+ Timeout object to ensure each one has its own start/stop configured.
162
+
163
+ :return: a copy of the timeout object
164
+ :rtype: :class:`Timeout`
165
+ """
166
+ # We can't use copy.deepcopy because that will also create a new object
167
+ # for _GLOBAL_DEFAULT_TIMEOUT, which socket.py uses as a sentinel to
168
+ # detect the user default.
169
+ return Timeout(connect=self._connect, read=self._read,
170
+ total=self.total)
171
+
172
+ def start_connect(self):
173
+ """ Start the timeout clock, used during a connect() attempt
174
+
175
+ :raises urllib3.exceptions.TimeoutStateError: if you attempt
176
+ to start a timer that has been started already.
177
+ """
178
+ if self._start_connect is not None:
179
+ raise TimeoutStateError("Timeout timer has already been started.")
180
+ self._start_connect = current_time()
181
+ return self._start_connect
182
+
183
+ def get_connect_duration(self):
184
+ """ Gets the time elapsed since the call to :meth:`start_connect`.
185
+
186
+ :return: Elapsed time.
187
+ :rtype: float
188
+ :raises urllib3.exceptions.TimeoutStateError: if you attempt
189
+ to get duration for a timer that hasn't been started.
190
+ """
191
+ if self._start_connect is None:
192
+ raise TimeoutStateError("Can't get connect duration for timer "
193
+ "that has not started.")
194
+ return current_time() - self._start_connect
195
+
196
+ @property
197
+ def connect_timeout(self):
198
+ """ Get the value to use when setting a connection timeout.
199
+
200
+ This will be a positive float or integer, the value None
201
+ (never timeout), or the default system timeout.
202
+
203
+ :return: Connect timeout.
204
+ :rtype: int, float, :attr:`Timeout.DEFAULT_TIMEOUT` or None
205
+ """
206
+ if self.total is None:
207
+ return self._connect
208
+
209
+ if self._connect is None or self._connect is self.DEFAULT_TIMEOUT:
210
+ return self.total
211
+
212
+ return min(self._connect, self.total)
213
+
214
+ @property
215
+ def read_timeout(self):
216
+ """ Get the value for the read timeout.
217
+
218
+ This assumes some time has elapsed in the connection timeout and
219
+ computes the read timeout appropriately.
220
+
221
+ If self.total is set, the read timeout is dependent on the amount of
222
+ time taken by the connect timeout. If the connection time has not been
223
+ established, a :exc:`~urllib3.exceptions.TimeoutStateError` will be
224
+ raised.
225
+
226
+ :return: Value to use for the read timeout.
227
+ :rtype: int, float, :attr:`Timeout.DEFAULT_TIMEOUT` or None
228
+ :raises urllib3.exceptions.TimeoutStateError: If :meth:`start_connect`
229
+ has not yet been called on this object.
230
+ """
231
+ if (self.total is not None and
232
+ self.total is not self.DEFAULT_TIMEOUT and
233
+ self._read is not None and
234
+ self._read is not self.DEFAULT_TIMEOUT):
235
+ # In case the connect timeout has not yet been established.
236
+ if self._start_connect is None:
237
+ return self._read
238
+ return max(0, min(self.total - self.get_connect_duration(),
239
+ self._read))
240
+ elif self.total is not None and self.total is not self.DEFAULT_TIMEOUT:
241
+ return max(0, self.total - self.get_connect_duration())
242
+ else:
243
+ return self._read