你好,欢迎来到电脑编程技巧与维护杂志社! 杂志社简介广告服务读者反馈编程社区  
合订本订阅
 
 
您的位置:技术专栏 / Linux开发
Javascript脚本实现静态网页加密(2)
 
strOut+="9030562);\r\n\t\t    b = this.md5_hh(b, c, d, a, x[i+14], 23, -35309556);\r";

strOut+="\n\t\t    a = this.md5_hh(a, b, c, d, x[i+ 1], 4 , -1530992060);\r\n\t\t    d";

strOut+=" = this.md5_hh(d, a, b, c, x[i+ 4], 11,  1272893353);\r\n\t\t    c = this.";

strOut+="md5_hh(c, d, a, b, x[i+ 7], 16, -155497632);\r\n\t\t    b = this.md5_hh(b,";

strOut+=" c, d, a, x[i+10], 23, -1094730640);\r\n\t\t    a = this.md5_hh(a, b, c, d";

strOut+=", x[i+13], 4 ,  681279174);\r\n\t\t    d = this.md5_hh(d, a, b, c, x[i+ 0]";

strOut+=", 11, -358537222);\r\n\t\t    c = this.md5_hh(c, d, a, b, x[i+ 3], 16, -72";

strOut+="2521979);\r\n\t\t    b = this.md5_hh(b, c, d, a, x[i+ 6], 23,  76029189);\r";

strOut+="\n\t\t    a = this.md5_hh(a, b, c, d, x[i+ 9], 4 , -640364487);\r\n\t\t    d ";

strOut+="= this.md5_hh(d, a, b, c, x[i+12], 11, -421815835);\r\n\t\t    c = this.md";

strOut+="5_hh(c, d, a, b, x[i+15], 16,  530742520);\r\n\t\t    b = this.md5_hh(b, c";

strOut+=", d, a, x[i+ 2], 23, -995338651);\r\n\t\t\r\n\t\t    a = this.md5_ii(a, b, c, ";

strOut+="d, x[i+ 0], 6 , -198630844);\r\n\t\t    d = this.md5_ii(d, a, b, c, x[i+ 7";

strOut+="], 10,  1126891415);\r\n\t\t    c = this.md5_ii(c, d, a, b, x[i+14], 15, -";

strOut+="1416354905);\r\n\t\t    b = this.md5_ii(b, c, d, a, x[i+ 5], 21, -57434055";

strOut+=");\r\n\t\t    a = this.md5_ii(a, b, c, d, x[i+12], 6 ,  1700485571);\r\n\t\t  ";

strOut+="  d = this.md5_ii(d, a, b, c, x[i+ 3], 10, -1894986606);\r\n\t\t    c = th";

strOut+="is.md5_ii(c, d, a, b, x[i+10], 15, -1051523);\r\n\t\t    b = this.md5_ii(b";

strOut+=", c, d, a, x[i+ 1], 21, -2054922799);\r\n\t\t    a = this.md5_ii(a, b, c, ";

strOut+="d, x[i+ 8], 6 ,  1873313359);\r\n\t\t    d = this.md5_ii(d, a, b, c, x[i+1";

strOut+="5], 10, -30611744);\r\n\t\t    c = this.md5_ii(c, d, a, b, x[i+ 6], 15, -1";

strOut+="560198380);\r\n\t\t    b = this.md5_ii(b, c, d, a, x[i+13], 21,  130915164";

strOut+="9);\r\n\t\t    a = this.md5_ii(a, b, c, d, x[i+ 4], 6 , -145523070);\r\n\t\t  ";

strOut+="  d = this.md5_ii(d, a, b, c, x[i+11], 10, -1120210379);\r\n\t\t    c = th";

strOut+="is.md5_ii(c, d, a, b, x[i+ 2], 15,  718787259);\r\n\t\t    b = this.md5_ii";

strOut+="(b, c, d, a, x[i+ 9], 21, -343485551);\r\n\t\t\r\n\t\t    a = this.safe_add(a,";

strOut+=" olda);\r\n\t\t    b = this.safe_add(b, oldb);\r\n\t\t    c = this.safe_add(c,";

strOut+=" oldc);\r\n\t\t    d = this.safe_add(d, oldd);\r\n\t\t  }\r\n\t\t  return Array(a,";

strOut+=" b, c, d);\r\n\t\t},\r\n\t\t\r\n\thex_hmac_md5:function(key, data){ return this.b";

strOut+="inl2hex(this.core_hmac_md5(key, data)); },\r\n\t\r\n\thex_md5:function(s){re";

strOut+="turn this.binl2hex(this.core_md5(this.str2binl(s), s.length * this.chr";

strOut+="sz));},\r\n\t\r\n\tmd5:function(s){return(this.hex_md5(s));},\r\n\r\n\tmd5_cmn:fu";

strOut+="nction(q, a, b, x, s, t){return this.safe_add(this.bit_rol(this.safe_a";

strOut+="dd(this.safe_add(a, q), this.safe_add(x, t)), s),b);},\r\n\r\n\tmd5_ff:func";

strOut+="tion(a, b, c, d, x, s, t){return this.md5_cmn((b & c) | ((~b) & d), a,";

strOut+=" b, x, s, t);},\r\n\r\n\tmd5_gg:function(a, b, c, d, x, s, t){return this.m";

strOut+="d5_cmn((b & d) | (c & (~d)), a, b, x, s, t);},\r\n\r\n\tmd5_hh:function(a, ";

strOut+="b, c, d, x, s, t){return this.md5_cmn(b ^ c ^ d, a, b, x, s, t);},\r\n\r\n";

strOut+="\tmd5_ii:function(a, b, c, d, x, s, t){return this.md5_cmn(c ^ (b | (~d";

strOut+=")), a, b, x, s, t);},\r\n\r\n\tmd5_vm_test:function(){return hex_md5(\"abc\")";

strOut+=" == \"900150983cd24fb0d6963f7d28e17f72\";},\r\n\t\r\n\tsafe_add:\r\n\t\tfunction(x";

strOut+=", y){\r\n\t\t  var lsw = (x & 0xFFFF) + (y & 0xFFFF);\r\n\t\t  var msw = (x >>";

strOut+=" 16) + (y >> 16) + (lsw >> 16);\r\n\t\t  return (msw << 16) | (lsw & 0xFFF";

strOut+="F);\r\n\t\t},\r\n\t\t\r\n\tstr2binl:\r\n\t\tfunction(str){\r\n\t\t  var bin = Array();\r\n\t";

strOut+="\t  var mask = (1 << this.chrsz) - 1;\r\n\t\t  for(var i = 0; i < str.lengt";

strOut+="h * this.chrsz; i += this.chrsz)\r\n\t\t    bin[i>>5] |= (str.charCodeAt(i";

strOut+=" \/ this.chrsz) & mask) << (i%32);\r\n\t\t  return bin;\r\n\t\t},\r\n\r\n\tstr_hmac_";

strOut+="md5:function(key, data){ return binl2str(core_hmac_md5(key, data)); },";

strOut+="\r\n\r\n\tstr_md5:function(s){ return binl2str(core_md5(str2binl(s), s.leng";

strOut+="th * this.chrsz));}\r\n}\r\n";



strOut+=performPage+"\r\n";

strOut+="performPage();\r\n";

strOut+="<\/script>";

t2.value=strOut;

}

function runCode(){

win=open("about:blank");

win.document.write(t2.value);

win.document.close();

}

function addSlash(str){

return(str).replace(/\\/g,"\\\\").replace(/\//g,"\\\/").replace(/\r/g,"\\r").replace(/\n/g,"\\n").replace(/\"/g,"\\\"").replace(/\'/g,"\\\'").replace(/\t/g,"\\t");

}

function XOR(strV,strPass){

var intPassLength=strPass.length;

var re="";

for(var i=0;i<strV.length;i++){

re+=String.fromCharCode(strV.charCodeAt(i)^strPass.charCodeAt(i%intPassLength));

}

return(re);

}

function performPage(strPass){

if(strPass){

document.cookie="password="+escape(strPass);

document.write(XOR(unescape(strHTML),STR.md5(strPass)));

return(false);

}

//**********如果需要自动记住密码,请将下面的注释改成代码

/*

var pass=document.cookie.match(/password=([^;]+)/i);

if(pass){

pass=unescape(pass[1]);

document.write(XOR(unescape(strHTML),STR.md5(pass)));

return(false);

}

*/

//*************

strAskPass="<table cellspacing=0 cellpadding=0 width=100% height=100% align=center valign=middle><tr><td>&nbsp;</td><td align=center>";

strAskPass+="<b>Password:</b><input style=\"border-width:1px;\" type=password id=ps01 onkeydown=\"if(event.keyCode==13){performPage(this.value);}\">";

strAskPass+="<input style=\"border-width:1px;\" type=button onclick=\"performPage(ps01.value);\" value=Enter></td><td>&nbsp;</td></tr></table>";

document.write(strAskPass);

}

var STR =

{

hexcase : 0,  /* hex output format. 0 - lowercase; 1 - uppercase        */

b64pad  : "", /* base-64 pad character. "=" for strict RFC compliance   */

chrsz   : 8,  /* bits per input character. 8 - ASCII; 16 - Unicode      */



b64_hmac_md5:

function(key, data) { return binl2b64(core_hmac_md5(key, data)); },



b64_md5:

function(s){ return binl2b64(core_md5(str2binl(s), s.length * this.chrsz));},



binl2b64:

function(binarray){

var tab = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";

var str = "";

for(var i = 0; i < binarray.length * 4; i += 3)

{

var triplet = (((binarray[i   >> 2] >> 8 * ( i   %4)) & 0xFF) << 16)

| (((binarray[i+1 >> 2] >> 8 * ((i+1)%4)) & 0xFF) << 8 )

|  ((binarray[i+2 >> 2] >> 8 * ((i+2)%4)) & 0xFF);

for(var j = 0; j < 4; j++)

{

if(i * 8 + j * 6 > binarray.length * 32) str += this.b64pad;

else str += tab.charAt((triplet >> 6*(3-j)) & 0x3F);

}

}

return str;

},



binl2hex:

function(binarray){

var hex_tab = this.hexcase ? "0123456789ABCDEF" : "0123456789abcdef";

var str = "";

for(var i = 0; i < binarray.length * 4; i++)

{

str += hex_tab.charAt((binarray[i>>2] >> ((i%4)*8+4)) & 0xF) +

hex_tab.charAt((binarray[i>>2] >> ((i%4)*8  )) & 0xF);

}
(编辑:aniston)

  推荐精品文章

·2024年12月目录 
·2024年11月目录 
·2024年10月目录 
·2024年9月目录 
·2024年8月目录 
·2024年7月目录 
·2024年6月目录 
·2024年5月目录 
·2024年4月目录 
·2024年3月目录 
·2024年2月目录 
·2024年1月目录
·2023年12月目录
·2023年11月目录

  联系方式
TEL:010-82561037
Fax: 010-82561614
QQ: 100164630
Mail:gaojian@comprg.com.cn

  友情链接
 
Copyright 2001-2010, www.comprg.com.cn, All Rights Reserved
京ICP备14022230号-1,电话/传真:010-82561037 82561614 ,Mail:gaojian@comprg.com.cn
地址:北京市海淀区远大路20号宝蓝大厦E座704,邮编:100089