Skip to content

Commit 4f0db76

Browse files
committed
更新文档
1 parent 5af86d4 commit 4f0db76

5 files changed

Lines changed: 28 additions & 3 deletions

File tree

0 Bytes
Binary file not shown.

middlewareAgent/.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
https-mitm-proxy-handbook
2-
node-mitmproxy
2+
node-mitmproxy
3+
node-mitm-proxy
0 Bytes
Binary file not shown.

middlewareAgent/browserAgent/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ httpTunnel.on('error', (e) => {
127127
console.error(e);
128128
}
129129
});
130-
130+
// http服务器必须在connect里面才能监听到https请求
131131
// https的请求通过http隧道方式转发
132132
httpTunnel.on('connect', (req, cltSocket, head) => {
133133
// connect to an origin server

middlewareAgent/browserAgent/https/createFakeHttpsWebSite.js

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,14 +62,38 @@ function createFakeHttpsWebSite(domain, successFun) {
6262
method: req.method,
6363
port: req.headers.host.split(':')[1] || 80,
6464
path: urlObject.path,
65-
headers: req.headers
65+
headers: req.headers,
66+
// key: pki.privateKeyToPem(fakeCertObj.key),
67+
// cert: pki.certificateToPem(fakeCertObj.cert),
6668
};
6769
res.writeHead(200, {
6870
'Content-Type': 'text/html;charset=utf-8'
6971
});
72+
// console.log(req);
7073
res.write(`<html><body>我是伪造的: ${options.protocol}//${options.hostname} 站点</body></html>`);
7174
res.end();
75+
// const trueReq = https.request(options);
76+
// trueReq.end();
77+
// res.end();
78+
// 根据客户端请求,向真正的目标服务器发起请求。
79+
// let realReq = https.request(options, (realRes) => {
80+
// console.log(realRes);
81+
// // realRes.pipe(res);
82+
// }).end().on('error', function (e) {
83+
// console.log(e);
84+
// });
85+
86+
// 通过pipe的方式把客户端请求内容转发给目标服务器
87+
// res.pipe(realReq);
88+
// realReq.pipe(res);
89+
90+
// realReq.on('error', (e) => {
91+
// console.error(e);
92+
// })
7293
});
94+
fakeServer.on('upgrade', (req, socket, head) => {
95+
96+
})
7397
fakeServer.on('error', (e) => {
7498
console.error(e);
7599
});

0 commit comments

Comments
 (0)