more refactoring

This commit is contained in:
Miroslav Stampar 2010-10-07 14:05:34 +00:00
parent e80a66acc5
commit 440ff639bb
3 changed files with 26 additions and 35 deletions

View File

@ -146,20 +146,19 @@ class Agent:
query = str()
case = getInjectionCase(kb.injType)
if kb.parenthesis is not None:
parenthesis = kb.parenthesis
else:
raise sqlmapNoneDataException, "unable to get the number of parenthesis"
if case is None:
raise sqlmapNoneDataException, "unsupported injection type"
if conf.prefix:
query = conf.prefix
else:
if case.usage.prefix._has_key('value'):
query = case.usage.prefix.value
elif case.usage.prefix._has_key('format'):
query = case.usage.prefix.format % eval(case.usage.prefix.params)
if kb.parenthesis not in ( None, 0 ):
query += "%s " % (")" * kb.parenthesis)
query += string
return replaceSpaces(query)
@ -181,20 +180,17 @@ class Agent:
randInt = randomInt()
randStr = randomStr()
if kb.parenthesis is not None:
parenthesis = kb.parenthesis
else:
raise sqlmapNoneDataException, "unable to get the number of parenthesis"
if comment:
string += comment
if conf.postfix:
string += " %s" % conf.postfix
else:
if kb.parenthesis is not None:
string += " AND %s" % ("(" * kb.parenthesis)
else:
raise sqlmapNoneDataException, "unable to get the number of parenthesis"
if case.usage.postfix._has_key('value'):
string += case.usage.postfix.value
elif case.usage.postfix._has_key('format'):
string += case.usage.postfix.format % eval(case.usage.postfix.params)
return replaceSpaces(string)

View File

@ -56,16 +56,11 @@ def checkForParenthesis():
return
for parenthesis in range(1, 4):
query = agent.prefixQuery("%s " % (")" * parenthesis))
query += "AND %s" % ("(" * parenthesis)
randInt = randomInt()
randStr = randomStr()
if case.usage.postfix._has_key('value'):
query += case.usage.postfix.value
elif case.usage.postfix._has_key('format'):
query += case.usage.postfix.format % eval(case.usage.postfix.params)
query = case.usage.prefix.format % eval(case.usage.prefix.params) +\
case.usage.postfix.format % eval(case.usage.postfix.params)
payload = agent.payload(newValue=query)
result = Request.queryPage(payload)

View File

@ -7,8 +7,8 @@
<negative format="%s%s%s AND %s%d=%d %s" params="value, prefix, &quot;)&quot; * parenthesis, &quot;(&quot; * parenthesis, randInt, randInt + 1, postfix"/>
</test>
<usage>
<prefix/>
<postfix/>
<prefix format="%s " params="')' * parenthesis"/>
<postfix format=" AND %s" params="'(' * parenthesis"/>
</usage>
</case>
<case name="numeric" desc="unescaped numeric">
@ -17,8 +17,8 @@
<negative format="%s%s AND %s%d=%d" params="value, &quot;)&quot; * parenthesis, &quot;(&quot; * parenthesis, randInt, randInt + 1"/>
</test>
<usage>
<prefix/>
<postfix format="%d=%d" params="randInt, randInt"/>
<prefix format="%s " params="')' * parenthesis"/>
<postfix format=" AND %s%d=%d" params="'(' * parenthesis, randInt, randInt"/>
</usage>
</case>
<case name="stringsingle" desc="single quoted string">
@ -27,8 +27,8 @@
<negative format="%s'%s AND %s'%s'='%s" params="value, &quot;)&quot; * parenthesis, &quot;(&quot; * parenthesis, randStr, randStr + randomStr(1)"/>
</test>
<usage>
<prefix value="'"/>
<postfix format="'%s'='%s" params="randStr, randStr"/>
<prefix format="'%s " params="')' * parenthesis"/>
<postfix format=" AND %s'%s'='%s" params="'(' * parenthesis, randStr, randStr"/>
</usage>
</case>
<case name="likesingle" desc="LIKE single quoted string">
@ -37,8 +37,8 @@
<negative format="%s'%s AND %s'%s' LIKE '%s" params="value, &quot;)&quot; * parenthesis, &quot;(&quot; * parenthesis, randStr, randStr + randomStr(1)"/>
</test>
<usage>
<prefix value="'"/>
<postfix format="'%s' LIKE '%s" params="randStr, randStr"/>
<prefix format="'%s " params="')' * parenthesis"/>
<postfix format=" AND %s'%s' LIKE '%s" params="'(' * parenthesis, randStr, randStr"/>
</usage>
</case>
<case name="stringdouble" desc="double quoted string">
@ -47,8 +47,8 @@
<negative format="%s\&quot;%s AND %s\&quot;%s\&quot;=\&quot;%s" params="value, &quot;)&quot; * parenthesis, &quot;(&quot; * parenthesis, randStr, randStr + randomStr(1)"/>
</test>
<usage>
<prefix value="&quot;"/>
<postfix format="\&quot;%s\&quot;=\&quot;%s" params="randStr, randStr"/>
<prefix format="&quot;%s " params="')' * parenthesis"/>
<postfix format=" AND %s\&quot;%s\&quot;=\&quot;%s" params="'(' * parenthesis, randStr, randStr"/>
</usage>
</case>
<case name="likedouble" desc="LIKE double quoted string">
@ -57,8 +57,8 @@
<negative format="%s\&quot;%s AND %s\&quot;%s\&quot; LIKE \&quot;%s" params="value, &quot;)&quot; * parenthesis, &quot;(&quot; * parenthesis, randStr, randStr + randomStr(1)"/>
</test>
<usage>
<prefix value="&quot;"/>
<postfix format="\&quot;%s\&quot; LIKE \&quot;%s" params="randStr, randStr"/>
<prefix format="&quot;%s " params="')' * parenthesis"/>
<postfix format=" AND %s\&quot;%s\&quot; LIKE \&quot;%s" params="'(' * parenthesis, randStr, randStr"/>
</usage>
</case>
</root>