Esempio n. 1
0
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
}
Esempio n. 2
0
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
}
Esempio n. 3
0
func (c *Conn) readImapStatusResponse(res []byte) (int, error) {
	return util.ReadUntilRegex(c.getUnderlyingConn(), res, imapStatusEndRegex)
}
Esempio n. 4
0
func (c *Conn) readPop3Response(res []byte) (int, error) {
	return util.ReadUntilRegex(c.getUnderlyingConn(), res, pop3EndRegex)
}