Minor code refactoring and added internal debug prints

This commit is contained in:
Bernardo Damele 2011-01-12 12:03:23 +00:00
parent af9725214a
commit b3a0f38f3f

View File

@ -67,15 +67,15 @@ class Agent:
if where is None and isTechniqueAvailable(kb.technique): if where is None and isTechniqueAvailable(kb.technique):
where = kb.injection.data[kb.technique].where where = kb.injection.data[kb.technique].where
# Debug print
#print "value: %s, newValue: %s, where: %s, kb.technique: %s" % (value, newValue, where, kb.technique)
if kb.injection.place is not None: if kb.injection.place is not None:
place = kb.injection.place place = kb.injection.place
if kb.injection.parameter is not None: if kb.injection.parameter is not None:
parameter = kb.injection.parameter parameter = kb.injection.parameter
if place == PLACE.UA:
retValue = parameter.replace(parameter, self.addPayloadDelimiters(parameter + newValue))
else:
paramString = conf.parameters[place] paramString = conf.parameters[place]
paramDict = conf.paramDict[place] paramDict = conf.paramDict[place]
origValue = paramDict[parameter] origValue = paramDict[parameter]
@ -84,6 +84,9 @@ class Agent:
if where == 1: if where == 1:
value = origValue value = origValue
elif where == 2: elif where == 2:
if newValue.startswith("-"):
value = ""
else:
value = "-%s" % randomInt() value = "-%s" % randomInt()
elif where == 3: elif where == 3:
value = "" value = ""
@ -102,12 +105,15 @@ class Agent:
child.text = self.addPayloadDelimiters(newValue) child.text = self.addPayloadDelimiters(newValue)
retValue = ET.tostring(root) retValue = ET.tostring(root)
elif place == PLACE.URI: elif place in (PLACE.UA, PLACE.URI):
retValue = paramString.replace("*", self.addPayloadDelimiters(newValue)) retValue = paramString.replace("*", self.addPayloadDelimiters(newValue))
else: else:
retValue = paramString.replace("%s=%s" % (parameter, origValue), retValue = paramString.replace("%s=%s" % (parameter, origValue),
"%s=%s" % (parameter, self.addPayloadDelimiters(newValue))) "%s=%s" % (parameter, self.addPayloadDelimiters(newValue)))
# Debug print
#print "retValue:", retValue
return retValue return retValue
def fullPayload(self, query): def fullPayload(self, query):