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

socks5_password not socks5_pass #142

Closed
vans163 opened this issue Feb 5, 2016 · 1 comment
Closed

socks5_password not socks5_pass #142

vans163 opened this issue Feb 5, 2016 · 1 comment

Comments

@vans163
Copy link

vans163 commented Feb 5, 2016

Example shows to use socks5_pass but you need to use socks5_password as key.

Also you cannot concat a binary like this:

        {<<?VERSION, 1, ?USERPASS, (byte_size(User)), User,
           (byte_size(Password)), Password>>, ?USERPASS}

You need to specifiy User/binary and Password/binary or its a bad arg error.

Infact the whole auth is broken, it needs to be by spec:

handshake(Socket, Options) when is_port(Socket) ->
    User = get_value(socks5_user, Options, <<>>),
    Password = get_value(socks5_pass, Options, <<>>),
    {Greeting, AuthMethod} = if
        User /= <<>>, Password /= <<>> ->
            {<<5, 1, 2>>, 2};
        true ->
            {<<5, 1, 0>>, 0}
    end,
    ok = gen_tcp:send(Socket, Greeting),
    case gen_tcp:recv(Socket, 2, 10000) of
        {ok, <<5, 2>>} ->
            UserLen = byte_size(User),
            PassLen = byte_size(Password),
            AuthReq = <<1, UserLen, User/binary, PassLen, Password/binary>>,
            ok = gen_tcp:send(Socket, AuthReq),
            case gen_tcp:recv(Socket, 2, 10000) of
                {ok, <<1,0>>} ->
                    ok
            end;

        {ok, <<5, 0>>} -> ok;

        {ok, <<5, 16#FF>>} ->
            {error, unacceptable};

        {error, Reason} ->
            {error, Reason}
    end.

You cant send the User/Pass along with the auth request that will break some socks5 servers state machines.

@cmullaparthi
Copy link
Owner

Fixed in version 4.2.3

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

2 participants