MCPcopy
hub / github.com/dreadl0ck/netcap / ExtractDataChannel

Function ExtractDataChannel

decoder/stream/ftp/ftp_reader.go:424–457  ·  view source on GitHub ↗

ExtractDataChannel extracts file from FTP data channel

(conv *core.ConversationInfo, data []byte, conn *FTPDataConnection)

Source from the content-addressed store, hash-verified

422
423// ExtractDataChannel extracts file from FTP data channel
424func ExtractDataChannel(conv *core.ConversationInfo, data []byte, conn *FTPDataConnection) error {
425 if len(data) == 0 {
426 return nil
427 }
428
429 ftpLog.Info("Extracting FTP data channel file",
430 zap.String("filename", conn.Filename),
431 zap.String("command", conn.Command),
432 zap.Int("dataSize", len(data)),
433 zap.String("ident", conv.Ident),
434 )
435
436 // Use file extraction framework
437 extractor, ok := file.GetExtractor("FTP")
438 if !ok {
439 ftpLog.Error("FTP file extractor not registered")
440 return nil
441 }
442
443 flowDirection := "server_to_client"
444 if conn.Command == "STOR" {
445 flowDirection = "client_to_server"
446 }
447
448 metadata := file.FileMetadata{
449 ConnectionUID: conv.Ident,
450 FlowDirection: flowDirection,
451 FTPCommand: conn.Command,
452 Filename: filepath.Base(conn.Filename),
453 Host: conn.IP,
454 }
455
456 return extractor.ExtractFile(conv, data, metadata)
457}

Callers 1

DecodeMethod · 0.85

Calls 6

GetExtractorFunction · 0.92
IntMethod · 0.80
InfoMethod · 0.65
ExtractFileMethod · 0.65
StringMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected