亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來(lái)到蟲(chóng)蟲(chóng)下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲(chóng)蟲(chóng)下載站

?? watcher1.txt

?? 基于TCP/IP的網(wǎng)絡(luò)入侵檢測(cè)程序
?? TXT
?? 第 1 頁(yè) / 共 2 頁(yè)
字號(hào):
/*********************************************************************  
Program: watcher  

A network level monitoring tool to detect incoming packets indicative of  
potential attacks.  

This software detects low level packet scanners and several DOS attacks.  
Its primary use is to detect low level packet scans, since these are usually  
done first to identify active systems and services to mount further attacks.  

The package assumes every incoming packet is potentially hostile.  Some checks  
are done to minimize false positives, but on occasion a site may be falsely  
identified as having performed a packet scan or SYNFLOOD attack.  This usually  
occurs if a large number of connections are done in a brief time right before  
the reporting timeout period (i.e. when browsing a WWW site with lots of  
little GIF's, each requiring a connection to download).  You can also get false  
positives if you scan another site, since the targets responses will be viewed  
as a potential scan of your system.  

By default, alerts are printed to SYSLOG every 10 seconds.  
***********************************************************************/  

#include <stdio.h>  
#include <sys/types.h>  
#include <sys/time.h>  
#include <sys/socket.h>  
#include <sys/file.h>  
#include <sys/time.h>  
#include <netinet/in.h>  
#include <netdb.h>  
#include <string.h>  
#include <errno.h>  
#include <ctype.h>  
#include <malloc.h>  
#include </tmp/tcp.h>  /* change this head file to your tcp.h */
#include <netinet/in_systm.h>  
#include <net/if_arp.h>  
#include <net/if.h>  
#include <netinet/udp.h>  
#include <netinet/ip.h>  
#include <netinet/ip_icmp.h>  
#include <linux/if_ether.h>  
#include <syslog.h>  
#include <linux/sockios.h>

#define PKTLEN 96    /* Should be enough for what we want */  
#ifndef IP_MF  
#define IP_MF    0x2000  
#endif  

/***** WATCH LEVELS ******/  

#define MYSELFONLY    1  
#define MYSUBNET    2  
#define HUMANITARIAN    3  

/***** REPORT LEVELS *****/  

#define REPORTALL    1  
#define REPORTDOS    2  
#define REPORTSCAN    3  

struct floodinfo {  
    u_short sport;  
    struct floodinfo *next;  
};  

struct addrlist {  
    u_long saddr;  
    int cnt;  
    int wwwcnt;  
    struct addrlist *next;  
};  

struct atk {  
    u_long saddr;  
    u_char eaddr[ETH_ALEN];  
    time_t atktime;  
};  

struct pktin {  
    u_long saddr;  
    u_short sport;  
    u_short dport;  
    time_t timein;  
    u_char eaddr[ETH_ALEN];  
    struct floodinfo *fi;  
    struct pktin *next;  
};  

struct scaninfo {  
    u_long addr;  
    struct atk teardrop;  
    struct atk land;  
    struct atk icmpfrag;  
    struct pktin *tcpin;  
    struct pktin *udpin;  
    struct scaninfo *next;  
    u_long icmpcnt;  
} ;  

struct scaninfo *Gsilist = NULL, *Gsi;  

u_long Gmaddr;  
time_t Gtimer = 10, Gtimein;  
int Gportlimit = 7;  
int Gsynflood = 8;  
int Gwebcount = 40;  
int Gicmplimit = 5;  
int Gwatchlevel = MYSELFONLY;  
int Greportlevel = REPORTALL;  
char *Gprogramname, *Gdevice = "eth0";  

/******** IP packet info ********/  

u_long Gsaddr, Gdaddr;  
int Giplen, Gisfrag, Gid;  

/****** Externals *************/  

extern int errno;  
extern char *optarg;  
extern int optind, opterr;  

void do_tcp(), do_udp(), do_icmp(), print_info(), process_packet();  
void addtcp(), addudp(), clear_pktin(), buildnet();  
void doargs(), usage(), addfloodinfo(), rmfloodinfo();  
struct scaninfo *doicare(), *addtarget();  
char *anetaddr(), *ether_ntoa();  
u_char *readdevice();  

main(argc, argv)  
int argc;  
char *argv[];  
{  
    int pktlen = 0, i, netfd;  
    u_char *pkt;  
    char hostname[32];  
    struct hostent *hp;  
    time_t t;  

    doargs(argc, argv);  
    openlog("WATCHER", 0, LOG_DAEMON);  
    if(gethostname(hostname, sizeof(hostname)) < 0)  
    {  
    perror("gethostname");  
    exit(-1);  
    }  
    if((hp = gethostbyname(hostname)) == NULL)  
    {  
    fprintf(stderr, "Cannot find own address\n");  
    exit(-1);  
    }  
    memcpy((char *)&Gmaddr, hp->h_addr, hp->h_length);  
    buildnet();  
    if((netfd = initdevice(O_RDWR, 0)) < 0)  
    exit(-1);  

    /* Now read packets forever and process them. */  

    t = time((time_t *)0);  
    while(pkt = readdevice(netfd, &pktlen))  
    {  
    process_packet(pkt, pktlen);  
    if(time((time_t *)0) - t > Gtimer)  
    {  
        /* Times up.  Print what we found and clean out old stuff. */  

        for(Gsi = Gsilist, i = 0; Gsi; Gsi = Gsi->next, i++)  
        {  
                clear_pktin(Gsi);  
            print_info();  
        Gsi->icmpcnt = 0;  
        }  
        t = time((time_t *)0);  
    }  
    }  
}  

/**********************************************************************  
Function: doargs  

Purpose:  sets values from environment or command line arguments.  
**********************************************************************/  
void doargs(argc, argv)  
int argc;  
char **argv;  
{  
    char c;  

    Gprogramname = argv[0];  
    while((c = getopt(argc,argv,"d:f:hi:m:p:r:t:w:")) != EOF)  
    {  
        switch(c)  
        {  
        case 'd':  
        Gdevice = optarg;  
        break;  
            case 'f':  
                Gsynflood = atoi(optarg);  
                break;  
        case 'h':  
        usage();  
        exit(0);  
        case 'i':  
        Gicmplimit = atoi(optarg);  
        break;  
        case 'm':  
        if(strcmp(optarg, "all") == 0)  
            Gwatchlevel = HUMANITARIAN;  
        else if(strcmp(optarg, "subnet") == 0)  
            Gwatchlevel = MYSUBNET;  
	else if(strcmp(optarg, "self") == 0)
	    Gwatchlevel = MYSELFONLY;
	else  
        {  
            usage();  
            exit(-1);  
        }  
        break;  
        case 'p':  
        Gportlimit = atoi(optarg);  
        break;  
        case 'r':  
        if(strcmp(optarg, "dos") == 0)  
            Greportlevel = REPORTDOS;  
        else if(strcmp(optarg, "scan") == 0)  
            Greportlevel = REPORTSCAN;  
        else  
        {  
            exit(-1);  
        }  
        break;  
        case 't':  
                Gtimer = atoi(optarg);  
                break;  
        case 'w':  
        Gwebcount = atoi(optarg);  
        break;  
        default:  
                usage();  
                exit(-1);  
        }  
    }  
}  

/**********************************************************************  
Function: usage  

Purpose:  Display the usage of the program  
**********************************************************************/  
void usage()  
{  
printf("Usage: %s [options]\n", Gprogramname);  
printf("  -d device       Use 'device' as the network interface device\n");  
printf("                  The first non-loopback interface is the default\n");  
printf("  -f flood        Assume a synflood attack occurred if more than\n");  
printf("                  'flood' uncompleted connections are received\n");  
printf("  -h              A little help here\n");  
printf("  -i icmplimit    Assume we may be part of a smurf attack if more\n");  
printf("                  than icmplimit ICMP ECHO REPLIES are seen\n");  
printf("  -m level        Monitor more than just our own host.\n");  
printf("                  A level of 'subnet' watches all addresses in our\n");  
printf("                  subnet and 'all' watches all addresses\n");  
printf("  -p portlimit    Logs a portscan alert if packets are received for\n");  
printf("                  more than portlimit ports in the timeout period.\n");  
printf("  -r reporttype   If reporttype is dos, only Denial Of Service\n");  
printf("                  attacks are reported.  If reporttype is scan\n");  
printf("                  then only scanners are reported.  Everything is\n");  
printf("                  reported by default.\n");  
printf("  -t timeout      Count packets and print potential attacks every\n");  
printf("                  timeout seconds\n");  
printf("  -w webcount     Assume we are being portscanned if more than\n");  
printf("                  webcount packets are received from port 80\n");  
}  

/**********************************************************************  
Function: buildnet  

Purpose:  Setup for monitoring of our host or entire subnet.  
**********************************************************************/  
void buildnet()  
{  
    u_long addr;  
    u_char *p;  
    int i;  

    if(Gwatchlevel == MYSELFONLY)        /* Just care about me */  
    {  
    (void) addtarget(Gmaddr);  
    }  
    else if(Gwatchlevel == MYSUBNET)        /* Friends and neighbors */  
    {  
    addr = htonl(Gmaddr);  
    addr = addr & 0xffffff00;  
    for(i = 0; i < 256; i++)  
        (void) addtarget(ntohl(addr + i));  
    }  
}  
/**********************************************************************  
Function: doicare  

Purpose:  See if we monitor this address  
**********************************************************************/  
struct scaninfo *doicare(addr)  
u_long addr;  
{  
    struct scaninfo *si;  
    int i;  

    for(si = Gsilist; si; si = si->next)  
    {  
    if(si->addr == addr)  
        return(si);  
    }  
    if(Gwatchlevel == HUMANITARIAN)    /* Add a new address, we always care */  
    {  
    si = addtarget(addr);  
    return(si);  
    }  
    return(NULL);  
}  

/**********************************************************************  
Function: addtarget  

Purpose:  Adds a new IP address to the list of hosts to watch.  
**********************************************************************/  
struct scaninfo *addtarget(addr)  
u_long addr;  
{  
    struct scaninfo *si;  

    if((si = (struct scaninfo *)malloc(sizeof(struct scaninfo))) == NULL)  
    {  
    perror("malloc scaninfo");  
    exit(-1);  
    }  
    memset(si, 0, sizeof(struct scaninfo));  
    si->addr = addr;  
    si->next = Gsilist;  
    Gsilist = si;  
    return(si);  
}  

/**********************************************************************  
Function: process_packet  

Purpose:  Process raw packet and figure out what we need to to with it.  

Pulls the packet apart and stores key data in global areas for reference  
by other functions.  
**********************************************************************/  
void process_packet(pkt, pktlen)  
u_char *pkt;  
int pktlen;  
{  
    struct ethhdr *ep;  
    struct iphdr *ip;  
    static struct align { struct iphdr ip; char buf[PKTLEN]; } a1;  
    u_short off;  

    Gtimein = time((time_t *)0);  
    ep = (struct ethhdr *) pkt;  
    if(ntohs(ep->h_proto) != ETH_P_IP)  
    return;  

    pkt += sizeof(struct ethhdr);  
    pktlen -= sizeof(struct ethhdr);  
    memcpy(&a1, pkt, pktlen);  
    ip = &a1.ip;  
    Gsaddr = ip->saddr;  
    Gdaddr = ip->daddr;  

    if((Gsi = doicare(Gdaddr)) == NULL)  
    return;  

    off = ntohs(ip->frag_off);  
    Gisfrag = (off & IP_MF);    /* Set if packet is fragmented */  
    Giplen = ntohs(ip->tot_len);  
    Gid = ntohs(ip->id);  
    pkt = (u_char *)ip + (ip->ihl << 2);  
    Giplen -= (ip->ihl << 2);  
    switch(ip->protocol)  
    {  
    case IPPROTO_TCP:  
        do_tcp(ep, pkt);  
        break;  
    case IPPROTO_UDP:  
        do_udp(ep, pkt);  
        break;  
    case IPPROTO_ICMP:  
        do_icmp(ep, pkt);  
        break;  
    default:  
        break;  
    }  
}  

/**********************************************************************  
Function: do_tcp  

Purpose:  Process this TCP packet if it is important.  
**********************************************************************/  
void do_tcp(ep, pkt)  
struct ethhdr *ep;  
u_char *pkt;  
{  
    struct tcphdr *thdr;  
    u_short sport, dport;  

    thdr = (struct tcphdr *) pkt;  
    if(thdr->th_flags & TH_RST) /* RST generates no response */  
    return;            /* Therefore can't be used to scan. */  
    sport = ntohs(thdr->th_sport);  
    dport = ntohs(thdr->th_dport);  

    if(thdr->th_flags & TH_SYN)  
    {  
    if(Gsaddr == Gdaddr && sport == dport)  
    {  
        Gsi->land.atktime = Gtimein;  
        Gsi->land.saddr = Gsaddr;  
        memcpy(Gsi->land.eaddr, ep->h_source, ETH_ALEN);  
    }  
    }  
    addtcp(sport, dport, thdr->th_flags, ep->h_source);  
}  

/**********************************************************************  
Function: addtcp  

Purpose:  Add this TCP packet to our list.  
**********************************************************************/  
void addtcp(sport, dport, flags, eaddr)  
u_short sport;  
u_short dport;  
u_char flags;  
u_char *eaddr;  
{  
    struct pktin *pi, *last, *tpi;  

    /* See if this packet relates to other packets already received. */  

    for(pi = Gsi->tcpin; pi; pi = pi->next)  
    {  
    if(pi->saddr == Gsaddr && pi->dport == dport)  
    {  
        if(flags == TH_SYN)  
        addfloodinfo(pi, sport);  
        else if((flags & TH_FIN) || (flags & TH_ACK))  
        rmfloodinfo(pi, sport);  
        return;  
    }  
    last = pi;  
    }  
    /* Must be new entry */  

    if((tpi = (struct pktin *)malloc(sizeof(struct pktin))) == NULL)  
    {  
    perror("Malloc");  
    exit(-1);  
    }  
    memset(tpi, 0, sizeof(struct pktin));  
    memcpy(tpi->eaddr, eaddr, ETH_ALEN);  
    tpi->saddr = Gsaddr;  
    tpi->sport = sport;  
    tpi->dport = dport;  
    tpi->timein = Gtimein;  
    if(flags == TH_SYN)  
    addfloodinfo(tpi, sport);  
    if(Gsi->tcpin)  
    last->next = tpi;  
    else  
    Gsi->tcpin = tpi;  
}  

?? 快捷鍵說(shuō)明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
在线一区二区三区做爰视频网站| 日韩在线一区二区| 成人app在线| 成人免费在线播放视频| 99久久99久久精品国产片果冻| 国产精品成人在线观看| 色呦呦网站一区| 无吗不卡中文字幕| 日韩三级电影网址| 国产成人精品1024| 亚洲精品乱码久久久久久黑人 | 久久99精品国产麻豆婷婷| 精品国产欧美一区二区| 国产美女精品一区二区三区| 国产精品国产三级国产普通话99| 91麻豆国产精品久久| 亚洲综合色噜噜狠狠| 欧美一区二区三区在线电影| 国产精品一区久久久久| 亚洲三级在线看| 555www色欧美视频| 国产不卡免费视频| 亚洲国产精品影院| proumb性欧美在线观看| 日韩福利电影在线| 国产精品毛片a∨一区二区三区| 欧洲亚洲国产日韩| 国产美女在线精品| 一区二区三区欧美| 久久亚洲一级片| 日本精品一级二级| 免费日本视频一区| 中文字幕一区免费在线观看| 欧美日韩国产高清一区二区三区 | 亚洲欧美另类综合偷拍| 7777女厕盗摄久久久| 国产99精品视频| 午夜伦理一区二区| 国产视频一区二区在线观看| 欧美色精品天天在线观看视频| 国内精品久久久久影院色| 亚洲国产日韩综合久久精品| 中文字幕欧美日韩一区| 9191成人精品久久| 99精品国产一区二区三区不卡| 青青草精品视频| 亚洲欧美激情一区二区| 精品粉嫩aⅴ一区二区三区四区| 成人一区二区在线观看| 亚洲欧美日韩成人高清在线一区| 日韩一区二区麻豆国产| 成人av在线一区二区| 日韩av中文字幕一区二区三区| 国产欧美精品区一区二区三区 | 成人免费毛片aaaaa**| 天天色天天操综合| 亚洲老司机在线| 国产嫩草影院久久久久| 日韩精品资源二区在线| 欧美丝袜丝nylons| 色猫猫国产区一区二在线视频| 国产福利一区在线| 免费不卡在线观看| 亚洲欧美日韩精品久久久久| 久久青草欧美一区二区三区| 欧美另类videos死尸| 91黄视频在线观看| 色婷婷av一区二区三区gif| 成人黄色在线看| 国产精品影视在线| 国产在线乱码一区二区三区| 麻豆精品国产传媒mv男同| 日本aⅴ亚洲精品中文乱码| 五月天久久比比资源色| 午夜欧美电影在线观看| 亚洲成人在线免费| 亚洲一区二区av在线| 亚洲欧美自拍偷拍色图| 国产精品久久久久aaaa| 欧美激情一区三区| 中文字幕欧美激情一区| 中文字幕第一区| 中文字幕欧美三区| 国产精品传媒视频| 亚洲免费在线视频一区 二区| 亚洲欧美日韩电影| 亚洲第一福利一区| 日本午夜精品视频在线观看| 久久精品国内一区二区三区| 精品一区二区三区欧美| 国产精品影视在线观看| 国产成人99久久亚洲综合精品| 国产乱子轮精品视频| 国产大陆a不卡| 成+人+亚洲+综合天堂| av不卡免费电影| 在线观看亚洲一区| 欧美日韩mp4| 日韩一卡二卡三卡四卡| 久久欧美一区二区| 国产精品国产a| 亚洲成人免费电影| 国产一区二区在线看| 91亚洲男人天堂| 欧美日韩一本到| 日韩一级精品视频在线观看| 337p粉嫩大胆噜噜噜噜噜91av | 国产精品美女久久久久久久久| 亚洲欧洲日韩女同| 亚洲 欧美综合在线网络| 麻豆成人91精品二区三区| 国产精品系列在线播放| 色拍拍在线精品视频8848| 欧美日韩电影在线播放| 久久久精品tv| 亚洲精品va在线观看| 麻豆国产精品777777在线| 99精品视频中文字幕| 在线成人高清不卡| 国产欧美中文在线| 一区二区三区精品在线观看| 老司机精品视频线观看86| 日本大香伊一区二区三区| 久久婷婷久久一区二区三区| 亚洲一区在线免费观看| 国产成人综合亚洲网站| 欧美另类变人与禽xxxxx| 中文字幕永久在线不卡| 久久国产剧场电影| 欧美三级欧美一级| 1000部国产精品成人观看| 免费的国产精品| 91福利视频在线| 国产精品久久一卡二卡| 精品一区二区免费| 欧美日本韩国一区二区三区视频| 亚洲乱码国产乱码精品精小说 | 69堂亚洲精品首页| 国产精品久久久久久妇女6080| 美女脱光内衣内裤视频久久影院| 99久久国产综合精品女不卡| 久久久国产精华| 男人的天堂久久精品| 在线精品观看国产| 1024成人网色www| 成人av在线资源网站| 久久久久久久久一| 久久精品国产一区二区三 | 91丨porny丨户外露出| 久久久久久久久久电影| 日韩电影在线免费观看| 91国产免费看| 亚洲女人小视频在线观看| 成人黄色电影在线| 国产人妖乱国产精品人妖| 九九视频精品免费| 日韩精品专区在线影院重磅| 日本最新不卡在线| 51精品视频一区二区三区| 亚洲成人av一区| 欧美精品一级二级| 视频一区欧美精品| 91精品国产91久久综合桃花 | 国产精品一区二区果冻传媒| 精品免费视频.| 久久国产视频网| 26uuu久久天堂性欧美| 九九国产精品视频| 精品毛片乱码1区2区3区| 久久成人综合网| 精品久久久久久无| 国产精品资源站在线| 久久久久国产一区二区三区四区| 国产麻豆视频一区| 欧美韩国日本综合| 成人激情综合网站| 亚洲嫩草精品久久| 99免费精品在线| 亚洲色欲色欲www| 欧美日韩一区在线观看| 天堂成人国产精品一区| 日韩欧美精品三级| 国产成人aaaa| 亚洲乱码日产精品bd| 欧美久久久一区| 国产裸体歌舞团一区二区| xvideos.蜜桃一区二区| 从欧美一区二区三区| 亚洲欧美日韩国产手机在线| 欧美性xxxxx极品少妇| 蜜桃91丨九色丨蝌蚪91桃色| 久久久久久久久久电影| 91免费国产视频网站| 午夜精品国产更新| 久久蜜桃av一区精品变态类天堂 | 欧美另类久久久品| 久久精品国产第一区二区三区| 国产日韩亚洲欧美综合| 欧美亚洲动漫精品| 极品美女销魂一区二区三区免费|