⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 snort_httpinspect.c

📁 Linux snort-2.4.4源代码
💻 C
📖 第 1 页 / 共 5 页
字号:
        snprintf(ErrorString, ErrStrLen,                "Invalid argument to '%s'.", CHUNK_LENGTH);        return -1;    }    ServerConf->chunk_length = iChunkLength;    return 0;}/***  NAME**    ProcessConfOpt::*//****  Set the CONF_OPT on and alert fields.****  We check to make sure of valid parameters and then**  set the appropriate fields.  Not much more to it, than**  that.****  @param ConfOpt  pointer to the configuration option**  @param Option   character pointer to the option being configured**  @param ErrorString error string buffer**  @param ErrStrLen   the length of the error string buffer****  @return an error code integer **          (0 = success, >0 = non-fatal error, <0 = fatal error)****  @retval  0 successs**  @retval -1 generic fatal error**  @retval  1 generic non-fatal error*/static int ProcessConfOpt(HTTPINSPECT_CONF_OPT *ConfOpt, char *Option,                          char *ErrorString, int ErrStrLen){    char *pcToken;    pcToken = strtok(NULL, CONF_SEPARATORS);    if(pcToken == NULL)    {        snprintf(ErrorString, ErrStrLen,                "No argument to token '%s'.", Option);        return -1;    }    /*    **  Check for the alert value    */    if(!strcmp(BOOL_YES, pcToken))    {        ConfOpt->alert = 1;    }    else if(!strcmp(BOOL_NO, pcToken))    {        ConfOpt->alert = 0;    }    else    {        snprintf(ErrorString, ErrStrLen,                "Invalid argument to token '%s'.", Option);        return -1;    }    ConfOpt->on = 1;    return 0;}/***  NAME**    ProcessNonRfcChar::*//*****  Configure any characters that the user wants alerted on in the**  URI.****  This function allocates the memory for CONF_OPT per character and**  configures the alert option.****  @param ConfOpt  pointer to the configuration option**  @param ErrorString error string buffer**  @param ErrStrLen   the length of the error string buffer****  @return an error code integer **          (0 = success, >0 = non-fatal error, <0 = fatal error)****  @retval  0 successs**  @retval -1 generic fatal error**  @retval  1 generic non-fatal error*/static int ProcessNonRfcChar(HTTPINSPECT_CONF *ServerConf,                             char *ErrorString, int ErrStrLen){    char *pcToken;    char *pcEnd;    int  iChar;    int  iEndChar = 0;    pcToken = strtok(NULL, CONF_SEPARATORS);    if(!pcToken)    {        snprintf(ErrorString, ErrStrLen,                "Invalid '%s' list format.", NON_RFC_CHAR);        return -1;    }    if(strcmp(START_PORT_LIST, pcToken))    {        snprintf(ErrorString, ErrStrLen,                "Must start a '%s' list with the '%s' token.",                NON_RFC_CHAR, START_PORT_LIST);        return -1;    }        while((pcToken = strtok(NULL, CONF_SEPARATORS)))    {        if(!strcmp(END_PORT_LIST, pcToken))        {            iEndChar = 1;            break;        }        iChar = strtol(pcToken, &pcEnd, 16);        if(*pcEnd)        {            snprintf(ErrorString, ErrStrLen,                    "Invalid argument to '%s'.  Must be a single "                    "character.", NON_RFC_CHAR);            return -1;        }        if(iChar < 0 || iChar > 255)        {            snprintf(ErrorString, ErrStrLen,                    "Invalid character value to '%s'.  Must be a single "                    "character no greater than 255.", NON_RFC_CHAR);            return -1;        }        ServerConf->non_rfc_chars[iChar] = 1;    }    if(!iEndChar)    {        snprintf(ErrorString, ErrStrLen,                "Must end '%s' configuration with '%s'.",                NON_RFC_CHAR, END_PORT_LIST);        return -1;    }    return 0;}/***  NAME**    ProcessServerConf::*//****  Process the global server configuration.****  Take the configuration and translate into the global server**  configuration.  We also check for any configuration errors and**  invalid keywords.****  @param ServerConf  pointer to the server configuration**  @param ErrorString error string buffer**  @param ErrStrLen   the length of the error string buffer****  @return an error code integer **          (0 = success, >0 = non-fatal error, <0 = fatal error)****  @retval  0 successs**  @retval -1 generic fatal error**  @retval  1 generic non-fatal error*/static int ProcessServerConf(HTTPINSPECT_GLOBAL_CONF *GlobalConf,                             HTTPINSPECT_CONF *ServerConf,                             char *ErrorString, int ErrStrLen){    char *pcToken;    int  iRet;    int  iPorts = 0;    HTTPINSPECT_CONF_OPT *ConfOpt;    /*    **  Check for profile keyword first, it's the only place in the    **  configuration that is correct.    */    pcToken = strtok(NULL, CONF_SEPARATORS);    if(pcToken == NULL)    {        snprintf(ErrorString, ErrStrLen,                "No tokens to '%s' configuration.", GLOBAL);        return 1;    }    if(!strcmp(PROFILE, pcToken))    {        if((iRet = ProcessProfile(GlobalConf, ServerConf,                                  ErrorString, ErrStrLen)))        {            return iRet;        }        pcToken = strtok(NULL, CONF_SEPARATORS);        if(pcToken == NULL)        {            snprintf(ErrorString, ErrStrLen,                     "No port list to the profile token.");            return -1;        }        do        {            if(!strcmp(PORTS, pcToken))            {                if((iRet = ProcessPorts(ServerConf,                                         ErrorString, ErrStrLen)))                {                    return iRet;                }                iPorts = 1;            }            else if(!strcmp(IIS_UNICODE_MAP, pcToken))            {                if((iRet = ProcessIISUnicodeMap(&ServerConf->iis_unicode_map,                                         &ServerConf->iis_unicode_map_filename,                                             &ServerConf->iis_unicode_codepage,                                                ErrorString,ErrStrLen)))                {                    return -1;                }            }            else if(!strcmp(ALLOW_PROXY, pcToken))            {                ServerConf->allow_proxy = 1;            }            else if(!strcmp(FLOW_DEPTH, pcToken))            {                if((iRet = ProcessFlowDepth(ServerConf,                                             ErrorString, ErrStrLen)))                {                    return iRet;                }            }            else if(!strcmp(GLOBAL_ALERT, pcToken))            {                ServerConf->no_alerts = 1;            }            else if(!strcmp(OVERSIZE_DIR, pcToken))            {                if((iRet = ProcessOversizeDir(ServerConf,                                               ErrorString, ErrStrLen)))                {                    return iRet;                }             }            else if(!strcmp(INSPECT_URI_ONLY, pcToken))            {                ServerConf->uri_only = 1;            }            else            {                snprintf(ErrorString, ErrStrLen,                         "Invalid token while configuring the profile token.  "                         "The only allowed tokens when configuring profiles "                         "are: '%s', '%s', '%s', '%s', '%s', '%s', and '%s'.",                         PORTS,IIS_UNICODE_MAP, ALLOW_PROXY, FLOW_DEPTH,                         GLOBAL_ALERT, OVERSIZE_DIR, INSPECT_URI_ONLY);                return -1;            }        } while((pcToken = strtok(NULL, CONF_SEPARATORS)));        if(!iPorts)        {            snprintf(ErrorString, ErrStrLen,                     "No port list to the profile token.");            return -1;        }        return 0;    }    /*    **  If there is no profile configuration then we go into the hard-core    **  configuration.    */    do    {        if(!strcmp(PORTS, pcToken))        {            if((iRet = ProcessPorts(ServerConf,                                     ErrorString, ErrStrLen)))            {                return iRet;            }        }        else if(!strcmp(FLOW_DEPTH, pcToken))        {            if((iRet = ProcessFlowDepth(ServerConf,                                         ErrorString, ErrStrLen)))            {                return iRet;            }        }        else if(!strcmp(IIS_UNICODE_MAP, pcToken))        {            if((iRet = ProcessIISUnicodeMap(&ServerConf->iis_unicode_map,                                         &ServerConf->iis_unicode_map_filename,                                            &ServerConf->iis_unicode_codepage,                                            ErrorString, ErrStrLen)))            {                return iRet;            }        }        else if(!strcmp(CHUNK_LENGTH, pcToken))        {            if((iRet = ProcessChunkLength(ServerConf,ErrorString,ErrStrLen )))            {                return iRet;            }        }        else if(!strcmp(PIPELINE, pcToken))        {            ServerConf->no_pipeline = 1;        }        else if(!strcmp(NON_STRICT, pcToken))        {            ServerConf->non_strict = 1;        }        else if(!strcmp(ALLOW_PROXY, pcToken))        {            ServerConf->allow_proxy = 1;        }        else if(!strcmp(GLOBAL_ALERT, pcToken))        {            ServerConf->no_alerts = 1;        }        else if(!strcmp(TAB_URI_DELIMITER, pcToken))        {            ServerConf->tab_uri_delimiter = 1;        }                else if(!strcmp(OVERSIZE_DIR, pcToken))        {            if((iRet = ProcessOversizeDir(ServerConf,                                           ErrorString, ErrStrLen)))            {                return iRet;            }         }        else if(!strcmp(INSPECT_URI_ONLY, pcToken))        {            ServerConf->uri_only = 1;        }        /*        **  Start the CONF_OPT configurations.        */        else if(!strcmp(ASCII, pcToken))        {            ConfOpt = &ServerConf->ascii;            if((iRet = ProcessConfOpt(ConfOpt, ASCII,                                       ErrorString, ErrStrLen)))            {                return iRet;            }        }        else if(!strcmp(UTF_8, pcToken))        {            /*            **  In order for this to work we also need to set ASCII            */            ServerConf->ascii.on    = 1;            ConfOpt = &ServerConf->utf_8;            if((iRet = ProcessConfOpt(ConfOpt, UTF_8,                                      ErrorString, ErrStrLen)))            {                return iRet;            }        }        else if(!strcmp(IIS_UNICODE, pcToken))        {            if(ServerConf->iis_unicode_map == NULL)            {                ServerConf->iis_unicode_map = GlobalConf->iis_unicode_map;            }            /*            **  We need to set up:            **    - ASCII            **    - DOUBLE_DECODE            **    - U_ENCODE            **    - BARE_BYTE            **    - IIS_UNICODE            **    - BASE36            */            ServerConf->ascii.on           = 1;            ConfOpt = &ServerConf->iis_unicode;            if((iRet = ProcessConfOpt(ConfOpt, IIS_UNICODE,                                      ErrorString, ErrStrLen)))            {                return iRet;            }        }        else if(!strcmp(DOUBLE_DECODE, pcToken))        {            ServerConf->ascii.on             = 1;            ConfOpt = &ServerConf->double_decoding;            if((iRet = ProcessConfOpt(ConfOpt, DOUBLE_DECODE,                                      ErrorString, ErrStrLen)))            {                return iRet;            }        }        else if(!strcmp(U_ENCODE, pcToken))        {            /*            **  With %U encoding, we don't want base36 on.            */            ServerConf->base36.on = 0;            ServerConf->base36.alert = 0;            /*            **  We set the unicode map to default if it's not already            **  set.            */            if(ServerConf->iis_unicode_map == NULL)            {                ServerConf->iis_unicode_map = GlobalConf->iis_unicode_map;            }            ConfOpt = &ServerConf->u_encoding;            if((iRet = ProcessConfOpt(ConfOpt, U_ENCODE,                                      ErrorString, ErrStrLen)))            {                return iRet;            }        }        else if(!strcmp(BARE_BYTE, pcToken))        {            ConfOpt = &ServerConf->bare_byte;            if((iRet = ProcessConfOpt(ConfOpt, BARE_BYTE,                                      ErrorString, ErrStrLen)))            {                return iRet;            }        }        else if(!strcmp(BASE36, pcToken))        {            ServerConf->ascii.on      = 1;            /*            **  With Base36 encoding, we don't want to have %U encoding            **  turned on.            */

⌨️ 快捷键说明

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