@@ -88,8 +88,10 @@ def webUpload(self, destFileName, directory, stream=None, content=None, filepath
8888 else :
8989 with open (filepath , "rb" ) as f :
9090 content = f .read ()
91+
9192 if content is not None :
9293 stream = StringIO .StringIO (content ) # string content
94+
9395 return self ._webFileStreamUpload (stream , destFileName , directory )
9496
9597 def _webFileStreamUpload (self , stream , destFileName , directory ):
@@ -114,12 +116,15 @@ def _webFileStreamUpload(self, stream, destFileName, directory):
114116 page = Request .getPage (url = self .webStagerUrl , multipart = multipartParams , raise404 = False )
115117
116118 if "File uploaded" not in page :
117- warnMsg = "unable to upload the backdoor through "
118- warnMsg += "the file stager on '%s'" % directory
119+ warnMsg = "unable to upload the file through the web file "
120+ warnMsg += "stager to '%s'" % directory
119121 logger .warn (warnMsg )
120122 return False
121123 else :
122124 return True
125+ else :
126+ logger .error ("sqlmap has not got a web backdoor nor a web file stager for %s" % self .webApi )
127+ return False
123128
124129 def _webFileInject (self , fileContent , fileName , directory ):
125130 outFile = posixpath .normpath ("%s/%s" % (directory , fileName ))
@@ -152,9 +157,6 @@ def webInit(self):
152157
153158 self .checkDbmsOs ()
154159
155- infoMsg = "trying to upload the file stager"
156- logger .info (infoMsg )
157-
158160 default = None
159161 choices = list (getPublicTypeMembers (WEB_API , True ))
160162
@@ -199,7 +201,6 @@ def webInit(self):
199201
200202 stagerName = "tmpu%s.%s" % (randomStr (lowercase = True ), self .webApi )
201203 stagerContent = decloak (os .path .join (paths .SQLMAP_SHELL_PATH , "stager.%s_" % self .webApi ))
202-
203204 success = False
204205
205206 for docRoot in kb .docRoot :
@@ -226,7 +227,6 @@ def webInit(self):
226227 else :
227228 localPath = directory
228229 uriPath = directory [2 :] if isWindowsDriveLetterPath (directory ) else directory
229- docRoot = docRoot [2 :] if isWindowsDriveLetterPath (docRoot ) else docRoot
230230
231231 if docRoot in uriPath :
232232 uriPath = uriPath .replace (docRoot , "/" )
@@ -243,6 +243,9 @@ def webInit(self):
243243 uriPath = posixpath .normpath (uriPath ).rstrip ('/' )
244244
245245 # Upload the file stager with the LIMIT 0, 1 INTO OUTFILE technique
246+ infoMsg = "trying to upload the file stager on '%s' " % localPath
247+ infoMsg += "via LIMIT INTO OUTFILE technique"
248+ logger .info (infoMsg )
246249 self ._webFileInject (stagerContent , stagerName , localPath )
247250
248251 self .webBaseUrl = "%s://%s:%d%s" % (conf .scheme , conf .hostname , conf .port , uriPath )
@@ -259,8 +262,8 @@ def webInit(self):
259262 singleTimeWarnMessage (warnMsg )
260263
261264 if isTechniqueAvailable (PAYLOAD .TECHNIQUE .UNION ):
262- infoMsg = "trying to upload the file stager via "
263- infoMsg += "UNION technique"
265+ infoMsg = "trying to upload the file stager on '%s' " % localPath
266+ infoMsg += "via UNION technique"
264267 logger .info (infoMsg )
265268
266269 handle , filename = mkstemp ()
0 commit comments