forked from pablouser1/SignTok
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Moved to JS, using JSDOM and added Docker
- Loading branch information
1 parent
912e098
commit 6980abb
Showing
20 changed files
with
1,274 additions
and
198 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
/.venv | ||
/.vscode | ||
__pycache__ | ||
/node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
FROM node:17 | ||
|
||
WORKDIR /usr/src/app | ||
|
||
COPY package.json ./ | ||
RUN yarn install | ||
COPY . . | ||
EXPOSE 8080 | ||
CMD [ "node", "server.js" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,21 @@ | ||
# SignTok | ||
Sign your TikTok urls easily. | ||
This is a port of [tiktok-signature](https://github.com/carcabot/tiktok-signature) to Python using Selenium and Selenium Stealth | ||
|
||
[](https://heroku.com/deploy) | ||
This is a port of [tiktok-signature](https://github.com/carcabot/tiktok-signature) using JSDOM | ||
|
||
## Installation | ||
``` | ||
pip install -r requirements.txt | ||
yarn install | ||
``` | ||
You also need to have Chrome installed | ||
|
||
## Usage | ||
For webserver: | ||
``` | ||
python web.py | ||
node server.py | ||
``` | ||
Then you can send a POST request to localhost:8080 with a raw/plain body containing the url | ||
|
||
For cli usage: | ||
``` | ||
python cli.py | ||
node index.js 'YOUR_URL_HERE' | ||
``` | ||
|
||
## TODO | ||
* Docker |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
const Signer = require("./src/Signer") | ||
|
||
if (process.argv.length > 2) { | ||
const signer = new Signer() | ||
const url = process.argv[2] | ||
|
||
const data = signer.sign(url) | ||
console.log(data) | ||
} |
Large diffs are not rendered by default.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"name": "signtok", | ||
"version": "1.0.0", | ||
"description": "Sign your TikTok requests easily", | ||
"repository": "https://github.com/pablouser1/SignTok", | ||
"author": "Pablo Ferreiro", | ||
"license": "MIT", | ||
"private": true, | ||
"scripts": { | ||
"start": "node server.js" | ||
}, | ||
"dependencies": { | ||
"canvas": "^2.9.1", | ||
"crypto-js": "^4.1.1", | ||
"express": "^4.17.3", | ||
"jsdom": "^19.0.0" | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
const Signer = require("./src/Signer") | ||
const bodyParser = require("body-parser") | ||
const express = require("express") | ||
|
||
const port = process.env.PORT || 8080 | ||
const app = express() | ||
app.use(bodyParser.text()) | ||
|
||
const signer = new Signer() | ||
|
||
app.get('/', (req, res) => { | ||
res.redirect('https://github.com/pablouser1/SignTok') | ||
}) | ||
|
||
app.post("/signature", (req, res) => { | ||
const url = req.body | ||
const data = signer.sign(url) | ||
console.log("Sent data from request with url: " + url) | ||
res.send({ | ||
status: "ok", | ||
data: { | ||
...data, | ||
navigator: signer.navigator() | ||
} | ||
}) | ||
}) | ||
|
||
app.listen(port, () => { | ||
console.log(`App listening on port ${port}`) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
const fs = require("fs") | ||
const Utils = require("./Utils") | ||
const { JSDOM, ResourceLoader } = require("jsdom") | ||
const CryptoJS = require("crypto-js") | ||
|
||
class Signer { | ||
static DEFAULT_USERAGENT = | ||
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/98.0.4758.109 Safari/537.36" | ||
static PASSWORD = CryptoJS.enc.Utf8.parse('webapp1.0+202106') | ||
/** | ||
* @type Window | ||
*/ | ||
window = null | ||
|
||
constructor(userAgent = Signer.DEFAULT_USERAGENT) { | ||
const signature_js = fs.readFileSync(__dirname + "/../js/signature.js", "utf-8") | ||
const resourceLoader = new ResourceLoader({ | ||
userAgent | ||
}) | ||
|
||
const { window } = new JSDOM(``, { | ||
url: "https://www.tiktok.com", | ||
referrer: "https://www.tiktok.com", | ||
contentType: "text/html", | ||
includeNodeLocations: true, | ||
runScripts: "outside-only", | ||
resources: resourceLoader | ||
}) | ||
this.window = window | ||
this.window.eval(signature_js.toString()) | ||
this.window.byted_acrawler.init({ | ||
"aid":24, | ||
"dfp":true | ||
}) | ||
} | ||
|
||
navigator() { | ||
return { | ||
deviceScaleFactor: this.window.devicePixelRatio, | ||
user_agent: this.window.navigator.userAgent, | ||
browser_language: this.window.navigator.language, | ||
browser_platform: this.window.navigator.platform, | ||
browser_name: this.window.navigator.appCodeName, | ||
browser_version: this.window.navigator.appVersion | ||
} | ||
} | ||
|
||
signature(url) { | ||
return this.window.byted_acrawler.sign({ url }) | ||
} | ||
|
||
xttparams(params) { | ||
params += "&is_encryption=1" | ||
const crypt = CryptoJS.AES.encrypt(params, Signer.PASSWORD, { | ||
iv: Signer.PASSWORD, | ||
mode: CryptoJS.mode.CBC, | ||
padding: CryptoJS.pad.Pkcs7 | ||
}).toString() | ||
return crypt | ||
} | ||
|
||
sign(url) { | ||
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) | ||
return { | ||
signature: signature, | ||
verify_fp: verifyFp, | ||
signed_url: signed_url, | ||
"x-tt-params": xttparams | ||
} | ||
} | ||
} | ||
|
||
module.exports = Signer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
class Utils { | ||
static verify_fp() { | ||
// TODO, add proper verify fp method | ||
return "verify_68b8ccfa65726db8b3db0cc07821d696" | ||
} | ||
} | ||
|
||
module.exports = Utils |
Oops, something went wrong.