Skip to content
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

Send raw binary data to postprocess function #5700

Closed
elliot-kaplan opened this issue May 2, 2024 · 1 comment
Closed

Send raw binary data to postprocess function #5700

elliot-kaplan opened this issue May 2, 2024 · 1 comment
Assignees
Milestone

Comments

@elliot-kaplan
Copy link

elliot-kaplan commented May 2, 2024

Is your feature request related to a problem? Please describe.
The "page" value sent to the postprocess function is encoded as a string that I have not been able to decode into the original byte value within the postprocess function. If I take the string and encode it as utf-8, any byte value between 0x80 and 0xff gets mangled

u't\xe8ststring'.encode('iso-8859-1') -> b't\xc3\xa8ststring'

if I take the string and try to encode it as 'iso-8859-1' . I inevitably get a ('UnicodeEncodeError: ordinal not in range(256)') error.

Describe the solution you'd like
I would like some way of getting the raw, binary response data out of the request response so that I have greater flexibility in processing the response data.

Describe alternatives you've considered
I've been trying to find where in the sqlmap codebase the pages are being converted to unicode so that I can manually switch the encoding to iso-8859-1, this hasn't been working and wouldn't be applicable for anyone else.

The workaround that I went with was to introduce the unzip logic through a burp extension (i.e. editing the HTTP response before it gets to sqlmap at all. Nonetheless I feel that there should be a mechanism to enable binary processing within a postprocess routine.

Additional context
The specific context that I need this for is an endpoint that returns xlsx files. My plan was to use ZipFile and BytesIO to convert the output to string via

zipfile = ZipFile(BytesIO(bytes(page, 'iso-8859-1')))
page = b''.join(zipfile.read(f) for f in zipfile.filelist).decode('iso-8859-1')

This specific context cannot be unique to this single application, so l expect to run into these issues again

stamparm added a commit that referenced this issue May 9, 2024
@stamparm stamparm self-assigned this May 9, 2024
@stamparm stamparm added this to the 1.9 milestone May 9, 2024
@stamparm stamparm closed this as completed May 9, 2024
@stamparm
Copy link
Member

stamparm commented May 9, 2024

@elliot-kaplan with the latest revision, raw page will be passed to the postprocess functions. Afterwards, it will be converted to the unicode (for later processing with sqlmap)

i think it makes sense to give it as raw (non-Unicode) for people to work on raw data

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants