httptoolkit / httptoolkit-server

The backend of HTTP Toolkit

Home Page:https://httptoolkit.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

possible to drop url and headers to a file ?

graysuit opened this issue · comments

First of all thanks for great httptoolkit tool, so much easier to use.

I want to intercept and extract specific header value(i.e Cookie) from specific url from android app.
Any way I edit any server file, so it drops url and headers to file ? So my program (dotnet) can access it.

image

Any ideas ?
Thank you

Hi @graysuit! I think this is a duplicate of either httptoolkit/httptoolkit#342 (where HAR files for all received requests would be automatically saved to disk, so you'd just to watch that, and then read the Cookie header from the JSON) or httptoolkit/httptoolkit#37 (which would let you add your own scripts within HTTP Toolkit, so you could write a script to do anything you like when matching requests are received, including writing the header to disk or sending it elsewhere).

Assuming at least one of those would work for you, I'm going to close this, but do please vote for either/both of those issues (just add a 👍 emoji) to help prioritize that, and you can also subscribe to those issues to get a notification from GitHub once this is available.

In the meantime, the best option to do this right now would be to create a custom proxy with Mockttp (guide here: https://httptoolkit.com/blog/javascript-mitm-proxy-mockttp/) and then configure that as your upstream proxy in HTTP Toolkit.

In the meantime, the best option to do this right now would be to create a custom proxy with Mockttp (guide here: https://httptoolkit.com/blog/javascript-mitm-proxy-mockttp/) and then configure that as your upstream proxy in HTTP Toolkit.

@pimterry But I fear that might be complex ,right? Specially there's android part as well.
Because I don't want to interfere with how httptoolkit desktop and android works. Just a mitm patch up.

Is that possible, if I can hack mockttp or httptoolkit-server code, edit any line, so it just drops out cookie ? Which part is responsible for displaying headers ?
For now I want to make custom build for my own personal use.

Which part is responsible for displaying headers ?

There is no one line of code somewhere that's responsible for this, it's a complicated project spread across a lot of repos (you can see the full list in the org)

Is that possible, if I can hack mockttp or httptoolkit-server code, edit any line, so it just drops out cookie ?

That's going to be a lot more complicated that creating a quick proxy to do this, and I don't have time to walk you through it I'm afraid. Feel free if you want, but it's not the best approach.

Doing it in your own standalone script will be much simpler. It should be very easy, just follow the Mockttp guide to get setup, and then reading the cookies from all requests through that proxy is literally one line:

mockttpServer.on('request', (req) => console.log(req.headers.cookie));

In terms of the Android part - if you use HTTP Toolkit alongside Mockttp, you can use all the normal HTTP Toolkit setup stuff as always, and everything will work just like normal (but note that redirecting all traffic from HTTP Toolkit via an upstream proxy requires HTTP Toolkit Pro).

Alternatively, you can skip HTTP Toolkit and just use Mockttp + Android directly - you just need to manually configure your proxy & CA certificate on the Android device.

I can't offer detailed support on this though, it's quite complicated and I just don't have time. The Mockttp guide should be a good starting point. Do feel free to dig into the source here for yourself if you'd prefer, but be aware that changing the internals is likely to be tricky, and it'll be very easy to break things in strange and unpredictable ways.