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

Skip to content

Commit d65d9e2

Browse files
committed
Implementation for an Issue #2
1 parent 688a2db commit d65d9e2

3 files changed

Lines changed: 21 additions & 4 deletions

File tree

lib/controller/controller.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
from lib.core.exception import sqlmapSilentQuitException
4848
from lib.core.exception import sqlmapValueException
4949
from lib.core.exception import sqlmapUserQuitException
50+
from lib.core.settings import ASP_NET_CONTROL_REGEX
5051
from lib.core.settings import DEFAULT_COOKIE_DELIMITER
5152
from lib.core.settings import DEFAULT_GET_POST_DELIMITER
5253
from lib.core.settings import EMPTY_FORM_FIELDS_REGEX
@@ -166,7 +167,7 @@ def __randomFillBlankFields(value):
166167
if not test or test[0] in ("y", "Y"):
167168
for match in re.finditer(EMPTY_FORM_FIELDS_REGEX, retVal):
168169
item = match.group("result")
169-
if not any(_ in item for _ in IGNORE_PARAMETERS):
170+
if not any(_ in item for _ in IGNORE_PARAMETERS) and not re.search(ASP_NET_CONTROL_REGEX, item):
170171
if item[-1] == DEFAULT_GET_POST_DELIMITER:
171172
retVal = retVal.replace(item, "%s%s%s" % (item[:-1], randomStr(), DEFAULT_GET_POST_DELIMITER))
172173
else:

lib/core/settings.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@
229229
META_REFRESH_REGEX = r'<meta http-equiv="?refresh"?[^>]+content="?[^">]+url=(?P<result>[^">]+)'
230230

231231
# Regular expression used for parsing empty fields in tested form data
232-
EMPTY_FORM_FIELDS_REGEX = r'(?P<result>[^=]+=(&|\Z))'
232+
EMPTY_FORM_FIELDS_REGEX = r'(&|\A)(?P<result>[^=]+=(&|\Z))'
233233

234234
# Reference: http://www.cs.ru.nl/bachelorscripties/2010/Martin_Devillers___0437999___Analyzing_password_strength.pdf
235235
COMMON_PASSWORD_SUFFIXES = ("1", "123", "2", "12", "3", "13", "7", "11", "5", "22", "23", "01", "4", "07", "21", "14", "10", "06", "08", "8", "15", "69", "16", "6", "18")
@@ -309,6 +309,9 @@
309309
# Parameters to be ignored in detection phase (upper case)
310310
IGNORE_PARAMETERS = ("__VIEWSTATE", "__VIEWSTATEENCRYPTED", "__EVENTARGUMENT", "__EVENTTARGET", "__EVENTVALIDATION", "ASPSESSIONID", "ASP.NET_SESSIONID", "JSESSIONID", "CFID", "CFTOKEN")
311311

312+
# Regular expression used for recognition of ASP.NET control parameters
313+
ASP_NET_CONTROL_REGEX = r"(?i)\Actl\d+\$"
314+
312315
# Turn off resume console info to avoid potential slowdowns
313316
TURN_OFF_RESUME_INFO_LIMIT = 20
314317

@@ -462,8 +465,11 @@
462465
# Strings for detecting formatting errors
463466
FORMAT_EXCEPTION_STRINGS = ("Type mismatch", "Error converting", "Failed to convert", "System.FormatException", "java.lang.NumberFormatException")
464467

465-
# Regular expression used for extracting ASP.NET View State values
466-
VIEWSTATE_REGEX = r'(?P<name>__VIEWSTATE[^"]*)[^>]+value="(?P<name>[^"]+)'
468+
# Regular expression used for extracting ASP.NET view state values
469+
VIEWSTATE_REGEX = r'(?P<name>__VIEWSTATE[^"]*)[^>]+value="(?P<value>[^"]+)'
470+
471+
# Regular expression used for extracting ASP.NET event validation values
472+
EVENTVALIDATION_REGEX = r'(?P<name>__EVENTVALIDATION[^"]*)[^>]+value="(?P<value>[^"]+)'
467473

468474
# Number of rows to generate inside the full union test for limited output (mustn't be too large to prevent payload length problems)
469475
LIMITED_ROWS_TEST_NUMBER = 15

lib/request/basic.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,12 @@
2828
from lib.core.exception import sqlmapCompressionException
2929
from lib.core.htmlentities import htmlEntities
3030
from lib.core.settings import DEFAULT_COOKIE_DELIMITER
31+
from lib.core.settings import EVENTVALIDATION_REGEX
3132
from lib.core.settings import MAX_CONNECTION_TOTAL_SIZE
3233
from lib.core.settings import ML
3334
from lib.core.settings import META_CHARSET_REGEX
3435
from lib.core.settings import PARSE_HEADERS_LIMIT
36+
from lib.core.settings import VIEWSTATE_REGEX
3537
from lib.parse.headers import headersParser
3638
from lib.parse.html import htmlParser
3739
from thirdparty.chardet import detect
@@ -260,3 +262,11 @@ def processResponse(page, responseHeaders):
260262

261263
if msg:
262264
logger.info("parsed error message: '%s'" % msg)
265+
266+
for regex in (EVENTVALIDATION_REGEX, VIEWSTATE_REGEX):
267+
match = re.search(regex, page)
268+
if match and PLACE.POST in conf.parameters:
269+
name, value = match.groups()
270+
conf.parameters[PLACE.POST] = re.sub("(%s=)[^&]+" % name, r"\g<1>%s" % value, conf.parameters[PLACE.POST])
271+
if PLACE.POST in conf.paramDict and name in conf.paramDict[PLACE.POST]:
272+
conf.paramDict[PLACE.POST][name] = value

0 commit comments

Comments
 (0)