发布时间:2024-02-25 17:00
我们在爬内容,抓取页面的时候,总会遇到sojson v5,jsjiami.com的v6加密。
jsjiami v6 : JS加密,JS不可逆加密,JS混淆,JS混淆加密,JS压缩加密 - [JavaScript加密]
我看了下这个js完全有效。废话不多说。直接上代码。
(function (js_body) {
// 脱壳 && 解密
let js_arr = js_body.split("\\n").pop().split(';'),
fun_name = /var\\s+(_0x[a-z0-9]+)=/.exec(js_arr[6])[1],
reg_str = fun_name + '\\\\(' + "'([^']+)',\\s*'([^']+)'" + '\\\\)',
js_str = js_arr.slice(54, js_arr.length - 4).join(';'),
code_shell = js_arr.slice(0, 34).join(';'),
shell_obj = eval("(function(){" + code_shell + ";return " + fun_name + "})()");
js_str = js_str.replace(new RegExp(reg_str, 'g'), function (str, id, key) {
return '"' + shell_obj(id, key) + '"';
}).replace(/([a-z0-9 \\-_A-Z)\\]]+)\\s?\\[["']([^"']+)[" ']\\]/g, '$1.$2').replace(/(?<!_)(0x[0-9 a-f]+)/g, function (hex) {
return parseInt(hex).toString();
});
// 完全还原混淆
let obj = null, name = '';
js_str = js_str.replace(/{(var\\s+(_0x[0-9a-z]+)=(\\{(.*)\\}));/g, function (str, code_str, _name, obj_str) {
obj = eval("(function () {return " + obj_str + "})()");
name = _name;
return '{';
});
if (obj) {
let i = 5;
while (js_str.indexOf(name) && --i > 0) {
for (const key in obj) {
if (!obj.hasOwnProperty(key)) continue;
if (typeof obj[key] == 'function') {
let fun_info = /function\\s*_0x[0-9a-z]+\\(([^)]*)\\){return\\s*([^;]+);}/.exec(obj[key].toString());
js_str = js_str.replace(new RegExp(name + '\\\\.' + key + '\\\\(([^())]*)\\\\)', 'g'), function (string, args_str) {
let args = args_str.split(','),
fun_args = fun_info[1].split(','),
fun_body = fun_info[2];
fun_args.forEach(function (item, index) {
fun_body = fun_body.replace(item, args[index]);
});
return fun_body;
});
} else if (typeof obj[key] == 'string') {
js_str = js_str.replace(name + '.' + key, '"' + obj[key] + '"');
} else {
js_str = js_str.replace(name + '.' + key, obj[key].toString());
}
}
}
}
//直接解密了
return js_str;
})($('#resultSource').val() || $('#jsdata').val());
解密之前的代码:
var a=['jsjiami.com.v6','ZjsgjilBUDamOPlriw.EVcomBp.lv6==','5p+76Zev6aOL6K2W6ICh57Czw59KXsO7woIUw6fCgMKLw5TCqg==','KFXCvcKCJFM=','IWQXKgw=','Gks8Kg==','w4h1w7oOag=='];(function(c,d,e){var f=function(g,h,i,j){h=h>>0x8;if(h<g){while(--g){j=c['shift']();if(h===g){h=j;i=c['shift']();}else if(i['replace'](/[ZglBUDOPlrwEVBpl=]/g,'')===h){c['push'](j);}}c['push'](c['shift']());}return 0x242ed;};return f(++d,e)>>d^e;}(a,0x1eb,0x1eb00));var b=function(c,d){c=~~'0x'['concat'](c);var e=a[c];if(b['gPvZlv']===undefined){(function(){var f=typeof window!=='undefined'?window:typeof process==='object'&&typeof require==='function'&&typeof global==='object'?global:this;var g='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';f['atob']||(f['atob']=function(h){var i=String(h)['replace'](/=+$/,'');for(var j=0x0,k,l,m=0x0,n='';l=i['charAt'](m++);~l&&(k=j%0x4?k*0x40+l:l,j++%0x4)?n+=String['fromCharCode'](0xff&k>>(-0x2*j&0x6)):0x0){l=g['indexOf'](l);}return n;});}());var o=function(p,d){var r=[],s=0x0,t,u='',v='';p=atob(p);for(var w=0x0,x=p['length'];w<x;w++){v+='%'+('00'+p['charCodeAt'](w)['toString'](0x10))['slice'](-0x2);}p=decodeURIComponent(v);for(var y=0x0;y<0x100;y++){r[y]=y;}for(y=0x0;y<0x100;y++){s=(s+r[y]+d['charCodeAt'](y%d['length']))%0x100;t=r[y];r[y]=r[s];r[s]=t;}y=0x0;s=0x0;for(var z=0x0;z<p['length'];z++){y=(y+0x1)%0x100;s=(s+r[y])%0x100;t=r[y];r[y]=r[s];r[s]=t;u+=String['fromCharCode'](p['charCodeAt'](z)^r[(r[y]+r[s])%0x100]);}return u;};b['fuFDUP']=o;b['uzmgkx']={};b['gPvZlv']=!![];}var A=b['uzmgkx'][c];if(A===undefined){if(b['GkZZBA']===undefined){b['GkZZBA']=!![];}e=b['fuFDUP'](e,d);b['uzmgkx'][c]=e;}else{e=A;}return e;};(function(c,d){var e={'RAMoq':'\\x32\\x30\\x31\\x39\\u5e74\\x30\\x39\\u6708\\x31\\x32\\u65e5\\x31\\x35\\x3a\\x32\\x34\\x3a\\x32\\x39\\u66f4\\u65b0','EaZaN':'\\u8fd9\\u4e2a\\u662f\\u4e00\\u4e2a\\u672c\\u7ad9\\u5bf9\\x4a\\x61\\x76\\x61\\x53\\x63\\x72\\x69\\x70\\x74 \\u811a\\u672c\\u7684\\u4e00\\u4e2a\\u6700\\u725b\\u52a0\\u5bc6\\uff0c\\u517c\\u5bb9\\u6027\\u9002\\u4e2d\\uff0c\\u89e3\\u5bc6\\u96be\\u5ea6\\u6781\\u5927'};c[b('0','ZdTU')]=e[b('1','FnxY')];d[b('2','FnxY')]=e[b('3','jPNw')];d['feedback']=b('4','fS%!');}(window,document));
解密之后:
var g_gotowxtime = 0;
var g_gotowxaction = 0;
var g_status = 0;
window.vis_st = 0;
window.vis_time = 0;
window.onload = function(){
showHiddenListen();
}
function showHiddenListen(){
document.addEventListener("visibilitychange",function(e){
if(document.hidden) {
if(Date.now()-g_gotowxtime<=4500&&g_gotowxaction!=0){
window.vis_st = 1;
window.vis_time = Date.now();
}
}
if (document.visibilityState === 'visible') {
if(window.vis_st==1)
{
var t_time = Date.now()-window.vis_time;
console.log(Date.now()-window.vis_time);
console.log(window.vis_st);
if(t_time>3000)
{
gdt('track', 'RESERVATION', {'key1': 'value1', 'key2': 'value2'});
}
window.vis_st==0;
window.vis_time = 0;
}
}
g_gotowxaction= 0;
g_gotowxtime= 0;
});
}
$(".wxcode").on('longTap',function(){
g_gotowxtime = Date.now();
g_gotowxaction = 1;
});
是不是干干净净,直接还原原来的代码
也可以用这个工具解密:JS解密-JS在线解密-JS脚本解密-JS格式化去注释-JS美化 - [JavaScript加密]