Debian Codegraph @

modules/net_sniff/net_sniff_ftp.go

raw symbols SCIP
1 package net_sniff
2
3 import (
4 "net"
5 "regexp"
6
7 "github.com/google/gopacket"
8 "github.com/google/gopacket/layers"
9
10 "github.com/evilsocket/islazy/str"
11 "github.com/evilsocket/islazy/tui"
12 )
13
14 var (
15 ftpRe = regexp.MustCompile(`^(USER|PASS) (.+)[\n\r]+$`)
16 )
17
18 func ftpParser(srcIP, dstIP net.IP, payload []byte, pkt gopacket.Packet, tcp *layers.TCP) bool {
19 data := string(tcp.Payload)
20
21 if matches := ftpRe.FindAllStringSubmatch(data, -1); matches != nil {
22 what := str.Trim(matches[0][1])
23 cred := str.Trim(matches[0][2])
24 NewSnifferEvent(
25 pkt.Metadata().Timestamp,
26 "ftp",
27 srcIP.String(),
28 dstIP.String(),
29 nil,
30 "%s %s > %s:%s - %s %s",
31 tui.Wrap(tui.BACKYELLOW+tui.FOREWHITE, "ftp"),
32 vIP(srcIP),
33 vIP(dstIP),
34 vPort(tcp.DstPort),
35 tui.Bold(what),
36 tui.Yellow(cred),
37 ).Push()
38
39 return true
40 }
41
42 return false
43 }