/
githubmirror
/
metasploit-framework
Обзор
Документация
Войти
/
githubmirror
/
metasploit-framework
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
modules/auxiliary/admin/postgres/postgres_sql.rb
63 строки
2 KB
g0t mi1k
#{rhost}:#{rport} -> #{Rex::Socket.to_authority(rhost, rport)}
19 май 2026, 18:12
19 май 2026, 18:12
0745cc6
Код
Авторство
О чём код?
## # This module requires Metasploit: https://metasploit.com/download # Current source: https://github.com/rapid7/metasploit-framework ## class MetasploitModule < Msf::Auxiliary include Msf::Exploit::Remote::Postgres include Msf::OptionalSession::PostgreSQL def initialize(info = {}) super( update_info( info, 'Name' => 'PostgreSQL Server Generic Query', 'Description' => %q{ This module will allow for simple SQL statements to be executed against a PostgreSQL instance given the appropriate credentials. }, 'Author' => [ 'todb' ], 'License' => MSF_LICENSE, 'References' => [ [ 'URL', 'https://www.postgresql.org' ] ], 'Notes' => { 'Stability' => [CRASH_SAFE], 'SideEffects' => [IOC_IN_LOGS], 'Reliability' => [] } ) ) end def auxiliary_commands { 'select' => 'Run a select query (a LIMIT clause is probably a really good idea)' } end def cmd_select(*args) datastore['SQL'] = "select #{args.join(' ')}" run end def rhost datastore['RHOST'] end def rport datastore['RPORT'] end def run self.postgres_conn = session.client if session ret = postgres_query(datastore['SQL'], datastore['RETURN_ROWSET']) case ret.keys[0] when :conn_error print_error "#{Rex::Socket.to_authority(rhost, rport)} Postgres - Authentication failure, could not connect." when :sql_error print_error "#{postgres_conn.peerhost}:#{postgres_conn.peerport} Postgres - #{ret[:sql_error]}" when :complete vprint_good "#{postgres_conn.peerhost}:#{postgres_conn.peerport} Postgres - Command complete." end postgres_logout if postgres_conn && session.blank? end end