Web攻防之二实施渗透测试(黑客如何拿网站权限)
通过上次的内容,我们知道可以通过注入得到需要的数据,比如后台管理员的账号、密码等,但是得到了账号密码后,我们要如何行动呢?
首先要制定一个渗透流程:
1、探测信息
2、利用漏洞得到管理账号密码
3、找到后台
4、登录后台取得web权限
探测信息
在实施第一步骤的时候,我们要得到一些基本信息:
1、server服务器的系统大概是什么?
2、Web环境是什么情况?
3、当前网站的域名ip的什么?
有了这个流程,捋好了思路,接着开始行动。
通过ping www.test.com命令行,得到的结果如图1所示:
图1
得到当前web ip为:193.168.20.223
接下来查看当前服务器运行的服务,在linux终端下输入命令:nmap -sV 193.168.20.223,得到的结果如下:
root@Security:~/Desktop# nmap -sV 193.168.20.223
Starting Nmap 5.59BETA1 ( http://nmap.org ) at 2012-04-11 09:09 CST
Nmap scan report for www.test.com (193.168.20.223)
Host is up (0.00060s latency).
Not shown: 992 closed ports
PORT STATE SERVICE VERSION
80/tcp open http Microsoft IIS httpd 6.0
135/tcp open msrpc Microsoft Windows RPC
139/tcp open netbios-ssn
443/tcp open ssl/http Microsoft IIS httpd 6.0
445/tcp open microsoft-ds Microsoft Windows 2003 or 2008 microsoft-ds
1027/tcp open msrpc Microsoft Windows RPC
3306/tcp open mysql MySQL (unauthorized)
3389/tcp open microsoft-rdp Microsoft Terminal Service
MAC Address: 00:0C:29:41:BE:DD (VMware)
Service Info: OS: Windows
Service detection performed. Please report any incorrect results at http://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 18.71 seconds
扫描结果为当前服务器运行的有http服务、msrpc、netbios-ssn、microsoft-ds、mysql、microsoft-rdp服务,具体情况如图2所示:
图2
然后再来查看当前的操作系统,在linux终端下输入命令:nmap -O 193.168.20.223,得到如下的结果:
root@Security:~/Desktop# nmap -O 193.168.20.223
Starting Nmap 5.59BETA1 ( http://nmap.org ) at 2012-04-11 09:11 CST
Nmap scan report for www.test.com (193.168.20.223)
Host is up (0.00060s latency).
Not shown: 992 closed ports
PORT STATE SERVICE
80/tcp open http
135/tcp open msrpc
139/tcp open netbios-ssn
443/tcp open https
445/tcp open microsoft-ds
1027/tcp open IIS
3306/tcp open mysql
3389/tcp open ms-term-serv
MAC Address: 00:0C:29:41:BE:DD (VMware)
Device type: general purpose
Running: Microsoft Windows 2003
OS details: Microsoft Windows Server 2003 SP1 or SP2
Network Distance: 1 hop
OS detection performed. Please report any incorrect results at http://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 3.67 seconds
得到的扫描结果为当前服务器操作系统是Microsoft Windows 2003,可能是sp1也可能是sp2,具体情况如图3所示:
图3
然后继续查看当前的web环境是用什么搭建的,通过在linux终端输入命令curl -I www.test.com,得到如下反馈结果:
root@Security:~# curl -I www.test.com
HTTP/1.1 200 OK
Date: Thu, 12 Apr 2012 07:04:07 GMT
Server: Microsoft-IIS/6.0
X-Powered-By: ASP.NET
Content-Length: 35380
Content-Type: text/html
Set-Cookie: ASPSESSIONIDCSTQCAQT=FFGDDPDDLDEEBFMENAGEBBJG; path=/
Cache-control: private
结果显示,Server: microsoft-IIS/6.0,如图4所示:
图4
要知道,渗透测试是一个精细活,为了确保以上信息的可靠,我们还可以通过一个脚本继续查看一下精确信息,以便对比刚才得到的结果。
在linux终端输入:cd pentest/enumeration/web/whatweb/
回车后继续输入: ./whatweb www.test.com
通过whatweb脚本得到如下结果:
root@Security:/# cd pentest/enumeration/web/whatweb/
root@Security:/pentest/enumeration/web/whatweb# ./whatweb www.test.com
http://www.test.com [200] HTTPServer[Microsoft-IIS/6.0], ASP_NET, Cookies
ASPSESSIONIDCSTQCAQT], Country[EUROPEAN UNION][EU], Title[%CE%DE%B1%EA%CC%E2%CE%C4%B5%B5], Microsoft-IIS[6.0], X-Powered-By[ASP.NET], ActiveX, IP[193.168.20.223], Adobe-Flash
具体情况如图5所示:
图5
到目前为止,渗透测试的前期工作基本上已经做完了,得到了如下重要信息:
当前服务器ip :193.168.20.223
操作系统类型 :windows 2003
Web服务器 :iis
端口 :80