Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting Connection Timeout Trying to Setup new Connection #130

Closed
Mythra opened this issue Jul 10, 2020 · 9 comments
Closed

Getting Connection Timeout Trying to Setup new Connection #130

Mythra opened this issue Jul 10, 2020 · 9 comments

Comments

@Mythra
Copy link

Mythra commented Jul 10, 2020

Hey! Thanks for this tool. I'm just getting started, so I may be doing something wrong, but I seem to be running into an issue trying to setup a connection.

I've gone ahead, and grabbed a token/cookie value from my browser, and set them as my IRC Password, however I'm still getting a failure to conenct. Upon turning on debug logging I see:

Jul 10 19:47:30 znc ircslack[22422]: time="2020-07-10T19:47:30Z" level=info msg="Starting Slack client" prefix=main
Jul 10 19:47:30 znc ircslack[22422]: time="2020-07-10T19:47:30Z" level=info msg="Connecting to RTM" prefix=slack-api
Jul 10 19:47:31 znc ircslack[22422]: time="2020-07-10T19:47:31Z" level=info msg="Using URL: 
Jul 10 19:47:31 znc ircslack[22422]: " prefix=slack-api
Jul 10 19:47:31 znc ircslack[22422]: time="2020-07-10T19:47:31Z" level=info msg="Failed to start or connect to RTM: invalid_auth" prefix=slack-api
Jul 10 19:47:31 znc ircslack[22422]: time="2020-07-10T19:47:31Z" level=info msg="invalid auth when connecting with RTM: invalid_auth" prefix=slack-api
Jul 10 19:47:31 znc ircslack[22422]: time="2020-07-10T19:47:31Z" level=info msg="Failed to connect with RTM on try 0: invalid_auth" prefix=slack-api
Jul 10 19:47:40 znc ircslack[22422]: time="2020-07-10T19:47:40Z" level=warning msg="Cannot connect to Slack: Connection to Slack timed out after 10s" prefix=main
Jul 10 19:47:40 znc ircslack[22422]: time="2020-07-10T19:47:40Z" level=warning msg="Error handling connection from 127.0.0.1:25416: read tcp 127.0.0.1:6666->127.0.0.1:25416: use of closed network connection" prefix=main

I'm pretty certain I've copied both the cookie, and token correctly, but am unsure of how to validate the rest of the setup/the token itself. Any help is appreciated,

thanks!

@insomniacslk
Copy link
Owner

insomniacslk commented Jul 11, 2020

Hi @securityinsanity , thanks for your feedback! The first thing that looks odd to me is the empty Slack websocket URL on the third line of the log, where it says "Using URL:", there I expect something like wss://cerberus-xxxx.lb.slack-msgs.com/websocket/XXXX (where XXXX is specific to your connection). In this case there seems to be just a newline instead. This comes from the slack library rather than from irc-slack directly.

Then there is "invalid_auth". From Slack's API documentation:

Some aspect of authentication cannot be validated.
Either the provided token is invalid or the request
originates from an IP address disallowed from making
the request.

I would safely assume that this is not a disallowed IP address issue, so the other option is "invalid token". To rule out any client issue, could you try the same process using irssi and report back here? The command line is irssi -c localhost -p 6666 -w 'your token'.
If the above doesn't work, we can look into why the websocket URL is empty

@insomniacslk
Copy link
Owner

Also can you confirm that the token you obtain with autotoken is of the form xoxp-XXXX|d=YYYY;? The important details are the |d= and the ; at the end. Thanks!

@Mythra
Copy link
Author

Mythra commented Jul 11, 2020

Hey! @insomniacslk , Autotoken doesn't seem to work for me (I believe it's because I have MFA!). However the tokens I have are in the format:

xoxc-xxxxxx|d=xxxx;

Using irssi I get the same result which (is good(?)):

[2020-07-11T00:20:10Z]  INFO main: Setting log level to 'info'
[2020-07-11T00:20:10Z]  INFO main: Starting server on 127.0.0.1:6666
[2020-07-11T00:20:10Z]  INFO main: Listening on 127.0.0.1:6666
[2020-07-11T00:20:27Z]  INFO main: Starting Slack client
[2020-07-11T00:20:27Z]  INFO slack-api: Connecting to RTM
[2020-07-11T00:20:27Z]  INFO slack-api: Using URL: 

[2020-07-11T00:20:27Z]  INFO slack-api: Failed to start or connect to RTM: invalid_auth
[2020-07-11T00:20:27Z]  INFO slack-api: invalid auth when connecting with RTM: invalid_auth
[2020-07-11T00:20:27Z]  INFO slack-api: Failed to connect with RTM on try 0: invalid_auth
[2020-07-11T00:20:37Z]  WARN main: Cannot connect to Slack: Connection to Slack timed out after 10s
[2020-07-11T00:20:37Z]  WARN main: Error handling connection from 127.0.0.1:27093: read tcp 127.0.0.1:6666->127.0.0.1:27093: use of closed network connection

@insomniacslk
Copy link
Owner

insomniacslk commented Jul 11, 2020

Yes, MFA would make autotoken fail (and it should be possible to add support for it).

Since you've used the manual procedure, it's still possible that the token is invalid. When I was developing autotoken, the first few times I copied the percent-encoded string instead of the decoded string. In the browser console the token can show up in both ways, depending on where it was copied from. Could you please check that you have a non-percent-encoded cookie?

@Mythra
Copy link
Author

Mythra commented Jul 11, 2020

I can confirm there is no percents in the cookie value (or in the xoxc- value). The cookie seems to be a valid base64 string.

Anyway I can perhaps try manually using the cookie with curl, or something of the like to validate it's correctness?

@Mythra
Copy link
Author

Mythra commented Jul 11, 2020

I disabled mfa and used autotoken, and it looks like it actually wanted the percent encoded value for me, and not the non-percent encoded value.

@Mythra Mythra closed this as completed Jul 11, 2020
@insomniacslk
Copy link
Owner

insomniacslk commented Jul 11, 2020

@securityinsanity I have implemented MFA support in autotoken in #131 . Just call autotoken with -mfa <your auth code>. If it doesn't work, there is another new flag, -show-browser that can be used to debug it. Hope that helps!

@Mythra
Copy link
Author

Mythra commented Jul 13, 2020

Thanks @insomniacslk , seems to be working for me so I can re-enable MFA. I appreciate your work on this!

@emersion
Copy link

I can confirm the cookie value needs to be percent-encoded, or otherwise causes an auth failure.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants