Skip to content

Commit

Permalink
跟进反反逆向策略
Browse files Browse the repository at this point in the history
  • Loading branch information
Vinlic committed Aug 6, 2024
1 parent eac327b commit 0699b20
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/api/controllers/chat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ async function acquireMetaToken(token: string, swapToken = false) {
timeout: 15000,
validateStatus: () => true,
});
const html = result.data;
let html = result.data;
if (
result.status != 200 ||
result.headers["content-type"].indexOf("text/html") == -1
Expand Down Expand Up @@ -82,8 +82,14 @@ async function acquireMetaToken(token: string, swapToken = false) {
match = scriptResult.data.match(regex);
if (!match)
throw new APIException(EX.API_REQUEST_FAILED, "script invalid");
const txLoginScriptResult = await axios.get('https://metaso.cn/txLogin.js');
if (txLoginScriptResult.status != 200 || txLoginScriptResult.headers["content-type"].indexOf("application/javascript") == -1)
throw new APIException(EX.API_REQUEST_FAILED, "script invalid");
const txLoginScript = txLoginScriptResult.data;
html += `<script>${txLoginScript}</script>`;
const dom = new JSDOM(html, {
url: "https://metaso.cn"
url: "https://metaso.cn",
runScripts: "dangerously"
});
metaToken = Function('window', `const {${Object.keys(dom.window).filter(v => v != 'window' && !v.includes('-')).join(',')}} = window;return ${match[0]}`)(dom.window)(metaToken);
}
Expand Down

0 comments on commit 0699b20

Please sign in to comment.