-
-
Notifications
You must be signed in to change notification settings - Fork 6k
Update inference.py #5953
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
Update inference.py #5953
Conversation
… On Sun, Aug 31, 2025, 19:15 ***@***.*** ***@***.***> wrote:
SQLMap Dictionary Similarity Feature Feature Description
This feature adds intelligent dictionary matching capability to sqlmap's
blind injection. When the partially inferred string during blind injection
has high similarity with common database/table names in the dictionary, it
will directly test the complete dictionary item, greatly saving blind
injection time.
How It Works
1. *Similarity Check*: During blind injection, when at least 3
characters are inferred, it checks similarity with dictionary items
2. *Threshold Judgment*: If similarity exceeds 0.8 (configurable), it
attempts to test the complete dictionary item
3. *Fast Matching*: If the test succeeds, it directly returns the
complete result, skipping remaining character inference
Usage 1. Dictionary Files
The feature automatically selects the appropriate dictionary based on the
query type:
- *Tables/Databases*: Uses data/txt/common-tables.txt for table and
database name inference
- *Columns*: Uses data/txt/common-columns.txt for column name inference
These files already contain common database, table, and column names. You
can add more entries to these files if needed.
2. Normal sqlmap Usage
The feature is automatically enabled without additional parameters. When
blind injection encounters content similar to dictionary items, it will
display information like:
[INFO] checking tables dictionary similarity for 'info' (similarity: 0.90)
[INFO] Tables dictionary match successful: 'information_schema'
[INFO] checking columns dictionary similarity for 'user' (similarity: 0.85)
[INFO] Columns dictionary match successful: 'username'
Configuration Options Similarity Threshold
You can modify the similarity threshold in
lib/techniques/blind/inference.py:
# Similarity threshold for dictionary matchingSIMILARITY_THRESHOLD = 0.8 # Can be adjusted between 0.7-0.9
Minimum Character Count
By default, similarity check is only performed when at least 3 characters
are inferred. You can modify this in the code:
if len(partialValue) >= 3: # Can be adjusted between 2-5
Advantages
1. *Significant Time Savings*: For common database/table names, can
save over 90% of blind injection time
2. *Intelligent Matching*: Uses sequence matching algorithm to handle
partial and similar matches
3. *Prefix Priority*: Gives higher weight to prefix matches, improving
accuracy
4. *Backward Compatibility*: Does not affect existing blind injection
functionality, only adds optimization
Example Scenarios Scenario 1: Inferring Database Name
- Blind injection inference: info -> information_schema
- Time saved: Reduced from 15 character inferences to 4 character
inferences
Scenario 2: Inferring Table Name
- Blind injection inference: user -> users
- Time saved: Reduced from 5 character inferences to 4 character
inferences
Scenario 3: Inferring Admin Table
- Blind injection inference: adm -> admin
- Time saved: Reduced from 5 character inferences to 3 character
inferences
Scenario 4: Inferring Column Names
- Blind injection inference: user -> username
- Time saved: Reduced from 8 character inferences to 4 character
inferences
Notes
1. *Dictionary Quality*: The quality of the dictionary file directly
affects matching effectiveness
2. *False Matches*: If the dictionary contains irrelevant items, it
may cause false matches
3. *Performance Impact*: Similarity checking brings minimal
performance overhead, but the time saved is worth it
Troubleshooting Dictionary File Not Found
Ensure data/txt/common-tables.txt and data/txt/common-columns.txt files
exist and are readable
Similarity Check Not Working
Check if there are "checking dictionary similarity" messages in the logs
Match Failure
Try lowering the similarity threshold or adding more relevant items to the
appropriate dictionary file
Technical Implementation
- *Similarity Algorithm*: Uses Python's difflib.SequenceMatcher
- *Integration Location*: lib/techniques/blind/inference.py
- *Supported Modes*: Single-threaded and multi-threaded blind injection
- *Caching Mechanism*: Dictionary content is cached for performance
------------------------------
You can view, comment on, or merge this pull request online at:
#5953
Commit Summary
- bb1120d
<bb1120d>
Update inference.py
File Changes
(1 file <https://github.com/sqlmapproject/sqlmap/pull/5953/files>)
- *M* lib/techniques/blind/inference.py
<https://github.com/sqlmapproject/sqlmap/pull/5953/files#diff-3cb530f971e849ea54d25211720d753f4f8c769d58100cbd7c90f980b9ae87a1>
(193)
Patch Links:
- https://github.com/sqlmapproject/sqlmap/pull/5953.patch
- https://github.com/sqlmapproject/sqlmap/pull/5953.diff
—
Reply to this email directly, view it on GitHub
<#5953>, or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAHA7U5EW2YNBL6WZXGYLRD3QMUUZAVCNFSM6AAAAACFIOEK3WVHI2DSMVQWIX3LMV43ASLTON2WKOZTGM3TANJQGY3TCNI>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
The --predict-output parameter allows only 1 thread, and there is no similarity match, only prefix matching. |
i am not really convinced in this all. based on 3 characters if there is
0.8 similarity you do a guess. this is prone to fubar due to loads of cache
misses. i dont see this usable in real world scenarios. you will just send
tons of equal check requests provoking tons of misses. like, if there is
"use" you will just send "user" in hope that there is a user at the other
end
…On Mon, Sep 1, 2025, 13:56 ***@***.*** ***@***.***> wrote:
*kn1g78* left a comment (sqlmapproject/sqlmap#5953)
<#5953 (comment)>
https://github.com/sqlmapproject/sqlmap/wiki/usage#output-prediction
… <#m_-3157782063329569616_>
On Sun, Aug 31, 2025, 19:15 *@*.*** *@*.*> wrote: SQLMap Dictionary
Similarity Feature Feature Description This feature adds intelligent
dictionary matching capability to sqlmap's blind injection. When the
partially inferred string during blind injection has high similarity with
common database/table names in the dictionary, it will directly test the
complete dictionary item, greatly saving blind injection time. How It Works
1. Similarity Check: During blind injection, when at least 3 characters are
inferred, it checks similarity with dictionary items 2. Threshold Judgment:
If similarity exceeds 0.8 (configurable), it attempts to test the complete
dictionary item 3. Fast Matching: If the test succeeds, it directly returns
the complete result, skipping remaining character inference Usage 1.
Dictionary Files The feature automatically selects the appropriate
dictionary based on the query type: - Tables/Databases: Uses
data/txt/common-tables.txt for table and database name inference - Columns:
Uses data/txt/common-columns.txt for column name inference These files
already contain common database, table, and column names. You can add more
entries to these files if needed. 2. Normal sqlmap Usage The feature is
automatically enabled without additional parameters. When blind injection
encounters content similar to dictionary items, it will display information
like: [INFO] checking tables dictionary similarity for 'info' (similarity:
0.90) [INFO] Tables dictionary match successful: 'information_schema'
[INFO] checking columns dictionary similarity for 'user' (similarity: 0.85)
[INFO] Columns dictionary match successful: 'username' Configuration
Options Similarity Threshold You can modify the similarity threshold in
lib/techniques/blind/inference.py: # Similarity threshold for dictionary
matchingSIMILARITY_THRESHOLD = 0.8 # Can be adjusted between 0.7-0.9
Minimum Character Count By default, similarity check is only performed when
at least 3 characters are inferred. You can modify this in the code: if
len(partialValue) >= 3: # Can be adjusted between 2-5 Advantages 1.
Significant Time Savings: For common database/table names, can save over
90% of blind injection time 2. Intelligent Matching: Uses sequence matching
algorithm to handle partial and similar matches 3. Prefix Priority: Gives
higher weight to prefix matches, improving accuracy 4. Backward
Compatibility: Does not affect existing blind injection functionality, only
adds optimization Example Scenarios Scenario 1: Inferring Database Name -
Blind injection inference: info -> information_schema - Time saved: Reduced
from 15 character inferences to 4 character inferences Scenario 2:
Inferring Table Name - Blind injection inference: user -> users - Time
saved: Reduced from 5 character inferences to 4 character inferences
Scenario 3: Inferring Admin Table - Blind injection inference: adm -> admin
- Time saved: Reduced from 5 character inferences to 3 character inferences
Scenario 4: Inferring Column Names - Blind injection inference: user ->
username - Time saved: Reduced from 8 character inferences to 4 character
inferences Notes 1. Dictionary Quality: The quality of the dictionary file
directly affects matching effectiveness 2. False Matches: If the dictionary
contains irrelevant items, it may cause false matches 3. Performance
Impact: Similarity checking brings minimal performance overhead, but the
time saved is worth it Troubleshooting Dictionary File Not Found Ensure
data/txt/common-tables.txt and data/txt/common-columns.txt files exist and
are readable Similarity Check Not Working Check if there are "checking
dictionary similarity" messages in the logs Match Failure Try lowering the
similarity threshold or adding more relevant items to the appropriate
dictionary file Technical Implementation - Similarity Algorithm: Uses
Python's difflib.SequenceMatcher - Integration Location:
lib/techniques/blind/inference.py - Supported Modes: Single-threaded and
multi-threaded blind injection - Caching Mechanism: Dictionary content is
cached for performance ------------------------------ You can view, comment
on, or merge this pull request online at: #5953
<#5953> Commit Summary -
bb1120d
<bb1120d>
<bb1120d
<bb1120d>>
Update inference.py File Changes (1 file
https://github.com/sqlmapproject/sqlmap/pull/5953/files
<https://github.com/sqlmapproject/sqlmap/pull/5953/files>) - M
lib/techniques/blind/inference.py
https://github.com/sqlmapproject/sqlmap/pull/5953/files#diff-3cb530f971e849ea54d25211720d753f4f8c769d58100cbd7c90f980b9ae87a1
<https://github.com/sqlmapproject/sqlmap/pull/5953/files#diff-3cb530f971e849ea54d25211720d753f4f8c769d58100cbd7c90f980b9ae87a1>
(193) Patch Links: -
https://github.com/sqlmapproject/sqlmap/pull/5953.patch
<https://github.com/sqlmapproject/sqlmap/pull/5953.patch> -
https://github.com/sqlmapproject/sqlmap/pull/5953.diff
<https://github.com/sqlmapproject/sqlmap/pull/5953.diff> — Reply to this
email directly, view it on GitHub <#5953
<#5953>>, or unsubscribe
https://github.com/notifications/unsubscribe-auth/AAHA7U5EW2YNBL6WZXGYLRD3QMUUZAVCNFSM6AAAAACFIOEK3WVHI2DSMVQWIX3LMV43ASLTON2WKOZTGM3TANJQGY3TCNI
<https://github.com/notifications/unsubscribe-auth/AAHA7U5EW2YNBL6WZXGYLRD3QMUUZAVCNFSM6AAAAACFIOEK3WVHI2DSMVQWIX3LMV43ASLTON2WKOZTGM3TANJQGY3TCNI>
. You are receiving this because you are subscribed to this thread.Message
ID: @.*>
The --predict-output parameter allows only 1 thread, and there is no
similarity match, only prefix matching.
—
Reply to this email directly, view it on GitHub
<#5953 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAHA7U2YL3TWDRND57LQ23D3QQYALAVCNFSM6AAAAACFIOEK3WVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZTENBSGA4DKNBTHA>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
u r right. |
SQLMap Dictionary Similarity Feature
Feature Description
This feature adds intelligent dictionary matching capability to sqlmap's blind injection. When the partially inferred string during blind injection has high similarity with common database/table names in the dictionary, it will directly test the complete dictionary item, greatly saving blind injection time.
How It Works
Usage
1. Dictionary Files
The feature automatically selects the appropriate dictionary based on the query type:
data/txt/common-tables.txt
for table and database name inferencedata/txt/common-columns.txt
for column name inferenceThese files already contain common database, table, and column names. You can add more entries to these files if needed.
2. Normal sqlmap Usage
The feature is automatically enabled without additional parameters. When blind injection encounters content similar to dictionary items, it will display information like:
Configuration Options
Similarity Threshold
You can modify the similarity threshold in
lib/techniques/blind/inference.py
:Minimum Character Count
By default, similarity check is only performed when at least 3 characters are inferred. You can modify this in the code:
Advantages
Example Scenarios
Scenario 1: Inferring Database Name
info
->information_schema
Scenario 2: Inferring Table Name
user
->users
Scenario 3: Inferring Admin Table
adm
->admin
Scenario 4: Inferring Column Names
user
->username
Notes
Troubleshooting
Dictionary File Not Found
Ensure
data/txt/common-tables.txt
anddata/txt/common-columns.txt
files exist and are readableSimilarity Check Not Working
Check if there are "checking dictionary similarity" messages in the logs
Match Failure
Try lowering the similarity threshold or adding more relevant items to the appropriate dictionary file
Technical Implementation