Created
December 8, 2021 02:19
-
-
Save inez/731269f8ec54d469e1d031a30a32889a to your computer and use it in GitHub Desktop.
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
require "net/http" | |
require "websocket" | |
store = OpenSSL::X509::Store.new | |
store.set_default_paths | |
ctx = OpenSSL::SSL::SSLContext.new(:TLSv1_2_client) | |
ctx.set_params(verify_mode: OpenSSL::SSL::VERIFY_PEER) | |
ctx.cert_store = store | |
sock = OpenSSL::SSL::SSLSocket.open( | |
'wss-backup.slack.com', | |
443, | |
context: ctx | |
) | |
######## | |
######## Apparently setting this hostname here is super important, as it's a hint for SNI. | |
######## In the output of this script look for 404 vs 101 depending on uncommenitng this or commenting it. | |
######## Also, I'm using Ruby 2.7.4. | |
######## | |
sock.hostname = 'wss-primary.slack.com' | |
sock.sync = true | |
puts sock.state | |
sock.connect | |
handshake = WebSocket::Handshake::Client.new( | |
url: 'wss://wss-backup.slack.com/websocket/r8VGtIZfIbt0u98IKuhBgs2_jpbkns1ySzL14za4A8J0Y9ZdBIZgDHtC6UNS5HjkzQKOLBgwJNdx4xBFyrbm8-errf2_mnLz7u674L8s9He9PlQhnlyPQ2UJWz2G1uAoTZcM4y5hudtSuG36/2' | |
) | |
handshake_str = handshake.to_s | |
sock.write(handshake_str) | |
loop do | |
got = sock.gets | |
puts got | |
handshake << got | |
break if handshake.finished? | |
end | |
puts handshake.inspect |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment