随着internet的普及,现在的web站点将面对更多的安全威胁。本文将介绍一些linux环境下的一些帮助系统管理员抵御网络攻击的自由安全工具。
现在,有大量的自由软件可以帮助我们加强web服务器的安全。然而,在商业领域,只有cybercop ( www.nai.com)、iss ( www.iss.net)、retina ( www.eeye.com)等几种相关产品。
加强web服务器的安全主要从三个方面入手。1).其所处的网络;2).运行的操作系统;3).服务器上运行的应用程序。本文我将详细介绍一些工具,你可以使用这些工具来加强自己web服务器的安全。
对于web服务器的测试最好能够采用结构化的方式。如果你是管理的是一个小网络,你可能对于每台服务器使用的操作系统和运行的程序有比较清楚的了解。但是对于一个大型网络,要对每台服务器都有清楚的了解是非常困难的。在这种情况下,可以采取以下四个步骤,进行了解:
指纹特征分析:扫描主机的操作系统、运行的应用程序和提供的服务。
缺陷分析:分析操作系统、应用程序、系统服务的潜在安全缺陷。
入侵测试:尝试利用上一步发现的缺陷进行攻击。
加固系统:修补上一步发现的缺陷,尽量减小系统的脆弱性。
本文将集中讨论前两步。
指纹特征分析
在网络安全规划中,指纹特征分析总是首先要做的。也就是说,在进行实际的测试之前,你不许知道测试目标使用的操作系统、运行的应用程序和提供的服务。这些细节可以帮助你发现潜在的安全缺陷。要知道这些细节,首先要判断系统的操作系统和打开的端口。
判断操作系统
nmap是一个伟大的端口扫描和操作系统检测工具,使用nmap可以非常有效地发现检测目标使用的操作系统:
#nmap -st -o 192.168.1.1
starting nmap v. 2.54beta5 ( www.insecure.org/nmap/ )
tcp sequence prediction: class=truly random
difficulty=9999999 (good luck!)
remote operating system guess: linux 2.0.32-34
从输出可以看出目标使用linux操作系统。nmap是通过分析收到的报文议判断操作系统的类型的。
端口扫描
然后,我们进行端口扫描来判断目标打开的端口。如果可以和系统的某个服务建立连接,那么在端口上监听的服务进程就存在安全缺陷就可能被利用。
#nmap -st 192.168.1.1
starting nmap v. 2.54beta5 ( www.insecure.org/nmap/ )
intesting ports on 192.168.1.1 (206.135.57.167):
(the 1529 ports scanned but not shown below are in state: closed)
port state service
19/tcp open chargen
21/tcp open ftp
23/tcp open telnet
25/tcp open smtp
37/tcp open time
79/tcp open finger
80/tcp filtered http
113/tcp open auth
443/tcp filtered https
1723/tcp filtered pptp
nmap run completed -- 1 ip address (1 host up) scanned in 12 seconds
扫描完毕tcp端口之后,我们还要找出打开的udp端口:
#nmap -su 192.168.1.1
starting nmap v. 2.54beta5 ( www.insecure.org/nmap/ )
port state service
37/udp open time
53/udp open domain
67/udp open bootps
69/udp open tftp
94/udp open objcall
111/udp open sunrpc
从端口扫描结果反县可以发现系统巡行ftp、http、auth、https、pptp、telnet、chargen、smtp、finger、time、domain、bootps、tftp、objcall、sunrpc。现在,我们把注意力转到linux操作系统和检测目标提供的这些服务中存在的安全缺陷。完成了以上的信息收集,下面我们还需要判断web服务器是否能够正常提供服务。
netcat
netcat(nc)是一个简单的unix网络工具,它可以使用tcp或者udp协议通过网络连接读写数据。它被设计为一个稳定的后端(back-end)工具,能够直接由其它程序和脚本轻松驱动。同时,它还是一个具有丰富功能的网络调试和探测工具,它能够建立你需要的几乎所有类型的连接,还有几个很有意思的内置功能。现在,我们使用nc建立到web服务器的连接,并发出一个html头请求:
#nc 192.168.1.2 80
get head/http1.0
http/1.1 400 bad request
server: microsoft-iis/4.0
date: wed, 06 dec 2000 00:45:56 gmt
content-type: text/html
set-cookie: aspsessionidqggqqqpo=mjmcgmiapihoglbnlfjpkcah; path=/
cache-control: private
通过收到的信息,我们可以确定测试目标使用的web服务器是microsoft iis4。现在,我们能够把我们的安全规划限制在操作系统、web服务器版本、以及服务器上的应用程序了。
从上面的扫描中,我们可以看到服务器中还有其它的一些端口也打开了。这些打开的端口可能有许多缺陷。在服务器中,打开的端口应该有严格的限制,否则对带来很多安全缺陷。在知道了上面这些信息之后,我们可以进入下一步进行缺陷分析了。
缺陷分析
缺陷分析可以集中于两个方面:操作系统和应用程序。不过,这里我们只关心应用程序,也就是web服务器软件。
缺陷扫描
有些缺陷扫描程序能够综合已知的web安全缺陷。下面我们就使用这类程序对网站进行缺陷扫描。
whisker
whisker是一个非常好的web服务器缺陷扫描软件。它能够进行大量的缺陷扫描,而且升级非常频繁,能够很快地加入对新缺陷的检查。
#./whisker.pl -h 192.168.1.2 -i -v
-- whisker / v1.4.0 / rain forest puppy / www.wiretrip.net --
- loaded script database of 1968 lines
= - = - = - = - = - =
= host: 192.168.1.2
+ 404 object not found: head /
= server: microsoft-iis/4.0
- appending ::\, %2e, or 0x81 to urls may give script source
- also try +.htr and %20%20.htw tricks
- security settings on directories can be bypassed if you use 8.3 names
+ 404 object not found: get /cfdocs/
+ 403 access forbidden: get /scripts/
+ 403 access forbidden: get /scripts/cfcache.map
+ 404 object not found: get /cfcache.map
+ 404 object not found: get /cfide/administrator/startstop.html
+ 404 object not found: get /cfappman/index.cfm
+ 404 object not found: get /cgi-bin/
+ 404 object not found: get /whisker.ida
+ 404 object not found: get /whisker.idc
+ 404 object not found: get /whisker.idq
+ 404 object not found: get /whisker.htw
+ 404 object not found: get /whisker.htr
+ 403 access forbidden: get /scripts/cpshost.dll
+ 404 object not found: get /samples/search/queryhit.htm
+ 404 object not found: get /adsamples/config/site.csc
+ 403 access forbidden: get /scripts/counter.exe
+ 404 object not found: get /scripts/repost.asp
+ 404 object not found: get /scripts/postinfo.asp
+ 403 access forbidden: get /scripts/fpadmcgi.exe
+ 403 access forbidden: get /scripts/samples/
+ 403 access forbidden: get /scripts/samples/search/webhits.exe
+ 403 access forbidden: get /scripts/iisadmin/
+ 403 access forbidden: get /scripts/iisadmin/ism.dll
+ 404 object not found: get /msadc/
+ 404 object not found: get /sites/
+ 404 object not found: get /siteserver/publishing/viewcode.asp
+ 404 object not found: get /advworks/equipment/catalog_type.asp
+ 404 object not found: get /iisadmpwd/aexp4b.htr
+ 403 access forbidden: head /scripts/samples/details.idc
+ 403 access forbidden: head /scripts/samples/ctguestb.idc
+ 200 ok: head /scripts/tools/newdsn.exe
- this can be used to make dsns, useful in use with our odbc exploit
- and the rds exploit (with msadcs.dll)
+ 403 access forbidden: get /scripts/iisadmin/bdir.htr
+ 404 object not found: head /carbo.dll
+ 403 access forbidden: head /scripts/proxy/
+ 403 access forbidden: head /scripts/proxy/w3proxy.dll
+ 404 object not found: head /prd.i/pgen/
+ 404 object not found: head /cgi-win/
+ 403 access forbidden: head /scripts/nlog-smb.cgi
+ 403 access forbidden: head /scripts/wwwboard/
+ 404 object not found: head /wwwboard/
+ 403 access forbidden: head /scripts/wwwboard.pl
+ 403 access forbidden: head /scripts/wwwboard/wwwboard.pl
+ 403 access forbidden: head /scripts/wwwboard.cgi
+ 403 access forbidden: head /scripts/wwwboard/wwwboard.cgi
+ 404 object not found: head /logs/
+ 404 object not found: head /database/
+ 404 object not found: head /databases/
+ 403 access forbidden: head /scripts/campas
+ 403 access forbidden: head /scripts/guestbook.cgi
+ 403 access forbidden: head /scripts/guestbook.pl
+ 403 access forbidden: head /scripts/edit.pl
+ 403 access forbidden: head /scripts/webbbs.cgi
+ 403 access forbidden: head /scripts/whois_raw.cgi
+ 404 object not found: head /webcart/
+ 404 object not found: head /webcart-lite/
+ 403 access forbidden: head /scripts/anyboard.cgi
+ 403 access forbidden: head /scripts/admin.php
+ 403 access forbidden: head /scripts/code.php
+ 403 access forbidden: head /scripts+ 403 access \
forbidden: head /scripts/bnbform.cgi
从输出结果中,我们可以看到有三种基本的检测结果:200 ok、403 access forbidden和404 object not found。这些结果表示:
200 ok
这个输出表示攻击检查成功。服务器存在这个缺陷。这些缺陷包括:newdsn.exe、htr和url扩展字符串。攻击者可能利用这些缺陷侵入服务器。
403 access forbidden
表示whisker已经发现了可以用于攻击检查的文件,但是哟高呼没有对它的访问权限。在这种情况下,攻击者暂时无法通过这些可能的缺陷侵入服务器,但是如果将来权限设置出现失误就可能给攻击者以可乘之机。
404 object not found
表示whisker没有发现可以用于攻击的文件。
whisker主要从以下的站点获得安全缺陷信息:http://www.foundstone.com、http://www.securityfocus.com、http://www.packetstorm.securify.com。
还有其它一些web服务器缺陷扫描程序,不过这些程序的包容性和反应速度都不及whisker。
cgichk.pl
cgichk.pl是一个使用perl编写的扫描程序,它有非常好的日志功能,能够对信息进行很好的回溯。
#./cgichk.pl
cgi scanner [in perl] v1.1
host: 192.168.1.2
http port [80]:
log session?(y/n)n
press [enter] to check the httpd version...
http/1.1 200 ok
server: microsoft-iis/4.0
date: wed, 01 nov 2000 19:57:13 gmt
content-type: text/html
set-cookie: aspsessionidqqqqqgzz=hgecmccdejalhkkhhcpmjlep; path=/
cache-control: private
press [enter] to check for cgi vulnerabilities...
searching for unlg - backdoor : not found
searching for thc - backdoor : not found
searching for phf : not found
searching for count.cgi : not found
searching for test-cgi : not found
searching for nph-test-cgi : not found
searching for nph-publish : not found
searching for php.cgi : not found
searching for handler : not found
searching for webgais : not found
searching for webdist.cgi : not found
searching for faxsurvey : not found
searching for htmlscript : not found
searching for pfdisplay : not found
searching for perl.exe : not found
searching for wwwboard.pl : not found
searching for www-sql : not found
searching for view-source : not found
searching for campas : not found
searching for aglimpse : not found
searching for glimpse : not found
searching for man.sh : not found
searching for at-admin.cgi : not found
searching for filemail.pl : not found
searching for maillist.pl : not found
searching for jj : not found
searching for info2www : not found
searching for files.pl : not found
searching for finger : not found
searching for bnbform.cgi : not found
searching for survey.cgi : not found
searching for anyform2 : not found
searching for textcounter.pl : not found
searching for classifields.cgi: not found
searching for wguest.exe : not found
searching for bdir - samples : not found
searching for cgimail.exe : not found
searching for newdsn.exe : found!
searching for fpcount.exe : not found
searching for counter.exe : not found
searching for visadmin.exe : not found
searching for openfile.cfm : not found
searching for exprcalc.cfm : not found
searching for dispopenedfile : not found
searching for sendmail.cfm : not found
searching for codebrws.asp : not found
searching for codebrws.asp : not found
searching for showcode.asp : not found
searching for search97.vts : not found
searching for carbo.dll :not found
server may have cgi vulnerabilities.
从结果可以看出,这个扫描程序只能发现whisker发现的一部分缺陷。其它的一些区别还包括输出的显示。whisker对输出的分类更详尽一些,例如:access forbidden和object not found的划分。
malice
malice也是一个使用perl写成的perl扫描程序,具有某些规避ids检测的功能,而且能够进行大量的检测。
./malice5.2.pl
malice .5.2
anti ids scanner that uses null scans with head requests
much props to doom for editing this.
host: 192.168.1.2
port: 80
http/1.1 200 ok
server: microsoft-iis/4.0
date: wed, 01 nov 2000 20:02:45 gmt
pics-label: (pics-1.0 "http://www.rsac.org/ratingsv01.html" l by \
"" on "1998.10.20t15:20-0400" exp "1999.10.20t12:00-0400" r \
(v 0 s 0 n 0 l 0))
content-type: text/html
set-cookie: aspsessionidqqqqqgzz=ohecmccdjggmodlbhbiedkgo; path=/
cache-control: private
checking 192.168.1.2 for cgi holes.....:
exploit found: /scripts/tools/newdsn.exe
location: /scripts/tools/newdsn.exe
exploit found: /?pageservices
location: /?pageservices
exploit found: webdav transversal
location: /secret/secret/sql_tool.shtml
exploit found: default.asp
location: /default.asp
malice能够进行一些其它扫描程序不能做的检查,而且它会试图避开ids系统的检测。从结果还可以看出,它查出了两个whisker没有发现的缺陷。malice的另一个不同之处是,它只显示能够的检测结果。
扫描完成后,我们就获得许多系统潜在的缺陷信息。下一步就是对这些潜在的缺陷进行实际的攻击测试。完成实际的攻击测试之后,根据测试结果对实际的缺陷进行修补。
本文讲到的一些和一些没有讲到的web服务器缺陷扫描工具可以从以下地址获得。
whisker:http://www.wiretricp.net
cgichk.pl:http://packetstorm.securify.com
malice:http://kickme.to/security666
netcat:http://www.securityfocus.org
nmap:http://www.insecure.org
md-webscan:http://www.internettrash.com/users/mordrian
结论
本文介绍了web服务器安全规划的前两步:指纹特征分析和缺陷分析。
作者:gary bahadur
编译:nixe0n
文章整理:西部数码--专业提供域名注册、虚拟主机服务
http://www.west263.com
以上信息与文章正文是不可分割的一部分,如果您要转载本文章,请保留以上信息,谢谢!


