Skip to content
New issue

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

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

Already on GitHub? # to your account

socks服务账号密码验证 #29

Open
1n7erface opened this issue Dec 26, 2024 · 0 comments
Open

socks服务账号密码验证 #29

1n7erface opened this issue Dec 26, 2024 · 0 comments

Comments

@1n7erface
Copy link

这个项目应该是所有代理项目中最适合入门的一个,尽管这个项目中存在一些难以避免的BUG,但是好在它的代码足够简洁、明了。使用原生go实现了端口转发和解析socks协议,感谢作者,祝工作顺利~
最后附上socks服务账号密码验证功能的概念性代码:
func isValidAccount(conn *TCPInteractive) (err error) { version := make([]byte, 1) _, err = conn.Read(version) if err != nil { common.Debug("Parsing socks protocol version error:%v", err) return err } if version[0] != 0x01 { common.Debug("not supported ver:%v", version) return errors.New(fmt.Sprintf("not supported ver:%v", version)) } ulen := make([]byte, 1) _, err = conn.Read(ulen) if err != nil { common.Debug("Analyzing the length of socks protocol username:%v", err) return err } uname := make([]byte, ulen[0]) _, err = ReadFull(*conn, uname) if err != nil { common.Debug("Reading socks protocol username error:%v", err) return err } plen := make([]byte, 1) _, err = conn.Read(plen) if err != nil { common.Debug("Analyzing the length of socks protocol password:%v", err) return err } passwd := make([]byte, plen[0]) _, err = ReadFull(*conn, passwd) if err != nil { common.Debug("Reading socks protocol password error:%v", err) return err } common.Debug("Socks protocol username:%v、password:%v", string(uname), string(passwd)) if string(uname) != structs.Param.Username || string(passwd) != structs.Param.Password { common.Debug("Socks5 account authentication failed") _, err = conn.Write([]byte{0x01, 0x01}) return errAccountError } else { common.Debug("Socks5 account authentication successfully") _, err = conn.Write([]byte{0x01, 0x00}) } if err != nil { common.Debug("Response to socks error:%v", err) return err } return nil }

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

No branches or pull requests

1 participant