Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
pinoyvendetta wants to merge3 commits intosqlmapproject:master
base:master
Choose a base branch
Loading
frompinoyvendetta:pv-sqlmap

Conversation

@pinoyvendetta
Copy link

@pinoyvendettapinoyvendetta commentedJul 1, 2025
edited
Loading

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:

    1UNIONSELECT GROUP_CONCAT(table_name)FROMINFORMATION_SCHEMA.TABLESWHERE table_schema= database()
  • After:

    1/*!50000UNION*//*!50000SELECT*//*!50000GROUP_CONCAT*/(/*!50000table_name*/)/*!50000FROM*//*!50000INFORMATION_SCHEMA.TABLES*//*!50000WHERE*//*!50000table_schema*/=/*!50000database()*/

This addition provides another valuable tool for penetration testers to use when faced with filtered environments.

Replaces common SQL keywords with MySQL versioned comments (e.g., 'SELECT' becomes '/*!50000SELECT*/').
sorted_keywords = sorted(keywords.keys(), key=len, reverse=True)

for keyword in sorted_keywords:
if "()" in keyword:
Copy link
Contributor

@tanaydintanaydinJul 14, 2025
edited
Loading

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Yes, Please improve it.

Copy link
Contributor

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Done. Please review. :)

ret_val = payload

if payload:
sorted_keywords = sorted(keywords.keys(), key=len, reverse=True)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

why sorting?

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

1 more reviewer

@tanaydintanaydintanaydin left review comments

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

2 participants

@pinoyvendetta@tanaydin

[8]ページ先頭

©2009-2025 Movatter.jp