1

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.

  • sounds like an [xy problem](https://en.wikipedia.org/wiki/XY_problem). there are a number of python packages that do this, [requests](https://realpython.com/python-requests/) being the most popular – willwrighteng Dec 08 '22 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. – SpiderPigXL Dec 09 '22 at 13:01

1 Answers1

1

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/.

Tim Perry
  • 11,766
  • 1
  • 57
  • 85
  • 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. – SpiderPigXL Dec 09 '22 at 12:57
  • 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. – Tim Perry Dec 12 '22 at 13:46