mirror of
https://github.com/sqlmapproject/sqlmap.git
synced 2024-11-22 17:46:37 +03:00
Fixes related to the #1206
This commit is contained in:
parent
c8aac19f75
commit
91bc02e3ba
|
@ -239,7 +239,8 @@ class Connect(object):
|
|||
retrying = kwargs.get("retrying", False)
|
||||
crawling = kwargs.get("crawling", False)
|
||||
skipRead = kwargs.get("skipRead", False)
|
||||
is_websocket = conf.url.startswith("ws")
|
||||
|
||||
websocket_ = url.lower().startswith("ws")
|
||||
|
||||
if not urlparse.urlsplit(url).netloc:
|
||||
url = urlparse.urljoin(conf.url, url)
|
||||
|
@ -372,18 +373,32 @@ class Connect(object):
|
|||
url = unicodeencode(url)
|
||||
post = unicodeencode(post, kb.pageEncoding)
|
||||
|
||||
if is_websocket:
|
||||
# WebSocket will add Host field of headers automatically
|
||||
disallowed_headers = ['Host']
|
||||
if websocket_:
|
||||
ws = websocket.WebSocket()
|
||||
ws.connect(url, header=["%s: %s" % _ for _ in headers.items() if _[0] not in disallowed_headers], cookie=cookie)
|
||||
ws.send(urldecode(post) if post else '')
|
||||
response = ws.recv()
|
||||
ws.connect(url, header=("%s: %s" % _ for _ in headers.items() if _[0] not in ("Host",)), cookie=cookie) # WebSocket will add Host field of headers automatically
|
||||
ws.send(urldecode(post or ""))
|
||||
page = ws.recv()
|
||||
ws.close()
|
||||
# WebSocket class does not have response headers
|
||||
return response, {}, 101
|
||||
code = ws.status
|
||||
status = httplib.responses[code]
|
||||
class _(dict):
|
||||
pass
|
||||
responseHeaders = _(ws.getheaders())
|
||||
responseHeaders.headers = ["%s: %s\r\n" % (_[0].capitalize(), _[1]) for _ in responseHeaders.items()]
|
||||
|
||||
elif method and method not in (HTTPMETHOD.GET, HTTPMETHOD.POST):
|
||||
requestHeaders += "\n".join("%s: %s" % (getUnicode(key.capitalize() if isinstance(key, basestring) else key), getUnicode(value)) for (key, value) in responseHeaders.items())
|
||||
requestMsg += "\n%s" % requestHeaders
|
||||
|
||||
if post is not None:
|
||||
requestMsg += "\n\n%s" % getUnicode(post)
|
||||
|
||||
requestMsg += "\n"
|
||||
|
||||
threadData.lastRequestMsg = requestMsg
|
||||
|
||||
logger.log(CUSTOM_LOGGING.TRAFFIC_OUT, requestMsg)
|
||||
else:
|
||||
if method and method not in (HTTPMETHOD.GET, HTTPMETHOD.POST):
|
||||
method = unicodeencode(method)
|
||||
req = MethodRequest(url, post, headers)
|
||||
req.set_method(method)
|
||||
|
@ -474,7 +489,7 @@ class Connect(object):
|
|||
pass
|
||||
|
||||
# Explicit closing of connection object
|
||||
if not conf.keepAlive:
|
||||
if conn and not conf.keepAlive:
|
||||
try:
|
||||
if hasattr(conn.fp, '_sock'):
|
||||
conn.fp._sock.close()
|
||||
|
|
Loading…
Reference in New Issue
Block a user