MCPcopy
hub / github.com/shadow1ng/fscan / doFTPAuth

Method doFTPAuth

plugins/services/ftp.go:80–110  ·  view source on GitHub ↗

doFTPAuth 执行FTP认证

(ctx context.Context, info *common.HostInfo, cred Credential, config *common.Config, state *common.State)

Source from the content-addressed store, hash-verified

78
79// doFTPAuth 执行FTP认证
80func (p *FTPPlugin) doFTPAuth(ctx context.Context, info *common.HostInfo, cred Credential, config *common.Config, state *common.State) *AuthResult {
81 target := info.Target()
82
83 conn, err := ftplib.Dial(target, ftplib.DialWithTimeout(config.Timeout))
84 if err != nil {
85 state.IncrementTCPFailedPacketCount()
86 return &AuthResult{
87 Success: false,
88 ErrorType: classifyFTPErrorType(err),
89 Error: err,
90 }
91 }
92 state.IncrementTCPSuccessPacketCount()
93
94 err = conn.Login(cred.Username, cred.Password)
95 if err != nil {
96 _ = conn.Quit()
97 return &AuthResult{
98 Success: false,
99 ErrorType: classifyFTPErrorType(err),
100 Error: err,
101 }
102 }
103
104 return &AuthResult{
105 Success: true,
106 Conn: &ftpConnWrapper{conn},
107 ErrorType: ErrorTypeUnknown,
108 Error: nil,
109 }
110}
111
112// ftpConnWrapper 包装 ftplib.ServerConn 以实现 io.Closer
113type ftpConnWrapper struct {

Callers 2

createAuthFuncMethod · 0.95
testAnonymousAccessMethod · 0.95

Calls 5

classifyFTPErrorTypeFunction · 0.85
TargetMethod · 0.80
DialMethod · 0.65

Tested by

no test coverage detected