Skip to content

Commit e85d25d

Browse files
Merge branch 'master' into master
2 parents 99c9e76 + 42e619e commit e85d25d

File tree

1 file changed

+19
-11
lines changed

1 file changed

+19
-11
lines changed

modules/banner/scanner.go

+19-11
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import (
1717
"net"
1818
"regexp"
1919
"strconv"
20+
"time"
2021

2122
"github.com/zmap/zgrab2"
2223
)
@@ -26,16 +27,19 @@ type Flags struct {
2627
zgrab2.BaseFlags `group:"Basic Options"`
2728
zgrab2.TLSFlags `group:"TLS Options"`
2829

29-
Probe string `long:"probe" default:"\\n" description:"Probe to send to the server. Use triple slashes to escape, for example \\\\\\n is literal \\n. Mutually exclusive with --probe-file."`
30-
ProbeFile string `long:"probe-file" description:"Read probe from file as byte array (hex). Mutually exclusive with --probe."`
31-
Pattern string `long:"pattern" description:"Pattern to match, must be valid regexp."`
32-
UseTLS bool `long:"tls" description:"Sends probe with TLS connection. Loads TLS module command options."`
33-
MaxTries int `long:"max-tries" default:"1" description:"Number of tries for timeouts and connection errors before giving up. Includes making TLS connection if enabled."`
34-
Hex bool `long:"hex" description:"Store banner value in hex. Mutually exclusive with --base64."`
35-
Base64 bool `long:"base64" description:"Store banner value in base64. Mutually exclusive with --hex."`
36-
MD5 bool `long:"md5" description:"Calculate MD5 hash of banner value."`
37-
SHA1 bool `long:"sha1" description:"Calculate SHA1 hash of banner value."`
38-
SHA256 bool `long:"sha256" description:"Calculate SHA256 hash of banner value."`
30+
ReadTimeout int `long:"read-timeout" default:"10" description:"Read timeout in milliseconds"`
31+
BufferSize int `long:"buffer-size" default:"8209" description:"Read buffer size in bytes"`
32+
MaxReadSize int `long:"max-read-size" default:"512" description:"Maximum amount of data to read in KiB (1024 bytes)"`
33+
Probe string `long:"probe" default:"\\n" description:"Probe to send to the server. Use triple slashes to escape, for example \\\\\\n is literal \\n. Mutually exclusive with --probe-file."`
34+
ProbeFile string `long:"probe-file" description:"Read probe from file as byte array (hex). Mutually exclusive with --probe."`
35+
Pattern string `long:"pattern" description:"Pattern to match, must be valid regexp."`
36+
UseTLS bool `long:"tls" description:"Sends probe with TLS connection. Loads TLS module command options."`
37+
MaxTries int `long:"max-tries" default:"1" description:"Number of tries for timeouts and connection errors before giving up. Includes making TLS connection if enabled."`
38+
Hex bool `long:"hex" description:"Store banner value in hex. Mutually exclusive with --base64."`
39+
Base64 bool `long:"base64" description:"Store banner value in base64. Mutually exclusive with --hex."`
40+
MD5 bool `long:"md5" description:"Calculate MD5 hash of banner value."`
41+
SHA1 bool `long:"sha1" description:"Calculate SHA1 hash of banner value."`
42+
SHA256 bool `long:"sha256" description:"Calculate SHA256 hash of banner value."`
3943
}
4044

4145
// Module is the implementation of the zgrab2.Module interface.
@@ -178,7 +182,11 @@ func (s *Scanner) Scan(target zgrab2.ScanTarget) (zgrab2.ScanStatus, any, error)
178182

179183
for try := 0; try < s.config.MaxTries; try++ {
180184
_, err = conn.Write(s.probe)
181-
data, readErr = zgrab2.ReadAvailable(conn)
185+
data, readErr = zgrab2.ReadAvailableWithOptions(conn,
186+
s.config.BufferSize,
187+
time.Duration(s.config.ReadTimeout)*time.Millisecond,
188+
0,
189+
s.config.MaxReadSize*1024)
182190
if err != nil {
183191
continue
184192
}

0 commit comments

Comments
 (0)