-
Notifications
You must be signed in to change notification settings - Fork 14.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add arch/platform detection for Postgres #19080
Add arch/platform detection for Postgres #19080
Conversation
|
||
# List of supported PostgreSQL platforms & architectures: | ||
# https://postgrespro.com/docs/postgresql/16/supported-platforms | ||
def map_compile_arch_to_architecture(compile_arch) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Taken from https://postgrespro.com/docs/postgresql/16/supported-platforms
I have bucket these by what I have covered versus not. Wanted to call this out in case anyone has thoughts or opinions.
Historical versions. Not covered and not present in rex/arch.rb
:
- Alpha
- Itanium
- M32R
- M68K
- M88K
- NS32K
- SuperH
- VAX
17.6 supported but not covered in rex/arch.rb
:
- S/390
- RISC-V
- PA-RISC
17.6 supported and covered in rex/arch.rb
:
- x86
- SPARC
- ARM
- MIPS
- PowerPC
"#{peerhost}:#{peerport}" | ||
# List of supported PostgreSQL platforms & architectures: | ||
# https://postgrespro.com/docs/postgresql/16/supported-platforms | ||
def map_compile_os_to_platform(compile_os) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Taken from https://postgrespro.com/docs/postgresql/16/supported-platforms
I have bucket these by what I have covered versus not. Wanted to call this out in case anyone has thoughts or opinions.
Historical versions. Not covered and not present in lib/msf/core/module/platform.rb
:
- 4.3BSD
- BEOS
- BSD/OS
- DG/UX
- Dynix
- NeXTSTEP
- QNX
- SCO
- SINIX
- Sprite
- SunOS
- Tru64 UNIX
- ULTRIX
Historical versions. Covered and present in lib/msf/core/module/platform.rb
:
- HP-UX
- IRIX
17.6 supported but not covered in lib/msf/core/module/platform.rb
:
- DragonFlyBSD
- illumos
17.6 supported and covered in lib/msf/core/module/platform.rb
:
- Linux
- Windows
- Solaris
- macOS
- FreeBSD
- OpenBSD
- NetBSD
- AIX
platform = Msf::Platform::Irix | ||
else | ||
# Return the query result if the value can't be mapped | ||
return compile_os |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding this to return whatever the query result is, evening if we don't mp it, I think it would be more useful to give the user the data instead of just Msf::Platform::Unknown
returning unknown
.
Maybe we need to return unknown here, happy to change it if needed 👍
arch = ARCH_X86 | ||
else | ||
# Return the query result if the value can't be mapped | ||
arch = compile_arch |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same thought process as https://github.com/rapid7/metasploit-framework/pull/19080/files#r1562403615
# I could get was grabbing the version and then plucking out the parts I needed. | ||
# Let me know if there is a better way to handle this that I may not have came across while | ||
# googling. | ||
query_result = query('select version()').rows.join.match(/.*on (\w+-\w+-\w+-\w+),/).captures |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Had to go with querying here, as the client data for the version doesn't contain the required information. It appears to be shortened.
[1] pry(#<Msf::Db::PostgresPR::Connection>)> self
=> #<Msf::Db::PostgresPR::Connection:0x00007fe889d5ed40
@conn=#<Socket:fd 15>,
@params=
{"username"=>"postgres",
"database"=>"template1",
"in_hot_standby"=>"off",
"integer_datetimes"=>"on",
"TimeZone"=>"Etc/UTC",
"IntervalStyle"=>"postgres",
"is_superuser"=>"on",
"application_name"=>"",
"default_transaction_read_only"=>"off",
"scram_iterations"=>"4096",
"DateStyle"=>"ISO, MDY",
"standard_conforming_strings"=>"on",
"session_authorization"=>"postgres",
"client_encoding"=>"UTF8",
"server_version"=>"16.1 (Debian 16.1-1.pgdg120+1)", <--- HERE
"server_encoding"=>"UTF8"},
@transaction_status=73>
[2] pry(#<Msf::Db::PostgresPR::Connection>)> query('select version()').rows
=> [["PostgreSQL 16.1 (Debian 16.1-1.pgdg120+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 12.2.0-14) 12.2.0, 64-bit"]]
18830e1
to
c1c8535
Compare
c1c8535
to
da17d2e
Compare
da17d2e
to
3f2e32e
Compare
5616d69
to
4e95934
Compare
4e95934
to
c694522
Compare
390fddc
to
b83f2e3
Compare
Release NotesAdds architecture and platform detection for PostgreSQL sessions |
This PR adds architecture and platform detection for PostgreSQL sessions by using a query.
Before
After
Verification
Docker target:
Commands to target:
msfconsole