func SetupFTPS(logStruct *FTPLog, connection net.Conn) (bool, error) { buffer := make([]byte, 1024) connection.Write([]byte("AUTH TLS\r\n")) respLen, err := util.ReadUntilRegex(connection, buffer, ftpEndRegex) if err != nil { return false, err } logStruct.AuthTLSResp = string(buffer[0:respLen]) retCode := ftpEndRegex.FindStringSubmatch(logStruct.AuthTLSResp)[1] if strings.HasPrefix(retCode, "2") { return true, nil } else { connection.Write([]byte("AUTH SSL\r\n")) respLen, err := util.ReadUntilRegex(connection, buffer, ftpEndRegex) if err != nil { return false, err } logStruct.AuthSSLResp = string(buffer[0:respLen]) retCode := ftpEndRegex.FindStringSubmatch(logStruct.AuthSSLResp)[1] if strings.HasPrefix(retCode, "2") { return true, nil } } return false, nil }
func GetFTPBanner(logStruct *FTPLog, connection net.Conn) (bool, error) { buffer := make([]byte, 1024) respLen, err := util.ReadUntilRegex(connection, buffer, ftpEndRegex) logStruct.Banner = string(buffer[0:respLen]) if err != nil { return false, err } retCode := ftpEndRegex.FindStringSubmatch(logStruct.Banner)[1] return strings.HasPrefix(retCode, "2"), nil }