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

Fix ssh #335

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
20 changes: 13 additions & 7 deletions modules/ssh.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,10 @@ type SSHScanner struct {

func init() {
var sshModule SSHModule
cmd, err := zgrab2.AddCommand("ssh", "SSH Banner Grab", sshModule.Description(), 22, &sshModule)
_, err := zgrab2.AddCommand("ssh", "SSH Banner Grab", sshModule.Description(), 22, &sshModule)
if err != nil {
log.Fatal(err)
}
s := ssh.MakeSSHConfig() //dummy variable to get default for host key, kex algorithm, ciphers
cmd.FindOptionByLongName("host-key-algorithms").Default = []string{strings.Join(s.HostKeyAlgorithms, ",")}
cmd.FindOptionByLongName("kex-algorithms").Default = []string{strings.Join(s.KeyExchanges, ",")}
cmd.FindOptionByLongName("ciphers").Default = []string{strings.Join(s.Ciphers, ",")}
}

func (m *SSHModule) NewFlags() interface{} {
Expand All @@ -65,8 +61,18 @@ func (f *SSHFlags) Help() string {
}

func (s *SSHScanner) Init(flags zgrab2.ScanFlags) error {
f, _ := flags.(*SSHFlags)
s.config = f
sc := ssh.MakeSSHConfig() //dummy variable to get default for host key, kex algorithm, ciphers
f, _ := flags.(*SSHFlags)
s.config = f
if len(s.config.Ciphers) == 0 {
s.config.Ciphers = string(strings.Join(sc.Ciphers, ","))
}
if len(s.config.KexAlgorithms) == 0 {
s.config.KexAlgorithms = string(strings.Join(sc.KeyExchanges, ","))
}
if len(s.config.HostKeyAlgorithms) == 0 {
s.config.HostKeyAlgorithms = string(strings.Join(sc.HostKeyAlgorithms, ","))
}
return nil
}

Expand Down