Remove `GetPort()` from modules
The previous patch allows the port to be specified in the `ScanTarget{}`. Since the port option in the Config may not be the port currently being scanned, delete the `GetPort()` function provided by each module. The `GetPort()` function is also not used. While we could just change the meaning of this function, to mean "Return the port in the Config", it is probably better to go ahead and just remove all references to it as there are no users.
This commit is contained in:
parent
a38194a7fd
commit
fb49609733
|
@ -95,11 +95,6 @@ func (scanner *Scanner) Protocol() string {
|
|||
return "#{MODULE_NAME}"
|
||||
}
|
||||
|
||||
// GetPort returns the port being scanned.
|
||||
func (scanner *Scanner) GetPort() uint {
|
||||
return scanner.config.Port
|
||||
}
|
||||
|
||||
// Scan TODO: describe what is scanned
|
||||
func (scanner *Scanner) Scan(target zgrab2.ScanTarget) (zgrab2.ScanStatus, interface{}, error) {
|
||||
conn, err := target.Open(&scanner.config.BaseFlags)
|
||||
|
|
|
@ -87,11 +87,6 @@ func (scanner *Scanner) Protocol() string {
|
|||
return "bacnet"
|
||||
}
|
||||
|
||||
// GetPort returns the port being scanned.
|
||||
func (scanner *Scanner) GetPort() uint {
|
||||
return scanner.config.Port
|
||||
}
|
||||
|
||||
// Scan probes for a BACNet service.
|
||||
// Behavior taken from original zgrab.
|
||||
// Connects to the configured port over UDP (default 47808/0xBAC0).
|
||||
|
|
|
@ -68,11 +68,6 @@ func (scanner *Scanner) Protocol() string {
|
|||
return "banner"
|
||||
}
|
||||
|
||||
// GetPort returns the port being scanned.
|
||||
func (scanner *Scanner) GetPort() uint {
|
||||
return scanner.config.Port
|
||||
}
|
||||
|
||||
// InitPerSender initializes the scanner for a given sender.
|
||||
func (scanner *Scanner) InitPerSender(senderID int) error {
|
||||
return nil
|
||||
|
|
|
@ -85,11 +85,6 @@ func (scanner *Scanner) Protocol() string {
|
|||
return "dnp3"
|
||||
}
|
||||
|
||||
// GetPort returns the port being scanned.
|
||||
func (scanner *Scanner) GetPort() uint {
|
||||
return scanner.config.Port
|
||||
}
|
||||
|
||||
// Scan probes for a DNP3 service.
|
||||
// Connects to the configured TCP port (default 20000) and reads the banner.
|
||||
func (scanner *Scanner) Scan(target zgrab2.ScanTarget) (zgrab2.ScanStatus, interface{}, error) {
|
||||
|
|
|
@ -85,11 +85,6 @@ func (scanner *Scanner) Protocol() string {
|
|||
return "fox"
|
||||
}
|
||||
|
||||
// GetPort returns the port being scanned.
|
||||
func (scanner *Scanner) GetPort() uint {
|
||||
return scanner.config.Port
|
||||
}
|
||||
|
||||
// Scan probes for a Tridium Fox service.
|
||||
// 1. Opens a TCP connection to the configured port (default 1911)
|
||||
// 2. Sends a static query
|
||||
|
|
|
@ -126,11 +126,6 @@ func (scanner *Scanner) GetTrigger() string {
|
|||
return scanner.config.Trigger
|
||||
}
|
||||
|
||||
// GetPort returns the configured port for the Scanner.
|
||||
func (s *Scanner) GetPort() uint {
|
||||
return s.config.Port
|
||||
}
|
||||
|
||||
// ftpEndRegex matches zero or more lines followed by a numeric FTP status code and linebreak, e.g. "200 OK\r\n"
|
||||
var ftpEndRegex = regexp.MustCompile(`^(?:.*\r?\n)*([0-9]{3})( [^\r\n]*)?\r?\n$`)
|
||||
|
||||
|
|
|
@ -135,11 +135,6 @@ func (scanner *Scanner) Protocol() string {
|
|||
return "imap"
|
||||
}
|
||||
|
||||
// GetPort returns the port being scanned.
|
||||
func (scanner *Scanner) GetPort() uint {
|
||||
return scanner.config.Port
|
||||
}
|
||||
|
||||
func getIMAPError(response string) error {
|
||||
if strings.HasPrefix(response, "a001 OK") {
|
||||
return nil
|
||||
|
|
|
@ -177,11 +177,6 @@ func (scanner *Scanner) Protocol() string {
|
|||
return "ipp"
|
||||
}
|
||||
|
||||
// GetPort returns the port being scanned.
|
||||
func (scanner *Scanner) GetPort() uint {
|
||||
return scanner.config.Port
|
||||
}
|
||||
|
||||
// FIXME: Add some error handling somewhere in here, unless errors should just be ignored and we get what we get
|
||||
func storeBody(res *http.Response, scanner *Scanner) {
|
||||
b := bufferFromBody(res, scanner)
|
||||
|
|
|
@ -113,11 +113,6 @@ func (scanner *Scanner) Protocol() string {
|
|||
return "modbus"
|
||||
}
|
||||
|
||||
// GetPort returns the port being scanned.
|
||||
func (scanner *Scanner) GetPort() uint {
|
||||
return scanner.config.Port
|
||||
}
|
||||
|
||||
// Conn wraps the connection state (more importantly, it provides the interface used by the old zgrab code, so that it
|
||||
// could be taken over as-is).
|
||||
type Conn struct {
|
||||
|
|
|
@ -215,11 +215,6 @@ func (scanner *Scanner) GetTrigger() string {
|
|||
return scanner.config.Trigger
|
||||
}
|
||||
|
||||
// GetPort returns the port being scanned
|
||||
func (scanner *Scanner) GetPort() uint {
|
||||
return scanner.config.Port
|
||||
}
|
||||
|
||||
// Validate checks that the flags are valid
|
||||
func (flags *Flags) Validate(args []string) error {
|
||||
return nil
|
||||
|
|
|
@ -108,11 +108,6 @@ func (scanner *Scanner) GetTrigger() string {
|
|||
return scanner.config.Trigger
|
||||
}
|
||||
|
||||
// GetPort returns the configured scanner port.
|
||||
func (scanner *Scanner) GetPort() uint {
|
||||
return scanner.config.Port
|
||||
}
|
||||
|
||||
// Scan performs the MSSQL scan.
|
||||
// 1. Open a TCP connection to the target port (default 1433).
|
||||
// 2. Send a PRELOGIN packet to the server.
|
||||
|
|
|
@ -205,11 +205,6 @@ func (scanner *Scanner) GetTrigger() string {
|
|||
return scanner.config.Trigger
|
||||
}
|
||||
|
||||
// GetPort returns the port that is being scanned.
|
||||
func (s *Scanner) GetPort() uint {
|
||||
return s.config.Port
|
||||
}
|
||||
|
||||
// Scan probles the target for a MySQL server.
|
||||
// 1. Connects and waits to receive the handshake packet.
|
||||
// 2. If the server supports SSL, send an SSLRequest packet, then
|
||||
|
|
|
@ -868,11 +868,6 @@ func (scanner *Scanner) GetTrigger() string {
|
|||
return scanner.config.Trigger
|
||||
}
|
||||
|
||||
// GetPort returns the port that is being scanned
|
||||
func (scanner *Scanner) GetPort() uint {
|
||||
return scanner.config.Port
|
||||
}
|
||||
|
||||
// SendAndReceive is a rough version of ntpdc.c's doquery(), except it only supports a single packet response
|
||||
func (scanner *Scanner) SendAndReceive(impl ImplNumber, req RequestCode, body []byte, sock net.Conn) (*PrivatePacketHeader, []byte, error) {
|
||||
outHeader, err := (&PrivatePacketHeader{
|
||||
|
|
|
@ -183,11 +183,6 @@ func (scanner *Scanner) Protocol() string {
|
|||
return "oracle"
|
||||
}
|
||||
|
||||
// GetPort returns the port being scanned.
|
||||
func (scanner *Scanner) GetPort() uint {
|
||||
return scanner.config.Port
|
||||
}
|
||||
|
||||
func (scanner *Scanner) getTNSDriver() *TNSDriver {
|
||||
mode := TNSModeOld
|
||||
if scanner.config.NewTNS {
|
||||
|
|
|
@ -150,11 +150,6 @@ func (scanner *Scanner) Protocol() string {
|
|||
return "pop3"
|
||||
}
|
||||
|
||||
// GetPort returns the port being scanned.
|
||||
func (scanner *Scanner) GetPort() uint {
|
||||
return scanner.config.Port
|
||||
}
|
||||
|
||||
func getPOP3Error(response string) error {
|
||||
if !strings.HasPrefix(response, "-") {
|
||||
return nil
|
||||
|
|
|
@ -319,11 +319,6 @@ func (s *Scanner) GetTrigger() string {
|
|||
return s.Config.Trigger
|
||||
}
|
||||
|
||||
// GetPort returns the port being scanned.
|
||||
func (s *Scanner) GetPort() uint {
|
||||
return s.Config.Port
|
||||
}
|
||||
|
||||
// DoSSL attempts to upgrade the connection to SSL, returning an error on failure.
|
||||
func (s *Scanner) DoSSL(sql *Connection) error {
|
||||
var conn *zgrab2.TLSConnection
|
||||
|
|
|
@ -211,11 +211,6 @@ func (scanner *Scanner) GetTrigger() string {
|
|||
return scanner.config.Trigger
|
||||
}
|
||||
|
||||
// GetPort returns the port being scanned
|
||||
func (scanner *Scanner) GetPort() uint {
|
||||
return scanner.config.Port
|
||||
}
|
||||
|
||||
// Close cleans up the scanner.
|
||||
func (scan *scan) Close() {
|
||||
defer scan.close()
|
||||
|
|
|
@ -84,11 +84,6 @@ func (scanner *Scanner) Protocol() string {
|
|||
return "siemens"
|
||||
}
|
||||
|
||||
// GetPort returns the port being scanned.
|
||||
func (scanner *Scanner) GetPort() uint {
|
||||
return scanner.config.Port
|
||||
}
|
||||
|
||||
// Scan probes for Siemens S7 services.
|
||||
// 1. Connect to TCP port 102
|
||||
// 2. Send a COTP connection packet with destination TSAP 0x0102, source TSAP 0x0100
|
||||
|
|
|
@ -87,11 +87,6 @@ func (scanner *Scanner) Protocol() string {
|
|||
return "smb"
|
||||
}
|
||||
|
||||
// GetPort returns the port being scanned.
|
||||
func (scanner *Scanner) GetPort() uint {
|
||||
return scanner.config.Port
|
||||
}
|
||||
|
||||
// Scan performs the following:
|
||||
// 1. Connect to the TCP port (default 445).
|
||||
// 2. Send a negotiation packet with the default values:
|
||||
|
|
|
@ -176,11 +176,6 @@ func (scanner *Scanner) Protocol() string {
|
|||
return "smtp"
|
||||
}
|
||||
|
||||
// GetPort returns the port being scanned.
|
||||
func (scanner *Scanner) GetPort() uint {
|
||||
return scanner.config.Port
|
||||
}
|
||||
|
||||
func getSMTPCode(response string) (int, error) {
|
||||
if len(response) < 5 {
|
||||
return 0, ErrInvalidResponse
|
||||
|
|
|
@ -80,8 +80,15 @@ func (s *SSHScanner) GetTrigger() string {
|
|||
func (s *SSHScanner) Scan(t zgrab2.ScanTarget) (zgrab2.ScanStatus, interface{}, error) {
|
||||
data := new(ssh.HandshakeLog)
|
||||
|
||||
port := strconv.FormatUint(uint64(s.config.Port), 10)
|
||||
rhost := net.JoinHostPort(t.Host(), port)
|
||||
var port uint
|
||||
// If the port is supplied in ScanTarget, let that override the cmdline option
|
||||
if t.Port != nil {
|
||||
port = *t.Port
|
||||
} else {
|
||||
port = s.config.Port
|
||||
}
|
||||
portStr := strconv.FormatUint(uint64(port), 10)
|
||||
rhost := net.JoinHostPort(t.Host(), portStr)
|
||||
|
||||
sshConfig := ssh.MakeSSHConfig()
|
||||
sshConfig.Timeout = s.config.Timeout
|
||||
|
|
|
@ -91,11 +91,6 @@ func (scanner *Scanner) Protocol() string {
|
|||
return "telnet"
|
||||
}
|
||||
|
||||
// GetPort returns the port being scanned.
|
||||
func (scanner *Scanner) GetPort() uint {
|
||||
return scanner.config.Port
|
||||
}
|
||||
|
||||
// Scan connects to the target (default port TCP 23) and attempts to grab the Telnet banner.
|
||||
func (scanner *Scanner) Scan(target zgrab2.ScanTarget) (zgrab2.ScanStatus, interface{}, error) {
|
||||
conn, err := target.Open(&scanner.config.BaseFlags)
|
||||
|
|
Loading…
Reference in New Issue