{"_id":"mitm-proxy","_rev":"9-b76733f71ca9747dd3ef69fa26abca57","name":"mitm-proxy","description":"A node module to create a http and https man-in-the-middle proxy","dist-tags":{"latest":"0.0.1"},"versions":{"0.0.1":{"name":"mitm-proxy","version":"0.0.1","author":{"name":"Horaci Cuevas"},"contributors":[{"name":"Horaci Cuevas","email":"horaci@gmail.com"}],"description":"A node module to create a http and https man-in-the-middle proxy","main":"proxy","engines":{"node":">0.4.0"},"keywords":["proxy","mitm","http","https"],"dependencies":{"colors":">=0.1.0"},"repository":{"type":"git","url":"git://github.com/horaci/node-mitm-proxy.git"},"_npmUser":{"name":"horaci","email":"horaci@gmail.com"},"_id":"mitm-proxy@0.0.1","devDependencies":{},"_engineSupported":true,"_npmVersion":"1.0.106","_nodeVersion":"v0.4.11","_defaultsLoaded":true,"dist":{"shasum":"ce26fea659716f1a6533602637541a446f56c696","tarball":"https://registry.npmjs.org/mitm-proxy/-/mitm-proxy-0.0.1.tgz","integrity":"sha512-aOBMDXwdwfOe6oVRnKZ/ebXwQ/GAHu9iVtoAHxZ3hR0LKkO8Tixjv+4MJ6y0tgNKPYavb1Jc1lPP/8Dd5VcSGw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIBCMTxKHybZcHHesBRaTFMSDFrjPwrN4dKHXNVLgYEPcAiEAhGFXgL3aIU5L0bF4QWijZCL1eizhWQjPWLxXS6JTdhU="}]},"maintainers":[{"name":"horaci","email":"horaci@gmail.com"}]}},"readme":"# node-mitm-proxy\n\nCreates a http and https proxy that allows to intercept requests, rewrite urls and store data on disk.\n\n## Example Use\n\nCheck the examples folder for more information.\n\nBasic usage: \n\n    var Proxy = require('mitm-proxy');\n    \n    new Proxy({proxy_port: 8080, verbose: true});\n\n## Proxy settings\n\n*   **proxy_port** \n    \n    Port where the proxy will listen to. Default: 8080\n\n*   **mitm_port**\n\n    Port where the mitm proxy will listen to. Default: 8000\n    You don't have to connect to this port, it's used internally.\n\n*   **verbose**\n\n    Output to STDOUT activity and errors. Default: true\n    \n*   **proxy_write**\n\n    Write the contents of every request to disk. Default: false\n\n*   **proxy_write_path**\n\n    Folder to write the contents to when proxy_write is enabled. Default: /tmp/proxy\n\n*   **key_path**\n\n    Path to SSL key that will be used by the mitm proxy. Default: mitm-proxy's internal SSL key.\n\n*   **cert_path**\n\n    Path to SSL certificate that will be used by the mitm proxy. Default: mitm-proxy's internal SSL certificate.\n\n## Processors\n\nmitm-proxy allows a processor to be passed as a second parameter to new Proxy(...)\n\nAn instance of the processor class will be created for every request that the proxy handles. \n\nThose processors allow to be notified about an event (request sent, response received, data received, etc.) and, when the methods are defined, interception methods like url rewritting.\n\n### Event handlers\n\nThe processor class will receive a proxy object on initialization that will be notified of the events.\n\n*   **request(request_object, url_object)**\n    \n    Once the proxy receives a proxy request, the request event will be triggered. That occurs before establishing a connection to the remote host. The event will receive the original request object (including request headers) and the final url (after url rewritting) that the proxy will request.\n\n*   **request_data(data)**\n\n    The proxy will be notified by all the data sent to the remote server. Usually POST and PUT methods.\n\n*   **request_end**\n\n    Once the client finishes sending the request data and is ready to receive the response, a request_end event will be triggered.\n\n*   **request_close**\n\n    If the client closes the connection uenxpectedly, a request_close event will be triggered.\n\n*   **response(response_object)**\n\n    Once the connection to the remote server has been established, the server responds with a response header. a response event will be triggered and will receive the original response from the remote server, which includes the repsonse headers and response code.\n    \n*   **response_data(data)**\n    \n    All data received from the server will be triggered in response_data events. Data will be a binary buffer.\n\n*   **response_end**\n\n    Once the remote server closes the request, a response_end event will be triggered.\n\n*   **response_close**\n\n    If the server closes the connection unexpectedly, a response_close event will be triggered.\n   \n\n### URL rewritting\n\nThe processor has a chance to rewrite the url that will be requested to the remote server. By implementing an instance method called **url_rewrite** in the processor, it will be called before establishing a connection to the remote server, allowing to change protocol, host, path or query.\n\nThe url_rewrite will receive an url object (http://nodejs.org/docs/v0.6.2/api/url.html) and expect also an url object returned. \n\nIf the method returns null or undefined, the original url will be used. \n\n\n#### Example\n\nThis will convert _any_ request to show the nodejs.org page.\n\n    var Proxy = require('mitm-proxy')\n      , url   = require('url');\n\n    var processor = function(proxy) {\n        this.url_rewrite = function(req_url) {\n            req_url.hostname = \"nodejs.org\";\n        };\n    };\n\n    new Proxy({proxy_port: 8080}, processor);\n\nRemarks: note that we only changed the server where it will connect and the path that it will request, the request will still hold the original request headers, including the Host: original_host header.\n\n### Request intercept\n\n-- todo --\n\n### Request data intercept\n\n-- todo --\n\n### Response intercept \n\n-- todo --\n\n### Response data intercept\n\n-- todo --\n\n## OS Configuration\n\nHTTP/HTTPS proxyes can be configured system wide. Keep in mind that most browsers will try to validate the SSL certificate and show a warning when using the mitm-proxy. Some domains will totally refuse to go through an invalid certificate in Chrome and other browsers, while others will give the option to ignore the warning.\n\n### Mac OSX\n\n* Go to 'System Preferences' => 'Network'\n* Select your network interface and click on the 'Advanced...' button. \n* Select the 'Proxies' tab\n* Activate 'Web Proxy (HTTP)' and type 'localhost' in the 'Web Proxy Server' text box and type '8080' in the port box next to it.\n* Activate 'Secure Web Proxy (HTTPS)' and type 'localhost' in the 'Web Proxy Server' text box and type '8080' in the port box next to it.\n* Click on 'OK' button to close the 'Advanced' settings.\n* Click on 'Apply' button in the 'Network' panel.\n\n### Ubuntu\n\n-- todo --\n\n### Windows\n\n-- todo --\n\n## Application specific\n\n### PhantomJS\n\nmitm-proxy is specially useful with headless browsers like phantom.js (http://phantomjs.org)\n\nTo enable the proxy in phantomjs add the following parameters to the phantomjs command:\n\n    phantomjs --ignore-ssl-errors=yes --proxy=localhost:8080 <phantomjs_script>\n\n## Processors\n\n","maintainers":[{"name":"horaci","email":"horaci@gmail.com"}],"time":{"modified":"2022-06-19T22:45:07.744Z","created":"2011-11-24T12:30:54.948Z","0.0.1":"2011-11-24T12:30:56.409Z"},"author":{"name":"Horaci Cuevas"},"repository":{"type":"git","url":"git://github.com/horaci/node-mitm-proxy.git"},"users":{"roothy":true,"goliatone":true,"mccataldo":true,"gearcraft1":true}}