鱼C论坛

 找回密码
 立即注册
查看: 3690|回复: 1

[已解决]谁能帮我看看这段 微信网页版 javascript代码的意思?

[复制链接]
发表于 2016-9-7 23:50:54 | 显示全部楼层 |阅读模式
10鱼币
本帖最后由 康小泡 于 2016-9-8 10:53 编辑

下面的代码是我连接微信网页的时候从服务器获取到的x-javascript文件中的代码,求大神帮我大致解释下以下各个函数的用途。


  1. function AQ_SECAPI_ESCAPE(Url,map){var tmpArr=new Array;for(var m=0;m<Url.length;m++){if(Url.charAt(m)=='&'){var keyLen=[3,4,5,9];var matchFlag=0;for(var n in keyLen){var l=keyLen[n];if(m+l<=Url.length){var subLow=Url.substr(m,l).toLowerCase();if(map[subLow]){tmpArr.push(map[subLow]);m=m+l-1;matchFlag=1;break;}}}
  2. if(matchFlag==0){tmpArr.push(Url.charAt(m));}}else{tmpArr.push(Url.charAt(m));}}
  3. return tmpArr.join("");}
  4. function AQ_SECAPI_CheckXss(){var map=new Object();var escapeChars="'"<>`script:daex/hml;bs64,";for(var i=0;i<escapeChars.length;i++){var cha=escapeChars.charAt(i);var dec=cha.charCodeAt();var dec7=dec;var hex=dec.toString(16);for(var j=0;j<(7-dec.toString().length);j++){dec7="0"+dec7;}
  5. map["&#"+dec+";"]=cha;map["&#"+dec7]=cha;map["&#x"+hex]=cha;}
  6. map["<"]="<";map[">"]=">";map["""]=""";var Url=location.href;var Refer=document.referrer;Url=decodeURIComponent(AQ_SECAPI_ESCAPE(Url,map));Refer=decodeURIComponent(AQ_SECAPI_ESCAPE(Refer,map));var XssPattern=new RegExp("['"<>`]|script:|data:text/html;base64,");if(XssPattern.test(Url)||XssPattern.test(Refer)){var version='1.5',cgi='http://zyjc.sec.qq.com/dom',img=new Image();img.src=cgi+"?v="+version+"&u="+encodeURIComponent(Url)+"&r="+encodeURIComponent(Refer);Url=Url.replace(/['"<>`]|script:/gi,'M');Url=Url.replace(/data:text\/html;base64,/gi,'data:text/plain;base64,');location.href=encodeURI(Url);}}
  7. AQ_SECAPI_CheckXss();(function(_wnd,_doc,_ln){function checkNonTxDomain(level,bid,pagetype){var checkInfo={bid:bid,childUrl:"",parentUrl:""},childCheckFlag,parentCheckFlag;try{checkInfo.childUrl=_ln.href;}catch(ign){}
  8. try{checkInfo.parentUrl=parent.location.href;}catch(ign){}
  9. if(Math.random()>level){return;}
  10. if(pagetype==1){try{parentCheckFlag=(parent!=_wnd)?generateNonTxDomainFromDom(parent.document,'datapp',checkInfo):false;}catch(ign){}}else{try{childCheckFlag=generateNonTxDomainFromDom(_doc,'datapt',checkInfo);parentCheckFlag=(parent!=_wnd)?generateNonTxDomainFromDom(parent.document,'datapp',checkInfo):false;}catch(ign){}
  11. try{if(parent!=_wnd){generateZyjIframed(checkInfo);}}catch(ign){}}}
  12. function generateZyjIframed(checkInfo){var data=[];data.push("beframed::url");packZyjUrlData(data,'beframed',checkInfo);}
  13. function packZyjUrlData(data,dataMark,checkInfo){var version='1.4',cgi='http://zyjc.sec.qq.com/cr',img=new Image();data.push("childUrl::"+encodeURIComponent(checkInfo.childUrl));data.push("parentUrl::"+encodeURIComponent(checkInfo.parentUrl));img.src=cgi+"?id="+checkInfo.bid+"&d="+dataMark+"=v"+version+"|"+data.join('|');return true;}
  14. function generateNonTxDomainFromDom(dom,parentMark,checkInfo){var scriptData=extractNonTxScriptWorm(dom);var iframeData=extractNonTxIframe(dom);var frameData=extractNonTxFrame(dom);var embedData=extractNonTxEmbed(dom);var imgData=extractNonTxIMG(dom);var hacks=scriptData.concat(iframeData,frameData,imgData,embedData);if(hacks.length<=0){return false;}
  15. hacks=distinctZyjArray(hacks);packZyjUrlData(hacks,parentMark,checkInfo);}
  16. function extractNonTxScriptWorm(dom){var scripts=dom.getElementsByTagName("script"),scriptData=[],tempScript,urlList,url,nonTxList,mapFunc,resultList;for(var i=0;i<scripts.length;i++){tempScript=scripts<I>;if(url=tempScript.src){scriptData.push(url);}}
  17. nonTxList=grepZyjList(scriptData,isAntiTxDomain);mapFunc=addTagToZyjUrlCallback('script');resultList=mapZyjList(nonTxList,mapFunc);return resultList;}
  18. function extractNonTxScript(dom){var scripts=dom.getElementsByTagName("script"),scriptData=[],tempScript,urlList,url,nonTxList,mapFunc,resultList;for(var i=0;i<scripts.length;i++){tempScript=scripts<I>;urlList=extractZyjUrlFromHtml(tempScript.innerHTML);scriptData=scriptData.concat(urlList);if(url=tempScript.src){scriptData.push(url);}}
  19. nonTxList=grepZyjList(scriptData,isAntiTxDomain);mapFunc=addTagToZyjUrlCallback('script_worm');resultList=mapZyjList(nonTxList,mapFunc);return resultList;}
  20. function extractZyjUrlFromHtml(html){var regUrl=/\bhttps?:\/\/[^"\'\s]+/ig,urlList=[];while(url=regUrl.exec(html)){urlList.push(url);}
  21. return urlList;}
  22. function grepZyjList(testList,testFunction){var grepList=[];for(var idx=0;idx<testList.length;++idx){var temp=testList[idx];if(testFunction(temp)){grepList.push(temp);}}
  23. return grepList;}
  24. function isAntiTxDomain(sUrl){var sDomain=extractZyjDomain(sUrl),regErrDom,regTxCom,regTxCn,regTxNet,regTxOther;if(!sDomain){return false;}
  25. regErrDom=/^xui.ptlogin2?\.?$/i;regTxCom=/(\.|^)(qq|paipai|soso|wenwen|tenpay|macromedia|gtimg|qstatic|qqmail|paipaiimg|qqgames|pengyou|foxmail|qzoneapp|qzone|qplus|imqq|tqapp|tencent|3366|21mmo|taotao|imrworldwide|idqqimg|17roco|expo2010china|fangqq|tencentmind|tencity|yingkebicheng|zhangzhongxing|expovol|otaworld|gzyunxun|heyyo|himoral|himorale|myrtx|qqwinner|redian|sjkx|rtxonline|nbaso|paipai\.500wan|qqjapan|qq\.salewell|sogou|weiyun|flzhan)\.com$/i;regTxCn=/(\.|^)(qq\.com|gtimg|gtimg\.com|qlogo|foxmail\.com|gtimg\.com|url|qpic|tencent\.com|expo2010|expo|himorale\.com|nbaso\.com|qqtest\.com|qq\.ucar|rtx\.com|soso\.com|tcimage)\.cn$/i;regTxNet=/(\.|^)(5999|gongyi)\.net$/i;regTxOther=/(\.|^)(himorale\.com\.hk|tencent\.com\.hk|qq\.chinacache\.net|qq\.com\.fastcdn\.com|qq\.com\.lxdns\.com|qq\.fastcdn\.com|soso\.com\.lxdns\.com|motu\.pagechoice\.net|ope\.tanx\.com|dap\.gentags\.net)$/i;if(regErrDom.test(sDomain)||regTxCom.test(sDomain)||regTxCn.test(sDomain)||regTxNet.test(sDomain)||regTxOther.test(sDomain)){return false;}
  26. return true;}
  27. function extractZyjDomain(sUrl){var regDomain=/^https?:\/\/([\w\-]+\.[\w\-.]+)/i,m=regDomain.exec(sUrl);if(!m){return;}
  28. return m[1];}
  29. function addTagToZyjUrlCallback(tag){return function(url){return tag+"::"+encodeURIComponent(url);};}
  30. function mapZyjList(testList,testFunction){var mapList=[],temp,mapTemp;for(var idx=0;idx<testList.length;++idx){temp=testList[idx];mapTemp=testFunction(temp);mapList.push(mapTemp);}
  31. return mapList;}
  32. function extractNonTxIframe(dom){var tagName='IFRAME',rawFunc=function(x){return x.src},mapFunc=addTagToZyjUrlCallback('iframe');return extractNonTxTagData(dom,tagName,rawFunc,isAntiTxDomain,mapFunc);}
  33. function extractNonTxEmbed(dom){var tagName='EMBED',rawFunc=function(x){return x.src},mapFunc=addTagToZyjUrlCallback('embed');return extractNonTxTagData(dom,tagName,rawFunc,isAntiTxDomain,mapFunc);}
  34. function extractNonTxTagData(dom,tag,rawFunc,grepFunc,mapFunc){var tags=dom.getElementsByTagName(tag);var tagRaw=mapZyjList(tags,rawFunc);var tagData=grepZyjList(tagRaw,grepFunc);var tagResult=mapZyjList(tagData,mapFunc);return tagResult;}
  35. function extractNonTxFrame(dom){var tagName='FRAME',rawFunc=function(x){return x.src},mapFunc=addTagToZyjUrlCallback('frame');return extractNonTxTagData(dom,tagName,rawFunc,isAntiTxDomain,mapFunc);}
  36. function extractNonTxForm(dom){var tagName='FORM',rawFunc=function(x){return x.action},mapFunc=addTagToZyjUrlCallback('form');return extractNonTxTagData(dom,tagName,rawFunc,isAntiTxDomain,mapFunc);}
  37. function extractNonTxIMG(dom){var tagName='IMG',rawFunc=function(x){return x.src},mapFunc=addTagToZyjUrlCallback('img');return extractNonTxTagData(dom,tagName,rawFunc,isAntiTxDomain,mapFunc);}
  38. function distinctZyjArray(list){var sortList=list.slice(0),derivedArray=[];sortList.sort();derivedArray.push(sortList[0]);for(var i=1;i<sortList.length;i+=1){if(sortList<I>!=sortList[i-1]){derivedArray.push(sortList<I>);}}
  39. return derivedArray;}
  40. _wnd.checkNonTxDomain=checkNonTxDomain;})(window,document,location);try{setTimeout(function(){checkNonTxDomain(0.1,100,1);},0);}catch(ign){}
  41. try{setTimeout(function(){checkNonTxDomain(0.1,100,0);},3000);}catch(ign){}</I></I></I></I>
复制代码

最佳答案
2016-9-7 23:50:55
都是安全相关的函数。
xss注入检测、域名检测等。
QQ图片20160907234954.png

最佳答案

查看完整内容

都是安全相关的函数。 xss注入检测、域名检测等。
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

发表于 2016-9-7 23:50:55 | 显示全部楼层    本楼为最佳答案   
都是安全相关的函数。
xss注入检测、域名检测等。
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2024-3-29 21:32

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表