diff --git a/modules/auxiliary/scanner/postgres/postgres_schemadump.rb b/modules/auxiliary/scanner/postgres/postgres_schemadump.rb index 20cceb3aa0491..dfc7a5b1c3fa4 100644 --- a/modules/auxiliary/scanner/postgres/postgres_schemadump.rb +++ b/modules/auxiliary/scanner/postgres/postgres_schemadump.rb @@ -28,7 +28,11 @@ def initialize end def run_host(_ip) - print_status 'When targeting a session, only the current database can be dumped.' if session + if session + print_status 'When targeting a session, only the current database can be dumped.' + self.postgres_conn = session.client + end + pg_schema = get_schema pg_schema.each do |db| report_note( @@ -70,7 +74,7 @@ def get_schema tmp_db = {} tmp_db['DBName'] = database_name tmp_db['Tables'] = [] - postgres_login({ database: database_name }) + postgres_login({ database: database_name }) unless session tmp_tblnames = smart_query("SELECT c.relname, n.nspname FROM pg_catalog.pg_class c LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace WHERE n.nspname NOT IN ('pg_catalog','pg_toast') AND pg_catalog.pg_table_is_visible(c.oid);") if tmp_tblnames && !tmp_tblnames.empty? tmp_tblnames.each do |tbl_row|