是否可以在没有握手的情况下启动 TCP 套接字连接?

Is it possible to start a TCP socket connection without a handshake?

我正在制作一个 SSL 服务器,但我不使用 python 的库,因为我想对该过程进行一些非正统的更改。因此,我不能简单地启动 TCP 连接,因为我需要通过握手传输加密细节,而我不能通过套接字进行。所以我正在使用 scapy 自己进行握手,但之后我想继续使用 TCP 套接字,而无需再次进行握手过程。这可能吗?

如果我对你的问题的理解正确,你使用 scapy 交换了一些段,现在想用它们制造一个正常的成熟套接字。

这不容易实现:出于所有实际目的,您的 TCP 不会注意到您在数据包中发送的任何内容,并且它不会保留此 TCP 连接的任何状态:所有状态都在您的应用程序中。

就是说,在 Linux 中有一个叫做 TCP_REPAIR 的东西可以让你把套接字置于给定状态。

When this option is used, a socket is switched into a special mode, in which any action performed on it does not result in anything defined by an appropriate protocol actions, but rather directly puts the socket into a state, in which the socket is expected to be at the end of the successfully finished operation.

如果你正确设置序号,socket应该"just work".,

One also needs to restore the TCP sequence numbers. To do so, the TCP_REPAIR_QUEUE and TCP_QUEUE_SEQ options were introduced.

当然,所有这些都是现代人特有的Linux;其他操作系统可能有也可能没有类似的机制。