mirror of
https://github.com/5ime/Tiktok_Signature.git
synced 2025-12-17 16:34:56 +08:00
Add
This commit is contained in:
commit
8f3f906ae3
36
README.md
Normal file
36
README.md
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
# 🛡️TikTok_Signature
|
||||||
|
|
||||||
|
> TikTok_Signature 是一个方便快捷的工具,可以帮助你自动生成抖音 xbogus、mstoken 和 ttwid。
|
||||||
|
|
||||||
|
## 功能介绍
|
||||||
|
|
||||||
|
TikTok_Signature 工具提供如下功能:
|
||||||
|
|
||||||
|
- 生成 xbogus
|
||||||
|
- 生成 mstoken
|
||||||
|
- 生成 ttwid
|
||||||
|
|
||||||
|
## 快速开始
|
||||||
|
|
||||||
|
[](https://github.com/5ime/TikTok_Signature)
|
||||||
|
|
||||||
|
1. 点击上方按钮,跳转至 `Vercel` 进行部署。
|
||||||
|
|
||||||
|
2. 输入一个你喜欢的 `Vercel` 项目名称并点击 `Create` 继续:
|
||||||
|
|
||||||
|
3. 此时 `Vercel` 会基于 `TikTok_Signature` 模板帮助你新建并初始化仓库,仓库名为你之前输入的项目名。
|
||||||
|
|
||||||
|
一两分钟后,满屏的烟花会庆祝你部署成功。此时点击 `Go to Dashboard` 可以跳转到应用的控制台。
|
||||||
|
|
||||||
|
1. 点击 `Visit` ,即可跳转到部署好的网站地址,此地址即为你的接口地址。
|
||||||
|
|
||||||
|
## 注意事项
|
||||||
|
|
||||||
|
- 本工具仅供学习交流使用,请勿用于非法和商业用途;
|
||||||
|
- 本工具基于抖音加密算法实现,算法可能会随时更新,故本工具也可能无法正常使用;
|
||||||
|
|
||||||
|
## 参考项目
|
||||||
|
|
||||||
|
- https://github.com/HH7H/X-Bogus/
|
||||||
|
|
||||||
|
- https://github.com/B1gM8c/X-Bogus
|
||||||
69
index.js
Normal file
69
index.js
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
const axios = require('axios');
|
||||||
|
const crypto = require('crypto');
|
||||||
|
const express = require("express");
|
||||||
|
const { sign } = require("./Signer.js");
|
||||||
|
|
||||||
|
const app = express();
|
||||||
|
app.use(express.json());
|
||||||
|
|
||||||
|
app.post("/", async (req, res) => {
|
||||||
|
try {
|
||||||
|
const { url, userAgent } = req.body;
|
||||||
|
|
||||||
|
if (!url || !userAgent) {
|
||||||
|
throw new Error("Missing required parameters.");
|
||||||
|
}
|
||||||
|
|
||||||
|
const query = url.includes("?") ? url.split("?")[1] : "";
|
||||||
|
const xbogus = sign(query, userAgent);
|
||||||
|
const newUrl = `${url}&X-Bogus=${xbogus}`;
|
||||||
|
const [xbogusToken, ttwid] = await Promise.all([msToken(107), getTtwid()]);
|
||||||
|
|
||||||
|
res.status(200).json({
|
||||||
|
code: 200,
|
||||||
|
msg: "success",
|
||||||
|
data: {
|
||||||
|
xbogus: xbogus,
|
||||||
|
mstoken: xbogusToken,
|
||||||
|
ttwid: ttwid,
|
||||||
|
url: newUrl
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} catch (err) {
|
||||||
|
console.error(err);
|
||||||
|
res.status(400).json({ code: 201, msg: err.message });
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
function msToken(length) {
|
||||||
|
const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
|
||||||
|
const randomBytes = crypto.randomBytes(length);
|
||||||
|
return Array.from(randomBytes, byte => characters[byte % characters.length]).join('');
|
||||||
|
}
|
||||||
|
|
||||||
|
async function getTtwid() {
|
||||||
|
try {
|
||||||
|
const url = 'https://ttwid.bytedance.com/ttwid/union/register/';
|
||||||
|
const data = {
|
||||||
|
"region": "cn",
|
||||||
|
"aid": 1768,
|
||||||
|
"needFid": false,
|
||||||
|
"service": "www.ixigua.com",
|
||||||
|
"migrate_info": { "ticket": "", "source": "node" },
|
||||||
|
"cbUrlProtocol": "https",
|
||||||
|
"union": true
|
||||||
|
};
|
||||||
|
const response = await axios.post(url, data, { headers: { 'Content-Type': 'application/json' } });
|
||||||
|
const setCookie = response.headers['set-cookie'];
|
||||||
|
const regex = /ttwid=([^;]+)/;
|
||||||
|
const match = regex.exec(setCookie[0]);
|
||||||
|
return match && match.length > 1 ? match[1] : '';
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error);
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
app.listen(80, () => {
|
||||||
|
console.log("Server is running on port 80");
|
||||||
|
});
|
||||||
10
package.json
Normal file
10
package.json
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
{
|
||||||
|
"name": "tiktok_signature",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"description": "A tool for generating TikTok Signature.",
|
||||||
|
"main": "index.js",
|
||||||
|
"dependencies": {
|
||||||
|
"axios": "^1.3.4",
|
||||||
|
"express": "^4.18.1"
|
||||||
|
}
|
||||||
|
}
|
||||||
15
vercel.json
Normal file
15
vercel.json
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
{
|
||||||
|
"builds": [
|
||||||
|
{
|
||||||
|
"src": "index.js",
|
||||||
|
"use": "@vercel/node"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"routes": [
|
||||||
|
{
|
||||||
|
"src": "/(.*)",
|
||||||
|
"dest": "index.js"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
Loading…
x
Reference in New Issue
Block a user