sqlmap/tamper/sleep2getlock.py

40 lines
868 B
Python
Raw Permalink Normal View History

#!/usr/bin/env python
"""
2022-01-03 13:30:34 +03:00
Copyright (c) 2006-2022 sqlmap developers (https://sqlmap.org/)
See the file 'LICENSE' for copying permission
"""
2020-09-17 16:22:50 +03:00
from lib.core.data import kb
from lib.core.enums import PRIORITY
__priority__ = PRIORITY.HIGHEST
def dependencies():
pass
def tamper(payload, **kwargs):
"""
2020-09-17 16:26:06 +03:00
Replaces instances like 'SLEEP(5)' with (e.g.) "GET_LOCK('ETgP',5)"
Requirement:
* MySQL
Tested against:
* MySQL 5.0 and 5.5
Notes:
* Useful to bypass very weak and bespoke web application firewalls
that filter the SLEEP() and BENCHMARK() functions
* Reference: https://zhuanlan.zhihu.com/p/35245598
2020-09-17 16:26:06 +03:00
>>> tamper('SLEEP(5)') == "GET_LOCK('%s',5)" % kb.aliasName
2020-09-17 16:22:50 +03:00
True
"""
2020-09-17 16:22:50 +03:00
if payload:
2020-09-17 16:26:06 +03:00
payload = payload.replace("SLEEP(", "GET_LOCK('%s'," % kb.aliasName)
return payload