How to intercept multipart/form data in fiddler and access a binary file which is a part of the request - fiddler

I am trying to intercept requests send to a server from my mobile device. There is this post request which will upload payload to the server and the request has a file of type .pb, which i cant read in fiddler. Is there a way to get hold of the file ?

It's not clear what "i cant read in fiddler" means.
Use Fiddler's HexView request inspector to inspect the POST body. You can select the bytes of the file upload and choose Save bytes to save the file out to your desktop.

Related

Can I mirror request data with Charles Proxy?

The mirror feature in Charles Proxy saves the responses -- I want to see the requests that are made for the corresponding saved response outside of the Charles UI so that I can programmatically match some of the data in the request to the response.
For instance, I might have a request to mysite.com/data?param=123 that results in the file data with the response value {"param": 123}. Then I might have another request mysite.com/data?param=456 and the same file data with a different response value.
I want to match the original request to the saved response.
You can use the Auto Save feature of Charles.
In "Charles - Tools - Auto Save", enable this feature and take "Save type" as "JSON Session File":
Then, all requests and corresponding responses will be saved as JSON data, which is pretty good for programming.

Gmail Api Resumable attachment. (Rest)

Does anyone has any example of Gmail Api resumable uploading(for attachments). I succeeded using the main upload for attachments up to 5 MB but I would like to send attachments over 30 MB.I cant use gmail SDK to everything needs to be in Rest Any suggestions?
Gmail API Resumable Upload
The steps for using resumable upload include:
Step 1: Start a resumable session
To initiate a resumable upload, make a POST or PUT request to the method's /upload URI and add the query parameter uploadType=resumable, for example:
POST https://www.googleapis.com/upload/gmail/v1/users/userId/messages/send?uploadType=resumable
For this initiating request, the body is either empty or it contains the metadata only; you'll transfer the actual contents of the file you want to upload in subsequent requests.
Step 2: Save the resumable session URI
If the session initiation request succeeds, the API server responds with a 200 OK HTTP status code. In addition, it provides a Location header that specifies your resumable session URI. The Location header, shown in the example below, includes an upload_id query parameter portion that gives the unique upload ID to use for this session.
Example: Resumable session initiation response
Here is the response to the request in Step 1:
HTTP/1.1 200 OK
Location: https://www.googleapis.com/upload/gmail/v1/users/userId/messages/send?uploadType=resumable&upload_id=xa298sd_sdlkj2
Content-Length: 0
Step 3: Upload the file
To upload the file, send a PUT request to the upload URI that you obtained in the previous step. The format of the upload request is:
PUT session_uri
Full code implementation sample is in the docs.
you need upload PUT method
but not binary body, only use multipart form body

specify response for fiddler core

I use fiddler core to intercept the request and provide a response to it. I know its possible to use saz files to save the response. But the problem is that I need to be able to customize the response. While its a saz file I cant customize the response manually.
Is there a way to save response caught by fiddler to a text file in json like format, so that I could edit it and could serve it as response to any request using fiddler core? For now i see I can save response as a plain text. But how do I load this request to fiddler or parse it with fiddler core to populate all the response properties? Is there some format I could use, that will allow me to manually edit the response?
UPDATE
I see I can just open saz archive, make my edits to reponse and use it to specify the response. Thats exactly what I was looking for. Also there is a way to save response session as har file. Is it possible to save one single response as har/saz file? Currently I can only save session and it contain all requests and responses. Is there a way to limit saved data to 1 request and 1 response?
You have a SAZ file, which contains the full content of a response. Your code may load the SAZ File into FiddlerCore using the Utilities.ReadSessionArchive method. You will then have an array of Session objects.
As FiddlerCore receives requests, you can evaluate whether or not you wish to reply to each request using a previously-loaded response or whether you want to instead let the request flow through to the server. To let the request flow through to the server, do nothing.
To return a previously-generated response, in FiddlerCore 2.4.6.4+ (not yet released), simply call utilAssignResponse on the new Session. For earlier versions of FiddlerCore without this new method, your OnBeforeRequest method should call a method that looks something like this:
public void utilAssignResponse(Session oS, HTTPResponseHeaders oRH, byte[] arrBody)
oS.utilCreateResponseAndBypassServer();
oS.oResponse.headers = (HTTPResponseHeaders)oRH.Clone();
oS.responseBodyBytes = arrBody ?? Utilities.emptyByteArray;
oS.oFlags["x-Fiddler-Generated"] = "Generated by myCode";
}

Google Cloud Storage: Setting incorrect MIME-type

I have a Node.js server running on a Google Compute Engine virtual instance. The server streams incoming files to Google Cloud Storage GCS. My code is here: Node.js stream upload directly to Google Cloud Storage
I'm passing Content-Type in the XML headers and it's working just fine for image/jpeg MIME-types, but for video/mp4 GCS is writing files as application/octet-stream.
There's not much to this, so I'm totally at a loss for what could be wrong ... any ideas are welcome!
Update/Solution
The problem was due to the fact that the multiparty module was creating content-type: octet-stream headers on the 'part' object that I was passing into the pipe to GCS. This caused GCS to receive two content-types, of which the octet part was last. As a result, GCS was using this for the inbound file.
Ok, looking at your HTTP request and response it seems like content-type is specified in the URL returned as part of the initial HTTP request. The initial HTTP request should return the endpoint which can be used to upload the file. I'm not sure why that is specified there but looking at the documentation (https://developers.google.com/storage/docs/json_api/v1/how-tos/upload - start a resumable session) it says that X-Upload-Content-Type needs to be specified, along some other headers. This doesn't seem to be specified in HTTP requests that were mentioned above. There might be an issue with the library used but the returned endpoint does not look as what is specified in the documentation.
Have a look at https://developers.google.com/storage/docs/json_api/v1/how-tos/upload, "Example: Resumable session initiation request" and see if you still have the same issue if you specify the same headers as suggested there.
Google Cloud Storage is content-type agnostic, i.e., it treats any kind of content in the same way (videos, music, zip files, documents, you name it).
But just to give some idea,
First I believe that the video () you are uploading is more or less size after it being uploded. so , it falls in application/<sub type>. (similar to section 3.3 of RFC 4337)
To make this correct, I believe you need to fight with storing mp4 metadata before and after the file being uploaded.
please let us know of your solution.
A solution that worked for me in a similar situation is below. TLDR: Save video from web app to GCS with content type video/mp4 instead of application/stream.
Here is the situation. You want to record video in the browser and save it to Google Cloud Storage with a content type set to video/mp4 instead of application/octet-stream. User records video and clicks button to send video file to your server for saving. After sending the video file from the client to your server, the server sends the video file to Google Cloud Storage for saving.
You successfully save the video to Google Cloud Storage and by default GCS assigns a content type of application/octet-stream to the video.
To assign a content type video/mp4 instead of application/octet-stream, here is some server-side Python code that works.
storage_client = storage.Client()
bucket = storage_client.bucket(bucket_name)
blob = bucket.blob(destination_blob_name)
blob.upload_from_file(file_obj, rewind=True)
blob.content_type = 'video/mp4'
blob.patch()
Here are some links that might help.
https://cloud.google.com/storage/docs/uploading-objects#storage-upload-object-python
https://stackoverflow.com/a/33320634/19829260
https://stackoverflow.com/a/64274097/19829260
NOTE: at the time of this writing, the Google Docs about editing metadata don't work for me because they say to set metadata but metadata seems to be read-only (see SO post https://stackoverflow.com/a/33320634/19829260)
https://cloud.google.com/storage/docs/viewing-editing-metadata#edit

webclient.download downloading incomplete tiff image from a url

I am using below code to download a tiff file from a lotus domino server.
string url
= "http://10.1.1.23\\Domino\\ImageDb.nsf\\500-99-9o9\\$File\\abc.tif";
// Create an instance of WebClient
WebClient client = new WebClient();
string filename
= "c:\\test.tif";
client.DownloadFile(url,filename);
But the file which is downloaded is of 4kb instead of 22kb and when i try to open it, its says its in improper/invalid format. Any guesses what is going wrong?
Using Fiddler, you will see that the 4kb file is the authentication HTML page that Domino automatically presents when an un-authenticated request for content is made via HTTP and the particular resource requested is not accessible anonymously.
In this case, it sounds like when you request this file resource in Domino, you will need to authenticate.
You can do this by providing a valid LTPToken in the request header, which is issued by the Domino server once you have authenticated. Alternatively, if authentication is not possible you can make the database ACL, and document accessible to "anonymous" users. Although not specifically C# code, these links will help you understand about LTPA on Domino, here, here and here