PostgreSQL Server Generic Query - Metasploit
This page contains detailed information about how to use the auxiliary/admin/postgres/postgres_sql metasploit module. For list of all metasploit modules, visit the Metasploit Module Library.
Module Overview
Name: PostgreSQL Server Generic Query
Module: auxiliary/admin/postgres/postgres_sql
Source code: modules/auxiliary/admin/postgres/postgres_sql.rb
Disclosure date: -
Last modification time: 2017-08-24 21:38:44 +0000
Supported architecture(s): -
Supported platform(s): -
Target service / protocol: postgres
Target network port(s): 5432
List of CVEs: -
This module will allow for simple SQL statements to be executed against a PostgreSQL instance given the appropriate credentials.
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
msf > use auxiliary/admin/postgres/postgres_sql
msf auxiliary(postgres_sql) > show targets
... a list of targets ...
msf auxiliary(postgres_sql) > set TARGET target-id
msf auxiliary(postgres_sql) > show options
... show and set options ...
msf auxiliary(postgres_sql) > exploit
Required Options
- RHOSTS: The target host(s), range CIDR identifier, or hosts file with syntax 'file:<path>'
Go back to menu.
Msfconsole Usage
Here is how the admin/postgres/postgres_sql auxiliary module looks in the msfconsole:
msf6 > use auxiliary/admin/postgres/postgres_sql
msf6 auxiliary(admin/postgres/postgres_sql) > show info
Name: PostgreSQL Server Generic Query
Module: auxiliary/admin/postgres/postgres_sql
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.
RETURN_ROWSET true no Set to true to see query result sets
RHOSTS yes The target host(s), range CIDR identifier, or hosts file with syntax 'file:<path>'
RPORT 5432 yes The target port
SQL select version() no The SQL query to execute
USERNAME postgres yes The username to authenticate as
VERBOSE false no Enable verbose output
Description:
This module will allow for simple SQL statements to be executed
against a PostgreSQL instance given the appropriate credentials.
References:
www.postgresql.org
Module Options
This is a complete list of options available in the admin/postgres/postgres_sql auxiliary module:
msf6 auxiliary(admin/postgres/postgres_sql) > show options
Module options (auxiliary/admin/postgres/postgres_sql):
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.
RETURN_ROWSET true no Set to true to see query result sets
RHOSTS yes The target host(s), range CIDR identifier, or hosts file with syntax 'file:<path>'
RPORT 5432 yes The target port
SQL select version() no The SQL query to execute
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 admin/postgres/postgres_sql auxiliary module:
msf6 auxiliary(admin/postgres/postgres_sql) > show advanced
Module advanced options (auxiliary/admin/postgres/postgres_sql):
Name Current Setting Required Description
---- --------------- -------- -----------
WORKSPACE no Specify the workspace for this module
Auxiliary Actions
This is a list of all auxiliary actions that the admin/postgres/postgres_sql module can do:
msf6 auxiliary(admin/postgres/postgres_sql) > show actions
Auxiliary actions:
Name Description
---- -----------
Evasion Options
Here is the full list of possible evasion options supported by the admin/postgres/postgres_sql auxiliary module in order to evade defenses (e.g. Antivirus, EDR, Firewall, NIDS etc.):
msf6 auxiliary(admin/postgres/postgres_sql) > 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 failure, could not connect.
Here is a relevant code snippet related to the "<RHOST>:<RPORT> Postgres - Authentication failure, could not connect." error message:
43:
44: def run
45: ret = postgres_query(datastore['SQL'],datastore['RETURN_ROWSET'])
46: case ret.keys[0]
47: when :conn_error
48: print_error "#{rhost}:#{rport} Postgres - Authentication failure, could not connect."
49: when :sql_error
50: print_error "#{rhost}:#{rport} Postgres - #{ret[:sql_error]}"
51: when :complete
52: vprint_good "#{rhost}:#{rport} Postgres - Command complete."
53: end
<RHOST>:<RPORT> Postgres - <RET:SQL_ERROR>
Here is a relevant code snippet related to the "<RHOST>:<RPORT> Postgres - <RET:SQL_ERROR>" error message:
45: ret = postgres_query(datastore['SQL'],datastore['RETURN_ROWSET'])
46: case ret.keys[0]
47: when :conn_error
48: print_error "#{rhost}:#{rport} Postgres - Authentication failure, could not connect."
49: when :sql_error
50: print_error "#{rhost}:#{rport} Postgres - #{ret[:sql_error]}"
51: when :complete
52: vprint_good "#{rhost}:#{rport} Postgres - Command complete."
53: end
54: postgres_logout if self.postgres_conn
55: 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
- #2525 Merged Pull Request: Change module boilerplate
- #1228 Merged Pull Request: MSFTIDY cleanup #1 - auxiliary
- #507 Merged Pull Request: Add a select command for the various SQL modules
References
See Also
Check also the following modules related to this module:
- auxiliary/admin/postgres/postgres_readfile
- auxiliary/scanner/postgres/postgres_dbname_flag_injection
- auxiliary/scanner/postgres/postgres_hashdump
- auxiliary/scanner/postgres/postgres_login
- auxiliary/scanner/postgres/postgres_schemadump
- auxiliary/scanner/postgres/postgres_version
- 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
- auxiliary/admin/mssql/mssql_sql
- auxiliary/admin/mysql/mysql_sql
- auxiliary/admin/oracle/oracle_sql
- auxiliary/admin/teradata/teradata_odbc_sql
- auxiliary/admin/http/sysaid_sql_creds
- auxiliary/admin/http/typo3_news_module_sqli
- auxiliary/admin/http/wp_google_maps_sqli
- auxiliary/admin/http/wp_symposium_sql_injection
- auxiliary/admin/mssql/mssql_enum
- auxiliary/admin/mssql/mssql_enum_domain_accounts
- auxiliary/admin/mssql/mssql_enum_domain_accounts_sqli
- auxiliary/admin/mssql/mssql_enum_sql_logins
- auxiliary/admin/mssql/mssql_escalate_dbowner
- auxiliary/admin/mssql/mssql_escalate_dbowner_sqli
- auxiliary/admin/mssql/mssql_escalate_execute_as
- auxiliary/admin/mssql/mssql_escalate_execute_as_sqli
- auxiliary/admin/mssql/mssql_exec
- auxiliary/admin/mssql/mssql_findandsampledata
- auxiliary/admin/mssql/mssql_idf
- auxiliary/admin/mssql/mssql_ntlm_stealer
- auxiliary/admin/mssql/mssql_ntlm_stealer_sqli
- auxiliary/admin/mssql/mssql_sql_file
- auxiliary/admin/mysql/mysql_enum
- auxiliary/admin/scada/advantech_webaccess_dbvisitor_sqli
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.