示例#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
}
示例#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
}
示例#3
0
文件: conn.go 项目: aaspring/zgrab
func (c *Conn) readImapStatusResponse(res []byte) (int, error) {
	return util.ReadUntilRegex(c.getUnderlyingConn(), res, imapStatusEndRegex)
}
示例#4
0
文件: conn.go 项目: aaspring/zgrab
func (c *Conn) readPop3Response(res []byte) (int, error) {
	return util.ReadUntilRegex(c.getUnderlyingConn(), res, pop3EndRegex)
}