PostgreSQL Version Probe - Metasploit
This page contains detailed information about how to use the auxiliary/scanner/postgres/postgres_version metasploit module. For list of all metasploit modules, visit the Metasploit Module Library.
Module Overview
Name: PostgreSQL Version Probe
Module: auxiliary/scanner/postgres/postgres_version
Source code: modules/auxiliary/scanner/postgres/postgres_version.rb
Disclosure date: -
Last modification time: 2017-08-26 21:01:10 +0000
Supported architecture(s): -
Supported platform(s): -
Target service / protocol: postgres
Target network port(s): 5432
List of CVEs: -
Enumerates the version of PostgreSQL servers.
Module Ranking and Traits
Module Ranking:
- normal: The exploit is otherwise reliable, but depends on a specific version and can't (or doesn't) reliably autodetect. More information about ranking can be found here.
Basic Usage
This module is a scanner module, and is capable of testing against multiple hosts.
msf > use auxiliary/scanner/postgres/postgres_version
msf auxiliary(postgres_version) > show options
... show and set options ...
msf auxiliary(postgres_version) > set RHOSTS ip-range
msf auxiliary(postgres_version) > exploit
Other examples of setting the RHOSTS option:
Example 1:
msf auxiliary(postgres_version) > set RHOSTS 192.168.1.3-192.168.1.200
Example 2:
msf auxiliary(postgres_version) > set RHOSTS 192.168.1.1/24
Example 3:
msf auxiliary(postgres_version) > set RHOSTS file:/tmp/ip_list.txt
Required Options
- RHOSTS: The target host(s), range CIDR identifier, or hosts file with syntax 'file:<path>'
Knowledge Base
Description
This module identifies the target host's PostgreSQL version. This occurs via the PostgreSQL API, which by default runs on port 5432.
Vulnerable Application
Installation of PostgreSQL on Kali Linux:
While many versions of Kali Linux come with a PostgreSQL installation out of the box, in the event that you are using a containerized Kali Linux or other minimal installation, installation and setup of PostgreSQL is required.
The following instructions assume you are beginning with a fresh Kali installation as the root user.
apt-get update
apt-get install postgresql
systemctl start postgresql
At this point, PostgreSQL is installed and the installation has created the necessary user accounts to run the server.
This is where most users would begin the verification process. At this point, we'll setup a user account for use within the postgres_version
module
sudo --login --user postgres
psql
CREATE USER msf_documentation WITH PASSWORD 'msf_documentation'
Verification Steps
use auxiliary/scanner/postgres/postgres_version
set RHOSTS [ips]
set RPORT [port]
set USERNAME [username]
set PASSWORD [password]
run
Scenarios
PostgreSQL 10.4 on Kali Linux
msf > use auxiliary/scanner/postgres/postgres_version
msf auxiliary(scanner/postgres/postgres_version) > set RHOSTS 10.10.10.25
RHOSTS => 10.10.10.25
msf auxiliary(scanner/postgres/postgres_version) > set USERNAME msf_documentation
USERNAME => msf_documentation
msf auxiliary(scanner/postgres/postgres_version) > set PASSWORD msf_documentation
PASSWORD => msf_documentation
msf auxiliary(scanner/postgres/postgres_version) > run
[*] 10.10.10.25:5432 Postgres - Version PostgreSQL 10.4 (Debian 10.4-2) on x86_64-pc-linux-gnu, compiled by gcc (Debian 7.3.0-18) 7.3.0, 64-bit (Post-Auth)
[*] Scanned 1 of 1 hosts (100% complete)
[*] Auxiliary module execution completed
Confirming
postgresql
# sudo --login --user postgres psql
psql (10.4 (Debian 10.4-2))
Type "help" for help.
postgres=# SELECT version();
version
----------------------------------------------------------------------------------------------------------------------------
Postgres - Version PostgreSQL 10.4 (Debian 10.4-2) on x86_64-pc-linux-gnu, compiled by gcc (Debian 7.3.0-18) 7.3.0, 64-bit
(1 row)
Go back to menu.
Msfconsole Usage
Here is how the scanner/postgres/postgres_version auxiliary module looks in the msfconsole:
msf6 > use auxiliary/scanner/postgres/postgres_version
msf6 auxiliary(scanner/postgres/postgres_version) > show info
Name: PostgreSQL Version Probe
Module: auxiliary/scanner/postgres/postgres_version
License: Metasploit Framework License (BSD)
Rank: Normal
Provided by:
todb <[email protected]>
Check supported:
No
Basic options:
Name Current Setting Required Description
---- --------------- -------- -----------
DATABASE template1 yes The database to authenticate against
PASSWORD postgres no The password for the specified username. Leave blank for a random password.
RHOSTS yes The target host(s), range CIDR identifier, or hosts file with syntax 'file:<path>'
RPORT 5432 yes The target port
THREADS 1 yes The number of concurrent threads (max one per host)
USERNAME postgres yes The username to authenticate as
VERBOSE false no Enable verbose output
Description:
Enumerates the version of PostgreSQL servers.
References:
http://www.postgresql.org
Module Options
This is a complete list of options available in the scanner/postgres/postgres_version auxiliary module:
msf6 auxiliary(scanner/postgres/postgres_version) > show options
Module options (auxiliary/scanner/postgres/postgres_version):
Name Current Setting Required Description
---- --------------- -------- -----------
DATABASE template1 yes The database to authenticate against
PASSWORD postgres no The password for the specified username. Leave blank for a random password.
RHOSTS yes The target host(s), range CIDR identifier, or hosts file with syntax 'file:<path>'
RPORT 5432 yes The target port
THREADS 1 yes The number of concurrent threads (max one per host)
USERNAME postgres yes The username to authenticate as
VERBOSE false no Enable verbose output
Advanced Options
Here is a complete list of advanced options supported by the scanner/postgres/postgres_version auxiliary module:
msf6 auxiliary(scanner/postgres/postgres_version) > show advanced
Module advanced options (auxiliary/scanner/postgres/postgres_version):
Name Current Setting Required Description
---- --------------- -------- -----------
ShowProgress true yes Display progress messages during a scan
ShowProgressPercent 10 yes The interval in percent that progress should be shown
WORKSPACE no Specify the workspace for this module
Auxiliary Actions
This is a list of all auxiliary actions that the scanner/postgres/postgres_version module can do:
msf6 auxiliary(scanner/postgres/postgres_version) > show actions
Auxiliary actions:
Name Description
---- -----------
Evasion Options
Here is the full list of possible evasion options supported by the scanner/postgres/postgres_version auxiliary module in order to evade defenses (e.g. Antivirus, EDR, Firewall, NIDS etc.):
msf6 auxiliary(scanner/postgres/postgres_version) > show evasion
Module evasion options:
Name Current Setting Required Description
---- --------------- -------- -----------
Go back to menu.
Error Messages
This module may fail with the following error messages:
Check for the possible causes from the code snippets below found in the module source code. This can often times help in identifying the root cause of the problem.
<RHOST>:<RPORT> Postgres - Authentication Error Fingerprint: <RESULT:UNKNOWN>
Here is a relevant code snippet related to the "<RHOST>:<RPORT> Postgres - Authentication Error Fingerprint: <RESULT:UNKNOWN>" error message:
86: vprint_good "#{rhost}:#{rport} Postgres - Logged in to '#{database}' with '#{user}':'#{password}'"
87: print_status "#{rhost}:#{rport} Postgres - Version #{result[:auth]} (Post-Auth)"
88: elsif result[:preauth]
89: print_good "#{rhost}:#{rport} Postgres - Version #{result[:preauth]} (Pre-Auth)"
90: else # It's something we don't know yet
91: vprint_status "#{rhost}:#{rport} Postgres - Authentication Error Fingerprint: #{result[:unknown]}"
92: print_status "#{rhost}:#{rport} Postgres - Version Unknown (Pre-Auth)"
93: end
94:
95: # Reporting
96: report_service(
<RHOST>:<RPORT> Connection Error
Here is a relevant code snippet related to the "<RHOST>:<RPORT> Connection Error" error message:
124:
125: # Logout
126: postgres_logout
127:
128: rescue Rex::ConnectionError
129: vprint_error "#{rhost}:#{rport} Connection Error: #{$!}"
130: return :done
131: end
132:
133: end
134: end
Go back to menu.
Related Pull Requests
- #8888 Merged Pull Request: spelling/grammar fixes part 1
- #8716 Merged Pull Request: Print_Status -> Print_Good (And OCD bits 'n bobs)
- #8338 Merged Pull Request: Fix msf/core and self.class msftidy warnings
- #6655 Merged Pull Request: use MetasploitModule as a class name
- #6648 Merged Pull Request: Change metasploit class names
- #5935 Merged Pull Request: My final round of updating modules to use the metasploit-credential API
- #5059 Merged Pull Request: Yard doc corrections
- #2525 Merged Pull Request: Change module boilerplate
- #1228 Merged Pull Request: MSFTIDY cleanup #1 - auxiliary
References
See Also
Check also the following modules related to this module:
- auxiliary/admin/postgres/postgres_readfile
- auxiliary/admin/postgres/postgres_sql
- auxiliary/scanner/postgres/postgres_dbname_flag_injection
- auxiliary/scanner/postgres/postgres_hashdump
- auxiliary/scanner/postgres/postgres_login
- auxiliary/scanner/postgres/postgres_schemadump
- auxiliary/server/capture/postgresql
- exploit/linux/postgres/postgres_payload
- exploit/multi/postgres/postgres_copy_from_program_cmd_exec
- exploit/multi/postgres/postgres_createlang
- exploit/windows/postgres/postgres_payload
Authors
- todb
Version
This page has been produced using Metasploit Framework version 6.1.24-dev. For more modules, visit the Metasploit Module Library.
Go back to menu.