Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
sqlmapproject
GitHub Repository: sqlmapproject/sqlmap
Path: blob/master/tamper/commalesslimit.py
2983 views
1
#!/usr/bin/env python
2
3
"""
4
Copyright (c) 2006-2025 sqlmap developers (https://sqlmap.org)
5
See the file 'LICENSE' for copying permission
6
"""
7
8
import os
9
import re
10
11
from lib.core.common import singleTimeWarnMessage
12
from lib.core.enums import DBMS
13
from lib.core.enums import PRIORITY
14
15
__priority__ = PRIORITY.HIGH
16
17
def dependencies():
18
singleTimeWarnMessage("tamper script '%s' is only meant to be run against %s" % (os.path.basename(__file__).split(".")[0], DBMS.MYSQL))
19
20
def tamper(payload, **kwargs):
21
"""
22
Replaces (MySQL) instances like 'LIMIT M, N' with 'LIMIT N OFFSET M' counterpart
23
24
Requirement:
25
* MySQL
26
27
Tested against:
28
* MySQL 5.0 and 5.5
29
30
>>> tamper('LIMIT 2, 3')
31
'LIMIT 3 OFFSET 2'
32
"""
33
34
retVal = payload
35
36
match = re.search(r"(?i)LIMIT\s*(\d+),\s*(\d+)", payload or "")
37
if match:
38
retVal = retVal.replace(match.group(0), "LIMIT %s OFFSET %s" % (match.group(2), match.group(1)))
39
40
return retVal
41
42