Skip to content

Commit

Permalink
Minor refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
stamparm committed Jul 23, 2012
1 parent b820975 commit 7f4fa7c
Show file tree
Hide file tree
Showing 11 changed files with 23 additions and 23 deletions.
2 changes: 1 addition & 1 deletion tamper/apostrophemask.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@ def tamper(payload):
* http://lukasz.pilorz.net/testy/full_width_utf/index.phps
"""

return payload.replace('\'', '%EF%BC%87') if payload else payload
return payload.replace('\'', "%EF%BC%87") if payload else payload
2 changes: 1 addition & 1 deletion tamper/apostrophenullencode.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ def tamper(payload):
* Output: AND %00%271%00%27=%00%271%00%27
"""

return payload.replace('\'', '%00%27') if payload else payload
return payload.replace('\'', "%00%27") if payload else payload
2 changes: 1 addition & 1 deletion tamper/chardoubleencode.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def tamper(payload):
retVal += payload[i:i+3]
i += 3
else:
retVal += '%%25%X' % ord(payload[i])
retVal += '%%25%.2X' % ord(payload[i])
i += 1

return retVal
2 changes: 1 addition & 1 deletion tamper/charencode.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def tamper(payload):
retVal += payload[i:i+3]
i += 3
else:
retVal += '%%%X' % ord(payload[i])
retVal += '%%%.2X' % ord(payload[i])
i += 1

return retVal
2 changes: 1 addition & 1 deletion tamper/charunicodeencode.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def tamper(payload):
retVal += "%%u00%s" % payload[i+1:i+3]
i += 3
else:
retVal += '%%u00%X' % ord(payload[i])
retVal += '%%u%.4X' % ord(payload[i])
i += 1

return retVal
2 changes: 1 addition & 1 deletion tamper/equaltolike.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def tamper(payload):

def process(match):
word = match.group()
word = "%sLIKE%s" % (" " if word[0]!=" " else "", " " if word[-1]!=" " else "")
word = "%sLIKE%s" % (" " if word[0] != " " else "", " " if word[-1] != " " else "")

return word

Expand Down
16 changes: 8 additions & 8 deletions tamper/ifnull2ifisnull.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,27 +36,27 @@ def tamper(payload):
if payload and payload.find("IFNULL") > -1:
while payload.find("IFNULL(") > -1:
index = payload.find("IFNULL(")
deepness = 1
depth = 1
comma, end = None, None

for i in xrange(index + len("IFNULL("), len(payload)):
if deepness == 1 and payload[i] == ',':
if depth == 1 and payload[i] == ',':
comma = i

elif deepness == 1 and payload[i] == ')':
elif depth == 1 and payload[i] == ')':
end = i
break

elif payload[i] == '(':
deepness += 1
depth += 1

elif payload[i] == ')':
deepness -= 1
depth -= 1

if comma and end:
A = payload[index + len("IFNULL("):comma]
B = payload[comma + 1:end]
newVal = "IF(ISNULL(%s),%s,%s)" % (A, B, A)
_ = payload[index + len("IFNULL("):comma]
__ = payload[comma + 1:end]
newVal = "IF(ISNULL(%s),%s,%s)" % (_, __, _)
payload = payload[:index] + newVal + payload[end+1:]
else:
break
Expand Down
6 changes: 3 additions & 3 deletions tamper/randomcase.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ def tamper(payload):
word = match.group()

if word.upper() in kb.keywords:
newWord = str()
_ = str()

for i in xrange(len(word)):
newWord += word[i].upper() if randomRange(0, 1) else word[i].lower()
_ += word[i].upper() if randomRange(0, 1) else word[i].lower()

retVal = retVal.replace(word, newWord)
retVal = retVal.replace(word, _)

return retVal
8 changes: 4 additions & 4 deletions tamper/randomcomments.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ def tamper(payload):
continue

if word.upper() in kb.keywords:
newWord = word[0]
_ = word[0]

for i in xrange(1, len(word) - 1):
newWord += "%s%s" % ("/**/" if randomRange(0, 1) else "", word[i])
_ += "%s%s" % ("/**/" if randomRange(0, 1) else "", word[i])

newWord += word[-1]
retVal = retVal.replace(word, newWord)
_ += word[-1]
retVal = retVal.replace(word, _)

return retVal
2 changes: 1 addition & 1 deletion tamper/space2mssqlblank.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def tamper(payload):
# CR 0D carriage return
# SO 0E shift out
# SI 0F shift in
blanks = ['%01', '%02', '%03', '%04', '%05', '%06', '%07', '%08', '%09', '%0B', '%0C', '%0D', '%0E', '%0F', '%0A']
blanks = ('%01', '%02', '%03', '%04', '%05', '%06', '%07', '%08', '%09', '%0B', '%0C', '%0D', '%0E', '%0F', '%0A')
retVal = payload

if payload:
Expand Down
2 changes: 1 addition & 1 deletion tamper/space2mysqlblank.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def tamper(payload):
# CR 0D carriage return
# VT 0B vertical TAB (MySQL and Microsoft SQL Server only)
# - A0 - (MySQL only)
blanks = ['%09', '%0A', '%0C', '%0D', '%0B', '%A0']
blanks = ('%09', '%0A', '%0C', '%0D', '%0B', '%A0')
retVal = payload

if payload:
Expand Down

0 comments on commit 7f4fa7c

Please sign in to comment.