Bug fix (bad idea is to do os.path.join on web URLs - especially on Windows OS)

This commit is contained in:
Miroslav Stampar 2014-02-16 21:44:57 +01:00
parent d05bfdd7dd
commit 43df4efd11

View File

@ -5,6 +5,7 @@ Copyright (c) 2006-2014 sqlmap developers (http://sqlmap.org/)
See the file 'doc/COPYING' for copying permission See the file 'doc/COPYING' for copying permission
""" """
import urlparse
import os import os
import re import re
import StringIO import StringIO
@ -222,9 +223,9 @@ class Web:
logger.info(infoMsg) logger.info(infoMsg)
self._webFileInject(stagerContent, stagerName, directory) self._webFileInject(stagerContent, stagerName, directory)
for x in list(re.finditer('/', directory)): for match in re.finditer('/', directory):
self.webBaseUrl = "%s://%s:%d%s" % (conf.scheme, conf.hostname, conf.port, directory[x.start():]) self.webBaseUrl = "%s://%s:%d%s" % (conf.scheme, conf.hostname, conf.port, directory[match.start():])
self.webStagerUrl = os.path.join(self.webBaseUrl, stagerName) self.webStagerUrl = urlparse.urljoin(self.webBaseUrl, stagerName)
self.webStagerFilePath = ntToPosixSlashes(os.path.join(directory, stagerName)) self.webStagerFilePath = ntToPosixSlashes(os.path.join(directory, stagerName))
debugMsg = "trying to see if the file is accessible from %s" % self.webStagerUrl debugMsg = "trying to see if the file is accessible from %s" % self.webStagerUrl