node-thin
is a HTTP/HTTPS debugging proxy which allows to use collection of middlewares/interceptors in order to trace/pre-process/post-process requests and resposes. The proxy in HTTPS mode actually allows simulate the man-in-the-middle (mitm) attack or traffic hijacking. Concept of middlewares is similar to connect (expressjs) frameworks.
Installation
npm i thin
Usage
Proxy:
var Thin = ; var proxy = ; // `req` and `res` params are `http.ClientRequest` and `http.ServerResponse` accordingly// be sure to check http://nodejs.org/api/http.html for more detailsproxy; // you can add different layers of "middleware" similar to "connect",// but with few exclusionsproxy; proxy;
Test server:
var express = ;var app = ; app; app; app; appall'/foobar' { // this route won't be reached because of mitm interceptor res;}; app; var fs = ;var https = ; https;
If you try to make a query to your server you should be able to see a log from thin
:
curl -d "foo=baz" -k -x https://localhost:8081 https://localhost:3001/test?foo=bar curl -d "foo=baz" -x http://localhost:8081 http://localhost:3000/test?foo=bar
You can intercept particular route:
curl -d "foo=baz" -k -x https://localhost:8081 https://localhost:3001/foobar
Response should be intercepted
instead of original
.