sqlmap/tamper/commalesslimit.py

41 lines
970 B
Python
Raw Normal View History

2019-03-21 16:00:09 +03:00
#!/usr/bin/env python2
2016-03-23 17:45:49 +03:00
"""
2019-01-05 23:38:52 +03:00
Copyright (c) 2006-2019 sqlmap developers (http://sqlmap.org/)
2017-10-11 15:50:46 +03:00
See the file 'LICENSE' for copying permission
2016-03-23 17:45:49 +03:00
"""
2018-02-10 13:06:31 +03:00
import os
2016-03-23 17:45:49 +03:00
import re
2018-02-08 18:49:16 +03:00
from lib.core.common import singleTimeWarnMessage
from lib.core.enums import DBMS
2016-03-23 17:45:49 +03:00
from lib.core.enums import PRIORITY
__priority__ = PRIORITY.HIGH
def dependencies():
2018-02-08 18:49:16 +03:00
singleTimeWarnMessage("tamper script '%s' is only meant to be run against %s" % (os.path.basename(__file__).split(".")[0], DBMS.MYSQL))
2016-03-23 17:45:49 +03:00
def tamper(payload, **kwargs):
"""
2018-07-31 02:17:11 +03:00
Replaces (MySQL) instances like 'LIMIT M, N' with 'LIMIT N OFFSET M' counterpart
2016-03-23 17:45:49 +03:00
Requirement:
* MySQL
Tested against:
* MySQL 5.0 and 5.5
>>> tamper('LIMIT 2, 3')
'LIMIT 3 OFFSET 2'
"""
retVal = payload
match = re.search(r"(?i)LIMIT\s*(\d+),\s*(\d+)", payload or "")
if match:
retVal = retVal.replace(match.group(0), "LIMIT %s OFFSET %s" % (match.group(2), match.group(1)))
return retVal