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

Skip to content

Commit aed137a

Browse files
committed
Fixes #3948
1 parent 9fd4a4f commit aed137a

10 files changed

Lines changed: 42 additions & 14 deletions

File tree

lib/controller/controller.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
from lib.core.common import hashDBRetrieve
3232
from lib.core.common import hashDBWrite
3333
from lib.core.common import intersect
34+
from lib.core.common import isDigit
3435
from lib.core.common import isListLike
3536
from lib.core.common import parseTargetUrl
3637
from lib.core.common import popValue
@@ -129,7 +130,7 @@ def _selectInjection():
129130
message += "[q] Quit"
130131
choice = readInput(message, default='0').upper()
131132

132-
if choice.isdigit() and int(choice) < len(kb.injections) and int(choice) >= 0:
133+
if isDigit(choice) and int(choice) < len(kb.injections) and int(choice) >= 0:
133134
index = int(choice)
134135
elif choice == 'Q':
135136
raise SqlmapUserQuitException

lib/core/common.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1245,6 +1245,22 @@ def isZipFile(filename):
12451245

12461246
return openFile(filename, "rb", encoding=None).read(len(ZIP_HEADER)) == ZIP_HEADER
12471247

1248+
def isDigit(value):
1249+
"""
1250+
Checks if provided (string) value consists of digits (Note: Python's isdigit() is problematic)
1251+
1252+
>>> u'\xb2'.isdigit()
1253+
True
1254+
>>> isDigit(u'\xb2')
1255+
False
1256+
>>> isDigit('123456')
1257+
True
1258+
>>> isDigit('3b3')
1259+
False
1260+
"""
1261+
1262+
return re.search(r"\A[0-9]+\Z", value or "") is not None
1263+
12481264
def checkFile(filename, raiseOnError=True):
12491265
"""
12501266
Checks for file existence and readability

lib/core/patch.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
from lib.core.common import filterNone
2222
from lib.core.common import getSafeExString
23+
from lib.core.common import isDigit
2324
from lib.core.common import isListLike
2425
from lib.core.common import readInput
2526
from lib.core.common import shellExec
@@ -62,6 +63,7 @@ def resolveCrossReferences():
6263
Place for cross-reference resolution
6364
"""
6465

66+
lib.core.threads.isDigit = isDigit
6567
lib.core.threads.readInput = readInput
6668
lib.core.common.getPageTemplate = getPageTemplate
6769
lib.core.convert.filterNone = filterNone

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.6"
21+
VERSION = "1.3.10.7"
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/core/threads.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,10 @@ def readInput(message, default=None, checkBatch=True, boolean=False):
7373
# It will be overwritten by original from lib.core.common
7474
pass
7575

76+
def isDigit(value):
77+
# It will be overwritten by original from lib.core.common
78+
pass
79+
7680
def getCurrentThreadData():
7781
"""
7882
Returns current thread's local data
@@ -125,10 +129,12 @@ def runThreads(numThreads, threadFunction, cleanupFunction=None, forwardExceptio
125129
choice = readInput(message, default=str(numThreads))
126130
if choice:
127131
skipThreadCheck = False
132+
128133
if choice.endswith('!'):
129134
choice = choice[:-1]
130135
skipThreadCheck = True
131-
if choice.isdigit():
136+
137+
if isDigit(choice):
132138
if int(choice) > MAX_NUMBER_OF_THREADS and not skipThreadCheck:
133139
errMsg = "maximum number of used threads is %d avoiding potential connection issues" % MAX_NUMBER_OF_THREADS
134140
logger.critical(errMsg)

lib/request/inject.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
from lib.core.common import hashDBRetrieve
2525
from lib.core.common import hashDBWrite
2626
from lib.core.common import initTechnique
27+
from lib.core.common import isDigit
2728
from lib.core.common import isNoneValue
2829
from lib.core.common import isNumPosStrValue
2930
from lib.core.common import isTechniqueAvailable
@@ -235,7 +236,7 @@ def _goInferenceProxy(expression, fromUser=False, batch=False, unpack=True, char
235236
elif choice == 'Q':
236237
raise SqlmapUserQuitException
237238

238-
elif choice.isdigit() and int(choice) > 0 and int(choice) <= count:
239+
elif isDigit(choice) and int(choice) > 0 and int(choice) <= count:
239240
stopLimit = int(choice)
240241

241242
infoMsg = "sqlmap is now going to retrieve the "
@@ -246,7 +247,7 @@ def _goInferenceProxy(expression, fromUser=False, batch=False, unpack=True, char
246247
message = "how many? "
247248
stopLimit = readInput(message, default="10")
248249

249-
if not stopLimit.isdigit():
250+
if not isDigit(stopLimit):
250251
errMsg = "invalid choice"
251252
logger.error(errMsg)
252253

@@ -261,7 +262,7 @@ def _goInferenceProxy(expression, fromUser=False, batch=False, unpack=True, char
261262

262263
return None
263264

264-
elif count and not count.isdigit():
265+
elif count and not isDigit(count):
265266
warnMsg = "it was not possible to count the number "
266267
warnMsg += "of entries for the SQL query provided. "
267268
warnMsg += "sqlmap will assume that it returns only "

lib/takeover/metasploit.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
from lib.core.common import Backend
2424
from lib.core.common import getLocalIP
2525
from lib.core.common import getRemoteIP
26+
from lib.core.common import isDigit
2627
from lib.core.common import normalizePath
2728
from lib.core.common import ntToPosixSlashes
2829
from lib.core.common import pollProcess
@@ -154,7 +155,7 @@ def _skeletonSelection(self, msg, lst=None, maxValue=1, default=1):
154155

155156
choice = readInput(message, default="%d" % default)
156157

157-
if not choice or not choice.isdigit() or int(choice) > maxValue or int(choice) < 1:
158+
if not choice or not isDigit(choice) or int(choice) > maxValue or int(choice) < 1:
158159
choice = default
159160

160161
choice = int(choice)
@@ -241,7 +242,7 @@ def _selectPayload(self):
241242
elif Backend.isDbms(DBMS.MSSQL) and Backend.isVersionWithin(("2005", "2008")):
242243
break
243244

244-
elif not choice.isdigit():
245+
elif not isDigit(choice):
245246
logger.warn("invalid value, only digits are allowed")
246247

247248
elif int(choice) < 1 or int(choice) > 2:

lib/takeover/udf.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
from lib.core.common import Backend
1212
from lib.core.common import checkFile
1313
from lib.core.common import dataToStdout
14+
from lib.core.common import isDigit
1415
from lib.core.common import isStackingAvailable
1516
from lib.core.common import readInput
1617
from lib.core.common import unArrayizeValue
@@ -339,11 +340,9 @@ def udfInjectCustom(self):
339340

340341
if choice == 'Q':
341342
break
342-
elif hasattr(choice, "isdigit") and choice.isdigit() and int(choice) > 0 and int(choice) <= len(udfList):
343+
elif isDigit(choice) and int(choice) > 0 and int(choice) <= len(udfList):
343344
choice = int(choice)
344345
break
345-
elif isinstance(choice, int) and choice > 0 and choice <= len(udfList):
346-
break
347346
else:
348347
warnMsg = "invalid value, only digits >= 1 and "
349348
warnMsg += "<= %d are allowed" % len(udfList)

lib/takeover/web.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
from lib.core.common import getSQLSnippet
2323
from lib.core.common import getTechnique
2424
from lib.core.common import getTechniqueData
25+
from lib.core.common import isDigit
2526
from lib.core.common import isTechniqueAvailable
2627
from lib.core.common import isWindowsDriveLetterPath
2728
from lib.core.common import normalizePath
@@ -200,7 +201,7 @@ def webInit(self):
200201
while True:
201202
choice = readInput(message, default=str(default))
202203

203-
if not choice.isdigit():
204+
if not isDigit(choice):
204205
logger.warn("invalid value, only digits are allowed")
205206

206207
elif int(choice) < 1 or int(choice) > len(choices):

plugins/generic/takeover.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
from lib.core.common import Backend
1111
from lib.core.common import getSafeExString
12+
from lib.core.common import isDigit
1213
from lib.core.common import isStackingAvailable
1314
from lib.core.common import openFile
1415
from lib.core.common import readInput
@@ -101,7 +102,7 @@ def osPwn(self):
101102
while True:
102103
tunnel = readInput(msg, default='1')
103104

104-
if tunnel.isdigit() and int(tunnel) in (1, 2):
105+
if isDigit(tunnel) and int(tunnel) in (1, 2):
105106
tunnel = int(tunnel)
106107
break
107108

@@ -172,7 +173,7 @@ def osPwn(self):
172173
while True:
173174
choice = readInput(msg, default='1')
174175

175-
if choice.isdigit() and int(choice) in (1, 2):
176+
if isDigit(choice) and int(choice) in (1, 2):
176177
choice = int(choice)
177178
break
178179

0 commit comments

Comments
 (0)