前言
keyjoker是一个做任务换steam Key的网站,但是任务频率极低,很容易错过。
这逼着我写脚本执行任务 #(阴险) ,里面有个discord加组任务,在此记录用户凭证的获取过程。
开始啦
常规操作,打开邀请页面,打开开发者工具(F12),进入“网络”选项,勾选保留日志
点击“接受邀请”,可以看到浏览器发送了有个接受请求
打开postman将request head复制进去,然后开始排除验证信息
一番操作之后,可以发现其实只有一个authorization在起作用 #(太开心)
接下来就是把这个authorization 搞到手就行了,
这种一般在存储中直接就能找到。
果然,在本地存储中找到了
于是顺手写下localStorage.getItem('token'),但是尴尬的事情发生了:
啊这是被屏蔽了 #(流汗滑稽)
额,去搜索引擎上查了一下,找到了解决方案
Discord window.localStorage is undefined. How to get access to the localStorage on Discord page?
// If we create an <iframe> and connect it to our document, its
// contentWindow property will return a new Window object with
// a freshly created `localStorage` property. Once we obtain the
// property descriptor, we can disconnect the <iframe> and let it
// be collected — the getter function itself doesn’t depend on
// anything from its origin realm to work**.
function getLocalStoragePropertyDescriptor() {
const iframe = document.createElement('iframe');
document.head.append(iframe);
const pd = Object.getOwnPropertyDescriptor(iframe.contentWindow, 'localStorage');
iframe.remove();
return pd;
}
// We have several options for how to use the property descriptor
// once we have it. The simplest is to just redefine it:
Object.defineProperty(window, 'localStorage', getLocalStoragePropertyDescriptor());
window.localStorage.heeeeey; // yr old friend is bak
// You can also use any function application tool, like `bind` or `call`
// or `apply`. If you hold onto a reference to the object somehow, it
// won’t matter if the global property gets deleted again, either.
const localStorage = getLocalStoragePropertyDescriptor().get.call(window);
于是轻松的获取到了
啊这,难搞的说。
经过一番测试,在点击刷新按钮后token出现了,页面开始加载时,token又消失了。 #(黑线)
理论上时js的锅,于是我禁用了js,token就一直都在了
那就简单了,只要在discord的js加载之前执行localStorage.getItem('token')就行了啊,
简单粗暴把脚本执行时间设置为页面开始加载的时候
// @run-at document-start
测试脚本,一切OK #(滑稽)
![[记录]在油猴脚本中获取discord用户凭证 [记录]在油猴脚本中获取discord用户凭证](https://cdn.jysafe.cn/wp-content/uploads/2020/07/2020071310252832.png!water.jpg)
![[记录]在油猴脚本中获取discord用户凭证 [记录]在油猴脚本中获取discord用户凭证](https://cdn.jysafe.cn/wp-content/uploads/2020/07/2020071310313239.png!water.jpg)
![[记录]在油猴脚本中获取discord用户凭证 [记录]在油猴脚本中获取discord用户凭证](https://cdn.jysafe.cn/wp-content/uploads/2020/07/2020071310343363.png!water.jpg)
![[记录]在油猴脚本中获取discord用户凭证 [记录]在油猴脚本中获取discord用户凭证](https://cdn.jysafe.cn/wp-content/uploads/2020/07/2020071310371442.png!water.jpg)
![[记录]在油猴脚本中获取discord用户凭证 [记录]在油猴脚本中获取discord用户凭证](https://cdn.jysafe.cn/wp-content/uploads/2020/07/2020071310424139.png!water.jpg)
![[记录]在油猴脚本中获取discord用户凭证 [记录]在油猴脚本中获取discord用户凭证](https://cdn.jysafe.cn/wp-content/uploads/2020/07/2020071310563776.png!water.jpg)
![[记录]在油猴脚本中获取discord用户凭证 [记录]在油猴脚本中获取discord用户凭证](https://cdn.jysafe.cn/wp-content/uploads/2020/07/2020071311053258.png!water.jpg)
![[记录]在油猴脚本中获取discord用户凭证 [记录]在油猴脚本中获取discord用户凭证](https://cdn.jysafe.cn/wp-content/uploads/2020/07/2020071311082810.png!water.jpg)
![[记录]在油猴脚本中获取discord用户凭证 [记录]在油猴脚本中获取discord用户凭证](https://cdn.jysafe.cn/wp-content/uploads/2020/07/2020071311121534.png!water.jpg)

