mirror of
				https://github.com/sqlmapproject/sqlmap.git
				synced 2025-11-04 09:57:38 +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)
 | 
					        retrying = kwargs.get("retrying",           False)
 | 
				
			||||||
        crawling = kwargs.get("crawling",           False)
 | 
					        crawling = kwargs.get("crawling",           False)
 | 
				
			||||||
        skipRead = kwargs.get("skipRead",           False)
 | 
					        skipRead = kwargs.get("skipRead",           False)
 | 
				
			||||||
        is_websocket = conf.url.startswith("ws")
 | 
					
 | 
				
			||||||
 | 
					        websocket_ = url.lower().startswith("ws")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if not urlparse.urlsplit(url).netloc:
 | 
					        if not urlparse.urlsplit(url).netloc:
 | 
				
			||||||
            url = urlparse.urljoin(conf.url, url)
 | 
					            url = urlparse.urljoin(conf.url, url)
 | 
				
			||||||
| 
						 | 
					@ -372,18 +373,32 @@ class Connect(object):
 | 
				
			||||||
            url = unicodeencode(url)
 | 
					            url = unicodeencode(url)
 | 
				
			||||||
            post = unicodeencode(post, kb.pageEncoding)
 | 
					            post = unicodeencode(post, kb.pageEncoding)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            if is_websocket:
 | 
					            if websocket_:
 | 
				
			||||||
                # WebSocket will add Host field of headers automatically
 | 
					 | 
				
			||||||
                disallowed_headers = ['Host']
 | 
					 | 
				
			||||||
                ws = websocket.WebSocket()
 | 
					                ws = websocket.WebSocket()
 | 
				
			||||||
                ws.connect(url, header=["%s: %s" % _ for _ in headers.items() if _[0] not in disallowed_headers], cookie=cookie)
 | 
					                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) if post else '')
 | 
					                ws.send(urldecode(post or ""))
 | 
				
			||||||
                response = ws.recv()
 | 
					                page = ws.recv()
 | 
				
			||||||
                ws.close()
 | 
					                ws.close()
 | 
				
			||||||
                # WebSocket class does not have response headers
 | 
					                code = ws.status
 | 
				
			||||||
                return response, {}, 101
 | 
					                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)
 | 
					                    method = unicodeencode(method)
 | 
				
			||||||
                    req = MethodRequest(url, post, headers)
 | 
					                    req = MethodRequest(url, post, headers)
 | 
				
			||||||
                    req.set_method(method)
 | 
					                    req.set_method(method)
 | 
				
			||||||
| 
						 | 
					@ -474,7 +489,7 @@ class Connect(object):
 | 
				
			||||||
                        pass
 | 
					                        pass
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            # Explicit closing of connection object
 | 
					            # Explicit closing of connection object
 | 
				
			||||||
            if not conf.keepAlive:
 | 
					            if conn and not conf.keepAlive:
 | 
				
			||||||
                try:
 | 
					                try:
 | 
				
			||||||
                    if hasattr(conn.fp, '_sock'):
 | 
					                    if hasattr(conn.fp, '_sock'):
 | 
				
			||||||
                        conn.fp._sock.close()
 | 
					                        conn.fp._sock.close()
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue
	
	Block a user