Skip to content

Instantly share code, notes, and snippets.

@unixfox
Last active August 6, 2022 20:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save unixfox/10a3f4e5a8499059ff18ad8d6b260585 to your computer and use it in GitHub Desktop.
Save unixfox/10a3f4e5a8499059ff18ad8d6b260585 to your computer and use it in GitHub Desktop.
Dirty script for checking the hash of a youtube video stream in 320P
  1. install nodejs
  2. install the library got: npm install got
  3. launch the script with bash execute.sh

I replicated the issue on a Digitalocean droplet in UK location with IPv6 disabled and the DNS server set to 8.8.8.8 if one wants to have an environment to the one that I used.

#!/bin/bash
while true
do
node script.js
done
import got from 'got';
import crypto from 'crypto'
const sha256 = crypto.createHash('sha256').setEncoding('hex');
(async () => {
const data = await got.post('https://www.youtube.com/youtubei/v1/player?key=AIzaSyAO_FJ2SlqU8Q4STEHLGCilw_Y9_11qcW8', {
json: {
"videoId": "7-BqJKE14Yo",
"context": {
"client": {
"hl": "en",
"gl": "US",
"clientName": "ANDROID",
"clientVersion": "16.20"
}
}
}
});
const dataJson = JSON.parse(data.body)
const streamURL = dataJson.streamingData.formats.find(x => x.quality === 'medium').url;
const urlStream = await got.stream(streamURL);
await urlStream.pipe(sha256)
.on('finish', function () {
const sha = sha256.read()
if (sha !== "0fde076863f1cfa9b78fad5d81d1577e17e753c13942dab077d2bb5bbccd7288") {
console.log("visitorData: " + dataJson.responseContext.visitorData)
console.log("streamURL: " + streamURL)
console.log("sha256: " + sha)
console.log("ip of the youtube server used: " + data.ip);
console.log(data.body)
}
});
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment