一、输入账号密码,进行抓包
二、F12打开开发者工具,抓包分析,password被加密了
三、全局搜索password关键字,挨个分析,在箭头标记处找到了关键代码
四、局部搜索,定位加密的关键点,通过JSEncrypt,setPublicKey等关键字分析是RSA加密
五、代码编写
1、调用RSA加密的基本代码编写
function aiyou(pwd,pubkey) { var t = new JSEncrypt(); t.setPublicKey(pubkey); var i=t.encrypt(pwd) return i; }
2、定位encrypt函数,定位到该JS文件,直接把原代码拷贝过来。
3、获取公钥,将鼠标放到setPublicKey,就可以看到一长串字符串。
4、测试脚本
六、python调用该JS代码
1、JS代码
/*! JSEncrypt v2.3.1 | https://npmcdn.com/jsencrypt@2.3.1/LICENSE.txt */ navigator=this window=this !function(t, e) { "function" == typeof define && define.amd ? define(["exports"], e) : e("object" == typeof exports && "string" != typeof exports.nodeName ? module.exports : t) }(this, function(t) { function e(t, e, i) { null != t && ("number" == typeof t ? this.fromNumber(t, e, i) : null == e && "string" != typeof t ? this.fromString(t, 256) : this.fromString(t, e)) return this.key } , ze.prototype.getPrivateKey = function() { return this.getKey().getPrivateKey() } , ze.prototype.getPrivateKeyB64 = function() { return this.getKey().getPrivateBaseKeyB64() } , ze.prototype.getPublicKey = function() { return this.getKey().getPublicKey() } , ze.prototype.getPublicKeyB64 = function() { return this.getKey().getPublicBaseKeyB64() } , ze.version = "2.3.1", JSEncrypt = ze }); function aiyou(pwd,pubkey) { var t = new JSEncrypt(); t.setPublicKey(pubkey); var i=t.encrypt(pwd) return i; }
2、Python代码
import execjs node=execjs.get() fp=open('jiami.js','r',encoding='utf8') ctx=node.compile(fp.read()) pwd='123456' pubkey="MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCjfeE0MIYsZes/HwV06/kvRw34Hmhn9WPt0feLPp1PVqdqZz1/xFvPPEAJ/lAvfqt5kyn+A06bvYXIhizTjlOzPgLE4897ihuSYXgfwcUshPZvydRLbftU6Exj5SLbv5tw4GInbgQv7RWLWOKyQA81q6lWae2Kcgd1XpDRsQNXVwIDAQAB" jsres='aiyou("%s","%s")'%(pwd,pubkey) res=ctx.eval(jsres) print(res)
七、运行结果: