|
URLScanを使ってIIS5だと名乗らないようにする
URLScanを使ってIIS5だと名乗らないようにする
0.改訂履歴
1.はじめに
このドキュメントでは,Microsoftが提供する,URLScanツール使って,IIS5.0を偽装?する手順を説明する.
2.目的
- IIS5.0の虚弱性を使ったセキュリティアタックのワームが存在するが,これをある程度防ぐ事が目的.
- そういうワームは,Webサーバが接続時にクライアントに返すヘッダを見て,IIS5.0と判断して規定の攻撃を加えてくる場合が多い.
- よって,IIS5.0であることを隠蔽することで,ある程度のアタックからIIS5.0で稼働するサーバを守る事が目的である.
3.検証環境
- Windows2000 Advanced Serverで稼働するIIS5.0
- 今回は,IISが稼働するサーバ上で作業を行った.
4.事前テスト
コマンドプロンプトからTELNETでIISに接続してみる
Microsoft Windows 2000 [Version 5.00.2195]
(C) Copyright 1985-2000 Microsoft Corp.
C:\Documents and Settings\Administrator>cd c:\
C:\>telnet 127.0.0.1 80
|
適当なHTTPを入力する
HTTP [Return][Return]
|
- 何も表示されない画面になるが,無視してキーボードからHTTPと入力する.
- リターンキーを2回入力する.
- すると,次のように表示さる.
前出のリクエストに対して,IISが返してきた応答
HTTP/1.1 400 Bad Request
Server: Microsoft-IIS/5.0
Date: Sat, 27 Jul 2002 03:30:58 GMT
Content-Type: text/html
Content-Length: 87
<html><head><title>Error</title></head><body>The parameter is incorrect. </body>
</html>
ホストとの接続が切断されました。
C:\>
|
- この反応を見ると,IIS5.0が応答していることが歴然である.
5.モジュールを入手する
- URLScanツールは,IIS LockDown Toolの一部として提供されている.
- まず,IIS Lockdown Toolをダウンロードする.
- IIS Lockdown Tool (version 2.1)
- ダウンロードしたファイルは次の通り.
ダウンロードしたファイルを確認してみる
C:\>cd iislockdowntool2.1
C:\IISlockDownTool2.1>dir
ドライブ C のボリューム ラベルは DriveC です
ボリューム シリアル番号は 1415-D45E です
C:\IISlockDownTool2.1 のディレクトリ
2002/07/27 12:55 <DIR> .
2002/07/27 12:55 <DIR> ..
2002/07/27 12:55 291,360 iislockd.exe
1 個のファイル 291,360 バイト
2 個のディレクトリ 2,040,623,104 バイトの空き領域
C:\IISlockDownTool2.1>
|
ファイルの抽出
C:\IISlockDownTool2.1>iislockd.exe /q /c /t:c:\lockdown_files
C:\IISlockDownTool2.1>
|
抽出したファイルを確認する
C:\IISlockDownTool2.1>cd c:\lockdown_files
C:\lockdown_files>dir /w
ドライブ C のボリューム ラベルは DriveC です
ボリューム シリアル番号は 1415-D45E です
C:\lockdown_files のディレクトリ
[.] [..]
404.dll iislockd.chm
iislockd.exe iislockd.ini
readme.txt RunLockdUnattended.doc
unattend.cmd UrlScan.doc
UrlScan.exe UrlScan.ini
urlscan_biztalk.ini urlscan_commerce.ini
urlscan_dynamic.ini urlscan_exchange2000.ini
urlscan_exchange5_5.ini urlscan_frontpage.ini
urlscan_sbs2000.ini urlscan_sharepoint_portal.ini
urlscan_sharepoint_teamservices.ini urlscan_static.ini
urlscan_unattend.txt
21 個のファイル 559,876 バイト
2 個のディレクトリ 2,040,033,280 バイトの空き領域
C:\lockdown_files>
|
6.URLScanのDLLを取り出す
- URLscan.exeも,実はアーカイブである.
- 次のように,アーカイブの展開方法についてヘルプを表示してみる.
URLScan.exeのヘルプを見る
C:\lockdown_files>urlscan.exe /?
C:\lockdown_files>
|
- ヘルプにあるとおり,EXEを実行してアーカイブからファイルを取り出す.
URLScan.exeを展開する
C:\lockdown_files>urlscan.exe /q /c /t:c:\urlscan
C:\lockdown_files>
|
URLScanの展開されたファイルを確認する
C:\lockdown_files>cd c:\urlscan
C:\urlscan>dir /w
ドライブ C のボリューム ラベルは DriveC です
ボリューム シリアル番号は 1415-D45E です
C:\urlscan のディレクトリ
[.] [..] ADVPACK.DLL UrlScan.dll UrlScan.inf
UrlScan.ini UrlScanR.dll W95INF16.DLL W95INF32.DLL
7 個のファイル 184,715 バイト
2 個のディレクトリ 2,039,828,480 バイトの空き領域
C:\urlscan>
|
7.URLScanをIISに組み込む
- URLScanは,DLLで提供されているが,これはISAPIでIISから利用される形式となっている.
- よって,IISにこのDLLを読み込むように設定して,有効にするためにIISを再起動する必要がある.
- [マイコンピュータ]→右クリック→[管理]を選択する.
- [コンピュータの管理]が起動する.
- [サービスとアプリケーション]→[インターネットインフォメーションサービス]を選択する.
- [マスタプロパティ]→[WWWサービス]→[編集]を選択する.
8.URLscanが有効になっているか確認する
- URLScan.DLLが読み込まれて正しく動作しているか確認する.
9.URLScan.iniを設定する
- URLScanは,URLScan.dllと同じディレクトリにあるurlscan.iniによって設定さえる.
- このファイルを編集後,IISを再起動することで変更が有効になる.
- インストール直後のurlscan.iniファイルを確認してみる.
urlscan.ini
[options]
UseAllowVerbs=1 ; if 1, use [AllowVerbs] section, else use
[DenyVerbs] section
UseAllowExtensions=0 ; if 1, use [AllowExtensions] section, else use
[DenyExtensions] section
NormalizeUrlBeforeScan=1 ; if 1, canonicalize URL before processing
VerifyNormalization=1 ; if 1, canonicalize URL twice and reject request
if a change occurs
AllowHighBitCharacters=0 ; if 1, allow high bit (ie. UTF8 or MBCS)
characters in URL
AllowDotInPath=0 ; if 1, allow dots that are not file extensions
RemoveServerHeader=0 ; if 1, remove "Server" header from response
EnableLogging=1 ; if 1, log UrlScan activity
PerProcessLogging=0 ; if 1, the UrlScan.log filename will contain a
PID (ie. UrlScan.123.log)
AllowLateScanning=0 ; if 1, then UrlScan will load as a low priority
filter.
PerDayLogging=1 ; if 1, UrlScan will produce a new log each day
with activity in the form UrlScan.010101.log
RejectResponseUrl= ; UrlScan will send rejected requests to the URL
specified here. Default is /<Rejected-by-UrlScan>
UseFastPathReject=0 ; If 1, then UrlScan will not use the
RejectResponseUrl or allow IIS to log the request
; If RemoveServerHeader is 0, then AlternateServerName can be
; used to specify a replacement for IIS's built in 'Server' header
AlternateServerName=
[AllowVerbs]
;
; The verbs (aka HTTP methods) listed here are those commonly
; processed by a typical IIS server.
;
; Note that these entries are effective if "UseAllowVerbs=1"
; is set in the [Options] section above.
;
GET
HEAD
POST
[DenyVerbs]
;
; The verbs (aka HTTP methods) listed here are used for publishing
; content to an IIS server via WebDAV.
;
; Note that these entries are effective if "UseAllowVerbs=0"
; is set in the [Options] section above.
;
PROPFIND
PROPPATCH
MKCOL
DELETE
PUT
COPY
MOVE
LOCK
UNLOCK
OPTIONS
SEARCH
[DenyHeaders]
;
; The following request headers alter processing of a
; request by causing the server to process the request
; as if it were intended to be a WebDAV request, instead
; of a request to retrieve a resource.
;
Translate:
If:
Lock-Token:
[AllowExtensions]
;
; Extensions listed here are commonly used on a typical IIS server.
;
; Note that these entries are effective if "UseAllowExtensions=1
; is set in the [Options] section above.
;
.htm
.html
.txt
.jpg
.jpeg
.gif
[DenyExtensions]
;
; Extensions listed here either run code directly on the server,
; are processed as scripts, or are static files that are
; generally not intended to be served out.
;
; Note that these entries are effective if "UseAllowExtensions=0"
; is set in the [Options] section above.
;
; Also note that ASP scripts are denied with the below
; settings. If you wish to enable ASP, remove the
; following extensions from this list:
; .asp
; .cer
; .cdx
; .asa
;
; Deny ASP requests
.asp
.cer
.cdx
.asa
; Deny executables that could run on the server
.exe
.bat
.cmd
.com
; Deny infrequently used scripts
.htw ; Maps to webhits.dll, part of Index Server
.ida ; Maps to idq.dll, part of Index Server
.idq ; Maps to idq.dll, part of Index Server
.htr ; Maps to ism.dll, a legacy administrative tool
.idc ; Maps to httpodbc.dll, a legacy database access tool
.shtm ; Maps to ssinc.dll, for Server Side Includes
.shtml ; Maps to ssinc.dll, for Server Side Includes
.stm ; Maps to ssinc.dll, for Server Side Includes
.printer ; Maps to msw3prt.dll, for Internet Printing Services
; Deny various static files
.ini ; Configuration files
.log ; Log files
.pol ; Policy files
.dat ; Configuration files
[DenyUrlSequences]
.. ; Don't allow directory traversals
./ ; Don't allow trailing dot on a directory name
\ ; Don't allow backslashes in URL
: ; Don't allow alternate stream access
% ; Don't allow escaping after normalization
& ; Don't allow multiple CGI processes to run on a single request
|
- なんか色々出来そうな気がしてきた!
10.サーバがIISだと名乗らないようにする
- urlscan.iniを編集する.
たいとる
[options]
UseAllowVerbs=1 ; if 1, use [AllowVerbs] section, else use
[DenyVerbs] section
UseAllowExtensions=0 ; if 1, use [AllowExtensions] section, else use
[DenyExtensions] section
NormalizeUrlBeforeScan=1 ; if 1, canonicalize URL before processing
VerifyNormalization=1 ; if 1, canonicalize URL twice and reject request
if a change occurs
AllowHighBitCharacters=0 ; if 1, allow high bit (ie. UTF8 or MBCS)
characters in URL
AllowDotInPath=0 ; if 1, allow dots that are not file extensions
RemoveServerHeader=1 ; if 1, remove "Server" header from response
EnableLogging=1 ; if 1, log UrlScan activity
|
- このように,RemoveServerHedaer=1とする.
- ファイルを保存して,IISを再起動する.
- 最初に行ったように,TELNETでIISに接続する.
TELNETでIISに接続する
C:\urlscan>telnet 127.0.0.1 80
|
- HTTPコマンドを実行する.
適当なHTTPを入力する
HTTP [Return][Return]
|
- 次のようにIISからレスポンスがある.
IISからのレスポンス
HTTP/1.1 400 Bad Request
Content-Type: text/html
Content-Length: 87
Connection: close
<html><head><title>Error</title></head><body>The parameter is incorrect. </body>
</html>
ホストとの接続が切断されました。
C:\urlscan>
|
- IISだと名乗らないようになりました.
参考資料
- [IIS]INFO: URLScan セキュリティ ツールについて
|
|