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

Skip to content

Commit cf3b02e

Browse files
committed
Proper fix for #1053
1 parent 6972020 commit cf3b02e

2 files changed

Lines changed: 6 additions & 5 deletions

File tree

lib/core/common.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1564,8 +1564,8 @@ def safeStringFormat(format_, params):
15641564
"""
15651565
Avoids problems with inappropriate string format strings
15661566
1567-
>>> safeStringFormat('foobar%d%s', ('1', 2))
1568-
u'foobar12'
1567+
>>> safeStringFormat('SELECT foo FROM %s LIMIT %d', ('bar', '1'))
1568+
u'SELECT foo FROM bar LIMIT 1'
15691569
"""
15701570

15711571
if format_.count(PAYLOAD_DELIMITER) == 2:

tamper/unmagicquotes.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def tamper(payload, **kwargs):
2626
* http://shiflett.org/blog/2006/jan/addslashes-versus-mysql-real-escape-string
2727
2828
>>> tamper("1' AND 1=1")
29-
'1%bf%27 AND 1=1-- '
29+
'1%bf%27-- '
3030
"""
3131

3232
retVal = payload
@@ -44,9 +44,10 @@ def tamper(payload, **kwargs):
4444
continue
4545

4646
if found:
47-
_ = re.sub("(?i)\s*(AND|OR)[\s(]+'[^']+'\s*(=|LIKE)\s*'.*", "", retVal)
47+
_ = re.sub(r"(?i)\s*(AND|OR)[\s(]+([^\s]+)\s*(=|LIKE)\s*\2", "", retVal)
4848
if _ != retVal:
4949
retVal = _
5050
retVal += "-- "
51-
51+
elif not any(_ in retVal for _ in ('#', '--', '/*')):
52+
retVal += "-- "
5253
return retVal

0 commit comments

Comments
 (0)