Skip to content

Instantly share code, notes, and snippets.

@OkoyaUsman
Last active April 27, 2025 06:13
Show Gist options
  • Save OkoyaUsman/23bbcde3431f43b01761344f3b9b9159 to your computer and use it in GitHub Desktop.
Save OkoyaUsman/23bbcde3431f43b01761344f3b9b9159 to your computer and use it in GitHub Desktop.
Decrypting HLS stream keys on the fly according to https://blog.jonlu.ca/posts/illegal-streams
(function() {
const originalFetch = window.fetch;
window.fetch = function(input, init){
if(init && init.method === 'GET' && input.indexOf("something.com/aes") !== -1) {
const rewrittenUrl = "https://example.com/key.php?key="+input;
init = { ...init, url: rewrittenUrl };
const modifiedRequest = new Request(rewrittenUrl, init);
return originalFetch.call(this, modifiedRequest);
}
return originalFetch.call(this, input, init);
};
})();
(function (open) {
XMLHttpRequest.prototype.open = function (method, url, async, user, pass) {
var rewrittenUrl = url;
if(url.indexOf("svcs.mlb")!=-1){
rewrittenUrl="https://example.com/key.php?id=keyURL";
}
if(url.indexOf("svcs.plus.espn")!=-1){
rewrittenUrl="https://example.com/key.php?id=keyURL";
}
open.call(this, method, rewrittenUrl, async, user, pass);
};
})(XMLHttpRequest.prototype.open);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment