Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c6557e2

Browse files
committed
Minor patches
1 parent fa17cfb commit c6557e2

6 files changed

Lines changed: 21 additions & 19 deletions

File tree

lib/core/settings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
from thirdparty.six import unichr as _unichr
1919

2020
# sqlmap version (<major>.<minor>.<month>.<monthly commit>)
21-
VERSION = "1.4.11.16"
21+
VERSION = "1.4.11.17"
2222
TYPE = "dev" if VERSION.count('.') > 2 and VERSION.split('.')[-1] != '0' else "stable"
2323
TYPE_COLORS = {"dev": 33, "stable": 90, "pip": 34}
2424
VERSION_STRING = "sqlmap/%s#%s" % ('.'.join(VERSION.split('.')[:-1]) if VERSION.count('.') > 2 and VERSION.split('.')[-1] == '0' else VERSION, TYPE)

lib/request/chunkedhandler.py

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"""
77

88
from lib.core.data import conf
9+
from lib.core.enums import HTTP_HEADER
910
from thirdparty.six.moves import urllib as _urllib
1011

1112
class ChunkedHandler(_urllib.request.HTTPHandler):
@@ -20,20 +21,17 @@ def _http_request(self, request):
2021

2122
if request.data is not None: # POST
2223
data = request.data
23-
if not request.has_header("Content-type"):
24-
request.add_unredirected_header(
25-
"Content-type",
26-
"application/x-www-form-urlencoded")
27-
if not request.has_header("Content-length") and not conf.chunked:
28-
request.add_unredirected_header(
29-
"Content-length", "%d" % len(data))
24+
if not request.has_header(HTTP_HEADER.CONTENT_TYPE):
25+
request.add_unredirected_header(HTTP_HEADER.CONTENT_TYPE, "application/x-www-form-urlencoded")
26+
if not request.has_header(HTTP_HEADER.CONTENT_LENGTH) and not conf.chunked:
27+
request.add_unredirected_header(HTTP_HEADER.CONTENT_LENGTH, "%d" % len(data))
3028

3129
sel_host = host
3230
if request.has_proxy():
3331
sel_host = _urllib.parse.urlsplit(request.get_selector()).netloc
3432

35-
if not request.has_header("Host"):
36-
request.add_unredirected_header("Host", sel_host)
33+
if not request.has_header(HTTP_HEADER.HOST):
34+
request.add_unredirected_header(HTTP_HEADER.HOST, sel_host)
3735
for name, value in self.parent.addheaders:
3836
name = name.capitalize()
3937
if not request.has_header(name):

lib/request/connect.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ def _connReadProxy(conn):
222222
try:
223223
part = conn.read(MAX_CONNECTION_READ_SIZE)
224224
except AssertionError:
225-
part = ""
225+
part = b""
226226

227227
if len(part) == MAX_CONNECTION_READ_SIZE:
228228
warnMsg = "large response detected. This could take a while"

lib/request/direct.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,9 @@ def direct(query, content=True):
4545
break
4646

4747
if select:
48-
if not query.upper().startswith("SELECT "):
48+
if re.search(r"(?i)\ASELECT ", query) is None:
4949
query = "SELECT %s" % query
50+
5051
if conf.binaryFields:
5152
for field in conf.binaryFields:
5253
field = field.strip()
@@ -58,7 +59,7 @@ def direct(query, content=True):
5859
output = hashDBRetrieve(query, True, True)
5960
start = time.time()
6061

61-
if not select and "EXEC " not in query.upper():
62+
if not select and re.search(r"(?i)\bEXEC ", query) is None:
6263
timeout(func=conf.dbmsConnector.execute, args=(query,), duration=conf.timeout, default=None)
6364
elif not (output and ("%soutput" % conf.tablePrefix) not in query and ("%sfile" % conf.tablePrefix) not in query):
6465
output, state = timeout(func=conf.dbmsConnector.select, args=(query,), duration=conf.timeout, default=None)

lib/request/dns.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,17 +76,20 @@ def __init__(self):
7676
self._check_localhost()
7777
self._requests = []
7878
self._lock = threading.Lock()
79+
7980
try:
8081
self._socket = socket._orig_socket(socket.AF_INET, socket.SOCK_DGRAM)
8182
except AttributeError:
8283
self._socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
84+
8385
self._socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
8486
self._socket.bind(("", 53))
8587
self._running = False
8688
self._initialized = False
8789

8890
def _check_localhost(self):
89-
response = ""
91+
response = b""
92+
9093
try:
9194
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
9295
s.connect(("", 53))
@@ -96,7 +99,7 @@ def _check_localhost(self):
9699
pass
97100
finally:
98101
if response and b"google" in response:
99-
raise socket.error("another DNS service already running on *:53")
102+
raise socket.error("another DNS service already running on '0.0.0.0:53'")
100103

101104
def pop(self, prefix=None, suffix=None):
102105
"""

lib/request/redirecthandler.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
from lib.core.common import getSafeExString
1414
from lib.core.common import logHTTPTraffic
1515
from lib.core.common import readInput
16+
from lib.core.convert import getBytes
1617
from lib.core.convert import getUnicode
1718
from lib.core.data import conf
1819
from lib.core.data import kb
@@ -64,8 +65,7 @@ def _ask_redirect_choice(self, redcode, redurl, method):
6465
self.redirect_request = self._redirect_request
6566

6667
def _redirect_request(self, req, fp, code, msg, headers, newurl):
67-
newurl = newurl.replace(' ', '%20')
68-
return _urllib.request.Request(newurl, data=req.data, headers=req.headers, origin_req_host=req.get_origin_req_host())
68+
return _urllib.request.Request(newurl.replace(' ', '%20'), data=req.data, headers=req.headers, origin_req_host=req.get_origin_req_host())
6969

7070
def http_error_302(self, req, fp, code, msg, headers):
7171
start = time.time()
@@ -75,7 +75,7 @@ def http_error_302(self, req, fp, code, msg, headers):
7575
try:
7676
content = fp.read(MAX_CONNECTION_TOTAL_SIZE)
7777
except: # e.g. IncompleteRead
78-
content = ""
78+
content = b""
7979
finally:
8080
if content:
8181
try: # try to write it back to the read buffer so we could reuse it in further steps
@@ -163,7 +163,7 @@ def _(self, length=None):
163163
retVal = getSafeExString(ex) # Note: pyflakes mistakenly marks 'ex' as undefined (NOTE: tested in both Python2 and Python3)
164164
except:
165165
retVal = ""
166-
return retVal
166+
return getBytes(retVal)
167167

168168
result.read = types.MethodType(_, result)
169169

0 commit comments

Comments
 (0)