-
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 mssql acceptance tests #19045
add mssql acceptance tests #19045
Conversation
d18d490
to
67d8a88
Compare
MSSQL_SA_PASSWORD: yourStrong(!)Password | ||
ACCEPT_EULA: 'Y' | ||
options: >- | ||
--health-cmd "/opt/mssql-tools/bin/sqlcmd -U sa -P 'yourStrong(!)Password' -Q 'select 1' -b -o /dev/null" |
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.
Would it be possible to randomly generate the MSSQL_SA_PASSWORD
here on L53 then refer to it in a variable on L56?
all: { | ||
required: [ | ||
'Instance Name:', | ||
'Scanned 1 of 1 hosts (100% complete)' |
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.
When a module fails silently in the background, this message will still be printed so this particular line does not really add anything.
spec/acceptance/mssql_spec.rb
Outdated
#{target_configuration_details} | ||
|
||
## Replication commands | ||
#{replication_commands.empty? ? 'no additional commands run' : replication_commands.join("\n")} |
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.
If this is intended to be a resource file then the no additional commands run
line would cause an error to be thrown. It should probably be within a comment to prevent that if the desired output is an RC file.
'Description' => %q{ This module will test the mssql sessions work }, | ||
'License' => MSF_LICENSE, | ||
'Author' => [ 'zachgoldman'], | ||
'Platform' => all_platforms, |
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.
You may be able to use either all or an empty string here instead.
67d8a88
to
61f9e36
Compare
lines: { | ||
all: { | ||
required: [ | ||
'Instance Name:', |
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.
'Instance Name:', | |
/Instance Name: "\w+"/, |
} | ||
}, | ||
{ | ||
name: "auxiliary/scanner/mssql/mssql_schemadump", |
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.
Not a blocker; Maybe we should populate the mssql database with something useful so these modules have more useful output
lines: { | ||
all: { | ||
required: [ | ||
'Instance Name:' |
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.
'Instance Name:' | |
/Instance Name: "\w+"/, |
skipped: false, | ||
}, | ||
{ | ||
name: "auxiliary/scanner/mssql/mssql_hashdump", |
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.
I think this module needs updated to support windows server 2022? Or it needs a print_status message to say that it's not doing anything
i.e. version is:
[5] pry(#<Msf::Modules::Auxiliary__Scanner__Mssql__Mssql_hashdump::MetasploitModule>)> version_year
=> "2022"
But the code handles:
metasploit-framework/modules/auxiliary/scanner/mssql/mssql_hashdump.rb
Lines 156 to 174 in 9e670d2
def mssql_hashdump(version_year) | |
is_sysadmin = mssql_query(mssql_is_sysadmin())[:rows][0][0] | |
if is_sysadmin == 0 | |
print_error("The provided credentials do not have privileges to read the password hashes") | |
return nil | |
end | |
case version_year | |
when "2000" | |
results = mssql_query(mssql_2k_password_hashes())[:rows] | |
when "2005", "2008", "2012", "2014" | |
results = mssql_query(mssql_2k5_password_hashes())[:rows] | |
end | |
return results | |
end |
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.
It looks like the 2005, etc, bucket handles this query just fine:
when "2005", "2008", "2012", "2014"
results = mssql_query(mssql_2k5_password_hashes())[:rows]
Result
[7] pry(#<Msf::Modules::Auxiliary__Scanner__Mssql__Mssql_hashdump::MetasploitModule>)> results = mssql_query(mssql_2k5_password_hashes())
=> {:sql=>"SELECT name, password_hash FROM master.sys.sql_logins",
:errors=>[],
:colinfos=>
[{:utype=>256, :flags=>8, :type=>231, :id=>:string, :max_size=>256, :codepage=>1033, :cflags=>208, :charset_id=>52, :msg_len=>4, :name=>"name"},
{:utype=>0, :flags=>33, :type=>165, :id=>:hex, :max_size=>256, :msg_len=>13, :name=>"password_hash"}],
:colnames=>["name", "password_hash"],
:rows=>
[["sa", "0200ade13faac48dbeb54dafd46d5611ce47b6f254072ae9d0be46f8e492759f2a59e4a651ae30e82206000aa9427dfcb90e8a130a2f3e813dad5edc6195a2a40f925ae756f1"],
["##MS_PolicyEventProcessingLogin##",
"020030db0ac7c247089e8047a9df006b507b3ef947fba7a7e0d3e33e434493160bba5dc12621d1b560f389faaddb50a35dfbbc0b4f7873480ca433a52eb82fa0af1fe5eeae2d"],
["##MS_PolicyTsqlExecutionLogin##",
"0200e7b8d1f6d5500faf98bc492a2b813f0d6a1831370c5e7a072c5a67063d197798fb41a2ff47bae0d78dbc61850d6106b9734d579f1f1d7a20157060956fa86d745274e201"]],
:done=>{:status=>16, :cmd=>193, :rows=>3}}
But the john
hash logic will need to be updated too so it's handled properly 93da4dc
There's some tweaks to make here still, but I'm good with this as a first pass - since we've got another PR that wants to make use of this test suite functionality we can make any remaining tweaks over there We'll ticket the hashdump module enhancements separately |
Release NotesAdds a set of acceptance tests for MSSQL modules |
This adds MSSQL session type acceptance tests
Creating a session:
Load test modules:
Running test module:
Running test suite (outside of msfconsole):
Verification: