#!/usr/bin/env python

"""
Copyright (c) 2006-2024 sqlmap developers (https://sqlmap.org/)
See the file 'LICENSE' for copying permission
"""

# 导入正则表达式模块
import re

# 从lib.core.enums模块中导入PRIORITY枚举
from lib.core.enums import PRIORITY

# 定义最低优先级
__priority__ = PRIORITY.LOWEST

# 定义依赖函数
def dependencies():
    pass

def tamper(payload, **kwargs):
    """
    Replaces AND and OR logical operators with their symbolic counterparts (&& and ||)

    >>> tamper("1 AND '1'='1")
    "1 %26%26 '1'='1"
    """

    retVal = payload

    # 如果payload不为空，则将payload中的AND替换为%26%26，将OR替换为%7C%7C
    if payload:
        retVal = re.sub(r"(?i)\bAND\b", "%26%26", re.sub(r"(?i)\bOR\b", "%7C%7C", payload))

    return retVal
