里面的方法,同样的,直接将整个 jsbn.js 文件剥离下来进行本地调试。 这里其实在 rsa.js 文件的第一行有一句注释:// Depends on jsbn.js and rng.js,我们可以猜测 rsa.js 是可能依赖 jsbn.js 和 rng.js 这两个文件的 [06.png] [07.png] 有了 jsbn.js 的代码,再次进行调试,会发现又提示 navigator 和 SecureRandom 未定义,navigator 我们已经非常熟悉了,是浏览器的相关信息 这里就证实了前面我们的猜想,rsa.js 确实是依赖 jsbn.js 和 rng.js 的。 [08.png] [09.png] rsa.js、jsbn.js、rng.js 都齐全了,再次本地调试,会发现 rng.js 里面的 rng_psize 未定义,鼠标放上去看到 rng_psize 就是一个定值
tweetnacl@0.14.5 deduped │ │ ├─┬ dashdash@1.14.1 │ │ │ └── assert-plus@1.0.0 deduped │ │ ├─┬ ecc-jsbn @0.1.2 │ │ │ ├── jsbn@0.1.1 deduped │ │ │ └── safer-buffer@2.1.2 deduped │ │ ├─┬ getpass@0.1.7 │ │ │ └── assert-plus@1.0.0 deduped │ │ ├── jsbn@0.1.1 │ │ ├── safer-buffer@2.1.2 │ │ └── tweetnacl 0.4.19 deduped ├─┬ socks5-http-client@1.0.4 │ └─┬ socks5-client@1.2.8 │ └─┬ ip-address@6.1.0 │ ├── jsbn
tweetnacl@0.14.5 deduped │ │ ├─┬ dashdash@1.14.1 │ │ │ └── assert-plus@1.0.0 deduped │ │ ├─┬ ecc-jsbn @0.1.2 │ │ │ ├── jsbn@0.1.1 deduped │ │ │ └── safer-buffer@2.1.2 deduped │ │ ├─┬ getpass@0.1.7 │ │ │ └── assert-plus@1.0.0 deduped │ │ ├── jsbn@0.1.1 │ │ ├── safer-buffer@2.1.2 │ │ └── tweetnacl 0.4.19 deduped ├─┬ socks5-http-client@1.0.4 │ └─┬ socks5-client@1.2.8 │ └─┬ ip-address@6.1.0 │ ├── jsbn
concat-map config-chain core-util-is cryptiles dashdash debuglog delayed-stream dezalgo ecc-jsbn http-signature iferr imurmurhash inflight inherits ini init-package-json isarray jodid25519 jsbn
链接:https://pan.baidu.com/s/1XpP60ntiLZKw6jsBN7wO5A 密码:tw28 8、打开软件,会弹出一个界面,如下图所示。
getPublicKey 和 encrypt 方法: [07.png] [08.png] [09.png] 将整个 rsa.js 复制下来进行本地调试,会提示 BigInteger 未定义,鼠标放上去会看到是用到了 jsbn.js 里面的方法,如果一个一个函数去扣的话会比较麻烦,直接将整个 jsbn.js 文件代码复制下来即可: [10.png] [11.png] 完整代码 GitHub 关注 K 哥爬虫,持续分享爬虫相关代码!
QQ登录注册之前使用的RSA加密算法就是参考http://www-cs-students.stanford.edu/~tjw/jsbn/的实现。
我们将整个声明模块下的内容全部复制到一个文件里面,如下: 将定义部分删除,将剩下的函数改为自执行函数: 然后将分发器导出到全局,如图: 执行一下我们导出的部分,输出如下:(部分用户可能会提示缺少模块 jsbn
│ │ ├── asn1@0.2.4 │ │ ├── bcrypt-pbkdf@1.0.2 │ │ ├── dashdash@1.14.1 │ │ ├── ecc-jsbn @0.1.2 │ │ ├── getpass@0.1.7 │ │ ├── jsbn@0.1.1 │ │ ├── safer-buffer@2.1.2 │ │ └─
─ dot-prop@4.2.0 ├─ dotenv-expand@5.1.0 ├─ dotenv@8.2.0 ├─ duplexer@0.1.1 ├─ duplexify@3.7.1 ├─ ecc-jsbn
/registry.yarnpkg.com/duplexer3/-/duplexer3-0.1.4.tgz#ee01dd1cac0ed3cbc7fdbea37dc0a8f1ce002ce2” ecc-jsbn @~0.1.1: version “0.1.1” resolved “https://registry.yarnpkg.com/ecc-jsbn/-/ecc-jsbn-0.1.1.tgz#0fc73a9ed5f0d53c38193398523ef7e543777505 ” dependencies: jsbn “~0.1.0” editions@^1.3.3: version “1.3.4” resolved “https://registry.yarnpkg.com @~0.1.0: version “0.1.1” resolved “https://registry.yarnpkg.com/jsbn/-/jsbn-0.1.1.tgz#a5e654c2e5a2deb5f201d96cefbca80c0ef2f513 assert-plus “^1.0.0” dashdash “^1.12.0” getpass “^0.1.1” optionalDependencies: bcrypt-pbkdf “^1.0.0” ecc-jsbn