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

Add additional logging for unknown postgres authtypes #12976

Conversation

adfoster-r7
Copy link
Contributor

@adfoster-r7 adfoster-r7 commented Feb 23, 2020

Add additional logging for unknown postgres authtypes.

Before

Unknown postgres authtypes result in a crash:

msf5 auxiliary(scanner/postgres/postgres_version) > run

[*] 127.0.0.1:8200 Postgres - Trying username:'postgres' with password:'postgres' against 127.0.0.1:8200 on database 'template1'
[-] Auxiliary failed: NoMethodError undefined method `auth_type' for #<Msf::Db::PostgresPR::UnknownAuthType:0x00007f88e11da198>
[-] Call stack:
[-]   /Users/adfoster/Documents/code/metasploit-framework/lib/postgres/postgres-pr/message.rb:139:in `block in parse'
[-]   /Users/adfoster/Documents/code/metasploit-framework/lib/postgres/postgres-pr/message.rb:81:in `parse'
[-]   /Users/adfoster/Documents/code/metasploit-framework/lib/postgres/postgres-pr/message.rb:137:in `parse'
[-]   /Users/adfoster/Documents/code/metasploit-framework/lib/postgres/postgres-pr/message.rb:116:in `create'
[-]   /Users/adfoster/Documents/code/metasploit-framework/lib/postgres/postgres-pr/message.rb:57:in `read'
[-]   /Users/adfoster/Documents/code/metasploit-framework/lib/postgres/postgres-pr/connection.rb:71:in `block in initialize'
[-]   /Users/adfoster/Documents/code/metasploit-framework/lib/postgres/postgres-pr/connection.rb:70:in `loop'
[-]   /Users/adfoster/Documents/code/metasploit-framework/lib/postgres/postgres-pr/connection.rb:70:in `initialize'
[-]   /Users/adfoster/Documents/code/metasploit-framework/lib/msf/core/exploit/postgres.rb:232:in `new'
[-]   /Users/adfoster/Documents/code/metasploit-framework/lib/msf/core/exploit/postgres.rb:232:in `postgres_fingerprint'
[-]   /Users/adfoster/Documents/code/metasploit-framework/modules/auxiliary/scanner/postgres/postgres_version.rb:80:in `do_fingerprint'
[-]   /Users/adfoster/Documents/code/metasploit-framework/modules/auxiliary/scanner/postgres/postgres_version.rb:36:in `run_host'
[-]   /Users/adfoster/Documents/code/metasploit-framework/lib/msf/core/auxiliary/scanner.rb:118:in `block (2 levels) in run'
[-]   /Users/adfoster/Documents/code/metasploit-framework/lib/msf/core/thread_manager.rb:106:in `block in spawn'
[*] Auxiliary module execution completed

After

Unknown postgres authtypes no longer crash and show additional logging information:

Without verbose true:

[*] 127.0.0.1:8200 Postgres - Trying username:'postgres' with password:'postgres' against 127.0.0.1:8200 on database 'template1'
[-] unknown auth type '1337' with buffer content:
52 00 00 00 0c 00 00 00 05 35 76 0f f5    |R........5v..|


[*] 127.0.0.1:8200 Postgres - Authentication Error Fingerprint: ::
[*] 127.0.0.1:8200 Postgres - Version Unknown (Pre-Auth)
[*] 127.0.0.1:8200 Postgres - Disconnected
[*] Scanned 1 of 1 hosts (100% complete)
[*] Auxiliary module execution completed

With verbose true:

run

[*] 127.0.0.1:8200 Postgres - Version Unknown (Pre-Auth)
[*] Scanned 1 of 1 hosts (100% complete)
[*] Auxiliary module execution completed

Verification

List the steps needed to make sure this thing works

  • Start a database with an unknown authtype on port 5432
  • Start msfconsole
  • use auxiliary/scanner/postgres/postgres_version
  • set RHOSTS 127.0.0.1
  • set verbose true
  • Verify there is no module crash.
  • Verify the details are logged correctly.

@busterb
Copy link
Member

busterb commented Feb 23, 2020

Looks good/works well for me! I can land this which will also make it easier for folks to verify what those unknown auth types are.

@bcook-r7 bcook-r7 merged commit 0da64cd into rapid7:master Feb 23, 2020
@busterb
Copy link
Member

busterb commented Feb 23, 2020

Release Notes

This adds additional logging to Metasploit's PostgreSQL protocol client when it encounters an unknown authentication type, rather than raising an exception later.

@adfoster-r7 adfoster-r7 deleted the add-additional-logging-for-unknown-postgres-authtypes branch February 23, 2020 14:41
@ccondon-r7 ccondon-r7 added the usability Usability improvements label Feb 23, 2020
@ATrashInTheWorld
Copy link

Thank you very much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug enhancement module rn-enhancement release notes enhancement usability Usability improvements
Projects
None yet
Development

Successfully merging this pull request may close these issues.

postgres scanner and exploits: NoMethodError undefined method `auth_type
6 participants