3

Is there a way to receive and process packets intercepted in http-toolkit programmatically using python? Is there any internal API I access?

Ideally I would like to receive the packets in a JSON or HAR format.

2
  • sounds like an xy problem. there are a number of python packages that do this, requests being the most popular Commented Dec 8, 2022 at 10:24
  • Hey! I suspected i didnt make myself clear enough. The end goal is to manipulate and capture HTTP traffic of an Android device. HTTP toolkit does it great but without a programmatic interface which caused me to ask the question. Commented Dec 9, 2022 at 13:01

1 Answer 1

4

Within HTTP Toolkit itself, this isn't possible right now, but it is planned in future. You can +1 on the issue to vote for it here: https://github.com/httptoolkit/httptoolkit/issues/37. With that, you'd be able to add your own scripts within HTTP Toolkit which could process or store packets elsewhere any way you like, including sending them to a Python process.

In the meantime, this may be possible using Mockttp. Mockttp is the internals of HTTP Toolkit as an open-source JavaScript library that you can use to build your own fully scriptable proxy, and once that's working you can easily add logic to forward packets to Python on top of that. There's a getting started guide here: https://httptoolkit.tech/blog/javascript-mitm-proxy-mockttp/.

Sign up to request clarification or add additional context in comments.

2 Comments

First of all thank you very much for your answer! Does Mockttp can easily connect to Android devices? The end goal is to programmatically capture and manipulate HTTP traffic of an Android device.
No - it's totally possible to intercept an Android device with Mockttp, but you'll need to do the setup for that manually. For fully automated setup, you'd still need HTTP Toolkit, which means waiting for the full feature linked above.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.