update regarding session page templates

This commit is contained in:
Miroslav Stampar 2010-12-07 14:35:31 +00:00
parent add6235b16
commit e53fef546e
3 changed files with 13 additions and 8 deletions

View File

@ -47,6 +47,7 @@ from lib.core.session import setString
from lib.core.session import setRegexp from lib.core.session import setRegexp
from lib.core.settings import TIME_MIN_DELTA from lib.core.settings import TIME_MIN_DELTA
from lib.request.connect import Connect as Request from lib.request.connect import Connect as Request
from lib.request.templates import getPageTemplate
from plugins.dbms.firebird.syntax import Syntax as Firebird from plugins.dbms.firebird.syntax import Syntax as Firebird
from plugins.dbms.postgresql.syntax import Syntax as PostgreSQL from plugins.dbms.postgresql.syntax import Syntax as PostgreSQL
from plugins.dbms.mssqlserver.syntax import Syntax as MSSQLServer from plugins.dbms.mssqlserver.syntax import Syntax as MSSQLServer
@ -258,20 +259,22 @@ def checkSqlInjection(place, parameter, value):
# For each test's <where> # For each test's <where>
for where in test.where: for where in test.where:
templatePayload = None
# Threat the parameter original value according to the # Threat the parameter original value according to the
# test's <where> tag # test's <where> tag
if where == 1: if where == 1:
origValue = value origValue = value
kb.pageTemplate = kb.originalPage
elif where == 2: elif where == 2:
origValue = "-%s" % randomInt() origValue = "-%s" % randomInt()
# Use different page template than the original one # Use different page template than the original one
# as we are changing parameters value, which will result # as we are changing parameters value, which will result
# most definitely with a different content # most definitely with a different content
kb.pageTemplate, _ = Request.queryPage(agent.payload(place, parameter, value, origValue), place, content=True) templatePayload = agent.payload(place, parameter, value, origValue)
elif where == 3: elif where == 3:
origValue = "" origValue = ""
kb.pageTemplate = kb.originalPage
kb.pageTemplate = getPageTemplate(templatePayload, place)
# Forge request payload by prepending with boundary's # Forge request payload by prepending with boundary's
# prefix and appending the boundary's suffix to the # prefix and appending the boundary's suffix to the
@ -396,6 +399,7 @@ def checkSqlInjection(place, parameter, value):
injection.data[stype].where = where injection.data[stype].where = where
injection.data[stype].vector = vector injection.data[stype].vector = vector
injection.data[stype].comment = comment injection.data[stype].comment = comment
injection.data[stype].templatePayload = templatePayload
if hasattr(test, "details"): if hasattr(test, "details"):
for detailKey, detailValue in test.details.items(): for detailKey, detailValue in test.details.items():

View File

@ -101,7 +101,7 @@ def __goInferenceProxy(expression, fromUser=False, expected=None, batch=False, r
if kb.injection.data[1].vector is not None: if kb.injection.data[1].vector is not None:
vector = agent.cleanupPayload(kb.injection.data[1].vector) vector = agent.cleanupPayload(kb.injection.data[1].vector)
kb.pageTemplate = getPageTemplate(kb.injection.data[1].payload, kb.injection.place) kb.pageTemplate = getPageTemplate(kb.injection.data[1].templatePayload, kb.injection.place)
else: else:
vector = queries[kb.misc.testedDbms].inference.query vector = queries[kb.misc.testedDbms].inference.query
kb.pageTemplate = kb.originalPage kb.pageTemplate = kb.originalPage

View File

@ -11,8 +11,9 @@ from lib.core.data import kb
from lib.request.connect import Connect as Request from lib.request.connect import Connect as Request
def getPageTemplate(payload, place): def getPageTemplate(payload, place):
retVal = None retVal = kb.originalPage
if (payload, place) not in kb.pageTemplates: if payload and place:
kb.pageTemplates[(payload, place)], _ = Request.queryPage(payload, place, content=True) if (payload, place) not in kb.pageTemplates:
retVal = kb.pageTemplates[(payload, place)] kb.pageTemplates[(payload, place)], _ = Request.queryPage(payload, place, content=True)
retVal = kb.pageTemplates[(payload, place)]
return retVal return retVal