Comments (8)
感谢分享。后续可以考虑使用libpcap来实现。目前该项目仍在开发中,尚有些问题待解决,特别是需要接入mux层。目前暂时只支持linux平台,待时机成熟的时候会考虑进行windows兼容。
再次感谢你的分享。
from kcptun-raw.
刚才尝试了一下,如果不绕过内核,内核会发RST包,但是仍然能够使用(程序会对包做协议头验证),不过会大大降低带宽载荷,另外如果广域网中间路由器对RST包做检测,也可能会切断伪TCP连接。
from kcptun-raw.
@Chion82
不绕过内核,只在 在客户端获取不到管理员/root权限的 情况下,才有意义,像未root的手机。但raw/packet socket也需要管理员/root权限。 中间路由器主动切断伪TCP连接也是用发送RST包的方式吧,只要中间路由器 不封端口/ip 或者 按协议丢包(此时需要混淆成http/https流量) 就不影响。
from kcptun-raw.
@linhua55 是的,这只是一个尝试,实际使用肯定还是要想办法绕过内核的。需要移植的话还有很多的工作需要做。btw,中间路由器在切断连接的时候除了发RST还会撤销NAT映射关系,在客户端心跳检测逻辑中有自动更换端口的设定,在NAT失效后可以重新选择随机端口尝试建立新的NAT通道。
from kcptun-raw.
It needs to bypass the kernel, since normally the TCP stack there will intercept any incoming packets and reset the connection. So we listen on a fake IP address and send gratuitous ARPs to the router. This is why curl.py needs your network interface and a fake IP address.
Sometimes the ARP spoofing or sniffing doesn't quite work. Usually if I run it 5 times it will work.
https://github.com/jvns/teeceepee
http://jvns.ca/blog/2014/08/12/what-happens-if-you-write-a-tcp-stack-in-python/
https://news.ycombinator.com/item?id=8167546
这个是 将计算机和一个假IP绑定,因此需要手动发送 ARP 包到路由器(ARP污染),从而将计算机网卡的MAC地址和这个假IP绑定。以让路由器接收到 发送给假IP的数据包后,转发给 这个计算机网卡。 然后需要用这个假IP来发送数据包 而本计算机中正常的内核TCP协议栈接收到发送给这个假IP的数据包后,不会进行处理(发RST包)。
可能 虚拟机的 桥接网卡 模式,也是这样(ARP投毒)实现的
from kcptun-raw.
这确实是一个不错的方法。在路由器上查询ARP缓存表,虚拟机和实体机的IP对应的是同一个MAC地址,看来桥接网卡确实是通过ARP投毒实现的。
from kcptun-raw.
理解错了,虚拟机 桥接网卡 使用的MAC地址是虚拟机自己的MAC地址,不是主机的MAC地址
在路由器中 绑定的 是: MAC地址和 端口(LAN口) (这个不是ARP表) 可能是多个MAC地址对应一个端口(LAN口),相当于 路由器的一个LAN口下面接了一个交换机 , 实际应该是 路由器接收到远端发来的一个包后 先查询NAT表,找到本地目标IP,再根据 本地目标IP查询ARP表,找到本地目标机器MAC地址,再根据 本地目标机器MAC地址 查询 上面这个 表 来决定 应该从哪个端口(LAN口)发出去
from kcptun-raw.
事实上我的路由器(是软路由)只有一个LAN口,下面接的是交换机再接电脑,所以在我的路由器上不存在物理端口和电脑的MAC直接对应的关系表。我是在路由器上使用arp -n
命令查询的,发现物理机和虚拟机确实是不同ip对应相同的MAC(都为物理机网卡的MAC),而其他客户端(另外的电脑和手机)都是不同IP对应不同的MAC。当然,虚拟机在dhcp握手阶段提交的是虚拟机的网卡MAC地址(可能是因为dhcp是在udp层提交MAC地址而不是dhcp服务器直接从链路层获取MAC的缘故?只是猜测,我并没有了解过dhcp协议报文),才能避免物理机和虚拟机分配到相同的IP。我认为应该还是发生了arp投毒。至于MAC地址和物理端口的缓存关系表是存在的,这个表应该是在家用路由器(即NAT路由器+交换机)的交换部分逻辑中。
from kcptun-raw.
Related Issues (16)
- Errors at compilation HOT 5
- 似乎端口被封了 HOT 10
- 一直报Request KCP init HOT 3
- 连接初始化问题 HOT 7
- 与ss不兼容? HOT 1
- 这个项目是 Kcptun 的 C 语言实现吗? HOT 2
- 在openwrt上无法工作? HOT 9
- 我从腾讯云无法到我的Ramnode HOT 4
- 能不能在connection_info中加入客户端ip区分不同的客户端? HOT 1
- 内核态filter支持 HOT 40
- cpu占用真的没办法减少吗?有点吃力啊感觉。 HOT 9
- SYN flag HOT 22
- 请问,iptables的设定是必须的吗?
- 求在Windows流量通过Linux虚拟机连接kcptun-raw的思路
- Default MTU 1440 may not work in cellular networks
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from kcptun-raw.