-
-
Notifications
You must be signed in to change notification settings - Fork 6k
Add new tamper script 'mysqlversioncomment.py' #5923
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
Replaces common SQL keywords with MySQL versioned comments (e.g., 'SELECT' becomes '/*!50000SELECT*/').
tamper/mysqlversioncomment.py
Outdated
sorted_keywords = sorted(keywords.keys(), key=len, reverse=True) | ||
|
||
for keyword in sorted_keywords: | ||
if "()" in keyword: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can simplify like
ret_val = re.sub(r"(?i)\b%s\b" % re.escape(keyword), keywords[keyword], ret_val)
you are always escaping, or add escaped strings for substitution which is faster
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, Please improve it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please check my merge request
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. Please review. :)
tamper/mysqlversioncomment.py
Outdated
ret_val = payload | ||
|
||
if payload: | ||
sorted_keywords = sorted(keywords.keys(), key=len, reverse=True) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why sorting?
Description
This pull request introduces a new tamper script,
mysqlversioncomment.py
, designed to obfuscate SQL injection payloads targeting MySQL databases. The script wraps a comprehensive list of common SQL keywords, functions, and information schema objects within MySQL-specific versioned comments (e.g.,/*!50000KEYWORD*/
).This obfuscation technique is effective at bypassing basic Web Application Firewalls (WAFs) and Intrusion Detection Systems (IDS) that perform simple keyword filtering without correctly parsing MySQL's versioned comment syntax.
How it Works
The script iterates through a predefined list of keywords and functions. To ensure correctness, it replaces longer keywords first (e.g.,
GROUP BY
beforeBY
) and uses word boundaries to prevent accidental replacement of substrings within other words.Example of transformation:
Before:
After:
This addition provides another valuable tool for penetration testers to use when faced with filtered environments.