声明:
该文章为学习使用,严禁用于商业用途和非法用途,违者后果自负,由此产生的一切后果均与作者无关
JavaScript混淆是一种通过对JavaScript代码进行转换和修改,以增加代码的复杂性和难以理解性的技术。它旨在阻止未经授权的访问、修改或复制JavaScript代码,从而保护知识产权和源代码的安全性,官网:https://obfuscator.io/。下面是JavaScript混淆技术的一些常见方法和其优缺点:
1.变量和函数重命名:通过将变量和函数名称替换为无意义的字符或缩写,使代码难以理解。这种方法可以增加代码的复杂性,使阅读和理解代码的过程更加困难。然而,它并不能提供真正的安全性,因为通过逆向工程仍然可以还原出原始的变量和函数名称。
2.代码压缩和格式化:通过删除空格、换行符和注释等不必要的字符,以及对代码进行简化和优化,可以减小代码的体积并增加阅读的难度。这种方法可以使代码更难以理解和分析,但同样不能提供真正的安全性。
3.字符串和代码片段的加密:通过对字符串和代码片段进行加密,使其在运行时动态解密。这种方法可以增加代码的复杂性和安全性,因为攻击者很难直接获取到明文的字符串和代码。然而,这种方法也会增加代码的执行时间和内存开销。
4.控制流扁平化:通过改变代码的控制流程,使其变得更加复杂和难以理解。这可以通过插入大量的条件语句、循环和跳转语句来实现。这种方法可以有效地增加代码的复杂性,但同样会增加代码的执行时间和内存开销。
优点:
混淆前代码
function hi() {
console.log("Hello World!");
}
hi();
混淆后代码
var _0x3ed0 = ['1241023ikpdYM', 'Hello\x20World!', '291190xIUkft', '1251274vQVPdI', '124952hgHyOi', '1983KQSSIW', '247DipWFn', '7354VgseoG', '49680CQWPxl', '1ZTWTUo', '648lISKkF'];
function _0x4ed9(_0x475ec5, _0x372034) {
return _0x4ed9 = function (_0x3ed0df, _0x4ed9c4) {
_0x3ed0df = _0x3ed0df - 0x96;
var _0x5a22f3 = _0x3ed0[_0x3ed0df];
return _0x5a22f3;
}, _0x4ed9(_0x475ec5, _0x372034);
}
(function (_0xa942b4, _0x57410c) {
var _0x4e4980 = _0x4ed9;
while (!![]) {
try {
var _0x1e86fa = parseInt(_0x4e4980(0x9b)) + parseInt(_0x4e4980(0x9e)) + -parseInt(_0x4e4980(0x97)) + -parseInt(_0x4e4980(0x9c)) * -parseInt(_0x4e4980(0xa0)) + -parseInt(_0x4e4980(0x98)) * parseInt(_0x4e4980(0x9d)) + -parseInt(_0x4e4980(0x96)) + parseInt(_0x4e4980(0x99)) * parseInt(_0x4e4980(0x9a));
if (_0x1e86fa === _0x57410c) break;else _0xa942b4['push'](_0xa942b4['shift']());
} catch (_0x178fbf) {
_0xa942b4['push'](_0xa942b4['shift']());
}
}
})(_0x3ed0, 0xb3f61);
function hi() {
var _0x81b55a = _0x4ed9;
console['log'](_0x81b55a(0x9f));
}
hi();
function _0x28b2f0(_0x176d9e) {
let _0x294e40 = [-0x6f, 0x34, 0x5b, 0x41, -0x41, 0x74, 0x77, 0x6a, -0x79, -0x52, -0x5, 0x50, 0x33, 0x61, 0x44, -0x53, -0x70, -0x33, 0x17, -0x2e, -0x22, -0x72, -0x37, -0xb, -0x7f, 0x5a, 0x21, 0x16, -0x1f, 0x32, -0x11, 0x14, -0x2c, 0xf, -0x5e, -0x7b, 0x76, -0x17, -0x3d, 0x72, 0x47, -0x68, -0x7e, -0x75, -0x51, -0x36, -0x12, -0x6e, -0x4, -0x5f, -0x5b, 0x5e, -0x50, -0xe, 0x78, 0x69, 0x55, 0x68, -0x56, -0x6c, 0x43, 0x19, 0x65, 0x6c, 0x10, -0x69, 0x6f, -0xa, 0x75, -0x49, 0x4d, 0x59, -0x1d, -0x62, -0x44, 0x70, 0x6b, -0x1, 0x56, 0x79, 0x58, -0x65, -0x7c, 0x45, -0x1e, -0x8, -0x71, -0x4a, -0x76, 0x39, -0x19, 0xc, -0x73, -0x6a, 0x5f, 0x7f, 0x54, 0x7c, -0x66, -0x1c, 0x49, 0x2b, -0x3c, 0x1c, 0x2e, 0x73, 0x1e, 0x7a, -0x4b, 0x7d, -0x43, -0x4d, 0x3, -0x7, -0x35, -0xd, 0x35, 0x4e, -0x48, 0x1, 0xb, -0x47, -0x27, -0x4f, -0x3, 0x13, 0x29, 0x7e, -0x2b, -0x7d, -0x1b, 0x22, 0x3f, 0x8, 0x48, -0x23, -0x29, -0x3f, 0x3c, -0x18, 0x66, 0x2f, -0x77, -0x67, -0x16, 0x2d, 0x3b, 0x40, -0x60, 0x31, 0x53, -0x6b, -0x78, -0x39, -0x46, 0x0, -0x26, -0x54, -0x28, 0x18, 0xe, 0x30, 0x1d, 0x2c, -0x24, -0x2f, 0x38, -0x5c, 0x26, 0x25, 0x4, -0x32, 0x67, 0xa, -0x59, 0x37, 0x71, -0x1a, 0x6e, 0x36, 0x24, -0x14, -0x4e, -0xc, -0x74, 0x46, -0x25, 0x5, -0x3e, -0x4c, -0x30, -0x40, 0x4f, 0x64, 0x28, 0x6, -0x3a, -0x5a, -0x13, -0x9, 0x27, 0x5d, -0x63, 0x15, 0x7, 0x1a, -0x2, 0x1b, -0x2d, 0x51, 0x3a, -0x7a, 0x4c, -0x42, 0x2, 0x5c, -0x2a, 0x62, -0x10, 0x9, 0x3d, 0x3e, -0xf, 0x63, -0x15, 0x1f, -0x38, 0x57, 0x11, -0x34, -0x45, -0x21, -0x3b, -0x55, 0x42, 0x4a, 0x12, -0x5d, -0x80, -0x57, -0x20, 0x2a, 0x20, -0x58, 0x6d, 0x60, 0xd, -0x6, 0x4b, -0x64, -0x31, 0x23, -0x61, 0x52, -0x6d, 0x7b]
, _0x5b0f2f = 0x0
, _0x2b75dc = 0x0
, _0x1d76cc = 0x0
, _0x340bcd = new Array();
for (let _0x52ad01 = 0x0; _0x52ad01 < _0x176d9e['length']; _0x52ad01++) {
_0x5b0f2f = _0x5b0f2f + 0x1 & 0xff,
_0x2b75dc = (0xff & _0x294e40[_0x5b0f2f]) + _0x2b75dc & 0xff;
const _0x37c2ef = _0x294e40[_0x5b0f2f];
_0x294e40[_0x5b0f2f] = _0x294e40[_0x2b75dc],
_0x294e40[_0x2b75dc] = _0x37c2ef,
_0x1d76cc = (0xff & _0x294e40[_0x5b0f2f]) + (0xff & _0x294e40[_0x2b75dc]) & 0xff,
_0x340bcd['push'](_0x176d9e[_0x52ad01] ^ _0x294e40[_0x1d76cc]);
}
return _0x340bcd;
}
function _0x22c377(_0xdf406f) {
let _0x33c5f2, _0x30793f, _0x3b6e7a = '';
for (var _0x3869e6 = 0x0; _0x3869e6 < _0xdf406f['length'];)
_0x33c5f2 = _0xdf406f[_0x3869e6],
_0x30793f = 0x0,
_0x33c5f2 >>> 0x7 === 0x0 ? (_0x3b6e7a += String['fromCharCode'](_0xdf406f[_0x3869e6]),
_0x3869e6 += 0x1) : 0xfc === (0xfc & _0x33c5f2) ? (_0x30793f = (0x3 & _0xdf406f[_0x3869e6]) << 0x1e,
_0x30793f |= (0x3f & _0xdf406f[_0x3869e6 + 0x1]) << 0x18,
_0x30793f |= (0x3f & _0xdf406f[_0x3869e6 + 0x2]) << 0x12,
_0x30793f |= (0x3f & _0xdf406f[_0x3869e6 + 0x3]) << 0xc,
_0x30793f |= (0x3f & _0xdf406f[_0x3869e6 + 0x4]) << 0x6,
_0x30793f |= 0x3f & _0xdf406f[_0x3869e6 + 0x5],
_0x3b6e7a += String['fromCharCode'](_0x30793f),
_0x3869e6 += 0x6) : 0xf8 === (0xf8 & _0x33c5f2) ? (_0x30793f = (0x7 & _0xdf406f[_0x3869e6]) << 0x18,
_0x30793f |= (0x3f & _0xdf406f[_0x3869e6 + 0x1]) << 0x12,
_0x30793f |= (0x3f & _0xdf406f[_0x3869e6 + 0x2]) << 0xc,
_0x30793f |= (0x3f & _0xdf406f[_0x3869e6 + 0x3]) << 0x6,
_0x30793f |= 0x3f & _0xdf406f[_0x3869e6 + 0x4],
_0x3b6e7a += String['fromCharCode'](_0x30793f),
_0x3869e6 += 0x5) : 0xf0 === (0xf0 & _0x33c5f2) ? (_0x30793f = (0xf & _0xdf406f[_0x3869e6]) << 0x12,
_0x30793f |= (0x3f & _0xdf406f[_0x3869e6 + 0x1]) << 0xc,
_0x30793f |= (0x3f & _0xdf406f[_0x3869e6 + 0x2]) << 0x6,
_0x30793f |= 0x3f & _0xdf406f[_0x3869e6 + 0x3],
_0x3b6e7a += String['fromCharCode'](_0x30793f),
_0x3869e6 += 0x4) : 0xe0 === (0xe0 & _0x33c5f2) ? (_0x30793f = (0x1f & _0xdf406f[_0x3869e6]) << 0xc,
_0x30793f |= (0x3f & _0xdf406f[_0x3869e6 + 0x1]) << 0x6,
_0x30793f |= 0x3f & _0xdf406f[_0x3869e6 + 0x2],
_0x3b6e7a += String['fromCharCode'](_0x30793f),
_0x3869e6 += 0x3) : 0xc0 === (0xc0 & _0x33c5f2) ? (_0x30793f = (0x3f & _0xdf406f[_0x3869e6]) << 0x6,
_0x30793f |= 0x3f & _0xdf406f[_0x3869e6 + 0x1],
_0x3b6e7a += String['fromCharCode'](_0x30793f),
_0x3869e6 += 0x2) : (_0x3b6e7a += String['fromCharCode'](_0xdf406f[_0x3869e6]),
_0x3869e6 += 0x1);
return _0x3b6e7a;
}
function _0x4c226c(_0x11f51e) {
const _0xb67436 = atob(_0x11f51e)
, _0x38c085 = new Int8Array(_0xb67436['length']);
for (let _0x32e9bf = 0x0; _0x32e9bf < _0xb67436['length']; _0x32e9bf++)
_0x38c085[_0x32e9bf] = _0xb67436['charCodeAt'](_0x32e9bf);
return _0x38c085;
}
function _0x18ae1d(_0x5c4d0e) {
return JSON.parse(_0x22c377(_0x28b2f0(_0x4c226c(_0x5c4d0e))));
}
// const _0x5c4d0e = 'ak+9VCsq4dEdB+UdVfGo8kh5JDEbMHGTCmF/AyXJQ0IgHk+nVAivRFLre97uhVPP2wTUOBnZbv5IuV3YW+bwj9+zZH1PAv9Or2kY0RpnIZr4lt+bG1j6Eh/bWp9BcjXF3RMjC0vP2kFG5fHQKseyMdL+FT/KupHyRVatagYMiuxNP3d+nDairLInNhH7UX9BGrgs1gN6hZgJ0vuBLeHPQ4WPcc6hZmE5dO4FmTeUoRye+iq1IXGqQRLD7mFdlfQPomT5BlSK28AoibAgjaoF6HbNf3oz7UDw9WxFzatw98cEpoLETFx74ZxgiCrYe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Ybd9H8puvzmj2y4XS4e6TV6if/cgUIHxBmCjH4gTBn0tpxxGlpZ0Q2YKV0QJSHrvH/faeme0Z9OadQkBhk00AAyXT/YtA8Su8+tW1UltdqltFzRKNZ6qWcVnZqxOBVzdZsEFUwVDMtR0Cc9CQljGJyfnF3ZIaNLAFI5I2nGte35JUtFJ34touAJKQ+ISc2mB6JwPutvpLXV8iP2D0mhT+b8kWwlLbePFPoQPgBH09v5TPbjdLgKl7tG5bAS146yQ8NFxSkTHzgX6LEuGORNWGCDU08MXyj6XbSLA7rlIPcgvlH2xF9oJPnk15EOWSnHkxW4753203Efkrstb8/CcZvTprfN2wRW4A+DGVM27snYnbV8XmL1pEQ8SUqjc1QdgRvphtmAKy73cJYcy0goptmiauEnU4dhaMInMgDPmrY44dtSnseUk5dc5/GF0Ilhn1OH6okohciYUmz1X+KMQen/QlfRQUM1Fi3f0h8LDPOk2KR/ZXbgOEGgXTOO5cUoOqeLjhklmucJHRS+2Dd5CEoi1ueBjqzfgzj8KE8mGrdfqm7KapQ6ea1P8s7tmFHO8RUYVYRSvzM1YYozQbBaP9Qbd6nDvgzBBmkyLmqLtY4PWK7wkbfn+OY9GGue8WexeWI5WQhHjAflzfSJFjVJWU/KlLmNs5mffl+YmzaZUf3mhLOnu/hOM37ENYE8VxT92iLiDBBz/VXE0fAIo17Z7yuf9na0vJYlq71z6SwAJoBormCVhAJ7k4CrUNtU6k2G/xofL5slSTt7hasGil03Cv5OYDclGq0gBcUwFvAajQbUK';
//
// console.log(_0x18ae1d(_0x5c4d0e))
import requests
import execjs
headers = {
"authority": "api.zzzmh.cn",
"accept": "application/json, text/plain, */*",
"accept-language": "zh-CN,zh;q=0.9",
"cache-control": "no-cache",
"content-type": "application/json;charset=UTF-8",
"origin": "https://bz.zzzmh.cn",
"pragma": "no-cache",
"referer": "https://bz.zzzmh.cn/",
"sec-ch-ua": "\"Google Chrome\";v=\"119\", \"Chromium\";v=\"119\", \"Not?A_Brand\";v=\"24\"",
"sec-ch-ua-mobile": "?0",
"sec-ch-ua-platform": "\"Windows\"",
"sec-fetch-dest": "empty",
"sec-fetch-mode": "cors",
"sec-fetch-site": "same-site",
"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36"
}
url = "https://api.zzzmh.cn/bz/v3/getData"
data = {
"size": 24,
"current": 2,
"sort": 0,
"category": 0,
"resolution": 0,
"color": 0,
"categoryId": 0,
"ratio": 0
}
with open('jijian.js','r') as js_file:
js = execjs.compile(js_file.read())
request_session = requests.session()
request_session.headers.update(headers)
response = request_session.post(url, json=data)
response_data = response.json()
response_data['result'] = js.call('_0x18ae1d',response_data['result'])
first_img_info = response_data['result']['list'][0]
response = requests.get(f'https://api.zzzmh.cn/bz/v3/getUrl/{first_img_info["i"]}21',allow_redirects=False)
print(response.headers['Location'])
with open('极简壁纸.jpg', 'wb') as f:
response = request_session.get(response.headers['Location'])
f.write(response.content)