Files
metasploit-gs/lib/rex/post/postgresql/ui/console/command_dispatcher/client.rb
T

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

50 lines
1.5 KiB
Ruby
Raw Normal View History

2023-09-19 10:35:51 +01:00
# -*- coding: binary -*-
2024-02-06 11:43:44 +00:00
require 'rex/post/sql/ui/console/command_dispatcher/client'
2023-09-19 10:35:51 +01:00
module Rex
module Post
module PostgreSQL
module Ui
###
#
# Core PostgreSQL client commands
#
###
class Console::CommandDispatcher::Client
2024-02-06 11:43:44 +00:00
include Rex::Post::Sql::Ui::Console::CommandDispatcher::Client
2023-09-19 10:35:51 +01:00
include Rex::Post::PostgreSQL::Ui::Console::CommandDispatcher
2024-02-06 11:43:44 +00:00
# @return [String]
2023-09-19 10:35:51 +01:00
def name
'PostgreSQL Client'
end
2024-02-06 11:43:44 +00:00
# @return [Object]
2023-09-19 10:35:51 +01:00
def cmd_query_help
print_line 'Usage: query'
print_line
print_line 'Run a single SQL query on the target.'
print_line @@query_opts.usage
print_line 'Examples:'
print_line
2024-02-06 11:43:44 +00:00
print_line ' query SELECT user;'
print_line ' query SELECT version();'
print_line ' query SELECT * FROM pg_catalog.pg_tables;'
print_line
end
2024-02-06 11:43:44 +00:00
# @param [Msf::Db::PostgresPR::Connection] result The PostgreSQL query result
# @return [Hash] Hash containing rows, columns and errors.
def normalise_sql_result(result)
# PostgreSQL errors are handled by raising an exception when querying,
# meaning we don't have that in the Result object.
{ rows: result.rows, columns: result.fields.each.map(&:name), errors: [] }
end
2023-09-19 10:35:51 +01:00
end
end
end
end
end