encode脚本和normal脚本混用的问题
来源:互联网 发布:网络语肥皂是什么意思 编辑:程序博客网 时间:2024/06/14 21:08
半年前第一次做脚本编码的时候,由于没有什么使用经验,于是在51js上询问了一下encode脚本和normal脚本混用是否有什么问题呢?结果没有得到任何有建设性的意见,这也至少说明了两个问题,一是没有人在意,二是就没有什么问题嘛。当然我更乐意于接受后一种结果,就开始了encode脚本和normal脚本的混合使用。
在这样的理解下做了很多的脚本,似乎也真的没有出现过什么问题,于是更加笃信自己当初的判断。结果又一次被IE暗算了,encode后的脚本和normal的脚本混和使用不是没有问题,也不是都有问题,只是在特定的条件下会出问题,真是晕死。看下面这个示例:
<html>
<head>
<title>JScript Encode Research</title>
<meta name="author" content="birdshome@cnblogs" />
</head>
<body>
<script language="jscript.encode" type="text/jscript.encode">
#@~^8gAAAA==~,P~,P,Pr(L^Ycw.WDWOza+Rtn/klo~xP6E mOkGUv#@#@&,~P,P~~, @#@&~,P~P,~,P~,P,lVDDcB}4%+1Y 2MWYKOXa+Rtnd/moBbi@#@&,P~P,~P,8I@#@&PP~~,P~P@#@&,P~,P,PP}4NnmDR/+k/CLP',WE mYbGU`*@#@&P~P~~,P~ @#@&P,P~~,PP~~,P~l^nMYcEr(L+1Yc/+k/CoBbI@#@&P,~P,PP,NIGjkAAA==^#~@
</script>
<script language="jscript.encode" type="text/jscript.encode">
#@~^FgEAAA==~,P~,P,P0!x1OkKx~2mG[`#,`8@#@&@#@&~~P,P,P~2U^KNnRa.WDWOza+R/nk/Co~{PW!x1YkKxvb@#@&P~P,P~~, @#@&~P,PP,~~P,P,.kOndkU+vv2 mG[Rw.GDWOXancHnk/mo+E#p@#@&,P~P,P~~)i@#@&@#@&,PP,~~P,2 mGNn t+d/mL+,'~W!xmOrKxc#@#@&,P~,P,PPP@#@&~P,P~P,P~~,PMrYSk ncBAx1W[+ //dlTnB*i@#@&,PP~~,P~8p~,V0MAAA==^#~@
</script>
<script language="jscript" type="text/jscript">
function Normal() {}
Normal.prototype.Message = function()
{
WriteLine('Normal.prototype.Message');
};
Normal.Message = function()
{
WriteLine('Normal.Message');
};
</script>
<script language="jscript" type="text/jscript">
var msg = '.prototype.Message" Fail.<br>';
function WriteLine(msg) { document.write(msg + '<br><br>'); }
var o = new Object();
try { o.Message(); }
catch(e) { WriteLine('Call "Object' + msg + e.message); }
try { Object.Message(); }
catch(e) { WriteLine('Call "Object.Message" Fail. <br>' + e.message); }
var e = new Encode();
try { e.Message(); }
catch(e) { WriteLine('Call "Encode' + msg + e.message); }
Encode.Message();
var n = new Normal();
try { n.Message(); }
catch(e) { WriteLine('Call "Normal' + msg + e.message); }
Normal.Message();
</script>
</body>
</html>
<head>
<title>JScript Encode Research</title>
<meta name="author" content="birdshome@cnblogs" />
</head>
<body>
<script language="jscript.encode" type="text/jscript.encode">
#@~^8gAAAA==~,P~,P,Pr(L^Ycw.WDWOza+Rtn/klo~xP6E mOkGUv#@#@&,~P,P~~, @#@&~,P~P,~,P~,P,lVDDcB}4%+1Y 2MWYKOXa+Rtnd/moBbi@#@&,P~P,~P,8I@#@&PP~~,P~P@#@&,P~,P,PP}4NnmDR/+k/CLP',WE mYbGU`*@#@&P~P~~,P~ @#@&P,P~~,PP~~,P~l^nMYcEr(L+1Yc/+k/CoBbI@#@&P,~P,PP,NIGjkAAA==^#~@
</script>
<script language="jscript.encode" type="text/jscript.encode">
#@~^FgEAAA==~,P~,P,P0!x1OkKx~2mG[`#,`8@#@&@#@&~~P,P,P~2U^KNnRa.WDWOza+R/nk/Co~{PW!x1YkKxvb@#@&P~P,P~~, @#@&~P,PP,~~P,P,.kOndkU+vv2 mG[Rw.GDWOXancHnk/mo+E#p@#@&,P~P,P~~)i@#@&@#@&,PP,~~P,2 mGNn t+d/mL+,'~W!xmOrKxc#@#@&,P~,P,PPP@#@&~P,P~P,P~~,PMrYSk ncBAx1W[+ //dlTnB*i@#@&,PP~~,P~8p~,V0MAAA==^#~@
</script>
<script language="jscript" type="text/jscript">
function Normal() {}
Normal.prototype.Message = function()
{
WriteLine('Normal.prototype.Message');
};
Normal.Message = function()
{
WriteLine('Normal.Message');
};
</script>
<script language="jscript" type="text/jscript">
var msg = '.prototype.Message" Fail.<br>';
function WriteLine(msg) { document.write(msg + '<br><br>'); }
var o = new Object();
try { o.Message(); }
catch(e) { WriteLine('Call "Object' + msg + e.message); }
try { Object.Message(); }
catch(e) { WriteLine('Call "Object.Message" Fail. <br>' + e.message); }
var e = new Encode();
try { e.Message(); }
catch(e) { WriteLine('Call "Encode' + msg + e.message); }
Encode.Message();
var n = new Normal();
try { n.Message(); }
catch(e) { WriteLine('Call "Normal' + msg + e.message); }
Normal.Message();
</script>
</body>
</html>
把上面的代码存为一个*.htm文件,打开后得到结果为:
Call "Object.prototype.Message" Fail.
Object doesn't support this property or method
Call "Object.Message" Fail.
Object doesn't support this property or method
Encode.prototype.Message
Encode.Message
Normal.prototype.Message
Normal.Message
Object doesn't support this property or method
Call "Object.Message" Fail.
Object doesn't support this property or method
Encode.prototype.Message
Encode.Message
Normal.prototype.Message
Normal.Message
上面那两段jscript.encode的代码很简单,就是:
Object.prototype.Message = function()
{
alert('Object.prototype.Message');
};
Object.Message = function()
{
alert('Object.Message');
};
{
alert('Object.prototype.Message');
};
Object.Message = function()
{
alert('Object.Message');
};
function Encode() {}
Encode.prototype.Message = function()
{
WriteLine('Encode.prototype.Message');
};
Encode.Message = function()
{
WriteLine('Encode.Message');
};
Encode.prototype.Message = function()
{
WriteLine('Encode.prototype.Message');
};
Encode.Message = function()
{
WriteLine('Encode.Message');
};
如果我们把上面两段代码替换那个html中的两段jscript.encode的代码,后面的运行将不会出任何异常,会得到这样的输出:
Object.prototype.Message
Object.Message
...
Object.Message
...
上面这些代码实例的试验,已经详细的说明了encode脚本代码的问题。就是,不能在非编码脚本中,引用编码脚本中导入到JScript内置对象上的原型(prototype)方法和静态方法。上面示例中的Object就是JScript的一个内置对象,我们分别导入了一个prototpye方法和静态方法Message()。而对于非内置对象Encode,我们在已编码代码中导入的prototype和static方法,都可以在非编码代码中正常的访问。
那么怎么访问内置对象的导入方法呢?其实解决起来也不复杂,只是比较繁琐。我们需要使用一些wrapper方法,把他们和被编码的代码放在一起,就可以在非编码代码中访问了,比如上面的Object的导入,我们可以这样包装它:
Object.prototype.Message = function()
{
WriteLine('Object.prototype.Message');
};
Object.Message = function()
{
WriteLine('Object.Message');
};
var obj = new Object();
function ObjectPrototypeMessage()
{
obj.Message();
}
function ObjectMessage()
{
Object.Message();
}
{
WriteLine('Object.prototype.Message');
};
Object.Message = function()
{
WriteLine('Object.Message');
};
var obj = new Object();
function ObjectPrototypeMessage()
{
obj.Message();
}
function ObjectMessage()
{
Object.Message();
}
这时,我们就可以通过ObjectPrototypeMessage和ObjectMessage这样的wrapper方法访问到已编码代码中内置对象的导入方法了。
- encode脚本和normal脚本混用的问题
- javascript处理HTML的Encode(转码)和Decode(解码)总结,避免js脚本注入问题
- (原创)解密JScript.Encode加密过的脚本
- 脚本带来的问题
- Linux脚本的问题
- cout和printf的混用而产生的顺序问题
- cocos2dx release和delete的混用的问题
- swing组件和awt组件混用带来的问题
- linux下fork和pthread混用的问题
- C和C++混用中出现的问题
- linux下fork和pthread混用的问题
- storyboard 和 xib混用出现的layout布局有问题
- debug和release版本dll混用导致的问题
- present和push混用,再跳转回来的问题
- QTsocket和标准C库socket混用遇到的问题
- spring XML和注解混用的一个小问题
- JScript.Encode脚本加密与解密
- JScript.Encode脚本加密与解密
- 判断用户浏览器是否是XP SP2的IE6
- 怀念母校--松江二中
- 模态窗口对字符串参数的巨无聊限制
- 随机数字直接生成图片的ASP代码
- 应用虑镜特效时遇到浏览器权限问题
- encode脚本和normal脚本混用的问题
- IE7提供XMLHttpRequest对象为兼容
- IE6使用add方法添加optGroup的bug
- Visual studio .net已检测到指定的Web服务器运行的不是asp.net1.1版,您将无法运行asp.net Web应用程序或服务
- IE解析完全相同html代码的不同表现
- xml
- 怎样在Web开发中完美控制IE标题栏
- IE6 Hotfix MS-042将导致其Crash!
- 前世欠你的一滴泪