FrontPage

  • ローカルルールにも sid, rev をつけた方がいいのかなぁ…
  • イベントをある程度抑制するには threshold コマンドを設定する。
  • ルールを変えずにイベントを完全に抑制するには suppress コマンドを設定する。

threshold

http://www.snort.org/docs/snort_htmanuals/htmanual_260/node23.html

  • limit
    • 期間内で、最初の m 個のイベントのみアラートに出す。
      • 10個/1分と指定して、10個/1分で発生したら、1分内に10回アラートが出る。
      • 10個/1分と指定して、11個/1分で発生したら、1分内に10回アラートが出る。
  • threshold
    • 期間内で、m 個イベントが発生するごとにアラートを出す。
      • 10個/1分と指定して、9個/1分で発生したら、アラートは出ない
      • 10個/1分と指定して、10個/1分で発生したら、1分内に1回アラートが出る。
      • 10個/1分と指定して、19個/1分で発生したら、1分内に1回アラートが出る。
      • 10個/1分と指定して、20個/1分で発生したら、1分内に2回アラートが出る。
  • both
    • 期間内で、m 個イベントが発生したら1回のみアラートを出す。
      • 10個/1分と指定して、9個/1分で発生したら、アラートは出ない
      • 10個/1分と指定して、10個以上/1分で発生したら、1分内に1回アラートが出る。

suppress

http://www.snort.org/docs/snort_htmanuals/htmanual_260/node24.html

http_inspect 設定の意味

profile の意味

  • profile all と書くと、各種オプションが IIS/Apache 両用(?)に設定される。
  • profile iis と書くと、各種オプションが IIS 用に設定される。
  • profile apache と書くと、各種オプションが Apache 用に設定される。
  • profile により設定されるオプションはオーバーライドできない。(!)

ログに HttpInspect Config: というのが出ていて、ここに設定した内容が表示されている。

profile all port { 80 } の場合

    DEFAULT SERVER CONFIG:
      Ports: 80
      Flow Depth: 300
      Max Chunk Length: 500000
      Inspect Pipeline Requests: YES
      URI Discovery Strict Mode: NO
      Allow Proxy Usage: NO
      Disable Alerting: NO
      Oversize Dir Length: 0
      Only inspect URI: NO
      Ascii: YES alert: NO
      Double Decoding: YES alert: YES
      %U Encoding: YES alert: YES
      Bare Byte: YES alert: YES
      Base36: OFF
      UTF 8: OFF
      IIS Unicode: YES alert: YES
      Multiple Slash: YES alert: NO
      IIS Backslash: YES alert: NO
      Directory Traversal: YES alert: NO
      Web Root Traversal: YES alert: YES
      Apache WhiteSpace: YES alert: NO
      IIS Delimiter: YES alert: NO
      IIS Unicode Map: GLOBAL IIS UNICODE MAP CONFIG
      Non-RFC Compliant Characters: NONE

profile apache port { 80 } の場合

    DEFAULT SERVER CONFIG:
      Ports: 80
      Flow Depth: 300
      Max Chunk Length: 500000
      Inspect Pipeline Requests: YES
      URI Discovery Strict Mode: NO
      Allow Proxy Usage: NO
      Disable Alerting: NO
      Oversize Dir Length: 0
      Only inspect URI: NO
      Ascii: YES alert: NO
      Double Decoding: OFF
      %U Encoding: OFF
      Bare Byte: OFF
      Base36: OFF
      UTF 8: YES alert: NO
      IIS Unicode: OFF
      Multiple Slash: YES alert: NO
      IIS Backslash: OFF
      Directory Traversal: YES alert: NO
      Web Root Traversal: YES alert: YES
      Apache WhiteSpace: YES alert: NO
      IIS Delimiter: OFF
      IIS Unicode Map:  NOT CONFIGURED
      Non-RFC Compliant Characters: NONE

profile iis port { 80 } の場合

    DEFAULT SERVER CONFIG:
      Ports: 80
      Flow Depth: 300
      Max Chunk Length: 500000
      Inspect Pipeline Requests: YES
      URI Discovery Strict Mode: NO
      Allow Proxy Usage: NO
      Disable Alerting: NO
      Oversize Dir Length: 0
      Only inspect URI: NO
      Ascii: YES alert: NO
      Double Decoding: YES alert: YES
      %U Encoding: YES alert: YES
      Bare Byte: YES alert: YES
      Base36: OFF
      UTF 8: OFF
      IIS Unicode: YES alert: YES
      Multiple Slash: YES alert: NO
      IIS Backslash: YES alert: NO
      Directory Traversal: YES alert: NO
      Web Root Traversal: YES alert: YES
      Apache WhiteSpace: YES alert: NO
      IIS Delimiter: YES alert: NO
      IIS Unicode Map: GLOBAL IIS UNICODE MAP CONFIG
      Non-RFC Compliant Characters: NONE

変換(デコード)関連オプションの意味

とにかく説明が悪すぎる…

ascii オプション(URLエンコードされた ASCII コードのデコード)の場合

  • 何も書かないと、変換を行わない(!)
  • ascii yes と書くと、変換を行い、異常時にアラートを出す。
  • ascii no と書くと、変換を行い(!)、異常時にアラートを出さない。

つまり、yes/no はアラートの on/off であって、変換の on/off ではない! 変換の on/off は、オプションを書くかどうかで決まる。

profile apache port { 80 } と同等の設定は以下となる。

preprocessor http_inspect_server: server default \
     ports { 80 } \
     flow_depth 300 \
     chunk_length 500000 \
     non_strict \
     ascii no \
     utf_8 no \
     multi_slash no \
     directory no \
     webroot yes \
     apache_whitespace no

誤検出とその対処

WEB-MISC backup access

alert に出たログ

TCP Options (3) => NOP NOP TS: 2090768356 621743868

[**] [1:1213:5] WEB-MISC backup access [**]
[Classification: Attempted Information Leak] [Priority: 2]
08/29-17:03:32.117208 ***.***.***.***:6698 -> ***.***.***.***:80
TCP TTL:47 TOS:0x0 ID:8327 IpLen:20 DgmLen:481 DF
***AP*** Seq: 0x60D63C8C  Ack: 0x78059DEE  Win: 0x4470  TcpLen: 32

web-misc.rules

alert tcp $EXTERNAL_NET any -> $HTTP_SERVERS $HTTP_PORTS
 (msg:"WEB-MISC backup access"; flow:to_server,established;
 uricontent:"/backup"; nocase; classtype:attempted-recon; sid:1213; rev:5;)

"/backup" を見つけたら警告を出せとなっている。

http-access.log に残っていたログ

***.***.***.*** - - [29/Aug/2006:17:03:10 +0900] "GET /image/backup.png HTTP/1.1" 200 1261

いわゆる誤検出。

該当ルールを殺す。threshold.conf に以下を追加。(snort.conf で include threshold.conf を有効にする。)

suppress gen_id 1, sig_id 1213

local.rules に該当ルールをコピーして加工する。uricontent の二重書きで例外処理。

alert tcp $EXTERNAL_NET any -> $HTTP_SERVERS $HTTP_PORTS
 (msg:"WEB-MISC backup access"; flow:to_server,established;
 uricontent:"/backup"; nocase; uricontent:!"/backup.png" nocase; classtype:attempted-recon;)

再起動して、/backup.png を拾わないこと、/backup を拾うことを確認する。

/backup.png より /image/backup.png の方がいいかも?

IIS UNICODE CODEPOINT ENCODING

alert に出たログ

[**] [119:7:1] (http_inspect) IIS UNICODE CODEPOINT ENCODING [**]
08/29-18:21:58.226121 221.186.253.2:14222 -> 219.166.18.182:80
TCP TTL:124 TOS:0x0 ID:3071 IpLen:20 DgmLen:1448 DF
***A**** Seq: 0x57A2986F  Ack: 0xDBD44353  Win: 0xFFFF  TcpLen: 20

IIS は、クライアントからの文字コードをホストの文字コードに変換しようとするらしい。 ms_unicode_generator.c とそれによってできた unicode.map を見ると、このマッピングがどうもかなり変なようだ。

preprocessors/HttpInspect/normalization/hi_norm.c の UDecode (%uxxxx の変換)と UTF8Decode (UTF-8 のデコード) で、ASCII にならない文字が出てくると、このエラーが出るようだ。

snort.conf

# http_inspect: normalize and detect HTTP traffic and protocol anomalies
#
# lots of options available here. See doc/README.http_inspect.
# unicode.map should be wherever your snort.conf lives, or given
# a full path to where snort can find it.
preprocessor http_inspect: global \
    iis_unicode_map unicode.map 1252

unicode.map には、コードページとUnicodeと変換後の文字コード(ASCII領域)の関係が書かれている。 global 定義そのものは必須のもよう。

コードページ 1252 は ISO-8859-1 と同等らしい。

1252  (ANSI - Latin I)

IIS を使用していて、日本の場合は、932 を指定するのが妥当。

preprocessor http_inspect: global \
    iis_unicode_map unicode.map 932

それ以外の場合は特にデフォルトから変更する必要はないと思われる。サーバー設定側でiis_unicode の設定をはずせば OK。

preprocessor http_inspect_server: server default profile apache ...

とするか、あるいは profile を書かず、かつ iis_unicode を書かなければ、このエラーは出ない。


トップ   編集 凍結 差分 バックアップ 添付 複製 名前変更 リロード   新規 一覧 単語検索 最終更新   ヘルプ   最終更新のRSS
Last-modified: 2006-08-30 (水) 16:09:23 (1469d)