Skip to content

Commit

Permalink
updates
Browse files Browse the repository at this point in the history
  • Loading branch information
praetorian-thendrickson committed Dec 18, 2023
1 parent 683198a commit 71979a7
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 33 deletions.
32 changes: 12 additions & 20 deletions pkg/plugins/services/redis/redis.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)]
Expand Down Expand Up @@ -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 {

Check failure on line 128 in pkg/plugins/services/redis/redis.go

View workflow job for this annotation

GitHub Actions / golangci

[golangci] pkg/plugins/services/redis/redis.go#L128

indent-error-flow: if block ends with a return statement, so drop this else and outdent its block (revive)
Raw output
pkg/plugins/services/redis/redis.go:128:9: indent-error-flow: if block ends with a return statement, so drop this else and outdent its block (revive)
	} else {
		return plugins.CreateServiceFrom(target, payload, false, "", plugins.TCP), nil
	}
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 {
Expand Down
12 changes: 1 addition & 11 deletions pkg/plugins/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ const (
ProtoRDP = "rdp"
ProtoRPC = "rpc"
ProtoRedis = "redis"
ProtoRedisTLS = "redistls"
ProtoRedisTLS = "redis"
ProtoRsync = "rsync"
ProtoRtsp = "rtsp"
ProtoSMB = "smb"
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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"`
Expand Down
12 changes: 10 additions & 2 deletions pkg/runner/report.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
}
}
Expand Down

0 comments on commit 71979a7

Please sign in to comment.