问答

python3 执行js出错

作者:admin 2021-08-04 我要评论

这是js代码 由于代码混淆了 要分析出来 /thread-354129-1-1.html?_dsign=3183fa78 这个链接 我用别的软件调试了js代码没问题 不知道为什么python执行了显示错误 ...

在说正事之前,我要推荐一个福利:你还在原价购买阿里云、腾讯云、华为云服务器吗?那太亏啦!来这里,新购、升级、续费都打折,能够为您省60%的钱呢!2核4G企业级云服务器低至69元/年,点击进去看看吧>>>)

这是js代码 由于代码混淆了 要分析出来/thread-354129-1-1.html?_dsign=3183fa78这个链接 我用别的软件调试了js代码没问题 不知道为什么python执行了显示错误

js代码:


var location = {
    href: function ($url) {
        console.log($url)
    },
    assign: function ($url) {
        console.log($url)
    },
    replace: function ($url) {
        console.log($url)
    }
}

function LNm() {
    'return LNm';
    return 'l?'
}
OgF = function(OgF_) {
    var _O = function(OgF_) {
        'return OgF';
        return OgF_;
    };
    return _O(OgF_);
};
_zn0Pw = location;
function WjWx(WjWx_) {
    function htm() {
        return getName();
    };
    return htm();
    return 'WjWx'
}
_WzyE0 = 'replace';
orq = function(orq_) {
    'return orq';
    return orq_;
};
uY = '3';
function D0() {
    'return D0';
    return '4'
}
function kJFm() {
    'kJFm';
    function _k() {
        return '129'
    };
    return _k();
}
r1 = '1';
Mf = function() {
    'Mf';
    var _M = function() {
        return '-'
    };
    return _M();
};
CP9P = function() {
    'CP9P';
    var _C = function() {
        return 'fa7'
    };
    return _C();
};
_oyQzX = 'href';
Ge = 'r';
cp = '/';
DP = function() {
    'DP';
    var _D = function() {
        return '-'
    };
    return _D();
};
function ju() {
    'ju';
    function _j() {
        return '1'
    };
    return _j();
}
function getName() {
    var caller = getName.caller;
    if (caller.name) {
        return caller.name
    }
    var str = caller.toString().replace(/[\s]*/g, "");
    var name = str.match(/^function([^\(]+?)\(/);
    if (name && name[1]) {
        return name[1];
    } else {
        return '';
    }
}
CL = function() {
    'CL';
    var _C = function() {
        return '-'
    };
    return _C();
};
_CzT4j = window;
_JPh6d = 'assign';
location[_WzyE0](cp + 'th' + Ge + 'ea' + (function() {
    'return ZI';
    return (function() {
        return 'd';
    })();
})() + DP() + orq('35') + D0() + kJFm() + CL() + ju() + Mf() + OgF('1.') + WjWx('jM9P') + LNm() + (function(dbo_) {
    return (function(dbo_) {
        return dbo_;
    })(dbo_);
})('_d') + (function() {
    'return fa';
    return (function() {
        return 's';
    })();
})() + (function() {
    'return B52h';
    return (function() {
        return 'ign';
    })();
})() + (function(CaH_) {
    'return CaH';
    return CaH_
})('=3') + r1 + (function() {
    'return mH';
    return (function() {
        return '8';
    })();
})() + uY + CP9P() + (function(mM6_) {
    return (function(mM6_) {
        return mM6_;
    })(mM6_);
})('8'));
_CzT4j['href'] = cp + 'th' + Ge + 'ea' + (function() {
    'return ZI';
    return (function() {
        return 'd';
    })();
})() + DP() + orq('35') + D0();

python3代码


import js2py
 
data=open('sjtest.js','r',encoding= 'utf8').read()
data=js2py.eval_js(data)

print(data)

python3执行后出错的内容:

Traceback (most recent call last):
  File "C:\Users\Xiaoma\Desktop\Source code\test.py", line 34, in <module>
    data=js2py.eval_js(data)
  File "D:\Program Files (x86)\Python37-32\lib\site-packages\js2py\evaljs.py", line 115, in eval_js
    return e.eval(js)
  File "D:\Program Files (x86)\Python37-32\lib\site-packages\js2py\evaljs.py", line 204, in eval
    self.execute(code, use_compilation_plan=use_compilation_plan)
  File "D:\Program Files (x86)\Python37-32\lib\site-packages\js2py\evaljs.py", line 199, in execute
    exec (compiled, self._context)
  File "<EvalJS snippet>", line 4, in <module>
  File "<EvalJS snippet>", line 3, in PyJs_LONG_0_
  File "D:\Program Files (x86)\Python37-32\lib\site-packages\js2py\base.py", line 949, in __call__
    return self.call(self.GlobalObject, args)
  File "D:\Program Files (x86)\Python37-32\lib\site-packages\js2py\base.py", line 1464, in call
    return Js(self.code(*args))
  File "D:\Program Files (x86)\Python37-32\lib\site-packages\js2py\host\jseval.py", line 45, in Eval
    executor(py_code)
  File "D:\Program Files (x86)\Python37-32\lib\site-packages\js2py\host\jseval.py", line 51, in executor
    exec (code, globals())
  File "<string>", line 267, in <module>
  File "<string>", line 241, in PyJs_LONG_20_
  File "D:\Program Files (x86)\Python37-32\lib\site-packages\js2py\base.py", line 949, in __call__
    return self.call(self.GlobalObject, args)
  File "D:\Program Files (x86)\Python37-32\lib\site-packages\js2py\base.py", line 1464, in call
    return Js(self.code(*args))
  File "<string>", line 23, in PyJsHoisted_WjWx_
  File "D:\Program Files (x86)\Python37-32\lib\site-packages\js2py\base.py", line 949, in __call__
    return self.call(self.GlobalObject, args)
  File "D:\Program Files (x86)\Python37-32\lib\site-packages\js2py\base.py", line 1464, in call
    return Js(self.code(*args))
  File "<string>", line 18, in PyJsHoisted_htm_
  File "D:\Program Files (x86)\Python37-32\lib\site-packages\js2py\base.py", line 949, in __call__
    return self.call(self.GlobalObject, args)
  File "D:\Program Files (x86)\Python37-32\lib\site-packages\js2py\base.py", line 1464, in call
    return Js(self.code(*args))
  File "<string>", line 74, in PyJsHoisted_getName_
  File "D:\Program Files (x86)\Python37-32\lib\site-packages\js2py\base.py", line 322, in get
    'Undefined and null dont have properties (tried getting property %s)' % repr(prop))
js2py.internals.simplex.JsException: TypeError: Undefined and null dont have properties (tried getting property 'name')
###
TypeError: Undefined and null dont have properties (tried getting property 'name')

这报错不是说得很清楚了吗???

版权声明:本文转载自网络,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。本站转载出于传播更多优秀技术知识之目的,如有侵权请联系QQ/微信:153890879删除

相关文章
  • python3 执行js出错

    python3 执行js出错

  • qt显示“static assertion failed: No

    qt显示“static assertion failed: No

  • js拖拽多个元素,选中多个元素后,水平

    js拖拽多个元素,选中多个元素后,水平

  • mysql中关于min与max的优化

    mysql中关于min与max的优化

腾讯云代理商
海外云服务器