📄 snot_main.c
字号:
/*
** snot: How to annoy an intrusion detection system
*/
#include "snot.h"
/* global variables */
/* All the text that matches the option strings */
char *option_text[OPTION_MAX] =
{ "msg", "ttl", "tos", "id", "ipopts", "fragbits", "dsize", "flags",
"seq", "ack", "itype", "icode", "icmp_id", "icmp_seq", "content",
"content_list", "offset", "depth", "nocase", "rpc", "reference"
};
/* ip options */
char *ipopts_text[IPOPTS_MAX] =
{ "rr", "eol", "nop", "ts", "sec", "lsrr", "lsrre", "ssrr", "satid"
};
int total_rules;
struct rule *rulehead;
struct var_list *vhead;
uint8_t netmask[33*16]; // modified
/* end globals */
int
main(int argc, char *argv[])
{
int i;
char *msrc=NULL;
char *mdst=NULL;
char *rulefile=NULL;
int mint=0, mdly=0, mnum=0;
#if(WIN32)
WSADATA wsdata;
WORD wVersionRequested;
/* Initialise winsock */
wVersionRequested = MAKEWORD(1,1);
i = WSAStartup(wVersionRequested, &wsdata);
if (i){
printf("main: Couldn't initialise winsock.\n");
}
#endif
while((i = getopt(argc, argv, "r:s:d:i:l:n:")) != -1)
{
switch(i)
{
case 'n':
mnum = atoi(optarg);
break;
case 'r':
rulefile = strdup(optarg);
break;
case 's':
msrc = strdup(optarg);
break;
case 'l':
mdly = atoi(optarg);
break;
case 'd':
mdst = strdup(optarg);
break;
#if(WIN32)
case 'i':
mint = atoi(optarg);
break;
#endif
}
}
if (rulefile == NULL)
{
printf("Usage: snot -r <rulefile> [-s <source IP>] [-d <dest IP>] [-n <number of packets>] [-l <delay>]");
#if(WIN32)
printf(" [-i <interface number>]");
#endif
printf("\n");
return(EXIT_FAILURE);
}
#if(WIN32)
#ifdef DEBUG
printf("Opening Adapter #%d\n",mint);
#endif
if(libnet_win32_init(mint) == FALSE)
{
exit(0);
}
#endif
printf("snot %s by sniph (sniph00@yahoo.com)\n\n", VERSION);
printf("----------------------------------------\n");
printf("Rulefile : %s\n",rulefile);
printf("Source Address :");
if(msrc) printf(" %s\n",msrc);
else printf(" Use rules file\n");
printf("Dest Address :");
if(mdst) printf(" %s\n",mdst);
else printf(" Use rules file\n");
printf("Number of Packets :");
if(mnum) printf(" %d\n",mnum);
else printf(" Unlimited\n");
printf("Delay (max seconds):");
if(mdly) printf(" %d\n",mdly);
else printf(" No Delay\n");
#if(WIN32)
printf("Interface : %d\n",mint);
#endif
printf("----------------------------------------\n");
printf("\n");
if(parse_rules(msrc,mdst,rulefile))
{
printf("Error parsing rules.. Exiting\n");
return(EXIT_FAILURE);
}
if (!total_rules)
{
printf("No rules successfully parsed.. Exiting\n");
return(EXIT_FAILURE);
}
printf("\n[Parse Rules - Completed parsing %d rules - Sending now]\n\n",total_rules);
if(send_packets(mdly,mnum))
{
printf("Error sending packets.. Exiting\n");
return(EXIT_FAILURE);
}
return(EXIT_SUCCESS);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -