Skip to content

Commit

Permalink
Add tls output to banner when we have a tls connection (#404)
Browse files Browse the repository at this point in the history
Co-authored-by: Zakir Durumeric <[email protected]>
  • Loading branch information
Seanstoppable and zakird authored Feb 18, 2024
1 parent ec3a192 commit 4a5e937
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
12 changes: 8 additions & 4 deletions modules/banner/scanner.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,9 @@ type Scanner struct {

// ScanResults instances are returned by the module's Scan function.
type Results struct {
Banner string `json:"banner,omitempty"`
Length int `json:"length,omitempty"`
Banner string `json:"banner,omitempty"`
Length int `json:"length,omitempty"`
TLSLog *zgrab2.TLSLog `json:"tls,omitempty"`
MD5 string `json:"md5,omitempty"`
SHA1 string `json:"sha1,omitempty"`
SHA256 string `json:"sha25,omitempty"`
Expand Down Expand Up @@ -166,6 +167,8 @@ func (s *Scanner) Scan(target zgrab2.ScanTarget) (zgrab2.ScanStatus, interface{}
}
break
}


if err != nil {
return zgrab2.TryGetScanStatus(err), nil, err
}
Expand Down Expand Up @@ -216,11 +219,12 @@ func (s *Scanner) Scan(target zgrab2.ScanTarget) (zgrab2.ScanStatus, interface{}
results.SHA256 = hex.EncodeToString(digest[:])
}
}

if tlsConn != nil {
results.TLSLog = tlsConn.GetLog()
}
if s.regex == nil {
return zgrab2.SCAN_SUCCESS, &results, nil
}

if s.regex.Match(data) {
return zgrab2.SCAN_SUCCESS, &results, nil
}
Expand Down
3 changes: 2 additions & 1 deletion zgrab2_schemas/zgrab2/banner.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
banner_scan_response = SubRecord({
"result": SubRecord({
"banner": String(),
"length": Unsigned32BitInteger()
"length": Unsigned32BitInteger(),
"tls": zgrab2.tls_log,
})
}, extends=zgrab2.base_scan_response)

Expand Down

0 comments on commit 4a5e937

Please sign in to comment.