Python实现WEBQQ登录与消息发送(第一版本2015.06.26)

王朝学院·作者佚名  2016-08-27
窄屏简体版  字體: 小  |  中  |  大  |  超大  

WEBQQ的登录步骤与协议,需要的度娘下,很多。

转载说明来源:http://www.cnblogs.com/ryhan/p/4602762.html

我这实现是参考了度娘搜的 和自己抓包分析的。

目前实现了登录后的定向发消息功能。中间遇到很多坑,前前后后用了我两周时间,今天终于能发消息了,经过实际测试,能发中文、英文消息给指定好友、指定群组。

PS:

1.暂时对需要验证码图片下载与识别没做。

2.主要的难点在协议分析,及各种加密算法。我走的捷径,用控件执行JS脚本。

下面是脚本的执行日志截图:

我直接贴代码了。如果有疑问,或者需要交流的,回帖联系我吧。

一、主要代码(Py):

py:pyQQ.py

1#!/usr/bin/env python2#-*- coding: utf-8 -*-34importrequests5importjson6importrandom7importre8fromencryptionimportQJsmd5Rsa9fromreqhashimportQJsHash10importurllib111213classWebQQ():1415def__init__(self, user, pwd):16self.user =user17self.pwd =pwd18self.htp =requests.session()1920def__PRintlog(self, title, url, text, newcookies, allcookies, data=''):2122print'步骤:', title23print'地址:', url24print'发送:', data25print'返回:', text2627print'-'* 20,'cookies','-'* 2028print'新增:', newcookies29print'所有:', allcookies3031print'*'* 493233def__checkVerify(self):3435url = ('https://ssl.ptlogin2.qq.com/check?pt_tea=1&uin=%s&appid=501004106'%self.user36+'&r=%s'%str(random.random()))37r =self.htp.get(url)38self.__printlog('检查验证码', url, r.text, r.cookies, self.htp.cookies)3940'''41r.text:4243ptui_checkVC('0','!UCA','\x00\x00\x00\x00\x3a\x02\x14\xcc','8e3d94255c24398ca0efd3b19aebb1386d0ac31b8ca2266267e7f4436d94c6edfb2e8ec953bfb70d731c0efdca63dc030e8d1a120fa2a0b8','0');4445参数 1:“0” 表示不需要验证码,但需要使用随后的缺省验证码来登录。“1” 表示需要验证码。46参数 2:如果以 “!” 开头则是传递给服务器的缺省验证码。47参数 3:QQ号码的十六进制格式。(登录加密时会用到)48参数4:登录参数的 pt_verifysession_v149参数6:是否使用随机盐(pt.isRandSalt = c)5051'''5253pattern = re.compile("ptui_checkVC\('(.*)','(.*)','(.*)','(.*)','(.*)'\);")54checkdatas =pattern.search(r.text).groups()5556self.needpic =checkdatas[0]57self.verifycode = checkdatas[1]58self.pt_verifysession_v1 = checkdatas[3]59606162#if self.checkdatas[0] == '1':63#print '需要处理密码问题'64#pass6566defuserLogin(self):6768#先搞验证码的问题69self.__checkVerify()7071#下面开始做密码加密运算,为登录做准备72rsapwd =QJsMd5Rsa.GetQQMd5Rsa(self.pwd, self.user, self.verifycode)73#print rsapwd7475#密码登录 需要替换4个参数 分别是u=%s&p=%s&verifycode=%s*****pt_verifysession_v1=%s76url = ('https://ssl.ptlogin2.qq.com/login?u=%s&p=%s&verifycode=%s&webqq_type=10&remember_uin=1&login2qq=1&aid=501004106'%(self.user, rsapwd, self.verifycode)77+'&u1=http%3A%2F%2Fw.qq.com%2Fproxy.html%3Flogin2qq%3D1%26webqq_type%3D10&h=1&ptredirect=0&ptlang=2052&daid=164'78+'&from_ui=1&pttype=1&dumy=&fp=loginerroralert&action=0-76-43894&mibao_CSS=m_webqq&t=3&g=1&js_type=0&js_ver=10126'79+'&login_sig=&pt_randsalt=0&pt_vcode_v1=0&pt_verifysession_v1=%s'%self.pt_verifysession_v1)80ref = ('https://ui.ptlogin2.qq.com/cgi-bin/login?daid=164&target=self&style=16&mibao_css=m_webqq&appid=501004106&enable_qlogin=0'81+'&no_verifyimg=1&s_url=http://w.qq.com/proxy.html&f_url=loginerroralert&strong_login=1&login_state=10&t=20131024001')82headers = {'Accept':'application/javascript, */*;q=0.8','Referer':ref}8384#这个地方是GET登录85r = self.htp.get(url, headers=headers)86self.__printlog('GET登录', url, r.text, r.cookies, self.htp.cookies)8788#这个值后面需要用到(POST登录的时候)89self.ptwebqq = r.cookies['ptwebqq']90#print ptwebqq9192#获取密码登录后的回调地址93#text = '''ptuiCB('0','0','http://ptlogin4.web2.qq.com/check_sig?pttype=1&uin=973214924&service=login&nodirect=0&ptsigx=8be9168e06bf82a19e05108cdce9a5d351aea559057553e6482b68414b364ddc556d468bffedfc35df1f87bb6faca53161e109b1790ad236a36426f8b3d2b232&s_url=http%3A%2F%2Fw.qq.com%2Fproxy.html%3Flogin2qq%3D1%26webqq_type%3D10&f_url=&ptlang=2052&ptredirect=100&aid=501004106&daid=164&j_later=0&low_login_hour=0&regmaster=0&pt_login_type=1&pt_aid=0&pt_aaid=0&pt_light=0&pt_3rd_aid=0','0','登录成功!', '旺旺雪饼');'''94pattern = re.compile("ptuiCB\('(.*)','(.*)','(.*)','(.*)','(.*)',\s+'(.*)'\);")95logindatas =pattern.search(r.text).groups()96#print logindatas979899#回调成功登录地址(拿到对应的cookies,POST登录的时候要)100url = logindatas[2]101r = self.htp.get(url, allow_redirects=False)102self.__printlog('回调登录返回的地址 拿Cookies', url, r.text, r.cookies, self.htp.cookies)103104105#Post Login登录106url ='http://d.web2.qq.com/channel/login2'107datas ='r={"ptwebqq":"%s","clientid":53999199,"psessionid":"","status":"online"}'%self.ptwebqq108ref = ('http://d.web2.qq.com/proxy.html?v=20130916001&callback=1&id=2')109#'User-Agent': 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.3; WOW64; Trident/7.0; .NET4.0E; .NET4.0C; .NET CLR 3.5.30729; .NET CLR 2.0.50727; .NET CLR 3.0.30729; .NET CLR 1.1.4322; InfoPath.3)'\110#这地方一直报错 500 ,尼玛!通过各种抓包对比发现是少了请求头 Content-Type: application/x-www-form-urlencoded111headers = {'Referer':ref,'Content-Type':'application/x-www-form-urlencoded'}112113#POST登录 到这个地方为止 已经成功登录 ,下一步就是去拿好友列表了114r = self.htp.post(url, data=datas, headers=headers)115self.__printlog('POST登录', url, r.text, r.cookies, self.htp.cookies, datas)116#r.text117'''118{119"retcode":0,120"result":{121"uin":973214924,122"cip":1017527010,123"index":1075,124"port":58759,125"status":"online",126"vfwebqq":"500df48dc767afb6e82d850e795340b16a6e42542bc63890f80fb172c2f7c37b3ec41ad817ad4771",127"psessionid":"8368046764001d636f6e6e7365727665725f77656271714031302e3133392e372e31363400000b190000106e036e0400cc14023a6d0000000a4077494e50395a55474c6d00000028500df48dc767afb6e82d850e795340b16a6e42542bc63890f80fb172c2f7c37b3ec41ad817ad4771",128"user_state":0,129"f":0130}131}132'''133self.result =json.loads(r.text)134self.vfwebqq = self.result['result']['vfwebqq']135self.psessionid = self.result['result']['psessionid']136137defgetGroups(self):138139#获取群组列表140hashkey =QJsHash.GetQQHash(self.user, self.ptwebqq)141url ='http://s.web2.qq.com/api/get_group_name_list_mask2'142143datas ='r={"vfwebqq":"%s","hash":"%s"}'%(self.vfwebqq, hashkey)144ref ='http://s.web2.qq.com/proxy.html?v=20130916001&callback=1&id=1'145headers = {'Referer':ref,'Content-Type':'application/x-www-form-urlencoded'146,'User-Agent':'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.3; WOW64; Trident/7.0; .NET4.0E; .NET4.0C; .NET CLR 3.5.30729; .NET CLR 2.0.50727; .NET CLR 3.0.30729; .NET CLR 1.1.4322; InfoPath.3)'147,'Accept-Language':'zh-CN,zh;q=0.8'148,'Origin':'http://s.web2.qq.com'}149150#去拿群组列表151r = self.htp.post(url, data=datas, headers=headers)152self.__printlog('获取群组列表', url, r.text, r.cookies, self.htp.cookies, datas)153154self.groups =json.loads(r.text)155156'''157{158"retcode":0,159"result":{160"gmasklist":[161],162"gnamelist":[163{164"flag":17826817,165"name":"20班",166"gid":2019657155,167"code":707730478168},169{170"flag":1090520065,171"name":"低调点",172"gid":4242729568,173"code":3367636394174}175],176"gmarklist":[177]178}179}180'''181defgetFriends(self):182183#获取好友列表184#hash算法 不对,一次哈希还不行。得到的值不对,拿不到好友列表185#搞错对象,Hash用的是ptwebqq值186hashkey =QJsHash.GetQQHash(self.user, self.ptwebqq)187url ='http://s.web2.qq.com/api/get_user_friends2'188189#获取自己的详细信息190datas ='r={"vfwebqq":"%s","hash":"%s"}'%(self.vfwebqq, hashkey)191ref ='http://s.web2.qq.com/proxy.html?v=20130916001&callback=1&id=1'192#这地方一直报错 500 ,尼玛!通过各种抓包对比发现是少了请求头 Content-Type: application/x-www-form-urlencoded193headers = {'Referer':ref,'Content-Type':'application/x-www-form-urlencoded'194,'User-Agent':'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.3; WOW64; Trident/7.0; .NET4.0E; .NET4.0C; .NET CLR 3.5.30729; .NET CLR 2.0.50727; .NET CLR 3.0.30729; .NET CLR 1.1.4322; InfoPath.3)'195,'Accept-Language':'zh-CN,zh;q=0.8'196,'Origin':'http://s.web2.qq.com'}197198#去拿好友列表了199r = self.htp.post(url, data=datas, headers=headers)200self.__printlog('获取好友列表', url, r.text, r.cookies, self.htp.cookies, datas)201202self.friends =json.loads(r.text)203204defsendGroupMsg(self, uin, msg, face=None):205'''206r=207{208"group_uin":4242729568,209"content":"["饿了",["font",{"name":"宋体","size":10,"style":[0,0,0],"color":"000000"}]]",210"face":774,211"clientid":53999199,212"msg_id":44050002,213"psessionid":"8368046764001d636f6e6e7365727665725f77656271714031302e3133392e372e31363400004881000010a5036e0400cc14023a6d0000000a40644f787a776b7454646d00000028b33a3a944975b00083704a7669f6f720d797f6eb2c8fd7df5ed4d17c98375e7b009e8b8d93bbe2fb"214}215216'''217msg = urllib.quote(msg,":?=/")218datas = ('r={"group_uin":%s,'% uin +219u'"content":"[\\\"%s\\\",[\\\"font\\\",{\\\"name\\\":\\\"\\u5B8B\\u4F53\\\",\\\"size\\\":10,\\\"style\\\":[0,0,0],\\\"color\\\":\\\"000000\\\"}]]",'% msg +220'"face":774,'+221'"clientid":53999199,'+222'"msg_id":44050002,'+223'"psessionid":"%s"'% self.psessionid +224'}')225226#发送群组消息227url ='http://d.web2.qq.com/channel/send_qun_msg2'228229ref ='http://d.web2.qq.com/proxy.html?v=20130916001&callback=1&id=2'230headers = {'Referer':ref231,'Content-Type':'application/x-www-form-urlencoded'232,'User-Agent':'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.3; WOW64; Trident/7.0; .NET4.0E; .NET4.0C; .NET CLR 3.5.30729; .NET CLR 2.0.50727; .NET CLR 3.0.30729; .NET CLR 1.1.4322; InfoPath.3)'233#, 'Accept-Language': 'zh-CN,zh;q=0.8'234}235236#去拿群组列表237r = self.htp.post(url, data=datas, headers=headers)238self.__printlog('发送群组消息', url, r.text, r.cookies, self.htp.cookies, datas)239240241pass242243defsendFriendMsg(self, uin, msg):244'''245r={246"to":3709697278247,"content":"[\"给我自己发\",[\"font\",{\"name\":\"宋体\",\"size\":10,\"style\":[0,0,0],\"color\":\"000000\"}]]"248,"face":774249,"clientid":53999199250,"msg_id":35090001251,"psessionid":"8368046764001d636f6e6e7365727665725f77656271714031302e3133392e372e31363400004881000010a5036e0400cc14023a6d0000000a40644f787a776b7454646d00000028e8f2fd0393d150b2404a4d198f196be7132786a4e3fc28c6b4014b78bcd1eda6bad51ef92d5e0862"252}253254'''255msg = urllib.quote(msg,":?=/")256datas = ('r={'+257'"to":%s'% uin +258',"content":"[\\\"%s\\\",[\\\"font\\\",{\\\"name\\\":\\\"\u5B8B\u4F53\\\",\\\"size\\\":10,\\\"style\\\":[0,0,0],\\\"color\\\":\\\"000000\\\"}]]"'% msg +259',"face":774'+260',"clientid":53999199'+261',"msg_id":35090001'+262',"psessionid":"%s"'% self.psessionid +263'}')264265url ='http://d.web2.qq.com/channel/send_buddy_msg2'266ref ='http://d.web2.qq.com/proxy.html?v=20130916001&callback=1&id=2'267headers = {'Referer':ref268,'Content-Type':'application/x-www-form-urlencoded'269,'User-Agent':'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.3; WOW64; Trident/7.0; .NET4.0E; .NET4.0C; .NET CLR 3.5.30729; .NET CLR 2.0.50727; .NET CLR 3.0.30729; .NET CLR 1.1.4322; InfoPath.3)'270}271272#发消息给好友273r = self.htp.post(url, data=datas, headers=headers)274self.__printlog('发送好友消息', url, r.text, r.cookies, self.htp.cookies, datas)275pass276277if__name__=='__main__':278279qq = WebQQ('这是帐号','这是密码')280qq.userLogin()281282qq.getGroups()283quin=qq.groups['result']['gnamelist'][1]['gid']284qq.sendGroupMsg(str(quin),'其实我是想写个聊天机器人的,不过有点高深,另外,登录验证码的破解逻辑,还没写')285286qq.getFriends()287fuin = qq.friends['result']['info'][6]['uin']288printfuin289qq.sendFriendMsg(str(fuin),'shen me qing kuang')

View Code

二、哈希算法(Py与JS):

py:reqhash.py

1#! /usr/bin/env python2#coding=utf-8345importwin32com.server.util, win32com.client67#以下代码解决输出乱码问题8importsys9#print sys.getdefaultencoding()10reload(sys)11sys.setdefaultencoding('utf8')12#print sys.getdefaultencoding()1314class__PyWinQQJsHash:1516def__init__(self):1718js = win32com.client.Dispatch('MSScriptControl.ScriptControl')19js.Language ='Javascript'20js.AllowUI =True21js.AddCode(self.__readJsFile("jsfiles/reqHash.js"))22self.jsengine =js2324def__readJsFile(self, filename):2526fp = file(filename,'r')27lines =''28forlineinfp:29lines +=line30returnlines3132def__driveJsCode(self, func, paras):3334ifparas:35returnself.jsengine.Run(func, paras[0], paras[1])36else:37returnself.jsengine.Run(func)3839defGetQQHash(self, qqnum, ptwebqq):40returnself.__driveJsCode("GetQQHash", [qqnum, ptwebqq])414243QJsHash =__PyWinQQJsHash()

View Code

js:reqHash.js

1functionGetQQHash(x, K) {2x += "";3for(varN = [], T = 0; T < K.length; T++)4N[T % 4] ^=K.charCodeAt(T);5varU = ["EC", "OK"], V =[];6V[0] = x >> 24 & 255 ^ U[0].charCodeAt(0);7V[1] = x >> 16 & 255 ^ U[0].charCodeAt(1);8V[2] = x >> 8 & 255 ^ U[1].charCodeAt(0);9V[3] = x & 255 ^ U[1].charCodeAt(1);10U =[];11for(T = 0; T < 8; T++)12U[T] = T % 2 == 0 ? N[T >> 1] : V[T >> 1];13N = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F"];14V = "";15for(T = 0; T < U.length; T++) {16V += N[U[T] >> 4 & 15];17V += N[U[T] & 15]18}19returnV20};

View Code

三、密码加密(Py与JS):

py:encryption.py

1#! /usr/bin/env python2#coding=utf-8345importwin32com.server.util, win32com.client6importjson78#以下代码解决输出乱码问题9importsys10fromtest.test_audioopimportdatas11#print sys.getdefaultencoding()12reload(sys)13sys.setdefaultencoding('utf8')14#print sys.getdefaultencoding()1516class__PyWinQQJsMd5Rsa:1718def__init__(self):1920js = win32com.client.Dispatch('MSScriptControl.ScriptControl')21js.Language ='JavaScript'22js.AllowUI =True23js.AddCode(self.__readJsFile("jsfiles/loginRsa.js"))24js.AddCode(self.__readJsFile("jsfiles/loginMd5.js"))25js.AddCode(self.__readJsFile("jsfiles/loginUtil.js"))26self.jsengine =js2728def__readJsFile(self, filename):2930fp = file(filename,'r')31lines =''32forlineinfp:33lines +=line34returnlines3536def__driveJsCode(self, func, paras):3738ifparas:39returnself.jsengine.Run(func, paras[0], paras[1], paras[2])40else:41returnself.jsengine.Run(func)4243defGetQQMd5Rsa(self, passWord, salt, verifycode):44returnself.__driveJsCode("GetQQMd5Rsa", [password, salt, verifycode])454647QJsMd5Rsa =__PyWinQQJsMd5Rsa()

View Code

js:loginUtil.js

1functionGetQQMd5Rsa(password, salt, verifycode) {23//return salt;4//return $.Encryption.getRSAEncryption(password, verifycode);5return$.Encryption.getEncryption(password,uin2hex(salt), verifycode);6//return typeof($.Encryption.getEncryption);7};89functionuin2hex(str) {10varmaxLength = 16;11varhex = parseInt(str).toString(16);12varlen =hex.length;13for(vari = len; i < maxLength; i++) {14hex = '0' +hex15}16vararr =[];17for(varj = 0; j < maxLength; j += 2) {18arr.push('\\x' + hex.substr(j, 2))19}20varresult = arr.join('');21eval('result="' + result + '"');22returnresult23}

View Code

js:loginRsa.js

1varwindow ={};2varnavigator ={};3$ ={};4$pt ={}5window.$ =$;6window.$pt =$pt;789//var window = window || {};10//var navigator = navigator || {};11//12//$ = window.$ || {};13//$pt = window.$pt || {};141516$.RSA = $pt.RSA =function() {17functiong(z, t) {18returnnewar(z, t)19}20functionah(aA, aB) {21vart = "";22varz = 0;23while(z + aB <aA.length) {24t += aA.substring(z, z + aB) + "\n";25z +=aB26}27returnt +aA.substring(z, aA.length)28}29functionr(t) {30if(t < 16) {31return"0" + t.toString(16)32}else{33returnt.toString(16)34}35}36functionaf(aB, aE) {37if(aE < aB.length + 11) {38uv_alert("Message too long for RSA");39returnnull40}41varaD =newArray();42varaA = aB.length - 1;43while(aA >= 0 && aE > 0) {44varaC = aB.charCodeAt(aA--);45aD[--aE] =aC46}47aD[--aE] = 0;48varz =newad();49vart =newArray();50while(aE > 2) {51t[0] = 0;52while(t[0] == 0) {53z.nextBytes(t)54}55aD[--aE] = t[0]56}57aD[--aE] = 2;58aD[--aE] = 0;59returnnewar(aD)60}61functionL() {62this.n =null;63this.e = 0;64this.d =null;65this.p =null;66this.q =null;67this.dmp1 =null;68this.dmq1 =null;69this.coeff =null70}71functiono(z, t) {72if(z !=null&& t !=null&& z.length > 0 && t.length > 0) {73this.n = g(z, 16);74this.e = parseInt(t, 16)75}else{76uv_alert("Invalid RSA public key")77}78}79functionW(t) {80returnt.modPowInt(this.e,this.n)81}82functionp(aA) {83vart = af(aA, (this.n.bitLength() + 7) >> 3);84if(t ==null) {85returnnull86}87varaB =this.doPublic(t);88if(aB ==null) {89returnnull90}91varz = aB.toString(16);92if((z.length & 1) == 0) {93returnz94}else{95return"0" +z96}97}98L.prototype.doPublic =W;99L.prototype.setPublic =o;100L.prototype.encrypt =p;101varaw;102varai = 244837814094590;103varZ = ((ai & 16777215) == 15715070);104functionar(z, t, aA) {105if(z !=null) {106if("number" ==typeofz) {107this.fromNumber(z, t, aA)108}else{109if(t ==null&& "string" !=typeofz) {110this.fromString(z, 256)111}else{112this.fromString(z, t)113}114}115}116}117functionh() {118returnnewar(null)119}120functionb(aC, t, z, aB, aE, aD) {121while(--aD >= 0) {122varaA = t *this[aC++] + z[aB] +aE;123aE = Math.floor(aA / 67108864);124z[aB++] = aA & 67108863125}126returnaE127}128functionay(aC, aH, aI, aB, aF, t) {129varaE = aH & 32767,130aG = aH >> 15;131while(--t >= 0) {132varaA =this[aC] & 32767;133varaD =this[aC++] >> 15;134varz = aG * aA + aD *aE;135aA = aE * aA + ((z & 32767) << 15) + aI[aB] + (aF & 1073741823);136aF = (aA >>> 30) + (z >>> 15) + aG * aD + (aF >>> 30);137aI[aB++] = aA & 1073741823138}139returnaF140}141functionax(aC, aH, aI, aB, aF, t) {142varaE = aH & 16383,143aG = aH >> 14;144while(--t >= 0) {145varaA =this[aC] & 16383;146varaD =this[aC++] >> 14;147varz = aG * aA + aD *aE;148aA = aE * aA + ((z & 16383) << 14) + aI[aB] +aF;149aF = (aA >> 28) + (z >> 14) + aG *aD;150aI[aB++] = aA & 268435455151}152returnaF153}154if(Z && (navigator.appName == "Microsoft Internet Explorer")) {155ar.prototype.am =ay;156aw = 30157}else{158if(Z && (navigator.appName != "Netscape")) {159ar.prototype.am =b;160aw = 26161}else{162ar.prototype.am =ax;163aw = 28164}165}166ar.prototype.DB =aw;167ar.prototype.DM = ((1 << aw) - 1);168ar.prototype.DV = (1 <<aw);169varaa = 52;170ar.prototype.FV = Math.pow(2, aa);171ar.prototype.F1 = aa -aw;172ar.prototype.F2 = 2 * aw -aa;173varae = "0123456789abcdefghijklmnopqrstuvwxyz";174varag =newArray();175varap, v;176ap = "0".charCodeAt(0);177for(v = 0; v <= 9; ++v) {178ag[ap++] =v179}180ap = "a".charCodeAt(0);181for(v = 10; v < 36; ++v) {182ag[ap++] =v183}184ap = "A".charCodeAt(0);185for(v = 10; v < 36; ++v) {186ag[ap++] =v187}188functionaz(t) {189returnae.charAt(t)190}191functionA(z, t) {192varaA =ag[z.charCodeAt(t)];193return(aA ==null) ? -1: aA194}195functionY(z) {196for(vart =this.t - 1; t >= 0; --t) {197z[t] =this[t]198}199z.t =this.t;200z.s =this.s201}202functionn(t) {203this.t = 1;204this.s = (t < 0) ? -1 : 0;205if(t > 0) {206this[0] =t207}else{208if(t < -1) {209this[0] = t +DV210}else{211this.t = 0212}213}214}215functionc(t) {216varz =h();217z.fromInt(t);218returnz219}220functionw(aE, z) {221varaB;222if(z == 16) {223aB = 4224}else{225if(z == 8) {226aB = 3227}else{228if(z == 256) {229aB = 8230}else{231if(z == 2) {232aB = 1233}else{234if(z == 32) {235aB = 5236}else{237if(z == 4) {238aB = 2239}else{240this.fromRadix(aE, z);241return242}243}244}245}246}247}248this.t = 0;249this.s = 0;250varaD =aE.length,251aA =false,252aC = 0;253while(--aD >= 0) {254vart = (aB == 8) ? aE[aD] & 255: A(aE, aD);255if(t < 0) {256if(aE.charAt(aD) == "-") {257aA =true258}259continue260}261aA =false;262if(aC == 0) {263this[this.t++] =t264}else{265if(aC + aB >this.DB) {266this[this.t - 1] |= (t & ((1 << (this.DB - aC)) - 1)) <<aC;267this[this.t++] = (t >> (this.DB -aC))268}else{269this[this.t - 1] |= t <<aC270}271}272aC +=aB;273if(aC >=this.DB) {274aC -=this.DB275}276}277if(aB == 8 && (aE[0] & 128) != 0) {278this.s = -1;279if(aC > 0) {280this[this.t - 1] |= ((1 << (this.DB - aC)) - 1) <<aC281}282}283this.clamp();284if(aA) {285ar.ZERO.subTo(this,this)286}287}288functionO() {289vart =this.s &this.DM;290while(this.t > 0 &&this[this.t - 1] == t) {--this.t291}292}293functionq(z) {294if(this.s < 0) {295return"-" +this.negate().toString(z)296}297varaA;298if(z == 16) {299aA = 4300}else{301if(z == 8) {302aA = 3303}else{304if(z == 2) {305aA = 1306}else{307if(z == 32) {308aA = 5309}else{310if(z == 4) {311aA = 2312}else{313returnthis.toRadix(z)314}315}316}317}318}319varaC = (1 << aA) - 1,320aF,321t =false,322aD = "",323aB =this.t;324varaE =this.DB - (aB *this.DB) %aA;325if(aB-->0) {326if(aE <this.DB && (aF =this[aB] >> aE) > 0) {327t =true;328aD =az(aF)329}330while(aB >= 0) {331if(aE <aA) {332aF = (this[aB] & ((1 << aE) - 1)) << (aA -aE);333aF |=this[--aB] >> (aE +=this.DB -aA)334}else{335aF = (this[aB] >> (aE -= aA)) &aC;336if(aE <= 0) {337aE +=this.DB; --aB338}339}340if(aF > 0) {341t =true342}343if(t) {344aD +=az(aF)345}346}347}348returnt ? aD: "0"349}350functionR() {351vart =h();352ar.ZERO.subTo(this, t);353returnt354}355functional() {356return(this.s < 0) ?this.negate() :this357}358functionG(t) {359varaA =this.s -t.s;360if(aA != 0) {361returnaA362}363varz =this.t;364aA = z -t.t;365if(aA != 0) {366returnaA367}368while(--z >= 0) {369if((aA =this[z] - t[z]) != 0) {370returnaA371}372}373return0374}375functionj(z) {376varaB = 1,377aA;378if((aA = z >>> 16) != 0) {379z =aA;380aB += 16381}382if((aA = z >> 8) != 0) {383z =aA;384aB += 8385}386if((aA = z >> 4) != 0) {387z =aA;388aB += 4389}390if((aA = z >> 2) != 0) {391z =aA;392aB += 2393}394if((aA = z >> 1) != 0) {395z =aA;396aB += 1397}398returnaB399}400functionu() {401if(this.t <= 0) {402return0403}404returnthis.DB * (this.t - 1) + j(this[this.t - 1] ^ (this.s &this.DM))405}406functionaq(aA, z) {407vart;408for(t =this.t - 1; t >= 0; --t) {409z[t + aA] =this[t]410}411for(t = aA - 1; t >= 0; --t) {412z[t] = 0413}414z.t =this.t +aA;415z.s =this.s416}417functionX(aA, z) {418for(vart = aA; t <this.t; ++t) {419z[t - aA] =this[t]420}421z.t = Math.max(this.t - aA, 0);422z.s =this.s423}424functions(aF, aB) {425varz = aF %this.DB;426vart =this.DB -z;427varaD = (1 << t) - 1;428varaC = Math.floor(aF /this.DB),429aE = (this.s << z) &this.DM,430aA;431for(aA =this.t - 1; aA >= 0; --aA) {432aB[aA + aC + 1] = (this[aA] >> t) |aE;433aE = (this[aA] & aD) <<z434}435for(aA = aC - 1; aA >= 0; --aA) {436aB[aA] = 0437}438aB[aC] =aE;439aB.t =this.t + aC + 1;440aB.s =this.s;441aB.clamp()442}443functionl(aE, aB) {444aB.s =this.s;445varaC = Math.floor(aE /this.DB);446if(aC >=this.t) {447aB.t = 0;448return449}450varz = aE %this.DB;451vart =this.DB -z;452varaD = (1 << z) - 1;453aB[0] =this[aC] >>z;454for(varaA = aC + 1; aA <this.t; ++aA) {455aB[aA - aC - 1] |= (this[aA] & aD) <<t;456aB[aA - aC] =this[aA] >>z457}458if(z > 0) {459aB[this.t - aC - 1] |= (this.s & aD) <<t460}461aB.t =this.t -aC;462aB.clamp()463}464functionab(z, aB) {465varaA = 0,466aC = 0,467t = Math.min(z.t,this.t);468while(aA <t) {469aC +=this[aA] -z[aA];470aB[aA++] = aC &this.DM;471aC >>=this.DB472}473if(z.t <this.t) {474aC -=z.s;475while(aA <this.t) {476aC +=this[aA];477aB[aA++] = aC &this.DM;478aC >>=this.DB479}480aC +=this.s481}else{482aC +=this.s;483while(aA <z.t) {484aC -=z[aA];485aB[aA++] = aC &this.DM;486aC >>=this.DB487}488aC -=z.s489}490aB.s = (aC < 0) ? -1 : 0;491if(aC < -1) {492aB[aA++] =this.DV +aC493}else{494if(aC > 0) {495aB[aA++] =aC496}497}498aB.t =aA;499aB.clamp()500}501functionD(z, aB) {502vart =this.abs(),503aC =z.abs();504varaA =t.t;505aB.t = aA +aC.t;506while(--aA >= 0) {507aB[aA] = 0508}509for(aA = 0; aA < aC.t; ++aA) {510aB[aA + t.t] = t.am(0, aC[aA], aB, aA, 0, t.t)511}512aB.s = 0;513aB.clamp();514if(this.s !=z.s) {515ar.ZERO.subTo(aB, aB)516}517}518functionQ(aA) {519vart =this.abs();520varz = aA.t = 2 *t.t;521while(--z >= 0) {522aA[z] = 0523}524for(z = 0; z < t.t - 1; ++z) {525varaB = t.am(z, t[z], aA, 2 * z, 0, 1);526if((aA[z + t.t] += t.am(z + 1, 2 * t[z], aA, 2 * z + 1, aB, t.t - z - 1)) >=t.DV) {527aA[z + t.t] -=t.DV;528aA[z + t.t + 1] = 1529}530}531if(aA.t > 0) {532aA[aA.t - 1] += t.am(z, t[z], aA, 2 * z, 0, 1)533}534aA.s = 0;535aA.clamp()536}537functionE(aI, aF, aE) {538varaO =aI.abs();539if(aO.t <= 0) {540return541}542varaG =this.abs();543if(aG.t <aO.t) {544if(aF !=null) {545aF.fromInt(0)546}547if(aE !=null) {548this.copyTo(aE)549}550return551}552if(aE ==null) {553aE =h()554}555varaC =h(),556z =this.s,557aH =aI.s;558varaN =this.DB - j(aO[aO.t - 1]);559if(aN > 0) {560aO.lShiftTo(aN, aC);561aG.lShiftTo(aN, aE)562}else{563aO.copyTo(aC);564aG.copyTo(aE)565}566varaK =aC.t;567varaA = aC[aK - 1];568if(aA == 0) {569return570}571varaJ = aA * (1 <<this.F1) + ((aK > 1) ? aC[aK - 2] >>this.F2: 0);572varaR =this.FV /aJ,573aQ = (1 <<this.F1) /aJ,574aP = 1 <<this.F2;575varaM =aE.t,576aL = aM -aK,577aD = (aF ==null) ?h() : aF;578aC.dlShiftTo(aL, aD);579if(aE.compareTo(aD) >= 0) {580aE[aE.t++] = 1;581aE.subTo(aD, aE)582}583ar.ONE.dlShiftTo(aK, aD);584aD.subTo(aC, aC);585while(aC.t <aK) {586aC[aC.t++] = 0587}588while(--aL >= 0) {589varaB = (aE[--aM] == aA) ?this.DM: Math.floor(aE[aM] * aR + (aE[aM - 1] + aP) *aQ);590if((aE[aM] += aC.am(0, aB, aE, aL, 0, aK)) <aB) {591aC.dlShiftTo(aL, aD);592aE.subTo(aD, aE);593while(aE[aM] < --aB) {594aE.subTo(aD, aE)595}596}597}598if(aF !=null) {599aE.drShiftTo(aK, aF);600if(z !=aH) {601ar.ZERO.subTo(aF, aF)602}603}604aE.t =aK;605aE.clamp();606if(aN > 0) {607aE.rShiftTo(aN, aE)608}609if(z < 0) {610ar.ZERO.subTo(aE, aE)611}612}613functionN(t) {614varz =h();615this.abs().divRemTo(t,null, z);616if(this.s < 0 && z.compareTo(ar.ZERO) > 0) {617t.subTo(z, z)618}619returnz620}621functionK(t) {622this.m =t623}624functionV(t) {625if(t.s < 0 || t.compareTo(this.m) >= 0) {626returnt.mod(this.m)627}else{628returnt629}630}631functionak(t) {632returnt633}634functionJ(t) {635t.divRemTo(this.m,null, t)636}637functionH(t, aA, z) {638t.multiplyTo(aA, z);639this.reduce(z)640}641functionau(t, z) {642t.squareTo(z);643this.reduce(z)644}645K.prototype.convert =V;646K.prototype.revert =ak;647K.prototype.reduce =J;648K.prototype.mulTo =H;649K.prototype.sqrTo =au;650functionB() {651if(this.t < 1) {652return0653}654vart =this[0];655if((t & 1) == 0) {656return0657}658varz = t & 3;659z = (z * (2 - (t & 15) * z)) & 15;660z = (z * (2 - (t & 255) * z)) & 255;661z = (z * (2 - (((t & 65535) * z) & 65535))) & 65535;662z = (z * (2 - t * z %this.DV)) %this.DV;663return(z > 0) ?this.DV - z: -z664}665functionf(t) {666this.m =t;667this.mp =t.invDigit();668this.mpl =this.mp & 32767;669this.mph =this.mp >> 15;670this.um = (1 << (t.DB - 15)) - 1;671this.mt2 = 2 *t.t672}673functionaj(t) {674varz =h();675t.abs().dlShiftTo(this.m.t, z);676z.divRemTo(this.m,null, z);677if(t.s < 0 && z.compareTo(ar.ZERO) > 0) {678this.m.subTo(z, z)679}680returnz681}682functionat(t) {683varz =h();684t.copyTo(z);685this.reduce(z);686returnz687}688functionP(t) {689while(t.t <=this.mt2) {690t[t.t++] = 0691}692for(varaA = 0; aA <this.m.t; ++aA) {693varz = t[aA] & 32767;694varaB = (z *this.mpl + (((z *this.mph + (t[aA] >> 15) *this.mpl) &this.um) << 15)) &t.DM;695z = aA +this.m.t;696t[z] +=this.m.am(0, aB, t, aA, 0,this.m.t);697while(t[z] >=t.DV) {698t[z] -=t.DV;699t[++z]++700}701}702t.clamp();703t.drShiftTo(this.m.t, t);704if(t.compareTo(this.m) >= 0) {705t.subTo(this.m, t)706}707}708functionam(t, z) {709t.squareTo(z);710this.reduce(z)711}712functiony(t, aA, z) {713t.multiplyTo(aA, z);714this.reduce(z)715}716f.prototype.convert =aj;717f.prototype.revert =at;718f.prototype.reduce =P;719f.prototype.mulTo =y;720f.prototype.sqrTo =am;721functioni() {722return((this.t > 0) ? (this[0] & 1) :this.s) == 0723}724functionx(aF, aG) {725if(aF > 4294967295 || aF < 1) {726returnar.ONE727}728varaE =h(),729aA =h(),730aD = aG.convert(this),731aC = j(aF) - 1;732aD.copyTo(aE);733while(--aC >= 0) {734aG.sqrTo(aE, aA);735if((aF & (1 << aC)) > 0) {736aG.mulTo(aA, aD, aE)737}else{738varaB =aE;739aE =aA;740aA =aB741}742}743returnaG.revert(aE)744}745functionan(aA, t) {746varaB;747if(aA < 256 ||t.isEven()) {748aB =newK(t)749}else{750aB =newf(t)751}752returnthis.exp(aA, aB)753}754ar.prototype.copyTo =Y;755ar.prototype.fromInt =n;756ar.prototype.fromString =w;757ar.prototype.clamp =O;758ar.prototype.dlShiftTo =aq;759ar.prototype.drShiftTo =X;760ar.prototype.lShiftTo =s;761ar.prototype.rShiftTo =l;762ar.prototype.subTo =ab;763ar.prototype.multiplyTo =D;764ar.prototype.squareTo =Q;765ar.prototype.divRemTo =E;766ar.prototype.invDigit =B;767ar.prototype.isEven =i;768ar.prototype.exp =x;769ar.prototype.toString =q;770ar.prototype.negate =R;771ar.prototype.abs =al;772ar.prototype.compareTo =G;773ar.prototype.bitLength =u;774ar.prototype.mod =N;775ar.prototype.modPowInt =an;776ar.ZERO = c(0);777ar.ONE = c(1);778varm;779varU;780varac;781functiond(t) {782U[ac++] ^= t & 255;783U[ac++] ^= (t >> 8) & 255;784U[ac++] ^= (t >> 16) & 255;785U[ac++] ^= (t >> 24) & 255;786if(ac >=M) {787ac -=M788}789}790functionT() {791d(newDate().getTime())792}793if(U ==null) {794U =newArray();795ac = 0;796varI;797if(navigator.appName == "Netscape" && navigator.appVersion < "5" && window.crypto &&window.crypto.random) {798varF = window.crypto.random(32);799for(I = 0; I < F.length; ++I) {800U[ac++] = F.charCodeAt(I) & 255801}802}803while(ac <M) {804I = Math.floor(65536 *Math.random());805U[ac++] = I >>> 8;806U[ac++] = I & 255807}808ac = 0;809T()810}811functionC() {812if(m ==null) {813T();814m =ao();815m.init(U);816for(ac = 0; ac < U.length; ++ac) {817U[ac] = 0818}819ac = 0820}821returnm.next()822}823functionav(z) {824vart;825for(t = 0; t < z.length; ++t) {826z[t] =C()827}828}829functionad() {}830ad.prototype.nextBytes =av;831functionk() {832this.i = 0;833this.j = 0;834this.S =newArray()835}836functione(aC) {837varaB, z, aA;838for(aB = 0; aB < 256; ++aB) {839this.S[aB] =aB840}841z = 0;842for(aB = 0; aB < 256; ++aB) {843z = (z +this.S[aB] + aC[aB % aC.length]) & 255;844aA =this.S[aB];845this.S[aB] =this.S[z];846this.S[z] =aA847}848this.i = 0;849this.j = 0850}851functiona() {852varz;853this.i = (this.i + 1) & 255;854this.j = (this.j +this.S[this.i]) & 255;855z =this.S[this.i];856this.S[this.i] =this.S[this.j];857this.S[this.j] =z;858returnthis.S[(z +this.S[this.i]) & 255]859}860k.prototype.init =e;861k.prototype.next =a;862functionao() {863returnnewk()864}865varM = 256;866functionS(aB, aA, z) {867aA = "F20CE00BAE5361F8FA3AE9CEFA495362FF7DA1BA628F64A347F0A8C012BF0B254A30CD92ABFFE7A6EE0DC424CB6166F8819EFA5BCCB20EDFB4AD02E412CCF579B1CA711D55B8B0B3AEB60153D5E0693A2A86F3167D7847A0CB8B00004716A9095D9BADC977CBB804DBDCBA6029A9710869A453F27DFDDF83C016D928B3CBF4C7";868z = "3";869vart =newL();870t.setPublic(aA, z);871returnt.encrypt(aB)872}873return{874rsa_encrypt: S875}876} ();877878(function(r) {879vars = "",880a = 0,881g =[],882x =[],883y = 0,884u = 0,885m =[],886t =[],887n =true;888functione() {889returnMath.round(Math.random() * 4294967295)890}891functioni(C, D, z) {892if(!z || z > 4) {893z = 4894}895varA = 0;896for(varB = D; B < D + z; B++) {897A <<= 8;898A |=C[B]899}900return(A & 4294967295) >>> 0901}902functionb(A, B, z) {903A[B + 3] = (z >> 0) & 255;904A[B + 2] = (z >> 8) & 255;905A[B + 1] = (z >> 16) & 255;906A[B + 0] = (z >> 24) & 255907}908functionw(C) {909if(!C) {910return""911}912varz = "";913for(varA = 0; A < C.length; A++) {914varB = Number(C[A]).toString(16);915if(B.length == 1) {916B = "0" +B917}918z +=B919}920returnz921}922functionv(A) {923varB = "";924for(varz = 0; z < A.length; z += 2) {925B += String.fromCharCode(parseInt(A.substr(z, 2), 16))926}927returnB928}929functionc(C, z) {930if(!C) {931return""932}933if(z) {934C =k(C)935}936varB =[];937for(varA = 0; A < C.length; A++) {938B[A] =C.charCodeAt(A)939}940returnw(B)941}942functionk(C) {943varB, D, A =[],944z =C.length;945for(B = 0; B < z; B++) {946D =C.charCodeAt(B);947if(D > 0 && D <= 127) {948A.push(C.charAt(B))949}else{950if(D >= 128 && D <= 2047) {951A.push(String.fromCharCode(192 | ((D >> 6) & 31)), String.fromCharCode(128 | (D & 63)))952}else{953if(D >= 2048 && D <= 65535) {954A.push(String.fromCharCode(224 | ((D >> 12) & 15)), String.fromCharCode(128 | ((D >> 6) & 63)), String.fromCharCode(128 | (D & 63)))955}956}957}958}959returnA.join("")960}961functionh(B) {962g =newArray(8);963x =newArray(8);964y = u = 0;965n =true;966a = 0;967varz =B.length;968varC = 0;969a = (z + 10) % 8;970if(a != 0) {971a = 8 -a972}973m =newArray(z + a + 10);974g[0] = ((e() & 248) | a) & 255;975for(varA = 1; A <= a; A++) {976g[A] = e() & 255977}978a++;979for(varA = 0; A < 8; A++) {980x[A] = 0981}982C = 1;983while(C <= 2) {984if(a < 8) {985g[a++] = e() & 255;986C++987}988if(a == 8) {989p()990}991}992varA = 0;993while(z > 0) {994if(a < 8) {995g[a++] = B[A++];996z--997}998if(a == 8) {999p()1000}1001}1002C = 1;1003while(C <= 7) {1004if(a < 8) {1005g[a++] = 0;1006C++1007}1008if(a == 8) {1009p()1010}1011}1012returnm1013}1014functionq(D) {1015varC = 0;1016varA =newArray(8);1017varz =D.length;1018t =D;1019if(z % 8 != 0 || z < 16) {1020returnnull1021}1022x =l(D);1023a = x[0] & 7;1024C = z - a - 10;1025if(C < 0) {1026returnnull1027}1028for(varB = 0; B < A.length; B++) {1029A[B] = 01030}1031m =newArray(C);1032u = 0;1033y = 8;1034a++;1035varE = 1;1036while(E <= 2) {1037if(a < 8) {1038a++;1039E++1040}1041if(a == 8) {1042A =D;1043if(!f()) {1044returnnull1045}1046}1047}1048varB = 0;1049while(C != 0) {1050if(a < 8) {1051m[B] = (A[u + a] ^ x[a]) & 255;1052B++;1053C--;1054a++1055}1056if(a == 8) {1057A =D;1058u = y - 8;1059if(!f()) {1060returnnull1061}1062}1063}1064for(E = 1; E < 8; E++) {1065if(a < 8) {1066if((A[u + a] ^ x[a]) != 0) {1067returnnull1068}1069a++1070}1071if(a == 8) {1072A =D;1073u =y;1074if(!f()) {1075returnnull1076}1077}1078}1079returnm1080}1081functionp() {1082for(varz = 0; z < 8; z++) {1083if(n) {1084g[z] ^=x[z]1085}else{1086g[z] ^= m[u +z]1087}1088}1089varA =j(g);1090for(varz = 0; z < 8; z++) {1091m[y + z] = A[z] ^x[z];1092x[z] =g[z]1093}1094u =y;1095y += 8;1096a = 0;1097n =false1098}1099functionj(A) {1100varB = 16;1101varG = i(A, 0, 4);1102varF = i(A, 4, 4);1103varI = i(s, 0, 4);1104varH = i(s, 4, 4);1105varE = i(s, 8, 4);1106varD = i(s, 12, 4);1107varC = 0;1108varJ = 2654435769 >>> 0;1109while(B-->0) {1110C +=J;1111C = (C & 4294967295) >>> 0;1112G += ((F << 4) + I) ^ (F + C) ^ ((F >>> 5) +H);1113G = (G & 4294967295) >>> 0;1114F += ((G << 4) + E) ^ (G + C) ^ ((G >>> 5) +D);1115F = (F & 4294967295) >>> 01116}1117varK =newArray(8);1118b(K, 0, G);1119b(K, 4, F);1120returnK1121}1122functionl(A) {1123varB = 16;1124varG = i(A, 0, 4);1125varF = i(A, 4, 4);1126varI = i(s, 0, 4);1127varH = i(s, 4, 4);1128varE = i(s, 8, 4);1129varD = i(s, 12, 4);1130varC = 3816266640 >>> 0;1131varJ = 2654435769 >>> 0;1132while(B-->0) {1133F -= ((G << 4) + E) ^ (G + C) ^ ((G >>> 5) +D);1134F = (F & 4294967295) >>> 0;1135G -= ((F << 4) + I) ^ (F + C) ^ ((F >>> 5) +H);1136G = (G & 4294967295) >>> 0;1137C -=J;1138C = (C & 4294967295) >>> 01139}1140varK =newArray(8);1141b(K, 0, G);1142b(K, 4, F);1143returnK1144}1145functionf() {1146varz =t.length;1147for(varA = 0; A < 8; A++) {1148x[A] ^= t[y +A]1149}1150x =l(x);1151y += 8;1152a = 0;1153returntrue1154}1155functiono(D, C) {1156varB =[];1157if(C) {1158for(varA = 0; A < D.length; A++) {1159B[A] = D.charCodeAt(A) & 2551160}1161}else{1162varz = 0;1163for(varA = 0; A < D.length; A += 2) {1164B[z++] = parseInt(D.substr(A, 2), 16)1165}1166}1167returnB1168}1169r.TEA ={1170encrypt:function(C, B) {1171varA =o(C, B);1172varz =h(A);1173returnw(z)1174},1175enAsBase64:function(E, D) {1176varC =o(E, D);1177varB =h(C);1178varz = "";1179for(varA = 0; A < B.length; A++) {1180z +=String.fromCharCode(B[A])1181}1182returnbtoa(z)1183},1184decrypt:function(B) {1185varA = o(B,false);1186varz =q(A);1187returnw(z)1188},1189initkey:function(z, A) {1190s =o(z, A)1191},1192bytesToStr: v,1193strToBytes: c,1194bytesInStr: w,1195dataFromStr: o1196};1197vard ={};1198d.PADCHAR = "=";1199d.ALPHA = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";1200d.getbyte =function(B, A) {1201varz =B.charCodeAt(A);1202if(z > 255) {1203throw"INVALID_CHARACTER_ERR: DOM Exception 5"1204}1205returnz1206};1207d.encode =function(D) {1208if(arguments.length != 1) {1209throw"SyntaxError: Not enough arguments"1210}1211varA =d.PADCHAR;1212varF =d.ALPHA;1213varE =d.getbyte;1214varC, G;1215varz =[];1216D = "" +D;1217varB = D.length - D.length % 3;1218if(D.length == 0) {1219returnD1220}1221for(C = 0; C < B; C += 3) {1222G = (E(D, C) << 16) | (E(D, C + 1) << 8) | E(D, C + 2);1223z.push(F.charAt(G >> 18));1224z.push(F.charAt((G >> 12) & 63));1225z.push(F.charAt((G >> 6) & 63));1226z.push(F.charAt(G & 63))1227}1228switch(D.length -B) {1229case1:1230G = E(D, C) << 16;1231z.push(F.charAt(G >> 18) + F.charAt((G >> 12) & 63) + A +A);1232

break;1233case2:1234G = (E(D, C) << 16) | (E(D, C + 1) << 8);1235z.push(F.charAt(G >> 18) + F.charAt((G >> 12) & 63) + F.charAt((G >> 6) & 63) +A);1236

break1237}1238returnz.join("")1239};1240if(!window.btoa) {1241window.btoa =d.encode1242}1243})(window);12441245//跟踪JS代码 发现 这地方需要全局声明(浏览器下这些对象默认是在window下de)1246TEA=window.TEA;1247btoa= window.btoa;

View Code

js:loginMd5.js

1//var window = window || {};2//var navigator = navigator|| {};3//4//$ = window.$ || {};5//$pt = window.$pt || {};67$.Encryption = $pt.Encryption =function() {8varhexcase = 1;9varb64pad = "";10varchrsz = 8;11varmode = 32;12functionmd5(s) {13returnhex_md5(s)14}15functionhex_md5(s) {16returnbinl2hex(core_md5(str2binl(s), s.length *chrsz))17}18functionstr_md5(s) {19returnbinl2str(core_md5(str2binl(s), s.length *chrsz))20}21functionhex_hmac_md5(key, data) {22returnbinl2hex(core_hmac_md5(key, data))23}24functionb64_hmac_md5(key, data) {25returnbinl2b64(core_hmac_md5(key, data))26}27functionstr_hmac_md5(key, data) {28returnbinl2str(core_hmac_md5(key, data))29}30functioncore_md5(x, len) {31x[len >> 5] |= 128 << ((len) % 32);32x[(((len + 64) >>> 9) << 4) + 14] =len;33vara = 1732584193;34varb = -271733879;35varc = -1732584194;36vard = 271733878;37for(vari = 0; i < x.length; i += 16) {38varolda =a;39varoldb =b;40varoldc =c;41varoldd =d;42a = md5_ff(a, b, c, d, x[i + 0], 7, -680876936);43d = md5_ff(d, a, b, c, x[i + 1], 12, -389564586);44c = md5_ff(c, d, a, b, x[i + 2], 17, 606105819);45b = md5_ff(b, c, d, a, x[i + 3], 22, -1044525330);46a = md5_ff(a, b, c, d, x[i + 4], 7, -176418897);47d = md5_ff(d, a, b, c, x[i + 5], 12, 1200080426);48c = md5_ff(c, d, a, b, x[i + 6], 17, -1473231341);49b = md5_ff(b, c, d, a, x[i + 7], 22, -45705983);50a = md5_ff(a, b, c, d, x[i + 8], 7, 1770035416);51d = md5_ff(d, a, b, c, x[i + 9], 12, -1958414417);52c = md5_ff(c, d, a, b, x[i + 10], 17, -42063);53b = md5_ff(b, c, d, a, x[i + 11], 22, -1990404162);54a = md5_ff(a, b, c, d, x[i + 12], 7, 1804603682);55d = md5_ff(d, a, b, c, x[i + 13], 12, -40341101);56c = md5_ff(c, d, a, b, x[i + 14], 17, -1502002290);57b = md5_ff(b, c, d, a, x[i + 15], 22, 1236535329);58a = md5_gg(a, b, c, d, x[i + 1], 5, -165796510);59d = md5_gg(d, a, b, c, x[i + 6], 9, -1069501632);60c = md5_gg(c, d, a, b, x[i + 11], 14, 643717713);61b = md5_gg(b, c, d, a, x[i + 0], 20, -373897302);62a = md5_gg(a, b, c, d, x[i + 5], 5, -701558691);63d = md5_gg(d, a, b, c, x[i + 10], 9, 38016083);64c = md5_gg(c, d, a, b, x[i + 15], 14, -660478335);65b = md5_gg(b, c, d, a, x[i + 4], 20, -405537848);66a = md5_gg(a, b, c, d, x[i + 9], 5, 568446438);67d = md5_gg(d, a, b, c, x[i + 14], 9, -1019803690);68c = md5_gg(c, d, a, b, x[i + 3], 14, -187363961);69b = md5_gg(b, c, d, a, x[i + 8], 20, 1163531501);70a = md5_gg(a, b, c, d, x[i + 13], 5, -1444681467);71d = md5_gg(d, a, b, c, x[i + 2], 9, -51403784);72c = md5_gg(c, d, a, b, x[i + 7], 14, 1735328473);73b = md5_gg(b, c, d, a, x[i + 12], 20, -1926607734);74a = md5_hh(a, b, c, d, x[i + 5], 4, -378558);75d = md5_hh(d, a, b, c, x[i + 8], 11, -2022574463);76c = md5_hh(c, d, a, b, x[i + 11], 16, 1839030562);77b = md5_hh(b, c, d, a, x[i + 14], 23, -35309556);78a = md5_hh(a, b, c, d, x[i + 1], 4, -1530992060);79d = md5_hh(d, a, b, c, x[i + 4], 11, 1272893353);80c = md5_hh(c, d, a, b, x[i + 7], 16, -155497632);81b = md5_hh(b, c, d, a, x[i + 10], 23, -1094730640);82a = md5_hh(a, b, c, d, x[i + 13], 4, 681279174);83d = md5_hh(d, a, b, c, x[i + 0], 11, -358537222);84c = md5_hh(c, d, a, b, x[i + 3], 16, -722521979);85b = md5_hh(b, c, d, a, x[i + 6], 23, 76029189);86a = md5_hh(a, b, c, d, x[i + 9], 4, -640364487);87d = md5_hh(d, a, b, c, x[i + 12], 11, -421815835);88c = md5_hh(c, d, a, b, x[i + 15], 16, 530742520);89b = md5_hh(b, c, d, a, x[i + 2], 23, -995338651);90a = md5_ii(a, b, c, d, x[i + 0], 6, -198630844);91d = md5_ii(d, a, b, c, x[i + 7], 10, 1126891415);92c = md5_ii(c, d, a, b, x[i + 14], 15, -1416354905);93b = md5_ii(b, c, d, a, x[i + 5], 21, -57434055);94a = md5_ii(a, b, c, d, x[i + 12], 6, 1700485571);95d = md5_ii(d, a, b, c, x[i + 3], 10, -1894986606);96c = md5_ii(c, d, a, b, x[i + 10], 15, -1051523);97b = md5_ii(b, c, d, a, x[i + 1], 21, -2054922799);98a = md5_ii(a, b, c, d, x[i + 8], 6, 1873313359);99d = md5_ii(d, a, b, c, x[i + 15], 10, -30611744);100c = md5_ii(c, d, a, b, x[i + 6], 15, -1560198380);101b = md5_ii(b, c, d, a, x[i + 13], 21, 1309151649);102a = md5_ii(a, b, c, d, x[i + 4], 6, -145523070);103d = md5_ii(d, a, b, c, x[i + 11], 10, -1120210379);104c = md5_ii(c, d, a, b, x[i + 2], 15, 718787259);105b = md5_ii(b, c, d, a, x[i + 9], 21, -343485551);106a =safe_add(a, olda);107b =safe_add(b, oldb);108c =safe_add(c, oldc);109d =safe_add(d, oldd)110}111if(mode == 16) {112returnArray(b, c)113}else{114returnArray(a, b, c, d)115}116}117functionmd5_cmn(q, a, b, x, s, t) {118returnsafe_add(bit_rol(safe_add(safe_add(a, q), safe_add(x, t)), s), b)119}120functionmd5_ff(a, b, c, d, x, s, t) {121returnmd5_cmn((b & c) | ((~b) &d), a, b, x, s, t)122}123functionmd5_gg(a, b, c, d, x, s, t) {124returnmd5_cmn((b & d) | (c & (~d)), a, b, x, s, t)125}126functionmd5_hh(a, b, c, d, x, s, t) {127returnmd5_cmn(b ^ c ^d, a, b, x, s, t)128}129functionmd5_ii(a, b, c, d, x, s, t) {130returnmd5_cmn(c ^ (b | (~d)), a, b, x, s, t)131}132functioncore_hmac_md5(key, data) {133varbkey =str2binl(key);134if(bkey.length > 16) {135bkey = core_md5(bkey, key.length *chrsz)136}137varipad = Array(16),138opad = Array(16);139for(vari = 0; i < 16; i++) {140ipad[i] = bkey[i] ^ 909522486;141opad[i] = bkey[i] ^ 1549556828142}143varhash = core_md5(ipad.concat(str2binl(data)), 512 + data.length *chrsz);144returncore_md5(opad.concat(hash), 512 + 128)145}146functionsafe_add(x, y) {147varlsw = (x & 65535) + (y & 65535);148varmsw = (x >> 16) + (y >> 16) + (lsw >> 16);149return(msw << 16) | (lsw & 65535)150}151functionbit_rol(num, cnt) {152return(num << cnt) | (num >>> (32 -cnt))153}154functionstr2binl(str) {155varbin =Array();156varmask = (1 << chrsz) - 1;157for(vari = 0; i < str.length * chrsz; i +=chrsz) {158bin[i >> 5] |= (str.charCodeAt(i / chrsz) & mask) << (i % 32)159}160returnbin161}162functionbinl2str(bin) {163varstr = "";164varmask = (1 << chrsz) - 1;165for(vari = 0; i < bin.length * 32; i +=chrsz) {166str += String.fromCharCode((bin[i >> 5] >>> (i % 32)) &mask)167}168returnstr169}170functionbinl2hex(binarray) {171varhex_tab = hexcase ? "0123456789ABCDEF": "0123456789abcdef";172varstr = "";173for(vari = 0; i < binarray.length * 4; i++) {174str += hex_tab.charAt((binarray[i >> 2] >> ((i % 4) * 8 + 4)) & 15) + hex_tab.charAt((binarray[i >> 2] >> ((i % 4) * 8)) & 15)175}176returnstr177}178functionbinl2b64(binarray) {179vartab = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";180varstr = "";181for(vari = 0; i < binarray.length * 4; i += 3) {182vartriplet = (((binarray[i >> 2] >> 8 * (i % 4)) & 255) << 16) | (((binarray[i + 1 >> 2] >> 8 * ((i + 1) % 4)) & 255) << 8) | ((binarray[i + 2 >> 2] >> 8 * ((i + 2) % 4)) & 255);183for(varj = 0; j < 4; j++) {184if(i * 8 + j * 6 > binarray.length * 32) {185str +=b64pad186}else{187str += tab.charAt((triplet >> 6 * (3 - j)) & 63)188}189}190}191returnstr192}193functionhexchar2bin(str) {194vararr =[];195for(vari = 0; i < str.length; i = i + 2) {196arr.push("\\x" + str.substr(i, 2))197}198arr = arr.join("");199eval("var temp = '" + arr + "'");200returntemp201}202function__monitor(mid, probability) {203if(Math.random() > (probability || 1)) {204return205}206try{207varurl = location.protocol + "//ui.ptlogin2.qq.com/cgi-bin/report?id=" +mid;208vars = document.createElement("img");209s.src =url210}catch(e) {}211}212functiongetEncryption(password, salt, vcode, isMd5) {213vcode = vcode || "";214password = password || "";215varmd5Pwd = isMd5 ?password: md5(password),216h1 =hexchar2bin(md5Pwd),217s2 = md5(h1 +salt),218rsaH1 =$pt.RSA.rsa_encrypt(h1),219rsaH1Len = (rsaH1.length / 2).toString(16),220hexVcode = TEA.strToBytes(vcode.toUpperCase(),true),221vcodeLen = Number(hexVcode.length / 2).toString(16);222while(vcodeLen.length < 4) {223vcodeLen = "0" +vcodeLen224}225while(rsaH1Len.length < 4) {226rsaH1Len = "0" +rsaH1Len227}228TEA.initkey(s2);229varsaltPwd = TEA.enAsBase64(rsaH1Len + rsaH1 + TEA.strToBytes(salt) + vcodeLen +hexVcode);230TEA.initkey("");231//setTimeout(function() {232//__monitor(488358, 1)233//},234//0);235returnsaltPwd.replace(/[\/\+=]/g,236function(a) {237return{238"/": "-",239"+": "*",240"=": "_"241} [a]242})243}244functiongetRSAEncryption(password, vcode, isMd5) {245varstr1 = isMd5 ?password: md5(password);246varstr2 = str1 +vcode.toUpperCase();247varstr3 =$.RSA.rsa_encrypt(str2);248returnstr3249}250return{251getEncryption: getEncryption,252getRSAEncryption: getRSAEncryption,253md5: md5254}255} ();

View Code

 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
 
© 2005- 王朝網路 版權所有 導航