LogicalTrust / BurpHttpMock

MIT License
16 stars 11 forks source link

How to mock (load in the response) binary files #6

Closed LaiKash closed 2 years ago

LaiKash commented 2 years ago

Hi!

This is not in fact an issue, I think. How can I insert a binary file (for example, an image) in the mocked response? The image could have code (steganography). Is there an option to load a file in the response?

Thanks!

mmmds commented 2 years ago

Hi @LaiKash , you can use "File contents" mock type to achieve it. First, you need to create a file with a full HTTP response with an image (or any other file).

filename="image.png"
echo -n -e "HTTP/1.1 200 OK\r\nContent-type: image/png\r\nContent-length: $(stat --printf=%s $filename)\r\n\r\n" > /tmp/response.txt
cat $filename >> /tmp/response.txt

Then, you need to modify the mock rule by

LaiKash commented 2 years ago

Hi @mmmds thanks a lot. That's how it works the "Redirect to URL" option too, I suppose. Can some kind of explanation about how to use these options be added to the README? I think this is not intuitive to use at first. It would be great!

Thanks again, feel free to close the issue.

mmmds commented 2 years ago

Readme updated to my best knowledge at this moment.