killtcp.c

来自「基于TCP/IP协议的网络入侵检测系统是在Linux平台下」· C语言 代码 · 共 42 行

C
42
字号
/*  Copyright (c) 1999 Rafal Wojtczuk <nergal@avet.com.pl>. All rights reserved.  See the file COPYING for license details.*/#include <libnet.h>#include "tcp.h"#include "util.h"#include "nids.h"static int libnetsock = 0;voidnids_killtcp(struct tcp_stream * a_tcp){  char buf[IP_H + TCP_H];    libnet_build_ip(TCP_H, 0, 12345, 0, 64, IPPROTO_TCP, a_tcp->addr.saddr,		  a_tcp->addr.daddr, 0, 0, buf);  libnet_build_tcp(a_tcp->addr.source, a_tcp->addr.dest,		   a_tcp->client.seq + a_tcp->server.window / 2, 0,		   0x4, 32000, 0, 0, 0, buf + IP_H);  libnet_do_checksum(buf, IPPROTO_TCP, TCP_H);  libnet_write_ip(libnetsock, buf, TCP_H + IP_H);    libnet_build_ip(TCP_H, 0, 12345, 0, 64, IPPROTO_TCP, a_tcp->addr.daddr,		  a_tcp->addr.saddr, 0, 0, buf);  libnet_build_tcp(a_tcp->addr.dest, a_tcp->addr.source,		   a_tcp->server.seq + a_tcp->client.window / 2, 0,		   0x4, 32000, 0, 0, 0, buf + IP_H);  libnet_do_checksum(buf, IPPROTO_TCP, TCP_H);  libnet_write_ip(libnetsock, buf, TCP_H + IP_H);}int raw_init(){	libnetsock = libnet_open_raw_sock(IPPROTO_RAW);	if (libnetsock <= 0)	    return 0;	else return 1;}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?