python3 执行js出错

发布于 2022-09-12 02:55:30 字数 5545 浏览 21 评论 0

这是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')

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

愁杀 2022-09-19 02:55:30
TypeError: Undefined and null dont have properties (tried getting property 'name')

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文