From 71979a7e77182ce830e0dc02ddc213b2fe797a37 Mon Sep 17 00:00:00 2001 From: Thomas Hendrickson Date: Mon, 18 Dec 2023 14:30:55 -0500 Subject: [PATCH] updates --- pkg/plugins/services/redis/redis.go | 32 +++++++++++------------------ pkg/plugins/types.go | 12 +---------- pkg/runner/report.go | 12 +++++++++-- 3 files changed, 23 insertions(+), 33 deletions(-) diff --git a/pkg/plugins/services/redis/redis.go b/pkg/plugins/services/redis/redis.go index a447202..934478b 100644 --- a/pkg/plugins/services/redis/redis.go +++ b/pkg/plugins/services/redis/redis.go @@ -31,7 +31,7 @@ type Info struct { } const REDIS = "redis" -const REDISTLS = "redistls" +const REDISTLS = "redis" // Check if the response is from a Redis server // returns an error if it's not validated as a Redis server @@ -84,17 +84,10 @@ func (p *REDISTLSPlugin) PortPriority(port uint16) bool { } func (p *REDISTLSPlugin) Run(conn net.Conn, timeout time.Duration, target plugins.Target) (*plugins.Service, error) { - result, err := DetectRedis(conn, timeout) - if err != nil { - return nil, err - } - payload := plugins.ServiceRedisTLS{ - AuthRequired: result.AuthRequired, - } - return plugins.CreateServiceFrom(target, payload, true, "", plugins.TCPTLS), nil + return DetectRedis(conn, target, timeout, true) } -func DetectRedis(conn net.Conn, timeout time.Duration) (*Info, error) { +func DetectRedis(conn net.Conn, target plugins.Target, timeout time.Duration, tls bool) (*plugins.Service, error) { //https://redis.io/commands/ping/ // PING is a supported command since 1.0.0 // [*1(CR)(NL)$4(CR)(NL)PING(CR)(NL)] @@ -127,19 +120,18 @@ func DetectRedis(conn net.Conn, timeout time.Duration) (*Info, error) { if err != nil { return nil, nil } - - return &result, nil -} - -func (p *REDISPlugin) Run(conn net.Conn, timeout time.Duration, target plugins.Target) (*plugins.Service, error) { - result, err := DetectRedis(conn, timeout) - if err != nil { - return nil, err - } payload := plugins.ServiceRedis{ AuthRequired: result.AuthRequired, } - return plugins.CreateServiceFrom(target, payload, false, "", plugins.TCP), nil + if tls { + return plugins.CreateServiceFrom(target, payload, true, "", plugins.TCPTLS), nil + } else { + return plugins.CreateServiceFrom(target, payload, false, "", plugins.TCP), nil + } +} + +func (p *REDISPlugin) Run(conn net.Conn, timeout time.Duration, target plugins.Target) (*plugins.Service, error) { + return DetectRedis(conn, target, timeout, false) } func (p *REDISPlugin) Name() string { diff --git a/pkg/plugins/types.go b/pkg/plugins/types.go index b4b2849..0cac2e9 100644 --- a/pkg/plugins/types.go +++ b/pkg/plugins/types.go @@ -65,7 +65,7 @@ const ( ProtoRDP = "rdp" ProtoRPC = "rpc" ProtoRedis = "redis" - ProtoRedisTLS = "redistls" + ProtoRedisTLS = "redis" ProtoRsync = "rsync" ProtoRtsp = "rtsp" ProtoSMB = "smb" @@ -114,10 +114,6 @@ func (e Service) Metadata() Metadata { var p ServiceRedis _ = json.Unmarshal(e.Raw, &p) return p - case ProtoRedisTLS: - var p ServiceRedisTLS - _ = json.Unmarshal(e.Raw, &p) - return p case ProtoHTTP: var p ServiceHTTP _ = json.Unmarshal(e.Raw, &p) @@ -407,12 +403,6 @@ type ServiceRedis struct { func (e ServiceRedis) Type() string { return ProtoRedis } -type ServiceRedisTLS struct { - AuthRequired bool `json:"authRequired:"` -} - -func (e ServiceRedisTLS) Type() string { return ProtoRedisTLS } - type ServiceFTP struct { Banner string `json:"banner"` AnonymousLogin bool `json:"anonymousLogin"` diff --git a/pkg/runner/report.go b/pkg/runner/report.go index db9e7ff..dc66a34 100644 --- a/pkg/runner/report.go +++ b/pkg/runner/report.go @@ -86,9 +86,17 @@ func Report(services []plugins.Service) error { csvWriter.Flush() default: if len(service.Host) > 0 { - log.Printf("%s://%s:%d (%s)\n", strings.ToLower(service.Protocol), service.Host, service.Port, service.IP) + if service.TLS { + log.Printf("%s://%s:%d (%s) (tls)\n", strings.ToLower(service.Protocol), service.Host, service.Port, service.IP) + } else { + log.Printf("%s://%s:%d (%s)\n", strings.ToLower(service.Protocol), service.Host, service.Port, service.IP) + } } else { - log.Printf("%s://%s:%d\n", strings.ToLower(service.Protocol), service.IP, service.Port) + if service.TLS { + log.Printf("%s://%s:%d (tls)\n", strings.ToLower(service.Protocol), service.IP, service.Port) + } else { + log.Printf("%s://%s:%d\n", strings.ToLower(service.Protocol), service.IP, service.Port) + } } } }