The W3C Extended log file format is the default log file format for IIS. It is a customizable ASCII text-based format. You can use IIS Manager to select which fields to include in the log file, which allows you to keep log files as small as possible. Because HTTP.sys handles the W3C Extended log file format, this format records HTTP.sys kernel-mode cache hits.
Table 10.1 lists and describes the available fields. Default fields are noted.
Table 10.1 W3C Extended Log File Fields
Field
Appears As
Description
Default Y/N
Date
date
The date on which the activity occurred.
Y
Time
time
The time, in coordinated universal time (UTC), at which the activity occurred.
Client IP Address
c-ip
The IP address of the client that made the request.
User Name
cs-username
The name of the authenticated user who accessed your server. Anonymous users are indicated by a hyphen.
Service Name and Instance Number
s-sitename
The Internet service name and instance number that was running on the client.
N
Server Name
s-computername
The name of the server on which the log file entry was generated.
Server IP Address
s-ip
The IP address of the server on which the log file entry was generated.
Server Port
s-port
The server port number that is configured for the service.
Method
cs-method
The requested action, for example, a GET method.
URI Stem
cs-uri-stem
The target of the action, for example, Default.htm.
URI Query
cs-uri-query
The query, if any, that the client was trying to perform. A Universal Resource Identifier (URI) query is necessary only for dynamic pages.
HTTP Status
sc-status
The HTTP status code.
Win32 Status
sc-win32-status
The Windows status code.
Bytes Sent
sc-bytes
The number of bytes that the server sent.
Bytes Received
cs-bytes
The number of bytes that the server received.
Time Taken
time-taken
The length of time that the action took, in milliseconds.
Protocol Version
cs-version
The protocol version —HTTP or FTP —that the client used.
Host
cs-host
The host header name, if any.
User Agent
cs(User-Agent)
The browser type that the client used.
Cookie
cs(Cookie)
The content of the cookie sent or received, if any.
Referrer
cs(Referrer)
The site that the user last visited. This site provided a link to the current site.
Protocol Substatus
sc-substatus
The substatus error code.
Note
FTP log files do not record the following fields:
•
You can select as many of the W3C Extended log file fields as you want. However, not all fields will contain information. For fields that are selected but for which there is no information, a hyphen (-) appears as a placeholder. If a field contains a nonprintable character, HTTP.sys replaces it with a plus sign (+) to preserve the log file format. This typically occurs with virus attacks, when, for example, a malicious user sends carriage returns and line feeds that, if not replaced with the plus sign (+), would break the log file format.
Fields are separated by spaces. Field prefixes have the following meanings:
s- Server actions
c- Client actions
cs- Client-to-server actions
sc- Server-to-client actions
For the time-taken field, the client-request timestamp is initialized when HTTP.sys receives the first byte, but before HTTP.sys begins parsing the request. The client-request timestamp is stopped when the last IIS send completion occurs. Time taken does not reflect time across the network. The first request to the site shows a slightly longer time taken than other similar requests because HTTP.sys opens the log file with the first request.
注:以下部分翻譯自Microsoft網站--《W3C Extended Log File Format (IIS 6.0)》的解釋。
******************************************************************************************
W3C擴充日志檔案格式是IIS(Microsoft IIS)的預設日志格式,其内容編碼為預設的ASCII文本。你可以通過IIS管理器選擇各種
不同的字段包含在這種日志檔案内,這樣可以使你的日志内容更加人性化。其實系統是通過HTTP.sys句柄來處理W3C擴充日志的,
W3C内容格式完全是通過讀取HTTP.sys的核心緩存進行篩選擷取的。
下表中列出各種可選字段(“字段辨別”列為實際參數名)及其描述,并通過Default列記錄該字段是否預設被‘包含’了。
“字段” “字段辨別” “描述” “Default(Y/N )”
日期 date 動作發生時的日期。 Y
時間 time 動作發生時的時間(預設為UTC标準)。 Y
用戶端IP位址 c-ip 通路伺服器的用戶端IP位址。 Y
使用者名 cs-username 通過身份驗證的通路伺服器的使用者名。不包括匿名使用者(用‘-’表示)。 Y
服務名 s-sitename 客戶所通路的Internet服務名以及執行個體号。 N
伺服器名 s-computername 産生日志條目的伺服器的名字。 N
伺服器IP 位址 s-ip 産生日志條目的伺服器的IP位址。 Y
伺服器端口 s-port 服務端提供服務的傳輸層端口。 Y
方法 cs-method 用戶端執行的行為(主要是GET與POST行為)。 Y
URI Stem cs-uri-stem 被通路的資源,如Default.asp等。 Y
URI Query cs-uri-query 用戶端送出的參數(包括GET與POST行為)。 Y
協定狀态 sc-status 用HTTP或者FTP術語所描述的、行為執行後的傳回狀态。 Y
Win32狀态 sc-win32-status 用Microsoft Windows的術語所描述的動作狀态。N
發送位元組數 sc-bytes 服務端發送給用戶端的位元組數。 N
接受位元組數 cs-bytes 服務端從用戶端接收到的位元組數。 N
花費時間 time-taken 執行此次行為所消耗的時間,以毫秒為機關。 N
協定版本 cs-version 用戶端所用的協定(HTTP、FTP)版本。對HTTP協定來說是HTTP 1.0或者HTTP 1.1。 N
主機 cs-host 用戶端的HTTP報頭(host header)資訊。 N
使用者代理 cs(User-Agent) 用戶端所用的浏覽器版本資訊。 Y
Cookie cs(Cookie) 發送或者接受到的cookie内容。 N
Referrer cs(Referer) 使用者浏覽的前一個網址,目前網址是從該網址連結過來的。 N
協定底層狀态 sc-substatus 協定底層狀态的一些錯誤資訊。 Y
關于status codes字段的更多詳細資料請浏覽:“http://go.microsoft.com/fwlink/?LinkId=14381”。
注:其實我們對比一下實際操作會發現“Default”一列是與客觀事實有些出入的:P。
下面我們就幾個案例進行“還原”:
案例一:某網站http://www.test.com的日志ex050104.log的一段内容:
##########################################################################################
#Software: Microsoft Internet Information Services 6.0
#Version: 1.0
#Date: 2005-01-03 16:00:00
#Fields: date time cs-method cs-uri-stem cs-uri-query c-ip cs(Referer) sc-status sc-bytes cs-bytes time-taken
2005-01-01 16:02:22 GET /Enterprise/detail.asp id=1612186 70.25.29.53 http://www.test.com/searchout.asp 200 17735 369 4656
這裡我們可以得到的資料是:這是一台裝有IIS version 6的WEB伺服器(通過#Software辨別),版本是1.0(#Version辨別),
生成日期是2005年1月3日的下午4點正(#Date辨別),下面生成的W3C日志内容(通過#Fields辨別)包括日期、時間、Client
to Server的方法、讀取的對象、參數、用戶端的IP位址、用戶端上一個通路的對象、服務傳回的狀态、Server to Client的
位元組、Server接收到的位元組、處理該條目的操作總共使用的時間。最後還原的結果是:
--------------------------------------------------------------------------------------
在2005年1月1日的下午4時2分22秒,70.25.29.53這個IP位址的用戶端向我們的伺服器送出了一個GET:
http://www.test.com/Enterprise/detail.asp?id=1612186
網址的請求,這個請求送出的網址可能是從http://www.test.com/searchout.asp連結過來的,本次操作傳回“操作成功”應
答(成功完成操作),此次操作中服務端發送給用戶端17735個位元組的資料,服務端也接收到369個位元組的資料,此次操作總共
花了4656毫秒。
從上面的知識點不難看到,其實我們要通過W3C擴充日志對HTTP應用層行為進行監控的話,以下幾個字段的記錄是必不可少的:
date、time、cs-method、cs-uri-stem、cs-uri-query、c-ip、cs-version、cs(User-Agent)、cs(Referer)、sc-status、
sc-bytes、cs-bytes、time-taken、cs-host、cs(Cookie)。解說一下:
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
date和time就不用說了;
cs-method與cs-uri-stem、cs-uri-query聯合起來,很快就可以還原出c-ip究竟進行過怎麼樣的請求;
sc-status可以幫助我們辨識這個請求是否成功‘執行’,進而辨識現象與這個請求操作的依從性;
cs-version、cs(User-Agent)、cs(Referer)、cs-bytes、cs-host與cs(Cookie)可以作為一個類比的特征指紋,鑒别出一些非
正常的請求,如HTTP探測、HTTP DoS與CC等;
cs-bytes、sc-bytes與time-taken可以幫助我們辨識本次請求所耗費的各種資源的情況(如對帶寬的影響、CPU/記憶體資源占用
的影響)。
最後,一套行之有效的總結、歸類、對比方法可以更快地幫你定位到問題的根源,例如:“通過多個cs-uri-query的值相同或
相似,且發生的時間點幾乎一緻等各種因素,判斷其可能遭受過CC攻擊”等,這樣的案例常有存在,關鍵看各人的領悟了:P。