Skip to content

Commit 458d594

Browse files
committed
Minor bug fix in MSSQL version fingerprint
1 parent 14578a7 commit 458d594

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

doc/THANKS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,9 @@ Guido Landi <lists@keamera.org>
113113
'sp_replwritetovarbin' stored procedure heap-based buffer overflow
114114
(MS09-004) exploit development, http://www.milw0rm.com/author/1413
115115

116+
Lee Lawson <Lee.Lawson@dns.co.uk>
117+
for reporting a minor bug
118+
116119
Nico Leidecker <nico@leidecker.info>
117120
for providing me with feedback on a few features
118121
for reporting a couple of bugs

plugins/dbms/mssqlserver.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
from lib.core.common import formatFingerprint
3333
from lib.core.common import getHtmlErrorFp
3434
from lib.core.common import getRange
35+
from lib.core.common import randomInt
3536
from lib.core.common import randomStr
3637
from lib.core.convert import urlencode
3738
from lib.core.data import conf
@@ -192,10 +193,12 @@ def checkDbms(self):
192193
logger.info(infoMsg)
193194

194195
for version in ( 0, 5, 8 ):
195-
payload = agent.fullPayload(" AND ( ( SUBSTRING((@@VERSION), 22, 1)=2 AND SUBSTRING((@@VERSION), 25, 1)=%d ) OR ( SUBSTRING((@@VERSION), 23, 1)=2 AND SUBSTRING((@@VERSION), 26, 1)=%d ) )" % (version, version))
196+
randInt = randomInt()
197+
query = " AND %d=(SELECT (CASE WHEN (( SUBSTRING((@@VERSION), 22, 1)=2 AND SUBSTRING((@@VERSION), 25, 1)=%d ) OR ( SUBSTRING((@@VERSION), 23, 1)=2 AND SUBSTRING((@@VERSION), 26, 1)=%d )) THEN %d ELSE %d END))" % (randInt, version, version, randInt, (randInt + 1))
198+
payload = agent.fullPayload(query)
196199
result = Request.queryPage(payload)
197200

198-
if result == True:
201+
if result is True:
199202
if version == 8:
200203
kb.dbmsVersion = [ "2008" ]
201204

@@ -212,7 +215,8 @@ def checkDbms(self):
212215
break
213216

214217
else:
215-
payload = agent.fullPayload(" AND SUBSTRING((@@VERSION), 22, 1)=7")
218+
query = " AND %d=(SELECT (CASE WHEN (SUBSTRING((@@VERSION), 22, 1)=7) THEN %d ELSE %d END))" % (randInt, randInt, (randInt + 1))
219+
payload = agent.fullPayload(query)
216220
result = Request.queryPage(payload)
217221

218222
if result == True:

0 commit comments

Comments
 (0)