zoukankan      html  css  js  c++  java
  • suricata HTTP关键字

    http request

    http request请求包括请求行、请求头、空行和内容。一个普通的request请求如下:

     http response

    http response应答包括应答行,头部,空行和内容,整体结构和request差不多,下图是针对上节request的应答包

    HTTP关键字

    之前的常用关键字中介绍了content以及许多修饰它的关键字,除此之外,http协议中还有一些修饰content的关键字,也是由于http协议使用量较大,关键字较多,因此单独拿出来学习。

    1、http_method

    http_method是content的修饰符,表示其所修饰的content只匹配http method部分。http可以使用的方法包括:GET, POST, PUT, HEAD, DELETE, TRACE, OPTIONS, CONNECT和PATCH。下面这个例子匹配GET方法,无论是否加http_method都能匹配:

    但是下面这种情况就必须加http_method关键字,因为在http的uri部分也有GET:

    2、http_uri和http_raw_uri

    http_uri和http_raw_uri这两个关键字都是说明所修饰的content是用来匹配http uri部分的内容。所不同的是http_uri指在匹配之前先对URI进行标准化,所谓的标准化就是对数据包中的uri按照RFC文档规定进行一定的转化,包括保留语义转化、一般保留语义转化、改变语义转化。保留语义转化有以下几种,详细的解释参考URL标准化-维基百科,而http_raw_uri则是直接对uri进行匹配。下面这两个关键字用法的一个例子:

    3、uricontent

    uricontent的作用和http_uri相同,都是匹配uri部分的,不同的是uricontent可以独立使用,相当于content+http_uri的效果。但是官方文档里说明这个关键字已经被弃用,但目前还对其进行支持

    4、urilen

    urilen关键字用于匹配请求URI的长度。可以使用<>运算符,分别表示小于和大于

    5、http_protocol

    该http_protocol关键字用于匹配http协议部分

    alert http any any -> any any (flow:to_server; http_protocol; content:"HTTP/1.0"; sid:1;)
    

    6、http_request_line和http_response_line

    该http_request_line关键字用于匹配 http request的request_line部分,该http_response_line关键字用于匹配 http request的request_line部分,

    alert http any any -> any any (http_request_line; content:"GET / HTTP/1.0"; sid:1;)
    

    7、http_header和http_raw_header

    和http_uri一样,http_header也是只匹配http的header部分的内容(不包括cookie),http_raw_header则是匹配没有标准化过的header(参考HTTP header),简单来说就是标准化的header在每个字段的结尾 之前都会去掉其余的空白字符。两个简单的例子

    8、http_cookie

    http_cookie从http_header中独立出来,但其使用方法和前几个关键字并无区别,这里就直接贴出例子

    9、http_user_agent

    http_user_agent用于匹配http的User-Agent字段的内容,它是http_header的一部分,但是把它单独拿出来说明其出现的频率比较高,用法与前几个没什么差别。关于http_user_agent和http_header的性能对比可以参考Suricata http_user_agent vs http_header,得出的结论是http_user_agent比http_header要快大约10%,除此之外规则中使用http_user_agent的可读性也比较好。例子如下:

    10、http_client_body和http_server_body

    使用了这两个修饰符的content表示只匹配http包中的内容部分,前者值匹配request包,而后者只匹配response。用法很简单:

    11、http_accept

     匹配http_header中的accept部分

    alert http any any -> any any (http_accept; content:"image/gif"; sid:1;)
    

    12、http_accept_enc

    匹配http_header中的HTTP Accept-Encoding部分

    alert http any any -> any any (http_accept_enc; content:"gzip"; sid:1;)
    

    13、http_accept_lang

    匹配http_header中的HTTP Accept-Language部分

    alert http any any -> any any (http_accept_lang; content:"en-us"; sid:1;)
    

    14、http_connection

    匹配http_header中的Connection部分

    alert http any any -> any any (http_connection; content:"keep-alive"; sid:1;)

    15、http_content_type

    匹配http_header中的Content-Type部分

    alert http any any -> any any (flow:to_client; http_content_type; content:"text/javascript"; sid:2;)
    

    16、http_content_len

    匹配http_header中的 Content-Length部分,并配合flow:to_server 或者 flow:to_client来表明是请求包还是响应包

    alert http any any -> any any (flow:to_server; http_content_len; content:"666"; sid:1;)
    
    alert http any any -> any any (flow:to_client; http_content_len; content:"555"; sid:2;)
    

    17、http_referer

    匹配http_header中的Referer部分 

    alert http any any -> any any (http_referer; content:".php"; sid:1;)
    

    18、http_stat_code和http_stat_msg

     这两个content修饰符分别匹配response应答包返回的状态码和状态信息,例子如下:

    19、file_data

    file_data的作用和http_server_body差不多,都是使content匹配response body中的内容,唯一不同的是使用了file_data关键字的规则,其在file_data之后的content都会受到它的影响。比如下面这条规则,值为”abc”和”xyz”的content都必须在response body里面匹配:

    alert http any any -> any any (file_data; content:"abc"; content:"xyz";)
  • 相关阅读:
    苹果一体机发射Wi-Fi
    iphone 屏蔽系统自动更新,消除设置上的小红点
    data parameter is nil 异常处理
    copy与mutableCopy的区别总结
    java axis2 webservice
    mysql 远程 ip访问
    mysql 存储过程小问题
    mysql游标错误
    is not writable or has an invalid setter method错误的解决
    Struts2中关于"There is no Action mapped for namespace / and action name"的总结
  • 原文地址:https://www.cnblogs.com/luxiaojun/p/8796069.html
Copyright © 2011-2022 走看看