Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add TLS support for fox #403

Merged
merged 3 commits into from
May 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions modules/fox/log.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
package fox

import (
"github.com/zmap/zgrab2"
)

// FoxLog is the struct returned to the caller.
type FoxLog struct {
// IsFox should always be true (otherwise, the result should have been nil).
Expand Down Expand Up @@ -58,4 +62,6 @@ type FoxLog struct {

// AuthAgentType corresponds to the "authAgentTypeSpecs" field.
AuthAgentType string `json:"auth_agent_type,omitempty"`

TLSLog *zgrab2.TLSLog `json:"tls,omitempty"`
}
29 changes: 28 additions & 1 deletion modules/fox/scanner.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"errors"
log "github.com/sirupsen/logrus"
"github.com/zmap/zgrab2"
"net"
)

// Flags holds the command-line configuration for the fox scan module.
Expand All @@ -17,6 +18,8 @@ type Flags struct {
zgrab2.BaseFlags

Verbose bool `long:"verbose" description:"More verbose logging, include debug fields in the scan results"`
UseTLS bool `long:"use-tls" description:"Sends probe with a TLS connection. Loads TLS module command options."`
zgrab2.TLSFlags
}

// Module implements the zgrab2.Module interface.
Expand Down Expand Up @@ -98,12 +101,36 @@ func (scanner *Scanner) Protocol() string {
// 4. If the response has the Fox response prefix, mark the scan as having detected the service.
// 5. Attempt to read any / all of the data fields from the Log struct
func (scanner *Scanner) Scan(target zgrab2.ScanTarget) (zgrab2.ScanStatus, interface{}, error) {
conn, err := target.Open(&scanner.config.BaseFlags)

var (
conn net.Conn
tlsConn *zgrab2.TLSConnection
err error
)

conn, err = target.Open(&scanner.config.BaseFlags)
if scanner.config.UseTLS {
tlsConn, err = scanner.config.TLSFlags.GetTLSConnection(conn)
if err != nil {
return zgrab2.TryGetScanStatus(err), nil, err
}
if err := tlsConn.Handshake(); err != nil {
return zgrab2.TryGetScanStatus(err), nil, err
}
conn = tlsConn
} else {
conn, err = target.Open(&scanner.config.BaseFlags)
}

if err != nil {
return zgrab2.TryGetScanStatus(err), nil, err
}

defer conn.Close()
result := new(FoxLog)
if tlsConn != nil {
result.TLSLog = tlsConn.GetLog()
}

err = GetFoxBanner(result, conn)
if !result.IsFox {
Expand Down
1 change: 1 addition & 0 deletions zgrab2_schemas/zgrab2/fox.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"brand_id": String(),
"sys_info": String(),
"agent_auth_type": String(),
"tls": zgrab2.tls_log,
}
)
},
Expand Down
Loading