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

Skip to content

Commit d28ca58

Browse files
committed
adding support for meta HTML header 'refresh' - popular one amongst login pages (stumbled when tested blind injections on Mutillidae login page)
1 parent 7cf4ba8 commit d28ca58

2 files changed

Lines changed: 31 additions & 0 deletions

File tree

lib/core/settings.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,9 @@
221221
# Regular expression used for parsing charset info from meta html headers
222222
META_CHARSET_REGEX = r'<meta http-equiv="?content-type"?[^>]+charset=(?P<result>[^">]+)'
223223

224+
# Regular expression used for parsing refresh info from meta html headers
225+
META_REFRESH_REGEX = r'<meta http-equiv="?refresh"?[^>]+content="?[^">]+url=(?P<result>[^">]+)'
226+
224227
# Regular expression used for parsing empty fields in tested form data
225228
EMPTY_FORM_FIELDS_REGEX = r'(?P<result>[^=]+=(&|\Z))'
226229

lib/request/connect.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
from lib.core.common import calculateDeltaSeconds
2222
from lib.core.common import clearConsoleLine
2323
from lib.core.common import cpuThrottle
24+
from lib.core.common import extractRegexResult
2425
from lib.core.common import getCurrentThreadData
2526
from lib.core.common import getFilteredPageContent
2627
from lib.core.common import unicodeToSafeHTMLValue
@@ -43,6 +44,7 @@
4344
from lib.core.exception import sqlmapConnectionException
4445
from lib.core.exception import sqlmapSyntaxException
4546
from lib.core.settings import HTTP_SILENT_TIMEOUT
47+
from lib.core.settings import META_REFRESH_REGEX
4648
from lib.core.settings import MIN_TIME_RESPONSES
4749
from lib.core.settings import URI_HTTP_HEADER
4850
from lib.core.threads import getCurrentThreadData
@@ -96,6 +98,7 @@ def getPage(**kwargs):
9698
auxHeaders = kwargs.get('auxHeaders', None)
9799
response = kwargs.get('response', False)
98100
ignoreTimeout = kwargs.get('ignoreTimeout', False)
101+
refreshing = kwargs.get('refreshing', False)
99102

100103
page = ""
101104
cookieStr = ""
@@ -131,6 +134,13 @@ def getPage(**kwargs):
131134

132135
return page
133136

137+
elif refreshing:
138+
# Reference(s):
139+
# http://vancouver-webpages.com/META/metatags.detail.html
140+
# http://webdesign.about.com/od/metataglibraries/a/aa080300a.htm
141+
get = None
142+
post = None
143+
134144
else:
135145
if conf.parameters.has_key(PLACE.GET) and not get:
136146
get = conf.parameters[PLACE.GET]
@@ -253,6 +263,24 @@ def getPage(**kwargs):
253263
page = decodePage(page, responseHeaders.get(HTTPHEADER.CONTENT_ENCODING), responseHeaders.get(HTTPHEADER.CONTENT_TYPE))
254264
status = getUnicode(conn.msg)
255265

266+
if extractRegexResult(META_REFRESH_REGEX, page, re.DOTALL | re.IGNORECASE) and not refreshing:
267+
url = extractRegexResult(META_REFRESH_REGEX, page, re.DOTALL | re.IGNORECASE)
268+
269+
if url.lower().startswith('http://'):
270+
kwargs['url'] = url
271+
else:
272+
kwargs['url'] = conf.url[:conf.url.rfind('/')+1] + url
273+
274+
kwargs['refreshing'] = True
275+
276+
debugMsg = "got HTML meta refresh header"
277+
logger.debug(debugMsg)
278+
279+
try:
280+
return Connect.__getPageProxy(**kwargs)
281+
except sqlmapSyntaxException:
282+
pass
283+
256284
# Explicit closing of connection object
257285
if not conf.keepAlive:
258286
try:

0 commit comments

Comments
 (0)