标签:process tst http pat 接收 evel key 致自己 views
int tcp_rcv_state_process(struct sock *sk, struct sk_buff *skb,
struct tcphdr *th, unsigned len)
{
struct tcp_opt *tp = tcp_sk(sk);
int queued = 0;
tp->saw_tstamp = 0;
switch (sk->sk_state) {
case TCP_CLOSE:
...
case TCP_LISTEN:
...
case TCP_SYN_SENT:
...
}
...
/* step 1: check sequence number */
if (!tcp_sequence(tp, TCP_SKB_CB(skb)->seq, TCP_SKB_CB(skb)->end_seq)) {
if (!th->rst)
tcp_send_dupack(sk, skb);
goto discard;
}
/* step 2: check RST bit */
if(th->rst) {
tcp_reset(sk);
goto discard;
}
...
/* step 5: check the ACK field */
if (th->ack) { //这是关键点
int acceptable = tcp_ack(sk, skb, FLAG_SLOWPATH);
switch(sk->sk_state) {
case TCP_SYN_RECV:
if (acceptable) {
...
} else {
//如果ack序号错误,返回1,则要发送auto-reset
return 1;
}
break;
case TCP_FIN_WAIT1:
...
case TCP_CLOSING:
...
case TCP_LAST_ACK:
...
}
} else //如果没有ack标志,则丢弃该报文,报文中含有fin与否对于服务器无关紧要,只是为了欺骗防火墙。
goto discard;
/* step 6: check the URG bit */
tcp_urg(sk, skb, th);
/* step 7: process the segment text */
switch (sk->sk_state) {
...
}
/* tcp_data could move socket to TIME-WAIT */
if (sk->sk_state != TCP_CLOSE) {
tcp_data_snd_check(sk);
tcp_ack_snd_check(sk);
}
if (!queued) {
discard:
__kfree_skb(skb);
}
//如果返回0,则正常,如果返回1,则会发送auto-reset,该reset并不会操作本地连接,只是在坏报文到来的反方向默默发送
return 0;
}
/*
* This routine will send an RST to the other tcp.
*
* Someone asks: why I NEVER use socket parameters (TOS, TTL etc.)
* for reset.
* Answer: if a packet caused RST, it is not for a socket
* existing in our system, if it is matched to a socket,
* it is just duplicate segment or bug in other side‘s TCP.
* So that we build reply only basing on parameters
* arrived with segment.
* Exception: precedence violation. We do not implement it in any case.
*/
static void tcp_v4_send_reset(struct sk_buff *skb)
{
...
}
case TCP_SYN_SENT:
...
在tcp_rcv_synsent_state_process函数中的tcp_send_ack之前发送两个坏报文即可,至于如何构造这两个坏报文,前面分析过了。再分享一下我老师大神的人工智能教程吧。零基础!通俗易懂!风趣幽默!还带黄段子!希望你也加入到我们人工智能的队伍中来!https://blog.csdn.net/jiangjunshow
标签:process tst http pat 接收 evel key 致自己 views
原文地址:https://www.cnblogs.com/ksiwnhiwhs/p/10390256.html