用 Linux 自带的工具实现了一个可以将 TCP 流量打印出来的中间人代理程序(透明的)。也不完全是 tcpdump,这只是将 TCP 内容简单的打印出来。
相当于一个反向的透明代理。
对一些开发任务很有用。
用 curl --proxy 127.0.0.1:8800 kawabangga.com -v
测试,效果如下:
➜ tmp ./tcp_proxy.sh 8800 kawabangga.com 80
=> GET http://kawabangga.com/ HTTP/1.1
=> Host: kawabangga.com
=> User-Agent: curl/7.66.0
=> Accept: */*
=> Proxy-Connection: Keep-Alive
=>
<= HTTP/1.1 301 Moved Permanently
<= Server: wts/1.6.0
<= Date: Thu, 07 Nov 2019 12:50:38 GMT
<= Content-Type: text/html; charset=iso-8859-1
<= Content-Length: 299
<= Connection: keep-alive
<= Location: https://www.kawabangga.com/
<= X-Cache: from WTS
<=
<= <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<= <html><head>
<= <title>301 Moved Permanently</title>
<= </head><body>
<= <h1>Moved Permanently</h1>
<= <p>The document has moved <a href="https://www.kawabangga.com/">here</a>.</p>
<= <hr>
<= <address>Apache Server at kawabangga.com Port 80</address>
<= </body></html>
1
hljjhb 2019-11-07 21:19:54 +08:00 via Android
赞,写的很有条理
虽然 nc 也不是标配啦😂 |
3
ManjusakaL 2019-11-07 23:36:56 +08:00 via Android
学习一个
|
4
warcraft1236 2019-11-08 09:52:27 +08:00 1
你这个打印的只是 http 的内容,不是 tcp 的包的内容啊
|
5
scriptB0y OP @warcraft1236 准确的说是 tcp data 内容
|
6
myqoo 2019-11-08 16:13:13 +08:00
说好的 tcp 呢???
|
8
abmin521 2019-11-10 12:47:52 +08:00 via iPhone
还以为是 bpf
不过也不错 |