-
Notifications
You must be signed in to change notification settings - Fork 14.6k
Combine ssh_login and ssh_login_pubkey modules #20704
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
base: master
Are you sure you want to change the base?
Conversation
|
|
||
| scanner.verbosity = :debug if datastore['SSH_DEBUG'] | ||
|
|
||
| scanner.scan! do |result| |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
realising this section is very similar between the two login methods bar the slight different in printing, I can probably DRY this up too
2eb18cc to
b29aba1
Compare
b29aba1 to
95e62cf
Compare
95e62cf to
c461a1b
Compare
| @ip = ip | ||
| print_brute :ip => ip, :msg => 'Starting bruteforce' | ||
|
|
||
| if datastore['USER_FILE'].blank? && datastore['USERNAME'].blank? && datastore['USERPASS_FILE'].blank? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you want to avoid chaining && maybe something like?
| if datastore['USER_FILE'].blank? && datastore['USERNAME'].blank? && datastore['USERPASS_FILE'].blank? | |
| if datastore.values_at('USER_FILE', 'USERNAME', 'USERPASS_FILE').all?(&:blank?) |
My testingCreated a keypair for testing: Username & PasswordSetup SSH server Confirmed session created with: or put username/password in files: or put username/password in file on same line, separated by space: Key based accessSetup SSH server. For some reason I could not get Confirmed session created with Confirmed session created with Also confirmed key and password auth works via PRO |
|
Questions
|
| 'PASSWORD' => result.credential.private | ||
| 'USERNAME' => result.credential.public | ||
| } | ||
| if used_key |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd extract the merge from the conditional because we're doing it in both branches e.g.
auth_type_options = if used_key
{
'PASSWORD' => nil
}
else
{
'PASSWORD' => result.credential.private,
'PRIVATE_KEY' => nil,
'KEY_FILE' => nil
}
end
base_options = {
'USERPASS_FILE' => nil,
'USER_FILE' => nil,
'PASS_FILE' => nil,
'USERNAME' => result.credential.public
}.merge(auth_type_options)
Resolves #14902
Combines the
ssh_loginandssh_login_pubkeymodules for an improved user experienceThere will be an accompanying Pro PR so I will draft this until we're sure Pro works with these changes
my setup for testing can be found here #20546
Verification Steps