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

Skip to content

Commit 9a62460

Browse files
committed
Falling back to web backdoor if UDF fails
1 parent 1c3982c commit 9a62460

5 files changed

Lines changed: 22 additions & 6 deletions

File tree

lib/core/option.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2012,6 +2012,7 @@ def _setKnowledgeBaseAttributes(flushAll=True):
20122012
kb.threadException = False
20132013
kb.tableExistsChoice = None
20142014
kb.uChar = NULL
2015+
kb.udfFail = False
20152016
kb.unionDuplicates = False
20162017
kb.wizardMode = False
20172018
kb.xpCmdshellAvailable = False

lib/core/settings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
from thirdparty.six import unichr as _unichr
1919

2020
# sqlmap version (<major>.<minor>.<month>.<monthly commit>)
21-
VERSION = "1.3.10.21"
21+
VERSION = "1.3.10.22"
2222
TYPE = "dev" if VERSION.count('.') > 2 and VERSION.split('.')[-1] != '0' else "stable"
2323
TYPE_COLORS = {"dev": 33, "stable": 90, "pip": 34}
2424
VERSION_STRING = "sqlmap/%s#%s" % ('.'.join(VERSION.split('.')[:-1]) if VERSION.count('.') > 2 and VERSION.split('.')[-1] == '0' else VERSION, TYPE)

lib/takeover/abstraction.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
from lib.core.common import readInput
1717
from lib.core.convert import getUnicode
1818
from lib.core.data import conf
19+
from lib.core.data import kb
1920
from lib.core.data import logger
2021
from lib.core.enums import AUTOCOMPLETE_TYPE
2122
from lib.core.enums import DBMS
@@ -48,7 +49,7 @@ def execCmd(self, cmd, silent=False):
4849
if Backend.isDbms(DBMS.PGSQL) and self.checkCopyExec():
4950
self.copyExecCmd(cmd)
5051

51-
elif self.webBackdoorUrl and not isStackingAvailable():
52+
elif self.webBackdoorUrl and (not isStackingAvailable() or kb.udfFail):
5253
self.webBackdoorRunCmd(cmd)
5354

5455
elif Backend.getIdentifiedDbms() in (DBMS.MYSQL, DBMS.PGSQL):
@@ -67,7 +68,7 @@ def evalCmd(self, cmd, first=None, last=None):
6768
if Backend.isDbms(DBMS.PGSQL) and self.checkCopyExec():
6869
retVal = self.copyExecCmd(cmd)
6970

70-
elif self.webBackdoorUrl and not isStackingAvailable():
71+
elif self.webBackdoorUrl and (not isStackingAvailable() or kb.udfFail):
7172
retVal = self.webBackdoorRunCmd(cmd)
7273

7374
elif Backend.getIdentifiedDbms() in (DBMS.MYSQL, DBMS.PGSQL):
@@ -104,7 +105,7 @@ def runCmd(self, cmd):
104105
self.execCmd(cmd)
105106

106107
def shell(self):
107-
if self.webBackdoorUrl and not isStackingAvailable():
108+
if self.webBackdoorUrl and (not isStackingAvailable() or kb.udfFail):
108109
infoMsg = "calling OS shell. To quit type "
109110
infoMsg += "'x' or 'q' and press ENTER"
110111
logger.info(infoMsg)

plugins/generic/misc.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ def cleanup(self, onlyFileTbl=False, udfDict=None, web=False):
137137
self.delRemoteFile(self.webStagerFilePath)
138138
self.delRemoteFile(self.webBackdoorFilePath)
139139

140-
if not isStackingAvailable() and not conf.direct:
140+
if (not isStackingAvailable() or kb.udfFail) and not conf.direct:
141141
return
142142

143143
if any((conf.osCmd, conf.osShell)) and Backend.isDbms(DBMS.PGSQL) and kb.copyExecTest:

plugins/generic/takeover.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
from lib.core.common import readInput
1616
from lib.core.common import runningAsAdmin
1717
from lib.core.data import conf
18+
from lib.core.data import kb
1819
from lib.core.data import logger
1920
from lib.core.enums import DBMS
2021
from lib.core.enums import OS
@@ -79,7 +80,20 @@ def osShell(self):
7980
raise SqlmapNotVulnerableException(errMsg)
8081

8182
self.getRemoteTempPath()
82-
self.initEnv(web=web)
83+
84+
try:
85+
self.initEnv(web=web)
86+
except SqlmapFilePathException:
87+
if not web:
88+
infoMsg = "falling back to web backdoor method..."
89+
logger.info(infoMsg)
90+
91+
web = True
92+
kb.udfFail = True
93+
94+
self.initEnv(web=web)
95+
else:
96+
raise
8397

8498
if not web or (web and self.webBackdoorUrl is not None):
8599
self.shell()

0 commit comments

Comments
 (0)