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

Skip to content

Commit 1b3b916

Browse files
committed
update of tampering modules
1 parent f700692 commit 1b3b916

4 files changed

Lines changed: 54 additions & 6 deletions

File tree

tamper/charencode.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import re
2+
import string
3+
4+
from lib.core.convert import urlencode
5+
from lib.core.exception import sqlmapUnsupportedFeatureException
6+
7+
"""
8+
value -> urlencode of nonencoded chars in value
9+
"""
10+
def tamper(place, value):
11+
retVal = value
12+
if value:
13+
if place != "URI":
14+
retVal = ""
15+
i = 0
16+
while i < len(value):
17+
if value[i] == '%' and (i < len(value) - 2) and value[i+1] in string.hexdigits and value[i+2] in string.hexdigits:
18+
retVal += value[i:i+3]
19+
i += 3
20+
else:
21+
retVal += '%%%X' % ord(value[i])
22+
i += 1
23+
else:
24+
raise sqlmapUnsupportedFeatureException, "can't use tampering module 'charencode.py' with 'URI' type injections"
25+
return retVal

tamper/ifnull2ifisnull.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from lib.core.convert import urlencode
55

66
"""
7-
Tampering IFNULL(A,B) -> IF(ISNULL(A),B,A)
7+
IFNULL(A,B) -> IF(ISNULL(A),B,A)
88
"""
99
def tamper(place, value):
1010
if value and value.find("IFNULL") > -1:
@@ -25,10 +25,13 @@ def tamper(place, value):
2525
deepness += 1
2626
elif value[i] == ')':
2727
deepness -= 1
28-
A = value[index + len("IFNULL("):comma]
29-
B = value[comma + 1:end]
30-
newVal = "IF(ISNULL(%s),%s,%s)" % (A, B, A)
31-
value = value[:index] + newVal + value[end+1:]
28+
if comma and end:
29+
A = value[index + len("IFNULL("):comma]
30+
B = value[comma + 1:end]
31+
newVal = "IF(ISNULL(%s),%s,%s)" % (A, B, A)
32+
value = value[:index] + newVal + value[end+1:]
33+
else:
34+
break
3235
if place != "URI":
3336
value = urlencode(value)
3437
return value

tamper/randomcase.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import re
2+
import string
3+
4+
from lib.core.convert import urlencode
5+
from lib.core.common import randomRange
6+
from lib.core.exception import sqlmapUnsupportedFeatureException
7+
8+
"""
9+
value -> random case of chars in value
10+
"""
11+
def tamper(place, value):
12+
retVal = value
13+
if value:
14+
retVal = ""
15+
for i in xrange(len(value)):
16+
if value[i].isalpha():
17+
retVal += value[i].upper() if randomRange(0,1) else value[i].lower()
18+
else:
19+
retVal += value[i]
20+
return retVal

tamper/space2comment.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from lib.core.convert import urlencode
55

66
"""
7-
Tampering ' ' -> /**/
7+
' ' -> /**/
88
"""
99
def tamper(place, value):
1010
if value:

0 commit comments

Comments
 (0)