关于XSHM(Cross-Site History Manipulation)

http://blog.chinaunix.net/uid-27070210-id-3255407.html


乍一看,好像和以前 css history hack 差不多,其实原理还是不一样的。
浏览器的 history 对象是比较特别的一个东西,与浏览历史不同,这个对象不是保存在本地的那个,也没那么多内容。
history对象是浏览器在生命周期中,比如tab页,访问的历史记录,用于提供"前进"、"后退"等操作。
在firebug里可以看到这个对象有以下几个属性:

history 对象里保存的url是一个list,这个list出于同源策略(SOP)的原因是不可读的。
但是 history.length 却是可读的,XSHM就是利用 history.length 可读,同时一些url发生变化时对length长度改变的特点来完成信息刺探的。
具体如下:
Browser History  is a global  list of pages  that have been visited using a browser tab.
By pressing the back and forward buttons of a browser, a user jumps through her browser
history.  If  a  page  contains  IFRAME,  any  location  changes  inside  IFRAME  are  also
recorded  in  the browser's  history. Consequently, opening  the  same URL multiple  times
will insert only one entry into the history list.  If a user opens Page A and this page uses
the HTTP Redirect directive to open Page B, only Page B will be stored in the browser‟s
history.

注意最后加粗的这句,如果发生了重定向,那么history对象只会增加重定向后指向的最终页面相同的页面不会重复进入history对象的list

利用这个特性,就可以实施许多跨域的刺探了
Algorithm:
1.  Create IFRAME with src=Page B
2.  Remember the current value of history.length 
3.  Change src of IFRAME to Page A
4.  If the value of history.length is the same– then the CONDITION is TRUE
比如作者的例子,检测用户是否有登录:


利用类似的方法,作者举了很多实际应用的例子,在某些情况下,配合其他漏洞使用,还是有一定作用的。

原文地址:https://www.cnblogs.com/suizhikuo/p/8072705.html