Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I recently came an assessment where an SQL injection was exploitable on a page that kept triggering a 302 return code. I used the
--ignore-redirectsswitch. However, for no obvious reasons at first, sqlmap failed to exploit the injection.Upon some quick investigation, here is the piece of code responsible for that behavior:
https://github.com/sqlmapproject/sqlmap/blob/master/lib/request/redirecthandler.py#L79
The
fp.readjust read the content of thefp.fpobjects which is of typeHTTPResponse(io.BufferedIOBase). However, in my context, this object is not truncable, seekable and is read only. Once read, it not readable again.I guess thats why the
finallyblock is important, it tries to reset the buffer for application code to parse its content again for sqlmap logic. However, in my case, thefp.fpobjects is set toNoneafter thefp.read([...])call. Moreover, even before it is being read, the ioBuffer does not allow truncating or similar operations that would result in the behavior of the try switch.Since the
truncate + writecode is from 13 years ago, I guess the under the hood objects of python have changed.The following pull request aims to solve that issue.
For context, the bug was encountered using both pypi package and the latest commit of sqlmap (6d4123c) on a debian 13 Trixie up-to-date: