Skip to content

Commit

Permalink
X-Bogus support
Browse files Browse the repository at this point in the history
  • Loading branch information
pablouser1 committed Aug 11, 2022
1 parent b614e0d commit 0e4e612
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 21 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,6 @@ If you plan to use the already deployed Vercel version, you should use https://s
```
node local.js 'YOUR_URL_HERE'
```

## Credits
* @H1W0XXX for providing a working X-Bogus script
8 changes: 8 additions & 0 deletions js/webmssdk.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "signtok",
"version": "1.1.3",
"version": "1.2.0",
"description": "Sign your TikTok requests easily",
"repository": "https://github.com/pablouser1/SignTok",
"author": "Pablo Ferreiro",
Expand Down
25 changes: 17 additions & 8 deletions src/Signer.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class Signer {

constructor(userAgent = Signer.DEFAULT_USERAGENT) {
const signature_js = fs.readFileSync(__dirname + "/../js/signature.js", "utf-8");
const webmssdk = fs.readFileSync(__dirname + "/../js/webmssdk.js", "utf-8");
const resourceLoader = new ResourceLoader({ userAgent });

const { window } = new JSDOM("", {
Expand All @@ -31,6 +32,7 @@ class Signer {
aid: 24,
dfp: true
});
this.window.eval(webmssdk);
}

navigator() {
Expand All @@ -48,25 +50,32 @@ class Signer {
return this.window.byted_acrawler.sign({ url });
}

bogus(params) {
return this.window._0x32d649(params);
}

xttparams(params) {
params += "&is_encryption=1";
// Encrypt query string using aes-128-cbc
const cipher = createCipheriv("aes-128-cbc", Signer.PASSWORD, Signer.PASSWORD);
return Buffer.concat([cipher.update(params), cipher.final()]).toString("base64");
}

sign(url) {
sign(url_str) {
const url = new URL(url_str);
const verifyFp = Utils.verify_fp();
url += "&verifyFp=" + verifyFp;
const signature = this.signature(url);
const signed_url = url + "&_signature=" + signature;
const params = new URL(url).searchParams.toString();
const xttparams = this.xttparams(params);
url.searchParams.append('verifyFp', verifyFp);
const signature = this.signature(url.toString());
url.searchParams.append('_signature', signature);
const bogus = this.bogus(url.searchParams.toString());
url.searchParams.append('X-Bogus', bogus);
const xttparams = this.xttparams(url.searchParams.toString());
return {
signature: signature,
verify_fp: verifyFp,
signed_url: signed_url,
"x-tt-params": xttparams
signed_url: url.toString(),
"x-tt-params": xttparams,
"X-Bogus": bogus
};
}
}
Expand Down
24 changes: 12 additions & 12 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ acorn@^7.1.1:
integrity sha512-nQyp0o1/mNdbTO1PO6kHkwSrmgZ0MT/jCCpNiwbUjGoRN4dlBhqJtoQuCnEOKzgTVwg0ZWiCoQy6SxMebQVh8A==

acorn@^8.5.0:
version "8.7.1"
resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.7.1.tgz#0197122c843d1bf6d0a5e83220a788f278f63c30"
integrity sha512-Xx54uLJQZ19lKygFXOWsscKUbsBZW0CPykPhVQdhIeIwrbPmJzqeASDInc8nKBnp/JT6igTs82qPXz069H8I/A==
version "8.8.0"
resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.8.0.tgz#88c0187620435c7f6015803f5539dae05a9dbea8"
integrity sha512-QOxyigPVrpZ2GXT+PFyZTl6TtOFc5egxHIP9IlQ+RbupQuX4RkT/Bee4/kQuC02Xkzg84JcT7oLYtDIQxp+v7w==

agent-base@6:
version "6.0.2"
Expand Down Expand Up @@ -435,9 +435,9 @@ minimatch@^3.1.1:
brace-expansion "^1.1.7"

minipass@^3.0.0:
version "3.3.3"
resolved "https://registry.yarnpkg.com/minipass/-/minipass-3.3.3.tgz#fd1f0e6c06449c10dadda72618b59c00f3d6378d"
integrity sha512-N0BOsdFAlNRfmwMhjAsLVWOk7Ljmeb39iqFlsV1At+jqRhSUP9yeof8FyJu4imaJiSUp8vQebWD/guZwGQC8iA==
version "3.3.4"
resolved "https://registry.yarnpkg.com/minipass/-/minipass-3.3.4.tgz#ca99f95dd77c43c7a76bf51e6d200025eee0ffae"
integrity sha512-I9WPbWHCGu8W+6k1ZiGpPu0GkoKBeorkfKNuAFBNS1HNFJvke82sxvI5bzcCNpWPorkOO5QQ+zomzzwRxejXiw==
dependencies:
yallist "^4.0.0"

Expand Down Expand Up @@ -533,9 +533,9 @@ prelude-ls@~1.1.2:
integrity sha512-ESF23V4SKG6lVSGZgYNpbsiaAkdab6ZgOxe52p7+Kid3W3u3bxR4Vfd/o21dmN7jSt0IwgZ4v5MUd26FEtXE9w==

psl@^1.1.33:
version "1.8.0"
resolved "https://registry.yarnpkg.com/psl/-/psl-1.8.0.tgz#9326f8bcfb013adcc005fdff056acce020e51c24"
integrity sha512-RIdOzyoavK+hA18OGGWDqUTsCLhtA7IcZ/6NCs4fFJaHBDab+pDDmDIByWFRQJq2Cd7r1OoQxBGKOaztq+hjIQ==
version "1.9.0"
resolved "https://registry.yarnpkg.com/psl/-/psl-1.9.0.tgz#d0df2a137f00794565fcaf3b2c00cd09f8d5a5a7"
integrity sha512-E/ZsdU4HLs/68gYzgGTkMicWTLPdAftJLfJFlLUAAKZGkStNU72sZjT66SnMDVOfOWY/YAoiD7Jxa9iHvngcag==

punycode@^2.1.1:
version "2.1.1"
Expand Down Expand Up @@ -772,9 +772,9 @@ wrappy@1:
integrity sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==

ws@^8.2.3:
version "8.8.0"
resolved "https://registry.yarnpkg.com/ws/-/ws-8.8.0.tgz#8e71c75e2f6348dbf8d78005107297056cb77769"
integrity sha512-JDAgSYQ1ksuwqfChJusw1LSJ8BizJ2e/vVu5Lxjq3YvNJNlROv1ui4i+c/kUUrPheBvQl4c5UbERhTwKa6QBJQ==
version "8.8.1"
resolved "https://registry.yarnpkg.com/ws/-/ws-8.8.1.tgz#5dbad0feb7ade8ecc99b830c1d77c913d4955ff0"
integrity sha512-bGy2JzvzkPowEJV++hF07hAD6niYSr0JzBNo/J29WsB57A2r7Wlc1UFcTR9IzrPvuNVO4B8LGqF8qcpsVOhJCA==

xml-name-validator@^4.0.0:
version "4.0.0"
Expand Down

0 comments on commit 0e4e612

Please sign in to comment.