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

Skip to content

Commit 893bc04

Browse files
committed
changes regarding Feature #157 (Evaluate BETWEEN for inference algorithm)
1 parent 8b74c40 commit 893bc04

4 files changed

Lines changed: 27 additions & 7 deletions

File tree

lib/core/optiondict.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@
6767
"regexp": "string",
6868
"eString": "string",
6969
"eRegexp": "string",
70+
"useBetween": "boolean",
7071
},
7172

7273
"Techniques": {

lib/parse/cmdline.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,10 @@ def cmdLineParser():
182182
help="Matches to be excluded before "
183183
"comparing page contents")
184184

185+
injection.add_option("--use-between", dest="useBetween",
186+
action="store_true",
187+
help="Use operator BETWEEN instead of default '>'")
188+
185189
# Techniques options
186190
techniques = OptionGroup(parser, "Techniques", "These options can "
187191
"be used to test for specific SQL injection "

lib/techniques/blind/inference.py

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -158,18 +158,30 @@ def getChar(idx, asciiTbl=asciiTbl):
158158
posValueOld = posValue
159159
posValue = chr(posValue)
160160

161-
forgedPayload = safeStringFormat(payload, (expressionUnescaped, idx, posValue))
161+
if not conf.useBetween:
162+
forgedPayload = safeStringFormat(payload, (expressionUnescaped, idx, posValue))
163+
else:
164+
forgedPayload = safeStringFormat(payload.replace('%3E', 'BETWEEN 0 AND '), (expressionUnescaped, idx, posValue))
165+
162166
result = Request.queryPage(urlencode(forgedPayload))
163167

164168
if kb.dbms == "SQLite":
165169
posValue = posValueOld
166170

167-
if result:
168-
minValue = posValue
169-
asciiTbl = asciiTbl[position:]
170-
else:
171-
maxValue = posValue
172-
asciiTbl = asciiTbl[:position]
171+
if not conf.useBetween: #normal
172+
if result:
173+
minValue = posValue
174+
asciiTbl = asciiTbl[position:]
175+
else:
176+
maxValue = posValue
177+
asciiTbl = asciiTbl[:position]
178+
else: #reversed
179+
if result:
180+
maxValue = posValue
181+
asciiTbl = asciiTbl[:position]
182+
else:
183+
minValue = posValue
184+
asciiTbl = asciiTbl[position:]
173185

174186
if len(asciiTbl) == 1:
175187
if maxValue == 1:

sqlmap.conf

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,9 @@ eString =
184184
# (http://www.python.org/doc/2.5.2/lib/re-syntax.html)
185185
eRegexp =
186186

187+
# Use operator BETWEEN instead of default '>'
188+
# Valid: True or False
189+
useBetween = False
187190

188191
# These options can be used to test for specific SQL injection technique
189192
# or to use one of them to exploit the affected parameter(s) rather than

0 commit comments

Comments
 (0)