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

Skip to content

Commit 6831031

Browse files
committed
Bug fix for displaying traffic output in higher verbosity levels
1 parent 6dc3762 commit 6831031

2 files changed

Lines changed: 22 additions & 22 deletions

File tree

lib/core/settings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
from lib.core.enums import OS
1818

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

lib/request/connect.py

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -608,7 +608,7 @@ class _(dict):
608608
page = getUnicode(page)
609609

610610
code = ex.code
611-
status = getattr(ex, "reason", None) or getSafeExString(ex).split(": ")[-1]
611+
status = getattr(ex, "reason", None) or getSafeExString(ex).split(": ", 1)[-1]
612612

613613
kb.originalCode = kb.originalCode or code
614614
threadData.lastHTTPError = (threadData.lastRequestUID, code, status)
@@ -782,33 +782,33 @@ class _(dict):
782782

783783
processResponse(page, responseHeaders, status)
784784

785-
if conn and getattr(conn, "redurl", None):
786-
_ = _urllib.parse.urlsplit(conn.redurl)
787-
_ = ("%s%s" % (_.path or "/", ("?%s" % _.query) if _.query else ""))
788-
requestMsg = re.sub(r"(\n[A-Z]+ ).+?( HTTP/\d)", r"\g<1>%s\g<2>" % getUnicode(_).replace("\\", "\\\\"), requestMsg, 1)
785+
if not skipLogTraffic:
786+
if conn and getattr(conn, "redurl", None):
787+
_ = _urllib.parse.urlsplit(conn.redurl)
788+
_ = ("%s%s" % (_.path or "/", ("?%s" % _.query) if _.query else ""))
789+
requestMsg = re.sub(r"(\n[A-Z]+ ).+?( HTTP/\d)", r"\g<1>%s\g<2>" % getUnicode(_).replace("\\", "\\\\"), requestMsg, 1)
789790

790-
if kb.resendPostOnRedirect is False:
791-
requestMsg = re.sub(r"(\[#\d+\]:\n)POST ", r"\g<1>GET ", requestMsg)
792-
requestMsg = re.sub(r"(?i)Content-length: \d+\n", "", requestMsg)
793-
requestMsg = re.sub(r"(?s)\n\n.+", "\n", requestMsg)
791+
if kb.resendPostOnRedirect is False:
792+
requestMsg = re.sub(r"(\[#\d+\]:\n)POST ", r"\g<1>GET ", requestMsg)
793+
requestMsg = re.sub(r"(?i)Content-length: \d+\n", "", requestMsg)
794+
requestMsg = re.sub(r"(?s)\n\n.+", "\n", requestMsg)
794795

795-
responseMsg += "[#%d] (%s %s):\r\n" % (threadData.lastRequestUID, conn.code, status)
796-
else:
797-
responseMsg += "[#%d] (%s %s):\r\n" % (threadData.lastRequestUID, code, status)
796+
responseMsg += "[#%d] (%s %s):\r\n" % (threadData.lastRequestUID, conn.code, status)
797+
elif "\n" not in responseMsg:
798+
responseMsg += "[#%d] (%s %s):\r\n" % (threadData.lastRequestUID, code, status)
798799

799-
if responseHeaders:
800-
logHeaders = getUnicode("".join(responseHeaders.headers).strip())
800+
if responseHeaders:
801+
logHeaders = getUnicode("".join(responseHeaders.headers).strip())
801802

802-
if not skipLogTraffic:
803803
logHTTPTraffic(requestMsg, "%s%s\r\n\r\n%s" % (responseMsg, logHeaders, (page or "")[:MAX_CONNECTION_CHUNK_SIZE]), start, time.time())
804804

805-
if conf.verbose <= 5:
806-
responseMsg += getUnicode(logHeaders)
807-
elif conf.verbose > 5:
808-
responseMsg += "%s\r\n\r\n%s" % (logHeaders, (page or "")[:MAX_CONNECTION_CHUNK_SIZE])
805+
if conf.verbose <= 5:
806+
responseMsg += getUnicode(logHeaders)
807+
elif conf.verbose > 5:
808+
responseMsg += "%s\r\n\r\n%s" % (logHeaders, (page or "")[:MAX_CONNECTION_CHUNK_SIZE])
809809

810-
if not multipart:
811-
logger.log(CUSTOM_LOGGING.TRAFFIC_IN, responseMsg)
810+
if not multipart:
811+
logger.log(CUSTOM_LOGGING.TRAFFIC_IN, responseMsg)
812812

813813
return page, responseHeaders, code
814814

0 commit comments

Comments
 (0)