问题描述:
如题,需要在 java 代码中执行 js, 使用的是 java8 自带引擎;
ScriptEngine engine = new ScriptEngineManager().getEngineByName("nashorn");
解析如下 js 代码时,发现结果 与 浏览器执行结果不一致;
js:
function DeCode() {
this.OO0O00OO00OO = function (a, b) {
return b > 0 ? a.substring(0, b) : null;
}, this.OO00OO0O00O0 = function (a, b) {
return a.length - b >= 0 && a.length >= 0 && a.length - b <= a.length ? a.substring(a.length - b, a.length) : null;
}, this.O0000OO0OO00O0 = function (a, b) {
var c, d, e, f, g, h, i, j, k = "";
for (c = 0; c < b.length; c++) {
k += b.charCodeAt(c).toString();
}
for (d = Math.floor(k.length / 5), e = parseInt(k.charAt(d) + k.charAt(2 * d) + k.charAt(3 * d) + k.charAt(4 * d) + k.charAt(5 * d)),
f = Math.round(b.length / 2), g = Math.pow(2, 31) - 1, h = parseInt(a.substring(a.length - 8, a.length), 16),
a = a.substring(0, a.length - 8), k += h; k.length > 10; ) {
k = (parseInt(k.substring(0, 10)) + parseInt(k.substring(10, k.length))).toString();
}
for (k = (e * k + f) % g, i = "", j = "", c = 0; c < a.length; c += 2) {
i = parseInt(parseInt(a.substring(c, c + 2), 16) ^ Math.floor(255 * (k / g))), j += String.fromCharCode(i),
k = (e * k + f) % g;
}
return j;
}, this.O0O000O0OO00O = function () {
var Fr16='1',oR22="5",GpK3680="96",ty39=6,FjJ3478=77,rU45=8,am59=7,bIr3352=130,Wt66=7,ku79='2',NiS3836='122',Lp83=2,Mp99=0,xMd3776=106,Kc107=0,Fdj3667=147,bv115='9',Ukn3997='64',ot123='5',uh139="5",kXD3476="140",sK144="0",Pnb3478="108",uk159=0,gI166="2",zo173="4",XBO3357="135",Fn182='4',GdP3884='65',Ui199='4',oKZ3848='145',JM207="7",scf4095="61",LW211="0",jtF3702="104",Gw222='1',hx236="1",ifa3439="129",sA243='5',PNC3566='77',oW253=5,Ski3789=132,NT263=4,ts275='4',eu281='4',aC298="8",gBA3768="157",bg300=3,yfv3434=147,uD314='5',nP328=2,og332=4,XDw4057=77,Kd348=1,fN350=3,bP367=3,CE372="6",lWB3947="142",Yv380=1,II391=1,kwe3433=140,am409="6",wCb3513="140",yN411="6",elB4337="136",pL420="0",GYM4366="113",sG436="3",UML3449="99",eJ441='1',FvN3976='82',zC459=5,ESz4065=68,Hk467=2,DWE3854=123,yX471=6,mM485="5",DQn4385="48",pB495=7,Qo501=1,aPM4367=145,rg512=3,PA520=3,cX534="1",sT544='8',xYB3927='87',Fr556='4',drE3834='150',io563="2",Qz575=6,kb584='1',ge592=6,FC601='1',oK615="5",bM625="4",Hj637='6',nNu3682='105',aQ645="9",zL657=4,jKC4635=55,rb661="9",Ydl4455="100",AO671="1",Uy686='4',Qyk3917='95',kO697=0,ZDs4096=98,Cj705=8,RZ718='6',BmR4504='149',iS720=9,nCH3861=143,Js732='9',sx743="6",po758="7",lTU3860="131",qL765=0,Lj771='0',gW789="4",Ch799='9',GGv4068='117',Jc802=0,JL816="5",Lj821=3,SaO4189=146,dw830='5',Fb843=8,bdS4826=54,MB855="4",IT865=6,aFy4057=98,eZ878=7,myS4802=51,dX884='0',XF892="7",Zx906=6,bM912='9',OAq4585='157',YW925="7",lbT4213="51",rW936="9",Rt948='5',XO959='0',WOM4818='56',mg967="5",Skg4870="80",Lz977='8',Na986='9',DM999=0,np1002=7,MBM5004=114,YG1012="8",Oy1025='9',Uc1035='2',OQn4400='50',go1042="3",IT1054="8",yM1068='6',BR1078="5",Ze1081="4",mJ1096="6",Eb1108='2',Jt1114=3,hMQ4286=78,Dp1124=4,xVm4853=71,pQ1134=0,KD1143=9,Ye1155="5",Ct1161="7",AO1173=4,dh1188=1,ZzC4655=96,jY1198="7",hu1201="2",JWS4301="94",on1219='6',St1227=0,VNa4951=86,MJ1236=7,Ock4735=139,TE1242=7,Qx1259=2,LM1268='2',JH1274='3',Gpv5224='73',MH1288='1',bUp4607='112',La1296='3',fuv4898='68',dg1307='6',WIM5020='91',NL1312='0',Inu4474='138',Pe1328='6',Pnn4588='86',IU1337="2",bsv4388="117",uq1347="7",KWr4474="115",Nh1359=9,os1364="3",lb1371='6',pXn4682='110',GW1382="5",cnO4731="65",Yi1396='9',xPM5046='75',UE1407="1",gc1411='7',BEc5211='99',kB1425="7",pwF4712="114",GZ1438="3",aZ1444=2,oQt4897=89,If1455=1,Tp1469="4",SE1479=8,Zm1488="4",iR1493='6',jL1504='5',Ng1516='9',bvK5034='103',un1522='1',PP1536="7",yc1542=4,SmN4951=129,Eo1556="2",Ow1560="5",jw1574='6',Fl1580='0',wtY5060='150',Zh1595=4,usM5017=155,fm1606="1",Ljl5216="125",On1612='4',KCl4900='152',HZ1621=6,OH1630="6",lc1640="5",Rf1656='8',wDR5013='157',HU1660="8",xjA5414="77",ts1674='6',usD5652='108',oL1688='6',PzE5462='107',EL1691="0",JYZ5687="66",Nb1707=4,Tz1719='7',Lpk5217='91',jp1728='3',DSy4865='69',rN1738='5',nA1741='4',xu1754=4,OIj5070=157,Ld1765="7",Okp4819="106",UF1777='0',Gl1783='4',loZ4796='74',WE1799="2",wGw5122="108",Pf1800='1',Tr1819=4,sv1820="6",iCX5169="131",wC1836="7",Sd1844='1',uet5464='105',oN1854="5",kEA5709="144",nx1862="2",ZBU5335="91",Ds1871='1',up1883='4',An1896='8',bL1900=0,ong4933=63,pj1915=2,Sr1921="3",yZG5203="86",Ze1934="8",JT1940=6,yo1954='0',MG1965=2,gvy5271=71,dC1974=3,uzx5497=98,Xh1981='8',sZ1994='2',RgI5193='112',CI2003=5,uQK5750=123,tB2010="2",gX2026="2",AJ2030=5,qQL5704=63,ak2046=1,gml5125=147,uL2052="3",by2069=9,XqT5288=62,ZC2070=6,hj2088='2',dA2096=9,PTd5586=53,NQ2101=0,Ln2118='4',VG2127='1',dCA5707='98',mO2131='4',NoM5536='86',VU2140="1",eH2154=0,qlp5477=151,hN2161='0',bK2173='6',kOK6039='86',sa2189="2",HR2198=0,MDz5450=147,Jd2206=3,kJU6207=84,DU2211=4,BM2222="7",GyM5537="108",Sh2230=4,oH2248=4,Tx2256='6',CB2264=6,RWg6077=151,Xh2279=6,JST6085=136,rS2285=0,ms2291="6",TjI5465="89",Yg2300=1,ib2311=2,CZ2322='3',EUV5442='76',ME2335=8,UWc6266=86,WX2343="8",xyg5504="126",KD2357='4',dKO5546='121',gd2364="0",EEV5999="59",Yt2371="2",DvW5402="152",FE2381=2,oYI5443=59,RR2390='5',cUG6358='81',pA2409='0',PMV5828='128',YI2416="2",WWz6063="118",Uk2421='3',eAL6424='136',RH2432=7,rL2446=6,VgA5841=122,HO2457="6",zK2461=7,cqz6223=81,jM2477='8',zc2485="8",WA2491='9',EkV5537='112',ZF2509=5,sH2519=7,yv2521=6,dTy5937=89,ih2534='1',Wmn5584='120',gD2546="7",RI2552="0",jU2563=3,efq6456=141,z3135=55,PERd7143=126,g3140='102',P3157='59',J3167='63',WkvQ7584='145',o3178='57',AdaR7773='58',l3187='61',P3193=103,d3207='51',iFTy7913='95',H3219=98,c3224=53,e3238='108',W3244='102',RPpn7845='99',A3250="57",R3265='53',a3273='98',S3286=102,njRS8387=71,m3292='53',r3307=105,MqIm8572=158,l3318='56',indI8412='75',h3320='62',U3332="102",sQAQ7939="76",G3344="51",pJNN7304="101",S3355=99,ajUv7145=122,n3364=57,e3379="106",nrMl7790="124",J3389='54',CiRH8069='49',v3396="56",JasJ8653="48",a3404=106,ZbWf8238=66,B3418='65',SwNH7459='64',U3428='54',M3438="58",K3445='103',E3455="52",W3464=50,yCdg7970=114,K3474=104,D3488='60',wFgb7210='52',q3493="59",k3508="101",ZOPu8544="91",Q3514="52",cGFC8613="61",I3525=106,I3532="106",hYfB8436="83",b3547=101,C3557=105,K3563=98,OyJR7408=61,F3573='58',Y3587=104,c3591="104",ncNH8662="63",a3600='59',MtzY7989='127',A3616=106,D3620='50',xnVc7751='110',v3630="60",S3645=56,fEPu8357=126,H3652='100',QKYx8911='135',t3664=65,LGsG8681=109,o3671="52",PKij7748="83",P3688="51",Wqwz8096="75",e3696=108,I3706='99',t3717=58,X3728='49',W3735="54",C3745=54,tPPN7147=158,S3757='62',YSLv8113='81',h3768='111',KCHa7157='112',B3774=57,j3786="63",f3793='50',GfxC8745='63',i3809='59',OFcE7587='71',O3817="102",U3827='64',GAKB9147='135',J3839='56',Z3843="63",q3855=106,HZdq9041=104,U3862=107,N3870='109',hBni8214='119',U3885='51',m3893=54,VTTw7820=66,x3903='60',cJuU9152='139',u3911='107',u3924="97",j3932="103",f3945='104',KJez7524='63',b3956="62",sCXE7609="143",C3962=110,l3974='59',k3984="107",w3991=61,z4003=98,lcuF7383=65,k4018=104,N4029=61,ZJUL7676=135,y4039="107",O4044='57',bXsU7706='153',X4056=107,H4069='57',B4072="100",kOte9137="48",r4086="59",Fecn8468="68",O4096="57",bfeZ8484="61",J4101='66',ZLlq8316='139',D4114=51,SRQl8462=89,f4128="61",L4132="64",pyzB9078="81",X4146="106",GWKH9418="152",e4159="104",uFtX9238="126",c4165=105,z4171=108,Swkb8342=145,Q4184='62',P4199='62',J4203=58,L4213='58',S4227=58,R4234='55',aCDY7905='50',t4244=56,x4258="50",i4268=107,JNUf9351=56,R4273=107,AqZx8855=120,c4284=61,EYVu8552=111,e4293='102',eFQN7832='99',Q4301='100',vEio8761='67',t4315=58,g4320='101',mqJB9657='140',a4339=104,p4343=102,n4357="56",i4366="55",t4378="102",b4385=56,bQba9489=64,B4394='102',ZgeY9711='129',X4408="101",s4415='103',A4423="58",c4431='98',f4449='56',z4454="101",kjar9603="124",h4464="59",B4470=61,OxTV9518=115,q4489=100,j4492="103",ADkR8560="145",x4508="62",piKh9492="61",f4510='60',Q4529=57,lLsI8872=132,e4532='63',a4540='56',OGlj8020='65',n4553='56',xaSq8193='158',h4561="100",hsYa9146="75",w4579="55",BAOn9744="108",J4586='53',QOfo9564='144',Q4593='65',SiqK8706='74',I4603=102,dVUX9585=101,q4610=62,v4621=56,W4635="57",V4649="98",W4658=59,Ltlx8233=52,J4661=102,w4675="56",BsHL8352="158",I4681=55,s4690='61',wsoJ9142='140',a4703=100,O4718="103",VCjH8300="149",o4728="55",Lbft8414="130",t4738="104",qzlN8936="65",U4748='106',EPrB10017='125',t4756=106,CZip10137=103,m4766="55",B4776=107,HHyU9382=106,u4782="106",H4791="55",k4800='59',YJBr8946='73',Z4811="99",v4825=52,m4839="104",f4841='52',F4850="59",FkUn9006="71",D4865='102',a4871="61",RFEB9831="142",w4888="59",w4892='97',MhfQ8803='100',r4904=56,fQzp9260=63,X4910='50',ljqM9083='54',U4922='101',rBUH8864='65',J4936="52",H4941="105",O4952=104,wKJA8520=96,c4961="56",QKlB9108="120",d4975="58",a4986=99,j4990="98",FEah10238="151",l5005="105",BKRz9997="68",O5018='58',k5022='48',C5034=54,q5042="58",EqaN10179="89",g5058=108,C5062='55',Nlqt8829='108',w5078=53,m5080=53,QRrN8503=135,t5099='101',m5103=107,g5114=100,q5123="103",OzCB9176="88",r5133="59",BVQw8790="74",n5141='51',r5158='106',W5167='55',kEkl10530='106',A5176=100,X5182=110,Cjyc10451=75,Q5190="55",q5202=50,W5211="61",B5224="56",f5231=57,YMvu9822=72,p5240="54",bkTw10561="48",r5254="58",O5263='53',ohlW9998='132',d5273="101",bwcG9973="121",h5284=98,A5294=59,qcXB8746=51,j5303=102,wNAm10679=139,P5317="53",c5327=54,rkpe9289=151,e5334='59',lGfb9389='99',g5346='63',COiX10147='113',o5358="53",pZQv10614="142";
var enkey=this.O(z3135,Fr16)+this.O(g3140,oR22)+this.O(P3157,ty39)+this.O(J3167,rU45)+this.O(o3178,am59)+this.O(l3187,Wt66)+this.O(P3193,ku79)+this.O(d3207,Lp83)+this.O(H3219,Mp99)+this.O(c3224,Kc107)+this.O(e3238,bv115)+this.O(W3244,ot123)+this.O(A3250,uh139)+this.O(R3265,sK144)+this.O(a3273,uk159)+this.O(S3286,gI166)+this.O(m3292,zo173)+this.O(r3307,Fn182)+this.O(l3318,Ui199)+this.O(h3320,JM207)+this.O(U3332,LW211)+this.O(G3344,Gw222)+this.O(S3355,hx236)+this.O(n3364,sA243)+this.O(e3379,oW253)+this.O(J3389,NT263)+this.O(v3396,ts275)+this.O(a3404,eu281)+this.O(B3418,aC298)+this.O(U3428,bg300)+this.O(M3438,uD314)+this.O(K3445,nP328)+this.O(E3455,og332)+this.O(W3464,Kd348)+this.O(K3474,fN350)+this.O(D3488,bP367)+this.O(q3493,CE372)+this.O(k3508,Yv380)+this.O(Q3514,II391)+this.O(I3525,am409)+this.O(I3532,yN411)+this.O(b3547,pL420)+this.O(C3557,sG436)+this.O(K3563,eJ441)+this.O(F3573,zC459)+this.O(Y3587,Hk467)+this.O(c3591,yX471)+this.O(a3600,mM485)+this.O(A3616,pB495)+this.O(D3620,Qo501)+this.O(v3630,rg512)+this.O(S3645,PA520)+this.O(H3652,cX534)+this.O(t3664,sT544)+this.O(o3671,Fr556)+this.O(P3688,io563)+this.O(e3696,Qz575)+this.O(I3706,kb584)+this.O(t3717,ge592)+this.O(X3728,FC601)+this.O(W3735,oK615)+this.O(C3745,bM625)+this.O(S3757,Hj637)+this.O(h3768,aQ645)+this.O(B3774,zL657)+this.O(j3786,rb661)+this.O(f3793,AO671)+this.O(i3809,Uy686)+this.O(O3817,kO697)+this.O(U3827,Cj705)+this.O(J3839,RZ718)+this.O(Z3843,iS720)+this.O(q3855,Js732)+this.O(U3862,sx743)+this.O(N3870,po758)+this.O(U3885,qL765)+this.O(m3893,Lj771)+this.O(x3903,gW789)+this.O(u3911,Ch799)+this.O(u3924,Jc802)+this.O(j3932,JL816)+this.O(f3945,Lj821)+this.O(b3956,dw830)+this.O(C3962,Fb843)+this.O(l3974,MB855)+this.O(k3984,IT865)+this.O(w3991,eZ878)+this.O(z4003,dX884)+this.O(k4018,XF892)+this.O(N4029,Zx906)+this.O(y4039,bM912)+this.O(O4044,YW925)+this.O(X4056,rW936)+this.O(H4069,Rt948)+this.O(B4072,XO959)+this.O(r4086,mg967)+this.O(O4096,Lz977)+this.O(J4101,Na986)+this.O(D4114,DM999)+this.O(f4128,np1002)+this.O(L4132,YG1012)+this.O(X4146,Oy1025)+this.O(e4159,Uc1035)+this.O(c4165,go1042)+this.O(z4171,IT1054)+this.O(Q4184,yM1068)+this.O(P4199,BR1078)+this.O(J4203,Ze1081)+this.O(L4213,mJ1096)+this.O(S4227,Eb1108)+this.O(R4234,Jt1114)+this.O(t4244,Dp1124)+this.O(x4258,pQ1134)+this.O(i4268,KD1143)+this.O(R4273,Ye1155)+this.O(c4284,Ct1161)+this.O(e4293,AO1173)+this.O(Q4301,dh1188)+this.O(t4315,jY1198)+this.O(g4320,hu1201)+this.O(a4339,on1219)+this.O(p4343,St1227)+this.O(n4357,MJ1236)+this.O(i4366,TE1242)+this.O(t4378,Qx1259)+this.O(b4385,LM1268)+this.O(B4394,JH1274)+this.O(X4408,MH1288)+this.O(s4415,La1296)+this.O(A4423,dg1307)+this.O(c4431,NL1312)+this.O(f4449,Pe1328)+this.O(z4454,IU1337)+this.O(h4464,uq1347)+this.O(B4470,Nh1359)+this.O(q4489,os1364)+this.O(j4492,lb1371)+this.O(x4508,GW1382)+this.O(f4510,Yi1396)+this.O(Q4529,UE1407)+this.O(e4532,gc1411)+this.O(a4540,kB1425)+this.O(n4553,GZ1438)+this.O(h4561,aZ1444)+this.O(w4579,If1455)+this.O(J4586,Tp1469)+this.O(Q4593,SE1479)+this.O(I4603,Zm1488)+this.O(q4610,iR1493)+this.O(v4621,jL1504)+this.O(W4635,Ng1516)+this.O(V4649,un1522)+this.O(W4658,PP1536)+this.O(J4661,yc1542)+this.O(w4675,Eo1556)+this.O(I4681,Ow1560)+this.O(s4690,jw1574)+this.O(a4703,Fl1580)+this.O(O4718,Zh1595)+this.O(o4728,fm1606)+this.O(t4738,On1612)+this.O(U4748,HZ1621)+this.O(t4756,OH1630)+this.O(m4766,lc1640)+this.O(B4776,Rf1656)+this.O(u4782,HU1660)+this.O(H4791,ts1674)+this.O(k4800,oL1688)+this.O(Z4811,EL1691)+this.O(v4825,Nb1707)+this.O(m4839,Tz1719)+this.O(f4841,jp1728)+this.O(F4850,rN1738)+this.O(D4865,nA1741)+this.O(a4871,xu1754)+this.O(w4888,Ld1765)+this.O(w4892,UF1777)+this.O(r4904,Gl1783)+this.O(X4910,WE1799)+this.O(U4922,Pf1800)+this.O(J4936,Tr1819)+this.O(H4941,sv1820)+this.O(O4952,wC1836)+this.O(c4961,Sd1844)+this.O(d4975,oN1854)+this.O(a4986,nx1862)+this.O(j4990,Ds1871)+this.O(l5005,up1883)+this.O(O5018,An1896)+this.O(k5022,bL1900)+this.O(C5034,pj1915)+this.O(q5042,Sr1921)+this.O(g5058,Ze1934)+this.O(C5062,JT1940)+this.O(w5078,yo1954)+this.O(m5080,MG1965)+this.O(t5099,dC1974)+this.O(m5103,Xh1981)+this.O(g5114,sZ1994)+this.O(q5123,CI2003)+this.O(r5133,tB2010)+this.O(n5141,gX2026)+this.O(r5158,AJ2030)+this.O(W5167,ak2046)+this.O(A5176,uL2052)+this.O(X5182,by2069)+this.O(Q5190,ZC2070)+this.O(q5202,hj2088)+this.O(W5211,dA2096)+this.O(B5224,NQ2101)+this.O(f5231,Ln2118)+this.O(p5240,VG2127)+this.O(r5254,mO2131)+this.O(O5263,VU2140)+this.O(d5273,eH2154)+this.O(h5284,hN2161)+this.O(A5294,bK2173)+this.O(j5303,sa2189)+this.O(P5317,HR2198)+this.O(c5327,Jd2206)+this.O(e5334,DU2211)+this.O(g5346,BM2222)+this.O(o5358,Sh2230);
return enkey;
}, this.O = function (a, b) {
return String.fromCharCode(parseInt(a) - parseInt(b));
}, this.O0000OO0OO00O = function (a, b, c) {
return a.length >= 0 ? a.substr(b, c) : null;
}, this.O0O000000O0O0 = function (a) {
return a.length;
}, this.O000O0OO0O0OO = function (a) {
b = this.O0O000O0OO00O();
var h, i, j, k, l, m, n, o, p, c = b, d = this.O0O000000O0O0(c), e = d, f = new Array(), g = new Array();
for (l = 1; d >= l; l++) {
f[l] = this.O0000OO0OO00O(c, l - 1, 1).charCodeAt(0), g[e] = f[l], e -= 1;
}
for (h = "", i = a, m = this.OO0O00OO00OO(i, 2), i = this.OO00OO0O00O0(i, this.O0O000000O0O0(i) - 2),
l = 0; l < this.O0O000000O0O0(i); l += 4) {
j = this.O0000OO0OO00O(i, l, 4), "" != j && (b = this.OO0O00OO00OO(j, 1), k = (parseInt(this.OO00OO0O00O0(j, 3)) - 100) / 3,
m == this.O0000OO0OO00O0("a9ab044c634a", "O0000OO0OO00O") ? (n = 2 * parseInt(b.charCodeAt(0)),
o = parseInt(f[k]), p = n - o, h += String.fromCharCode(p)) : (n = 2 * parseInt(b.charCodeAt(0)),
o = parseInt(g[k]), p = n - o, h += String.fromCharCode(p)));
}
return h;
};
}
function getUrl(){
var XCODE = new DeCode();
var file = XCODE.O000O0OO0O0OO('e0L1094112J121J12721393142M145015121574160J175518741903199N2145217N226G232K235c24742506253I2651268');
var playUrl = 'http://demo.xxx.com/media/' + file + '.mp4';
print('playUrl: ' + playUrl);
return playUrl;
};
getUrl();
1
zhantss 2018-05-13 03:08:35 +08:00
这个 decode 有意思
我猜大概是因为代码里面某一些弱类型在大部分引擎中按照这段代码的作者想法意愿执行 但是 Nashorn 把 js 转换为字节码形式执行时,这些弱类型转换出乎了意料,so 结果就不对了 你要不试试 J2V8? |
2
xqin 2018-05-13 10:20:55 +08:00
简单翻译了一下, Java 版的代码如下:
https://paste.ofcode.org/pH7sSe7GA33h8sX28DCAg3 |
3
unlimitedsola 2018-05-13 12:18:26 +08:00
楼上 6
|
4
flybird1971 OP @zhantss 谢谢,改用 J2V8,结果正常了
|
5
flybird1971 OP |