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

Skip to content

Commit 468eed8

Browse files
committed
Fixes #3753
1 parent 5650abb commit 468eed8

3 files changed

Lines changed: 19 additions & 16 deletions

File tree

lib/core/settings.py

Lines changed: 4 additions & 4 deletions
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.3.6.38"
21+
VERSION = "1.3.6.39"
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)
@@ -678,8 +678,8 @@
678678
# Length of prefix and suffix used in non-SQLI heuristic checks
679679
NON_SQLI_CHECK_PREFIX_SUFFIX_LENGTH = 6
680680

681-
# Connection chunk size (processing large responses in chunks to avoid MemoryError crashes - e.g. large table dump in full UNION injections)
682-
MAX_CONNECTION_CHUNK_SIZE = 10 * 1024 * 1024
681+
# Connection read size (processing large responses in parts to avoid MemoryError crashes - e.g. large table dump in full UNION injections)
682+
MAX_CONNECTION_READ_SIZE = 10 * 1024 * 1024
683683

684684
# Maximum response total page size (trimmed if larger)
685685
MAX_CONNECTION_TOTAL_SIZE = 100 * 1024 * 1024
@@ -690,7 +690,7 @@
690690
# Maximum (multi-threaded) length of entry in bisection algorithm
691691
MAX_BISECTION_LENGTH = 50 * 1024 * 1024
692692

693-
# Mark used for trimming unnecessary content in large chunks
693+
# Mark used for trimming unnecessary content in large connection reads
694694
LARGE_CHUNK_TRIM_MARKER = "__TRIMMED_CONTENT__"
695695

696696
# Generic SQL comment formation

lib/request/connect.py

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ class WebSocketException(Exception):
9797
from lib.core.settings import IPS_WAF_CHECK_PAYLOAD
9898
from lib.core.settings import IS_WIN
9999
from lib.core.settings import LARGE_CHUNK_TRIM_MARKER
100-
from lib.core.settings import MAX_CONNECTION_CHUNK_SIZE
100+
from lib.core.settings import MAX_CONNECTION_READ_SIZE
101101
from lib.core.settings import MAX_CONNECTIONS_REGEX
102102
from lib.core.settings import MAX_CONNECTION_TOTAL_SIZE
103103
from lib.core.settings import MAX_CONSECUTIVE_CONNECTION_ERRORS
@@ -211,15 +211,18 @@ def _connReadProxy(conn):
211211
if not conn:
212212
break
213213
else:
214-
_ = conn.read(MAX_CONNECTION_CHUNK_SIZE)
214+
try:
215+
part = conn.read(MAX_CONNECTION_READ_SIZE)
216+
except AssertionError:
217+
part = ""
215218

216-
if len(_) == MAX_CONNECTION_CHUNK_SIZE:
219+
if len(part) == MAX_CONNECTION_READ_SIZE:
217220
warnMsg = "large response detected. This could take a while"
218221
singleTimeWarnMessage(warnMsg)
219-
_ = re.sub(r"(?si)%s.+?%s" % (kb.chars.stop, kb.chars.start), "%s%s%s" % (kb.chars.stop, LARGE_CHUNK_TRIM_MARKER, kb.chars.start), _)
220-
retVal += _
222+
part = re.sub(r"(?si)%s.+?%s" % (kb.chars.stop, kb.chars.start), "%s%s%s" % (kb.chars.stop, LARGE_CHUNK_TRIM_MARKER, kb.chars.start), part)
223+
retVal += part
221224
else:
222-
retVal += _
225+
retVal += part
223226
break
224227

225228
if len(retVal) > MAX_CONNECTION_TOTAL_SIZE:
@@ -631,14 +634,14 @@ class _(dict):
631634
if responseHeaders:
632635
logHeaders = getUnicode("".join(responseHeaders.headers).strip())
633636

634-
logHTTPTraffic(requestMsg, "%s%s\r\n\r\n%s" % (responseMsg, logHeaders, (page or "")[:MAX_CONNECTION_CHUNK_SIZE]), start, time.time())
637+
logHTTPTraffic(requestMsg, "%s%s\r\n\r\n%s" % (responseMsg, logHeaders, (page or "")[:MAX_CONNECTION_READ_SIZE]), start, time.time())
635638

636639
skipLogTraffic = True
637640

638641
if conf.verbose <= 5:
639642
responseMsg += getUnicode(logHeaders)
640643
elif conf.verbose > 5:
641-
responseMsg += "%s\r\n\r\n%s" % (logHeaders, (page or "")[:MAX_CONNECTION_CHUNK_SIZE])
644+
responseMsg += "%s\r\n\r\n%s" % (logHeaders, (page or "")[:MAX_CONNECTION_READ_SIZE])
642645

643646
if not multipart:
644647
logger.log(CUSTOM_LOGGING.TRAFFIC_IN, responseMsg)
@@ -815,12 +818,12 @@ class _(dict):
815818
if responseHeaders:
816819
logHeaders = getUnicode("".join(responseHeaders.headers).strip())
817820

818-
logHTTPTraffic(requestMsg, "%s%s\r\n\r\n%s" % (responseMsg, logHeaders, (page or "")[:MAX_CONNECTION_CHUNK_SIZE]), start, time.time())
821+
logHTTPTraffic(requestMsg, "%s%s\r\n\r\n%s" % (responseMsg, logHeaders, (page or "")[:MAX_CONNECTION_READ_SIZE]), start, time.time())
819822

820823
if conf.verbose <= 5:
821824
responseMsg += getUnicode(logHeaders)
822825
elif conf.verbose > 5:
823-
responseMsg += "%s\r\n\r\n%s" % (logHeaders, (page or "")[:MAX_CONNECTION_CHUNK_SIZE])
826+
responseMsg += "%s\r\n\r\n%s" % (logHeaders, (page or "")[:MAX_CONNECTION_READ_SIZE])
824827

825828
if not multipart:
826829
logger.log(CUSTOM_LOGGING.TRAFFIC_IN, responseMsg)

lib/request/redirecthandler.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
from lib.core.enums import REDIRECTION
2424
from lib.core.exception import SqlmapConnectionException
2525
from lib.core.settings import DEFAULT_COOKIE_DELIMITER
26-
from lib.core.settings import MAX_CONNECTION_CHUNK_SIZE
26+
from lib.core.settings import MAX_CONNECTION_READ_SIZE
2727
from lib.core.settings import MAX_CONNECTION_TOTAL_SIZE
2828
from lib.core.settings import MAX_SINGLE_URL_REDIRECTIONS
2929
from lib.core.settings import MAX_TOTAL_REDIRECTIONS
@@ -101,7 +101,7 @@ def http_error_302(self, req, fp, code, msg, headers):
101101

102102
redirectMsg += logHeaders
103103
if content:
104-
redirectMsg += "\r\n\r\n%s" % getUnicode(content[:MAX_CONNECTION_CHUNK_SIZE])
104+
redirectMsg += "\r\n\r\n%s" % getUnicode(content[:MAX_CONNECTION_READ_SIZE])
105105

106106
logHTTPTraffic(threadData.lastRequestMsg, redirectMsg, start, time.time())
107107
logger.log(CUSTOM_LOGGING.TRAFFIC_IN, redirectMsg)

0 commit comments

Comments
 (0)