赞
踩
http://www.zhihu.com/question/26628342
单单解释三者的区别,似乎有点单调。说到xss,就必须要提一提js,脱离了js去谈xss都是耍流氓!
1,)先来分析一下LZ说的DOM-based XSS。- <?php
- error_reporting(0);
- $name = $_GET["name"];
- ?>
- <input id="text" type="text" value="<?php echo $name;?>" />
- <div id="print"></div>
- <script type="text/javascript">
- var text = document.getElementById("text");
- var print = document.getElementById("print");
- print.innerHTML = text.value; // 获取 text的值,并且输出在print内。这里是导致xss的主要原因。
- </script>
- <?php
- error_reporting(0);
- $name = $_GET["name"];
- //连接服务器
- $conn = mysql_connect("127.0.0.1","root","");
- //打开数据库
- mysql_select_db("test",$conn);
- //执行SQL
- mysql_query("set names 'utf8'");
- $sql_insert = "insert into liuyan(id,content) values('$id','$name')";
- $result = mysql_query($sql_insert,$conn);
- $sql_select = "select * from liuyan";
- $results = mysql_fetch_array(mysql_query($sql_select));
- echo $results[content];
- ?>
http://localhost/2.php?name=%3Cscript%3Ealert(1)%3C/script%3E
- <?php
- $name = $_GET["name"];
- ?>
- <input type="text" value="<?php echo $name?>">
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。