sqlmap icon indicating copy to clipboard operation
sqlmap copied to clipboard

Send raw binary data to `postprocess` function

Open elliot-kaplan opened this issue 1 year ago • 0 comments

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

elliot-kaplan avatar May 02 '24 15:05 elliot-kaplan