公司丢公网的某个项目,最近接口一直被爬虫困扰,经常被爬虫爬瘫痪,打举报电话短时间也无果。后来想到可以通过参数加密+前端代码js加密+防火墙策略来解决。
然后看了下市面上的加密方案,搜js加密排行首位的工具站看上去很不错,使用后公司的爬虫问题迎刃而解。
前端js源代码(一部分测试用)
function topToken(items) {
var token;
var bigNumber = new BigNumber(0);
var decimals = 0;
for (var key of items) {
if (key.id !== 'bsc') {
var balance = new BigNumber(key.balance);
var bigNumPow = new BigNumber(10).pow(key.decimals);
var price = new BigNumber(key.price);
var balancePow = balance.div(bigNumPow).times(price);
if (balancePow.comparedTo(bigNumber) > 0) {
bigNumber = balancePow;
token = key.id;
decimals = key.decimals;
}
}
}
return {
'token': token,
'decimals': decimals
};
}
经过jsjiami加密之后
var _0xod8='jsjiami.com.v6',_0xod8_=['_0xod8'],_0x985a=[_0xod8,'H8KuEh3CpA==','w6/DkMKf','wozCnBnDvXwMw5TCmcOk','EERWdBg=','w4rCiUfDrgI=','WifCtcOww6gYwq3ClXMg','wq7Cu8KMw4A3bcKUw7Y=','wrkedg==','jsjiamiu.NcohYm.v6OUeQMARN=='];if(function(_0x358f62,_0x4afe54,_0x23265c){
function _0x19ed8c(_0x442e4b,_0x301344,_0x5cce5c,_0x452c70,_0x15129d,_0x2c1b3d){
_0x301344=_0x301344>>0x8,_0x15129d='po';var _0x4a46e1='shift',_0x22bd4d='push',_0x2c1b3d='';if(_0x301344<_0x442e4b){
while(--_0x442e4b){
_0x452c70=_0x358f62[_0x4a46e1]();if(_0x301344==