USHORT th_win; //16位窗口大小
USHORT th_sum; //16位TCP检验和
USHORT th_urp; //16位紧急指针
}tcphdr;
分析数据包模块实现
系统采用异常检测分析方法。对每一个进入的源IP地址作时间溢出判定,如果时间没有溢出,根据捕获信息,更新记录信息。否则,清空记录信息并重新记录。当记录信息中的规则变量超过规定值时,推测有异常行为。本系统实现了端口扫描和SYN洪水攻击的检测。
typedef struct tagrule{ // SYN洪水攻击的数据结构
struct ip_address keyword; // 记录源IP地址
time_t t1_tmpbuf_com; // IP地址进入时间
int count; // 记录某人连接我时SYN=1的次数
}synrule;
typedef struct tagrule2{ // 端口扫描的数据结构
struct ip_address keyword; // 记录源IP地址
time_t t2_tmpbuf_com; // IP地址进入时间
int count[NUM2]; // 记录某人当前扫描我的端口
int k;
}scnrule;
int scanport(ip_header *ih,int dport,int timeout,time_t t_tmpbuf_now,rule2 scanrule[]) //检测端口扫描的规则函数
{
int h;
int m;
h=0;
if(timeout<=0)
{
for(h=0;h<i&&h<NUM2;h++)//查询进入的IP是否曾经出现
{
if( ih->saddr.byte1==scanrule[h].keyword.byte1&&
ih->saddr.byte2==scanrule[h].keyword.byte2&&
ih->saddr.byte3==scanrule[h].keyword.byte3&&
ih->saddr.byte4==scanrule[h].keyword.byte4)
{
t_tmpbuf_add=t_tmpbuf_now-scanrule[h].t2_tmpbuf_com;
if (t_tmpbuf_add>30)
{
printf("The time is out: %ld\n",t_tmpbuf_add);
scanrule[h].k=0;
scanrule[h].count[scanrule[h].k]=dport;
scanrule[h].k++;
scanrule[h].t2_tmpbuf_com=t_tmpbuf_now;
return scanrule[h].k;
}
for(m=0;m<scanrule[h].k;m++)
{
if(scanrule[h].count[m]==dport) //0表示存在
{
&
首页 上一页 4 5 6 7 8 9 10 下一页 尾页 7/10/10
免费个人入侵检测系统的实现(七)由毕业论文网(www.huoyuandh.com)会员上传。