mirror of
https://github.com/sqlmapproject/sqlmap.git
synced 2025-06-12 09:03:12 +03:00
Python3 is a game-changer and I won't loose my mind
This commit is contained in:
parent
41c3139c01
commit
e56c422a8c
|
@ -17,7 +17,7 @@ from lib.core.enums import DBMS_DIRECTORY_NAME
|
||||||
from lib.core.enums import OS
|
from lib.core.enums import OS
|
||||||
|
|
||||||
# sqlmap version (<major>.<minor>.<month>.<monthly commit>)
|
# sqlmap version (<major>.<minor>.<month>.<monthly commit>)
|
||||||
VERSION = "1.3.3.65"
|
VERSION = "1.3.3.66"
|
||||||
TYPE = "dev" if VERSION.count('.') > 2 and VERSION.split('.')[-1] != '0' else "stable"
|
TYPE = "dev" if VERSION.count('.') > 2 and VERSION.split('.')[-1] != '0' else "stable"
|
||||||
TYPE_COLORS = {"dev": 33, "stable": 90, "pip": 34}
|
TYPE_COLORS = {"dev": 33, "stable": 90, "pip": 34}
|
||||||
VERSION_STRING = "sqlmap/%s#%s" % ('.'.join(VERSION.split('.')[:-1]) if VERSION.count('.') > 2 and VERSION.split('.')[-1] == '0' else VERSION, TYPE)
|
VERSION_STRING = "sqlmap/%s#%s" % ('.'.join(VERSION.split('.')[:-1]) if VERSION.count('.') > 2 and VERSION.split('.')[-1] == '0' else VERSION, TYPE)
|
||||||
|
|
|
@ -68,6 +68,7 @@ try:
|
||||||
from lib.core.settings import UNICODE_ENCODING
|
from lib.core.settings import UNICODE_ENCODING
|
||||||
from lib.core.settings import VERSION
|
from lib.core.settings import VERSION
|
||||||
from lib.parse.cmdline import cmdLineParser
|
from lib.parse.cmdline import cmdLineParser
|
||||||
|
from thirdparty.six import PY2
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
errMsg = "user aborted"
|
errMsg = "user aborted"
|
||||||
|
|
||||||
|
@ -161,7 +162,7 @@ def main():
|
||||||
liveTest()
|
liveTest()
|
||||||
else:
|
else:
|
||||||
from lib.controller.controller import start
|
from lib.controller.controller import start
|
||||||
if conf.profile:
|
if conf.profile and PY2:
|
||||||
from lib.core.profiling import profile
|
from lib.core.profiling import profile
|
||||||
globals()["start"] = start
|
globals()["start"] = start
|
||||||
profile()
|
profile()
|
||||||
|
|
8
thirdparty/clientform/clientform.py
vendored
8
thirdparty/clientform/clientform.py
vendored
|
@ -94,13 +94,13 @@ else:
|
||||||
_logger.addHandler(handler)
|
_logger.addHandler(handler)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from six.moves import cStringIO as _cStringIO
|
|
||||||
from six.moves import urllib as _html_entities
|
|
||||||
from six.moves import urllib as _urllib
|
|
||||||
except ImportError:
|
|
||||||
from thirdparty.six.moves import cStringIO as _cStringIO
|
from thirdparty.six.moves import cStringIO as _cStringIO
|
||||||
from thirdparty.six.moves import http_client as _html_entities
|
from thirdparty.six.moves import http_client as _html_entities
|
||||||
from thirdparty.six.moves import urllib as _urllib
|
from thirdparty.six.moves import urllib as _urllib
|
||||||
|
except ImportError:
|
||||||
|
from six.moves import cStringIO as _cStringIO
|
||||||
|
from six.moves import urllib as _html_entities
|
||||||
|
from six.moves import urllib as _urllib
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import sgmllib
|
import sgmllib
|
||||||
|
|
77
thirdparty/keepalive/keepalive.py
vendored
77
thirdparty/keepalive/keepalive.py
vendored
|
@ -26,10 +26,10 @@
|
||||||
>>> import urllib2
|
>>> import urllib2
|
||||||
>>> from keepalive import HTTPHandler
|
>>> from keepalive import HTTPHandler
|
||||||
>>> keepalive_handler = HTTPHandler()
|
>>> keepalive_handler = HTTPHandler()
|
||||||
>>> opener = urllib2.build_opener(keepalive_handler)
|
>>> opener = _urllib.request.build_opener(keepalive_handler)
|
||||||
>>> urllib2.install_opener(opener)
|
>>> _urllib.request.install_opener(opener)
|
||||||
>>>
|
>>>
|
||||||
>>> fo = urllib2.urlopen('http://www.python.org')
|
>>> fo = _urllib.request.urlopen('http://www.python.org')
|
||||||
|
|
||||||
If a connection to a given host is requested, and all of the existing
|
If a connection to a given host is requested, and all of the existing
|
||||||
connections are still in use, another connection will be opened. If
|
connections are still in use, another connection will be opened. If
|
||||||
|
@ -105,8 +105,13 @@ EXTRA ATTRIBUTES AND METHODS
|
||||||
|
|
||||||
from __future__ import print_function
|
from __future__ import print_function
|
||||||
|
|
||||||
import urllib2
|
try:
|
||||||
import httplib
|
from thirdparty.six.moves import http_client as _http_client
|
||||||
|
from thirdparty.six.moves import urllib as _urllib
|
||||||
|
except ImportError:
|
||||||
|
from six.moves import http_client as _http_client
|
||||||
|
from six.moves import urllib as _urllib
|
||||||
|
|
||||||
import socket
|
import socket
|
||||||
import thread
|
import thread
|
||||||
|
|
||||||
|
@ -214,7 +219,7 @@ class KeepAliveHandler:
|
||||||
def do_open(self, req):
|
def do_open(self, req):
|
||||||
host = req.host
|
host = req.host
|
||||||
if not host:
|
if not host:
|
||||||
raise urllib2.URLError('no host given')
|
raise _urllib.error.URLError('no host given')
|
||||||
|
|
||||||
try:
|
try:
|
||||||
h = self._cm.get_ready_conn(host)
|
h = self._cm.get_ready_conn(host)
|
||||||
|
@ -238,8 +243,8 @@ class KeepAliveHandler:
|
||||||
self._cm.add(host, h, 0)
|
self._cm.add(host, h, 0)
|
||||||
self._start_transaction(h, req)
|
self._start_transaction(h, req)
|
||||||
r = h.getresponse()
|
r = h.getresponse()
|
||||||
except (socket.error, httplib.HTTPException) as err:
|
except (socket.error, _http_client.HTTPException) as err:
|
||||||
raise urllib2.URLError(err)
|
raise _urllib.error.URLError(err)
|
||||||
|
|
||||||
if DEBUG: DEBUG.info("STATUS: %s, %s", r.status, r.reason)
|
if DEBUG: DEBUG.info("STATUS: %s, %s", r.status, r.reason)
|
||||||
|
|
||||||
|
@ -274,7 +279,7 @@ class KeepAliveHandler:
|
||||||
r = h.getresponse()
|
r = h.getresponse()
|
||||||
# note: just because we got something back doesn't mean it
|
# note: just because we got something back doesn't mean it
|
||||||
# worked. We'll check the version below, too.
|
# worked. We'll check the version below, too.
|
||||||
except (socket.error, httplib.HTTPException):
|
except (socket.error, _http_client.HTTPException):
|
||||||
r = None
|
r = None
|
||||||
except:
|
except:
|
||||||
# adding this block just in case we've missed
|
# adding this block just in case we've missed
|
||||||
|
@ -323,8 +328,8 @@ class KeepAliveHandler:
|
||||||
h.putrequest(req.get_method() or 'GET', req.selector, skip_host=req.has_header("Host"), skip_accept_encoding=req.has_header("Accept-encoding"))
|
h.putrequest(req.get_method() or 'GET', req.selector, skip_host=req.has_header("Host"), skip_accept_encoding=req.has_header("Accept-encoding"))
|
||||||
else:
|
else:
|
||||||
h.putrequest(req.get_method() or 'GET', req.get_selector(), skip_host=req.has_header("Host"), skip_accept_encoding=req.has_header("Accept-encoding"))
|
h.putrequest(req.get_method() or 'GET', req.get_selector(), skip_host=req.has_header("Host"), skip_accept_encoding=req.has_header("Accept-encoding"))
|
||||||
except (socket.error, httplib.HTTPException) as err:
|
except (socket.error, _http_client.HTTPException) as err:
|
||||||
raise urllib2.URLError(err)
|
raise _urllib.error.URLError(err)
|
||||||
|
|
||||||
if not req.headers.has_key('Connection'):
|
if not req.headers.has_key('Connection'):
|
||||||
req.headers['Connection'] = 'keep-alive'
|
req.headers['Connection'] = 'keep-alive'
|
||||||
|
@ -341,7 +346,7 @@ class KeepAliveHandler:
|
||||||
def _get_connection(self, host):
|
def _get_connection(self, host):
|
||||||
return NotImplementedError
|
return NotImplementedError
|
||||||
|
|
||||||
class HTTPHandler(KeepAliveHandler, urllib2.HTTPHandler):
|
class HTTPHandler(KeepAliveHandler, _urllib.request.HTTPHandler):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
KeepAliveHandler.__init__(self)
|
KeepAliveHandler.__init__(self)
|
||||||
|
|
||||||
|
@ -351,7 +356,7 @@ class HTTPHandler(KeepAliveHandler, urllib2.HTTPHandler):
|
||||||
def _get_connection(self, host):
|
def _get_connection(self, host):
|
||||||
return HTTPConnection(host)
|
return HTTPConnection(host)
|
||||||
|
|
||||||
class HTTPSHandler(KeepAliveHandler, urllib2.HTTPSHandler):
|
class HTTPSHandler(KeepAliveHandler, _urllib.request.HTTPSHandler):
|
||||||
def __init__(self, ssl_factory=None):
|
def __init__(self, ssl_factory=None):
|
||||||
KeepAliveHandler.__init__(self)
|
KeepAliveHandler.__init__(self)
|
||||||
if not ssl_factory:
|
if not ssl_factory:
|
||||||
|
@ -369,7 +374,7 @@ class HTTPSHandler(KeepAliveHandler, urllib2.HTTPSHandler):
|
||||||
try: return self._ssl_factory.get_https_connection(host)
|
try: return self._ssl_factory.get_https_connection(host)
|
||||||
except AttributeError: return HTTPSConnection(host)
|
except AttributeError: return HTTPSConnection(host)
|
||||||
|
|
||||||
class HTTPResponse(httplib.HTTPResponse):
|
class HTTPResponse(_http_client.HTTPResponse):
|
||||||
# we need to subclass HTTPResponse in order to
|
# we need to subclass HTTPResponse in order to
|
||||||
# 1) add readline() and readlines() methods
|
# 1) add readline() and readlines() methods
|
||||||
# 2) add close_connection() methods
|
# 2) add close_connection() methods
|
||||||
|
@ -391,9 +396,9 @@ class HTTPResponse(httplib.HTTPResponse):
|
||||||
|
|
||||||
def __init__(self, sock, debuglevel=0, strict=0, method=None):
|
def __init__(self, sock, debuglevel=0, strict=0, method=None):
|
||||||
if method: # the httplib in python 2.3 uses the method arg
|
if method: # the httplib in python 2.3 uses the method arg
|
||||||
httplib.HTTPResponse.__init__(self, sock, debuglevel, method)
|
_http_client.HTTPResponse.__init__(self, sock, debuglevel, method)
|
||||||
else: # 2.2 doesn't
|
else: # 2.2 doesn't
|
||||||
httplib.HTTPResponse.__init__(self, sock, debuglevel)
|
_http_client.HTTPResponse.__init__(self, sock, debuglevel)
|
||||||
self.fileno = sock.fileno
|
self.fileno = sock.fileno
|
||||||
self.code = None
|
self.code = None
|
||||||
self._method = method
|
self._method = method
|
||||||
|
@ -404,7 +409,7 @@ class HTTPResponse(httplib.HTTPResponse):
|
||||||
self._url = None # (same)
|
self._url = None # (same)
|
||||||
self._connection = None # (same)
|
self._connection = None # (same)
|
||||||
|
|
||||||
_raw_read = httplib.HTTPResponse.read
|
_raw_read = _http_client.HTTPResponse.read
|
||||||
|
|
||||||
def close(self):
|
def close(self):
|
||||||
if self.fp:
|
if self.fp:
|
||||||
|
@ -468,11 +473,11 @@ class HTTPResponse(httplib.HTTPResponse):
|
||||||
return list
|
return list
|
||||||
|
|
||||||
|
|
||||||
class HTTPConnection(httplib.HTTPConnection):
|
class HTTPConnection(_http_client.HTTPConnection):
|
||||||
# use the modified response class
|
# use the modified response class
|
||||||
response_class = HTTPResponse
|
response_class = HTTPResponse
|
||||||
|
|
||||||
class HTTPSConnection(httplib.HTTPSConnection):
|
class HTTPSConnection(_http_client.HTTPSConnection):
|
||||||
response_class = HTTPResponse
|
response_class = HTTPResponse
|
||||||
|
|
||||||
#########################################################################
|
#########################################################################
|
||||||
|
@ -483,14 +488,14 @@ def error_handler(url):
|
||||||
global HANDLE_ERRORS
|
global HANDLE_ERRORS
|
||||||
orig = HANDLE_ERRORS
|
orig = HANDLE_ERRORS
|
||||||
keepalive_handler = HTTPHandler()
|
keepalive_handler = HTTPHandler()
|
||||||
opener = urllib2.build_opener(keepalive_handler)
|
opener = _urllib.request.build_opener(keepalive_handler)
|
||||||
urllib2.install_opener(opener)
|
_urllib.request.install_opener(opener)
|
||||||
pos = {0: 'off', 1: 'on'}
|
pos = {0: 'off', 1: 'on'}
|
||||||
for i in (0, 1):
|
for i in (0, 1):
|
||||||
print(" fancy error handling %s (HANDLE_ERRORS = %i)" % (pos[i], i))
|
print(" fancy error handling %s (HANDLE_ERRORS = %i)" % (pos[i], i))
|
||||||
HANDLE_ERRORS = i
|
HANDLE_ERRORS = i
|
||||||
try:
|
try:
|
||||||
fo = urllib2.urlopen(url)
|
fo = _urllib.request.urlopen(url)
|
||||||
foo = fo.read()
|
foo = fo.read()
|
||||||
fo.close()
|
fo.close()
|
||||||
try: status, reason = fo.status, fo.reason
|
try: status, reason = fo.status, fo.reason
|
||||||
|
@ -510,25 +515,25 @@ def continuity(url):
|
||||||
format = '%25s: %s'
|
format = '%25s: %s'
|
||||||
|
|
||||||
# first fetch the file with the normal http handler
|
# first fetch the file with the normal http handler
|
||||||
opener = urllib2.build_opener()
|
opener = _urllib.request.build_opener()
|
||||||
urllib2.install_opener(opener)
|
_urllib.request.install_opener(opener)
|
||||||
fo = urllib2.urlopen(url)
|
fo = _urllib.request.urlopen(url)
|
||||||
foo = fo.read()
|
foo = fo.read()
|
||||||
fo.close()
|
fo.close()
|
||||||
m = md5.new(foo)
|
m = md5.new(foo)
|
||||||
print(format % ('normal urllib', m.hexdigest()))
|
print(format % ('normal urllib', m.hexdigest()))
|
||||||
|
|
||||||
# now install the keepalive handler and try again
|
# now install the keepalive handler and try again
|
||||||
opener = urllib2.build_opener(HTTPHandler())
|
opener = _urllib.request.build_opener(HTTPHandler())
|
||||||
urllib2.install_opener(opener)
|
_urllib.request.install_opener(opener)
|
||||||
|
|
||||||
fo = urllib2.urlopen(url)
|
fo = _urllib.request.urlopen(url)
|
||||||
foo = fo.read()
|
foo = fo.read()
|
||||||
fo.close()
|
fo.close()
|
||||||
m = md5.new(foo)
|
m = md5.new(foo)
|
||||||
print(format % ('keepalive read', m.hexdigest()))
|
print(format % ('keepalive read', m.hexdigest()))
|
||||||
|
|
||||||
fo = urllib2.urlopen(url)
|
fo = _urllib.request.urlopen(url)
|
||||||
foo = ''
|
foo = ''
|
||||||
while 1:
|
while 1:
|
||||||
f = fo.readline()
|
f = fo.readline()
|
||||||
|
@ -543,15 +548,15 @@ def comp(N, url):
|
||||||
|
|
||||||
sys.stdout.write(' first using the normal urllib handlers')
|
sys.stdout.write(' first using the normal urllib handlers')
|
||||||
# first use normal opener
|
# first use normal opener
|
||||||
opener = urllib2.build_opener()
|
opener = _urllib.request.build_opener()
|
||||||
urllib2.install_opener(opener)
|
_urllib.request.install_opener(opener)
|
||||||
t1 = fetch(N, url)
|
t1 = fetch(N, url)
|
||||||
print(' TIME: %.3f s' % t1)
|
print(' TIME: %.3f s' % t1)
|
||||||
|
|
||||||
sys.stdout.write(' now using the keepalive handler ')
|
sys.stdout.write(' now using the keepalive handler ')
|
||||||
# now install the keepalive handler and try again
|
# now install the keepalive handler and try again
|
||||||
opener = urllib2.build_opener(HTTPHandler())
|
opener = _urllib.request.build_opener(HTTPHandler())
|
||||||
urllib2.install_opener(opener)
|
_urllib.request.install_opener(opener)
|
||||||
t2 = fetch(N, url)
|
t2 = fetch(N, url)
|
||||||
print(' TIME: %.3f s' % t2)
|
print(' TIME: %.3f s' % t2)
|
||||||
print(' improvement factor: %.2f' % (t1/t2, ))
|
print(' improvement factor: %.2f' % (t1/t2, ))
|
||||||
|
@ -562,7 +567,7 @@ def fetch(N, url, delay=0):
|
||||||
starttime = time.time()
|
starttime = time.time()
|
||||||
for i in range(N):
|
for i in range(N):
|
||||||
if delay and i > 0: time.sleep(delay)
|
if delay and i > 0: time.sleep(delay)
|
||||||
fo = urllib2.urlopen(url)
|
fo = _urllib.request.urlopen(url)
|
||||||
foo = fo.read()
|
foo = fo.read()
|
||||||
fo.close()
|
fo.close()
|
||||||
lens.append(len(foo))
|
lens.append(len(foo))
|
||||||
|
@ -584,7 +589,7 @@ def test_timeout(url):
|
||||||
info = warning = error = debug
|
info = warning = error = debug
|
||||||
DEBUG = FakeLogger()
|
DEBUG = FakeLogger()
|
||||||
print(" fetching the file to establish a connection")
|
print(" fetching the file to establish a connection")
|
||||||
fo = urllib2.urlopen(url)
|
fo = _urllib.request.urlopen(url)
|
||||||
data1 = fo.read()
|
data1 = fo.read()
|
||||||
fo.close()
|
fo.close()
|
||||||
|
|
||||||
|
@ -598,7 +603,7 @@ def test_timeout(url):
|
||||||
sys.stderr.write('\r')
|
sys.stderr.write('\r')
|
||||||
|
|
||||||
print(" fetching the file a second time")
|
print(" fetching the file a second time")
|
||||||
fo = urllib2.urlopen(url)
|
fo = _urllib.request.urlopen(url)
|
||||||
data2 = fo.read()
|
data2 = fo.read()
|
||||||
fo.close()
|
fo.close()
|
||||||
|
|
||||||
|
|
5
thirdparty/odict/ordereddict.py
vendored
5
thirdparty/odict/ordereddict.py
vendored
|
@ -20,7 +20,10 @@
|
||||||
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||||
# OTHER DEALINGS IN THE SOFTWARE.
|
# OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
from UserDict import DictMixin
|
try:
|
||||||
|
from UserDict import DictMixin
|
||||||
|
except ImportError:
|
||||||
|
from collections import MutableMapping as DictMixin
|
||||||
|
|
||||||
class OrderedDict(dict, DictMixin):
|
class OrderedDict(dict, DictMixin):
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user