diff --git a/cmd/nuclei/ssh.yaml b/cmd/nuclei/ssh.yaml new file mode 100644 index 000000000..0c5719cb1 --- /dev/null +++ b/cmd/nuclei/ssh.yaml @@ -0,0 +1,31 @@ +id: ssh-auth-methods + +info: + name: SSH Auth Methods - Detection + author: Ice3man543 + severity: info + description: | + SSH (Secure Shell) authentication modes are methods used to verify the identity of users and ensure secure access to remote systems. Common SSH authentication modes include password-based authentication, which relies on a secret passphrase, and public key authentication, which uses cryptographic keys for a more secure and convenient login process. Additionally, multi-factor authentication (MFA) can be employed to enhance security by requiring users to provide multiple forms of authentication, such as a password and a one-time code. + reference: + - https://nmap.org/nsedoc/scripts/ssh-auth-methods.html + metadata: + max-request: 1 + shodan-query: product:"OpenSSH" + tags: js,detect,ssh,enum,network + +javascript: + - pre-condition: | + isPortOpen(Host,Port); + code: | + var m = require("nuclei/ssh"); + var c = m.SSHClient(); + var response = c.ConnectSSHInfoMode(Host, Port); + Export(response); + args: + Host: "{{Host}}" + Port: "222,2222,22" + + extractors: + - type: json + json: + - '.UserAuth' \ No newline at end of file diff --git a/pkg/protocols/javascript/js.go b/pkg/protocols/javascript/js.go index 2d927555f..194e526e7 100644 --- a/pkg/protocols/javascript/js.go +++ b/pkg/protocols/javascript/js.go @@ -792,6 +792,25 @@ func (request *Request) getPorts() []string { return []string{} } +// getPorts returns a slice of ports from the Port argument +func (request *Request) getPorts() []string { + portStr := request.getPort() + if portStr == "" { + return []string{} + } + + // Split by comma and clean up whitespace + ports := strings.Split(portStr, ",") + var cleanedPorts []string + for _, port := range ports { + cleaned := strings.TrimSpace(port) + if cleaned != "" { + cleanedPorts = append(cleanedPorts, cleaned) + } + } + return cleanedPorts +} + func (request *Request) getExcludePorts() string { for k, v := range request.Args { if strings.EqualFold(k, "exclude-ports") {