{"id":13827387,"url":"https://github.com/wuchangming/node-mitmproxy","last_synced_at":"2025-04-05T14:07:29.032Z","repository":{"id":3542286,"uuid":"50078878","full_name":"wuchangming/node-mitmproxy","owner":"wuchangming","description":"node-mitmproxy is an extensible man-in-the-middle(MITM) proxy server for HTTP/HTTPS base on Node.js.","archived":false,"fork":false,"pushed_at":"2022-12-04T13:56:34.000Z","size":1104,"stargazers_count":275,"open_issues_count":21,"forks_count":61,"subscribers_count":13,"default_branch":"master","last_synced_at":"2024-04-14T09:05:12.293Z","etag":null,"topics":["mitm","node-mitmproxy"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/wuchangming.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-01-21T03:19:40.000Z","updated_at":"2024-04-12T12:57:41.000Z","dependencies_parsed_at":"2022-08-06T14:15:08.058Z","dependency_job_id":null,"html_url":"https://github.com/wuchangming/node-mitmproxy","commit_stats":{"total_commits":89,"total_committers":1,"mean_commits":89.0,"dds":0.0,"last_synced_commit":"8e206b1bbbc1b59cc790a978785b6315593bb7f7"},"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wuchangming%2Fnode-mitmproxy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wuchangming%2Fnode-mitmproxy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wuchangming%2Fnode-mitmproxy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wuchangming%2Fnode-mitmproxy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wuchangming","download_url":"https://codeload.github.com/wuchangming/node-mitmproxy/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247345853,"owners_count":20924102,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["mitm","node-mitmproxy"],"created_at":"2024-08-04T09:01:55.265Z","updated_at":"2025-04-05T14:07:29.009Z","avatar_url":"https://github.com/wuchangming.png","language":"JavaScript","funding_links":[],"categories":["\u003ca id=\"b4959a15647a6dcf79901f76655d0ca8\"\u003e\u003c/a\u003emitmproxy"],"sub_categories":["\u003ca id=\"3bd67ee9f322e2c85854991c85ed6da0\"\u003e\u003c/a\u003e投毒\u0026\u0026Poisoning"],"readme":"# node-mitmproxy 3.x\n\n[![npm](https://img.shields.io/npm/dt/node-mitmproxy.svg)](https://www.npmjs.com/package/node-mitmproxy)  \nnode-mitmproxy是一个基于nodejs，支持http/https的中间人(MITM)代理，便于渗透测试和开发调试。\n\n## 1、特性\n1、支持https  \n2、支持配置的方式启动，也支持以模块的方式引入到代码中\n\n## 2、安装\n\n###### windows\n```\n    npm install node-mitmproxy -g\n```\n###### Mac\n```\n    sudo npm install node-mitmproxy -g\n```\n\n## 3、使用\n\n#### 关于配置文件\n\n###### 简单配置：\n\nsimpleConfig.js\n```\nmodule.exports = {\n    sslConnectInterceptor: (req, cltSocket, head) =\u003e true,\n    requestInterceptor: (rOptions, req, res, ssl, next) =\u003e {\n        console.log(`正在访问：${rOptions.protocol}//${rOptions.hostname}:${rOptions.port}`);\n        console.log('cookie:', rOptions.headers.cookie);\n        res.end('hello node-mitmproxy!');\n        next();\n    }\n};\n\n```\n效果图：  \n\u003cimg width=500 src=\"./doc/img/hello_node-mitmproxy.jpg\" /\u003e\n\n[详细配置说明](https://github.com/wuchangming/node-mitmproxy#4配置详细说明)  \n[更多例子](./example/config/)\n#### 启动方式\n```\nnode-mitmproxy -c simpleConfig.js\n```\n\n### 安装node-mitmproxy CA根证书\n生成CA根证书的默认路径：`%用户名%/node-mitmproxy`\n\n#### PC下安装根证书方式\n###### Mac\n```\nsudo security add-trusted-cert -d -r trustRoot -k /Library/Keychains/System.keychain ~/node-mitmproxy/node-mitmproxy.ca.crt\n```\n###### windows\n注: 证书需要安装到  ** 受信任的根证书目录 ** 下  \n参考 [issues#3](https://github.com/wuchangming/node-mitmproxy/issues/3)\n```\nstart %HOMEPATH%/node-mitmproxy/node-mitmproxy.ca.crt\n```\n\n## 以nodejs模块的方式引用到代码中\n```\nvar mitmproxy = require('node-mitmproxy');\n\nmitmproxy.createProxy({\n    sslConnectInterceptor: (req, cltSocket, head) =\u003e true,\n    requestInterceptor: (rOptions, req, res, ssl, next) =\u003e {\n        console.log(`正在访问：${rOptions.protocol}//${rOptions.hostname}:${rOptions.port}`);\n        console.log('cookie:', rOptions.headers.cookie);\n        res.end('Hello node-mitmproxy!');\n        next();\n    },\n    responseInterceptor: (req, res, proxyReq, proxyRes, ssl, next) =\u003e {\n        next();\n    }\n});\n```\n\n\n## 4、配置详细说明\n\n#### port\n启动端口（默认：6789）\n```\n    port: 6789\n```\n\n#### sslConnectInterceptor\n判断该connnect请求是否需要代理，传入参数参考[http connnect](https://nodejs.org/api/http.html#http_event_connect) 。\n```\n    sslConnectInterceptor: (clientReq, clientSocket, head) =\u003e true,\n```\n\n#### requestInterceptor\n拦截客户端请求/响应  \n\n参数说明：  \n1、requestOptions：客户端请求参数  \n2、clientReq: 客户端请求，参考[http.IncomingMessage](https://nodejs.org/api/http.html#http_class_http_incomingmessage)  \n3、clientRes: 客户端响应，参考[http.ServerResponse](https://nodejs.org/api/http.html#http_class_http_serverresponse)  \n4、ssl: 该请求是否为https  \n5、next: 回调函数，执行完拦截逻辑后调用该方法  \n```\n    requestInterceptor: (requestOptions, clientReq, clientRes, ssl, next) =\u003e {\n        next();\n    }\n```\n#### responseInterceptor\n拦截服务端请求/响应  \n参数说明：  \n\n1、clientReq: 客户端请求，参考[http.IncomingMessage](https://nodejs.org/api/http.html#http_class_http_incomingmessage)  \n2、clientRes: 客户端响应，参考[http.ServerResponse](https://nodejs.org/api/http.html#http_class_http_serverresponse)  \n3、proxyReq: 服务端请求，参考[http.IncomingMessage](https://nodejs.org/api/http.html#http_class_http_incomingmessage)  \n4、proxyRes: 服务端响应，参考[http.ServerResponse](https://nodejs.org/api/http.html#http_class_http_serverresponse)  \n5、ssl: 该请求是否为https  \n6、next: 回调函数，执行完拦截逻辑后调用该方法  \n```\n    responseInterceptor: (clientReq, clientRes, proxyReq, proxyRes, ssl, next) =\u003e {\n        next();\n    }\n```\n#### caCertPath\nCA根证书路径(ps: 无特殊情况无需配置)  \n默认：%HOMEPATH%/node-mitmproxy/node-mitmproxy.ca.crt  \n```\ncaCertPath: 'xxxx/xxxx.crt'\n```\n\n#### caKeyPath\nCA根证书密钥路径(ps: 无特殊情况无需配置)  \n默认：%HOMEPATH%/node-mitmproxy/node-mitmproxy.ca.key.pem  \n```\ncaKeyPath: 'xxxx/xxxx.pem'\n```\n\n## 5、更多\n#### 关于伪造https证书的逻辑图\n\u003cimg src=\"doc/img/node-MitmProxy https.png\" width=650/\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwuchangming%2Fnode-mitmproxy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwuchangming%2Fnode-mitmproxy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwuchangming%2Fnode-mitmproxy/lists"}