Skip to content

Instantly share code, notes, and snippets.

@matzew

matzew/sph.md Secret

Last active September 24, 2023 05:28
  • Star 6 You must be signed in to star a gist
  • Fork 5 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save matzew/cbda360d72eaaef75971 to your computer and use it in GitHub Desktop.
SimplePush Hack

SimplePush by hand

  1. establish WSS connection
var websocket = new WebSocket("wss://push.services.mozilla.com");
websocket.onopen = function(event) {alert("OPEN");};
websocket.onclose = function(e) {alert('closed')};
websocket.onmessage = function(e) {console.log(e.data); };

once 'open'ed send HELLO:

var helloMsg = {messageType: "hello",uaid: "",channelIDs: []};
websocket.send(JSON.stringify( helloMsg ));

After payload received, did an register:

var reg = {"messageType": "register","channelID": "d9b74644-4f97-46aa-b8fa-9393985cd6cd"};
websocket.send(JSON.stringify( reg ));

From that payload, use the pushEndpoint URL string, in a cURL, like:

curl -i --header "Content-Type:application/x-www-form-urlencoded" -X PUT -d "version=2" 
https://push.services.mozilla.com/update/MGlYke2SrEmYE8ceyuSTwxawxuEJnMeHtTCFDckvUo9Gwat44C5Z5vjlQEd1od1hj6o38UB6Ytc5xgXwSLAH2VS8qKyZ1eLNTQSX6_AEeH73ohUy2A==

And noticed a logged update :-)

@vicencb
Copy link

vicencb commented Sep 16, 2022

Hi matzew,
i am trying to make this work as a proof of concept for another project, but i always get the websocket closed as soon as the hello message is sent.
The protocol looks compliant with the documentation.
Am i looking at the proper documentation or has the server changed?
If the server changed, where can i look for documentation? and, could you update this gist?

Regards,
Vicente.

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