引起boom

This commit is contained in:
chn
2019-11-03 20:14:13 +08:00
parent 4d37c4dee4
commit 4fdb049597
3 changed files with 11 additions and 3 deletions

View File

@@ -11,7 +11,6 @@
#include <linux/types.h> #include <linux/types.h>
#include <linux/random.h> #include <linux/random.h>
#include <linux/moduleparam.h> #include <linux/moduleparam.h>
#include <asm/limits.h>
#include <linux/time.h> #include <linux/time.h>
const static unsigned char* str_ua_begin = "User-Agent: "; const static unsigned char* str_ua_begin = "User-Agent: ";

View File

@@ -41,6 +41,8 @@ void rkpManager_del(struct rkpManager* rkpm)
u_int8_t rkpManager_execute(struct rkpManager* rkpm, struct sk_buff* skb) u_int8_t rkpManager_execute(struct rkpManager* rkpm, struct sk_buff* skb)
{ {
printk("syn %d ack %d\n", tcp_hdr(skb) -> syn, tcp_hdr(skb) -> ack);
printk("sport %d dport %d\n", tcp_hdr(skb) -> source, tcp_hdr(skb) -> dest);
if(rkpSettings_first(skb)) if(rkpSettings_first(skb))
// 新增加一个流或覆盖已经有的流 // 新增加一个流或覆盖已经有的流
{ {
@@ -80,12 +82,15 @@ u_int8_t rkpManager_execute(struct rkpManager* rkpm, struct sk_buff* skb)
rkps_new -> next = rkpm -> data[id]; rkps_new -> next = rkpm -> data[id];
rkpm -> data[id] = rkps_new; rkpm -> data[id] = rkps_new;
} }
return NF_ACCEPT;
} }
else else
// 使用已经有的流 // 使用已经有的流
{ {
u_int8_t id = (ntohs(tcp_hdr(skb) -> source) + ntohs(tcp_hdr(skb) -> dest)) & 0xFF; u_int8_t id = (ntohs(tcp_hdr(skb) -> source) + ntohs(tcp_hdr(skb) -> dest)) & 0xFF;
struct rkpStream *rkps = rkpm -> data[id]; struct rkpStream *rkps = rkpm -> data[id];
printk("rkpStream_belong %d\n", rkpStream_belong(rkps, skb));
while(rkps != 0) while(rkps != 0)
if(rkpStream_belong(rkps, skb)) if(rkpStream_belong(rkps, skb))
return rkpStream_execute(rkps, skb); return rkpStream_execute(rkps, skb);

View File

@@ -76,13 +76,17 @@ void rkpStream_del(struct rkpStream* rkps)
} }
bool rkpStream_belong(const struct rkpStream* rkps, const struct sk_buff* skb) bool rkpStream_belong(const struct rkpStream* rkps, const struct sk_buff* skb)
{ {
printk("rkpStream_belong\n");
printk("syn %d ack %d\n", tcp_hdr(skb) -> syn, tcp_hdr(skb) -> ack);
printk("sport %d dport %d\n", tcp_hdr(skb) -> source, tcp_hdr(skb) -> dest);
printk("rkpSettings_request %d\n", rkpSettings_request(skb));
if(rkpSettings_request(skb)) if(rkpSettings_request(skb))
{ {
if(rkps -> id[0] != ntohl(ip_hdr(skb) -> saddr)) if(rkps -> id[0] != ntohl(ip_hdr(skb) -> saddr))
return false; return false;
if(rkps -> id[1] != ntohl(ip_hdr(skb) -> daddr)) if(rkps -> id[1] != ntohl(ip_hdr(skb) -> daddr))
return false; return false;
if(rkps -> id[2] != (ntohs(tcp_hdr(skb) -> source) << 16) + ntohs(tcp_hdr(skb) -> dest)) if(rkps -> id[2] != ((u_int32_t)ntohs(tcp_hdr(skb) -> source) << 16) + ntohs(tcp_hdr(skb) -> dest))
return false; return false;
return true; return true;
} }
@@ -92,7 +96,7 @@ bool rkpStream_belong(const struct rkpStream* rkps, const struct sk_buff* skb)
return false; return false;
if(rkps -> id[1] != ntohl(ip_hdr(skb) -> saddr)) if(rkps -> id[1] != ntohl(ip_hdr(skb) -> saddr))
return false; return false;
if(rkps -> id[2] != (ntohs(tcp_hdr(skb) -> dest) << 16) + ntohs(tcp_hdr(skb) -> source)) if(rkps -> id[2] != ((u_int32_t)ntohs(tcp_hdr(skb) -> dest) << 16) + ntohs(tcp_hdr(skb) -> source))
return false; return false;
return true; return true;
} }