|
52 | 52 | from lib.core.exception import sqlmapSyntaxException |
53 | 53 | from lib.core.settings import HTTP_ACCEPT_HEADER_VALUE |
54 | 54 | from lib.core.settings import HTTP_SILENT_TIMEOUT |
| 55 | +from lib.core.settings import MAX_CONNECTION_CHUNK_SIZE |
55 | 56 | from lib.core.settings import META_REFRESH_REGEX |
56 | | -from lib.core.settings import IS_WIN |
57 | 57 | from lib.core.settings import MIN_TIME_RESPONSES |
58 | | -from lib.core.settings import WARN_TIME_STDEV |
| 58 | +from lib.core.settings import IS_WIN |
| 59 | +from lib.core.settings import LARGE_CHUNK_TRIM_MARKER |
59 | 60 | from lib.core.settings import UNENCODED_ORIGINAL_VALUE |
60 | 61 | from lib.core.settings import URI_HTTP_HEADER |
| 62 | +from lib.core.settings import WARN_TIME_STDEV |
61 | 63 | from lib.request.basic import decodePage |
62 | 64 | from lib.request.basic import forgeHeaders |
63 | 65 | from lib.request.basic import processResponse |
@@ -117,6 +119,21 @@ def __retryProxy(**kwargs): |
117 | 119 | kwargs['retrying'] = True |
118 | 120 | return Connect.__getPageProxy(**kwargs) |
119 | 121 |
|
| 122 | + @staticmethod |
| 123 | + def __connReadProxy(conn): |
| 124 | + retVal = "" |
| 125 | + while True: |
| 126 | + _ = conn.read(MAX_CONNECTION_CHUNK_SIZE) |
| 127 | + if len(_) == MAX_CONNECTION_CHUNK_SIZE: |
| 128 | + warnMsg = "large response detected. This could take a while" |
| 129 | + singleTimeWarnMessage(warnMsg) |
| 130 | + _ = 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), _) |
| 131 | + retVal += _ |
| 132 | + else: |
| 133 | + retVal += _ |
| 134 | + break |
| 135 | + return retVal |
| 136 | + |
120 | 137 | @staticmethod |
121 | 138 | def getPage(**kwargs): |
122 | 139 | """ |
@@ -205,7 +222,7 @@ def getPage(**kwargs): |
205 | 222 |
|
206 | 223 | multipartOpener = urllib2.build_opener(proxyHandler, multipartpost.MultipartPostHandler) |
207 | 224 | conn = multipartOpener.open(unicodeencode(url), multipart) |
208 | | - page = conn.read() |
| 225 | + page = Connect.__connReadProxy(conn) |
209 | 226 | responseHeaders = conn.info() |
210 | 227 | responseHeaders[URI_HTTP_HEADER] = conn.geturl() |
211 | 228 | page = decodePage(page, responseHeaders.get(HTTPHEADER.CONTENT_ENCODING), responseHeaders.get(HTTPHEADER.CONTENT_TYPE)) |
@@ -306,11 +323,11 @@ def getPage(**kwargs): |
306 | 323 | # Get HTTP response |
307 | 324 | if hasattr(conn, 'redurl'): |
308 | 325 | page = threadData.lastRedirectMsg[1] if kb.redirectChoice == REDIRECTION.NO\ |
309 | | - else conn.read() |
| 326 | + else Connect.__connReadProxy(conn) |
310 | 327 | skipLogTraffic = kb.redirectChoice == REDIRECTION.NO |
311 | 328 | code = conn.redcode |
312 | 329 | else: |
313 | | - page = conn.read() |
| 330 | + page = Connect.__connReadProxy(conn) |
314 | 331 |
|
315 | 332 | code = code or conn.code |
316 | 333 | responseHeaders = conn.info() |
|
0 commit comments