2010-10-14 18:05:05 +04:00
|
|
|
#!/usr/bin/env python
|
|
|
|
|
2010-10-14 18:41:14 +04:00
|
|
|
"""
|
|
|
|
$Id$
|
2010-10-14 19:13:36 +04:00
|
|
|
|
|
|
|
Copyright (c) 2006-2010 sqlmap developers (http://sqlmap.sourceforge.net/)
|
2010-10-15 03:18:29 +04:00
|
|
|
See the file 'doc/COPYING' for copying permission
|
2010-10-14 18:41:14 +04:00
|
|
|
"""
|
2010-10-14 18:02:43 +04:00
|
|
|
|
2010-11-04 13:29:40 +03:00
|
|
|
from lib.core.priority import PRIORITY
|
|
|
|
|
|
|
|
__priority__ = PRIORITY.LOW
|
|
|
|
|
2010-10-29 20:11:50 +04:00
|
|
|
def tamper(value):
|
2010-10-17 01:33:15 +04:00
|
|
|
"""
|
|
|
|
Replaces ' ' with '/**/'
|
2010-11-04 11:03:59 +03:00
|
|
|
Example: 'SELECT id FROM users' becomes 'SELECT/**/id/**/FROM/**/users'
|
2010-10-17 01:33:15 +04:00
|
|
|
"""
|
|
|
|
|
2010-10-14 15:06:28 +04:00
|
|
|
retVal = value
|
2010-10-14 18:02:43 +04:00
|
|
|
|
2010-10-13 18:27:35 +04:00
|
|
|
if value:
|
2010-10-14 15:06:28 +04:00
|
|
|
retVal = ""
|
2010-10-17 01:33:15 +04:00
|
|
|
quote, doublequote, firstspace = False, False, False
|
2010-10-14 15:06:28 +04:00
|
|
|
|
|
|
|
for i in xrange(len(value)):
|
|
|
|
if not firstspace:
|
2010-10-14 15:12:03 +04:00
|
|
|
if value[i].isspace():
|
|
|
|
firstspace = True
|
|
|
|
retVal += "/**/"
|
|
|
|
continue
|
2010-10-14 18:02:43 +04:00
|
|
|
|
2010-10-14 15:06:28 +04:00
|
|
|
elif value[i] == '\'':
|
2010-10-17 01:33:15 +04:00
|
|
|
quote = not quote
|
2010-10-14 18:02:43 +04:00
|
|
|
|
2010-10-14 15:06:28 +04:00
|
|
|
elif value[i] == '"':
|
|
|
|
doublequote = not doublequote
|
2010-10-14 18:02:43 +04:00
|
|
|
|
2010-10-17 01:33:15 +04:00
|
|
|
elif value[i]==" " and not doublequote and not quote:
|
2010-10-14 15:06:28 +04:00
|
|
|
retVal += "/**/"
|
|
|
|
continue
|
2010-10-14 18:02:43 +04:00
|
|
|
|
2010-10-14 15:06:28 +04:00
|
|
|
retVal += value[i]
|
|
|
|
|
|
|
|
return retVal
|
|
|
|
|