Skip to content

Instantly share code, notes, and snippets.

@m4rk4
Created October 30, 2020 01:53
Show Gist options
  • Save m4rk4/706745226f5a89cb1833dbb4507605e0 to your computer and use it in GitHub Desktop.
Save m4rk4/706745226f5a89cb1833dbb4507605e0 to your computer and use it in GitHub Desktop.
espn-fcast
var socket;
var fcastUrl;
fetch('https://fastcast.semfs.engsvc.go.com/public/websockethost')
.then(
function(response) {
if (response.status !== 200) {
console.log('Looks like there was a problem. Status Code: ' + response.status);
return;
}
// Examine the text in the response
response.json().then(function(data) {
console.log(data);
var wsUri = 'wss://'+data.ip+':'+data.securePort+'/FastcastService/pubsub/profiles/12000?TrafficManager-Token='+data.token;
console.log(wsUri);
socket = new WebSocket(wsUri);
socket.onopen = function(event) {
console.log('socket open: ' + event.data);
socket.send('{"op": "C"}');
};
socket.onmessage = function(event) {
console.log('socket message received from server: ' + event.data);
var data = JSON.parse(event.data);
console.log('op = ' + data.op);
if (data.op == 'C') {
var msg = {
op: "S",
sid: data.sid,
tc: "event-topevents"
};
socket.send(JSON.stringify(msg));
} else if (data.op == 'H') {
fcastUrl = data.pl;
}
};
});
}
)
.catch(function(err) {
console.log('Fetch Error :-S', err);
});
@harrijon
Copy link

I know this was a while back, but did you happen to figure out how data.pl was encrypted? I can get wss hooked up and receive data, but the key field is encrypted in some manner, and I can't figure it out. Here is a sample. The key field it pl.pl.

{"pl":"{"ts":1655143007315,"~c":1,"pl":"eJyLrlbKL1CyUipKLchJTE5V0lEqSCzJAAoUW5kZGNTlWBkZW5rWpVqZGZkYmFnUJUMZ+vkpKcX6ieWJlfq5+XmplT6ZeSC9ZYk5palKVsZmBrU6lBockpqY6w/i0MKClNSSxMycYoSJSi6ufgq6hsbGShQaXJRYjs3FRnpmrtpGlJuNK0SoYX5Gfm4qNrNBwUK5yfjiE2xDLAAeZsYr"}","op":"P","tc":"event-topevents","mid":15223020}

@bencryption66
Copy link

bencryption66 commented Dec 4, 2022

@harrijon you probably figured this out already, but I encountered the same problem. It's compressed and then base64 encoded. You have to decode first, then inflate. But you need to use an old version of pako (1.0.11) to inflate it, the newer versions won't work.
Something like this:

const pako = require('pako')

var pl = 'eJyLrlbKL1CyUipKLchJTE5V0lEqSCzJAAoUW5kZGNTlWBkZW5rWpVqZGZkYmFnUJUMZ+vkpKcX6ieWJlfq5+XmplT6ZeSC9ZYk5palKVsZmBrU6lBockpqY6w/i0MKClNSSxMycYoSJSi6ufgq6hsbGShQaXJRYjs3FRnpmrtpGlJuNK0SoYX5Gfm4qNrNBwUK5yfjiE2xDLAAeZsYr'
var compressed_raw = atob(pl)
var result = JSON.parse(pako.inflate(compressed_raw, { to: "string" }))


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment