From 074fbbcea51d50c3065102d27b29fea4d542cd3b Mon Sep 17 00:00:00 2001 From: Miroslav Stampar Date: Wed, 23 Mar 2016 15:45:49 +0100 Subject: [PATCH] Implementation for an Issue #1776 --- lib/core/settings.py | 2 +- tamper/commalesslimit.py | 39 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 tamper/commalesslimit.py diff --git a/lib/core/settings.py b/lib/core/settings.py index 8aaaef5df..040b1b71b 100644 --- a/lib/core/settings.py +++ b/lib/core/settings.py @@ -20,7 +20,7 @@ from lib.core.enums import OS from lib.core.revision import getRevisionNumber # sqlmap version (...) -VERSION = "1.0.3.7" +VERSION = "1.0.3.8" REVISION = getRevisionNumber() STABLE = VERSION.count('.') <= 2 VERSION_STRING = "sqlmap/%s#%s" % (VERSION, "stable" if STABLE else "dev") diff --git a/tamper/commalesslimit.py b/tamper/commalesslimit.py new file mode 100644 index 000000000..570c2ebdf --- /dev/null +++ b/tamper/commalesslimit.py @@ -0,0 +1,39 @@ +#!/usr/bin/env python + +""" +Copyright (c) 2006-2016 sqlmap developers (http://sqlmap.org/) +See the file 'doc/COPYING' for copying permission +""" + +import os +import re + +from lib.core.common import singleTimeWarnMessage +from lib.core.enums import PRIORITY + +__priority__ = PRIORITY.HIGH + +def dependencies(): + pass + +def tamper(payload, **kwargs): + """ + Replaces instances like 'LIMIT M, N' with 'LIMIT N OFFSET M' + + 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