{"record":{"id":"18823369cf357f89","repo":"shadow1ng/fscan","slug":"s-d-socks5-unsupported-command","errorCode":null,"errorMessage":"%s: %d [socks5_unsupported_command]","messagePattern":"(.+?): (.+?) \\[socks5_unsupported_command\\]","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"plugins/local/socks5proxy.go","lineNumber":205,"sourceCode":"}\n\n// handleSocks5Request 处理SOCKS5连接请求\nfunc (p *Socks5ProxyPlugin) handleSocks5Request(clientConn net.Conn, session *common.ScanSession) (net.Conn, int, error) {\n\theader := make([]byte, 4)\n\tif _, err := io.ReadFull(clientConn, header); err != nil {\n\t\treturn nil, 0, fmt.Errorf(\"%s: %w\", i18n.GetText(\"socks5_request_read_failed\"), err)\n\t}\n\n\tif header[0] != 0x05 || header[2] != 0x00 {\n\t\treturn nil, 0, fmt.Errorf(\"%s\", i18n.GetText(\"socks5_invalid_request\"))\n\t}\n\n\tcmd := header[1]\n\tif cmd != 0x01 { // 只支持CONNECT命令\n\t\t// 发送不支持的命令响应\n\t\tresponse := []byte{0x05, 0x07, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}\n\t\t_, _ = clientConn.Write(response)\n\t\treturn nil, 0, fmt.Errorf(i18n.GetText(\"socks5_unsupported_command\")+\": %d\", cmd)\n\t}\n\n\t// 解析目标地址\n\taddrType := header[3]\n\tvar targetHost string\n\tvar targetPort int\n\n\tswitch addrType {\n\tcase 0x01: // IPv4\n\t\taddr := make([]byte, 6)\n\t\tif _, err := io.ReadFull(clientConn, addr); err != nil {\n\t\t\treturn nil, 0, fmt.Errorf(\"%s\", i18n.GetText(\"ipv4_address_invalid\"))\n\t\t}\n\t\ttargetHost = fmt.Sprintf(\"%d.%d.%d.%d\", addr[0], addr[1], addr[2], addr[3])\n\t\ttargetPort = int(addr[4])<<8 + int(addr[5])\n\tcase 0x03: // 域名\n\t\tlenBuf := make([]byte, 1)\n\t\tif _, err := io.ReadFull(clientConn, lenBuf); err != nil {","sourceCodeStart":187,"sourceCodeEnd":223,"githubUrl":"https://github.com/shadow1ng/fscan/blob/95cc12e753bf43de7004e5aef42a9ffba3934303/plugins/local/socks5proxy.go#L187-L223","documentation":"Guard in handleSocks5Request: the SOCKS5 command code (header[1]) is not 0x01 (CONNECT). Only the CONNECT command is supported, so BIND (0x02) or UDP ASSOCIATE (0x03) requests trigger this after a 0x07 'command not supported' reply has been written back to the client.","triggerScenarios":"Thrown at plugins/local/socks5proxy.go:205 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Restrict proxy usage to TCP CONNECT-style outbound connections","Extend handleSocks5Request to implement BIND or UDP ASSOCIATE if those modes are required","Verify the client application is a real SOCKS5 client sending well-formed requests"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"95cc12e753bf43de7004e5aef42a9ffba3934303","analyzedAt":"2026-09-06T17:07:30.094Z","contentChangedAt":"2026-09-06T17:07:30.094Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}