-
Notifications
You must be signed in to change notification settings - Fork 14.6k
Add an SMB to MSSQL NTLM Relay module #20637
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
base: master
Are you sure you want to change the base?
Conversation
It's redundant with the Mssql::Auth option which is an enum and supports all the authentication mechanisms. This eliminates the ambiguity between the meaning and precedence of the options.
lib/msf/core/exploit/remote/smb/relay/ntlm/target/mssql/client.rb
Outdated
Show resolved
Hide resolved
| ---- --------------- -------- ----------- | ||
| CHOST no The local client address | ||
| CPORT no The local client port | ||
| Proxies no A proxy chain of format type:host:port[,type:host:port][...]. Supported proxies: sapni, socks4, http, socks5, socks5 |
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.
| Proxies no A proxy chain of format type:host:port[,type:host:port][...]. Supported proxies: sapni, socks4, http, socks5, socks5 | |
| Proxies no A proxy chain of format type:host:port[,type:host:port][...]. Supported proxy types: sapni, socks4, http, socks5, socks5 |
If the domain is set, using NTLM where the domain is used, otherwise use plaintext / sql authentiction.
df77514 to
000d310
Compare
| Msf::OptString.new('DATABASE', [ false, 'The database to authenticate against', '']), | ||
| Msf::OptString.new('USERNAME', [ false, 'The username to authenticate as', 'sa']), |
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.
These seemed very wrong. At least on the database server I freshly installed, there is no MSSQL database. Using this as the default value meant that authentication was failing unless I explicitly cleared it. If the credentials are correct but a database is specified and it doesn't exist, authentication will fail.
Also the default username that's created when the database is installed is sa not MSSQL.
This adds a new NTLM relay module for relaying from SMB to MSSQL servers. On success, an MSSQL session will be opened to allow the user to run arbitrary queries and some modules.
The authentication code in the existing MSSQL client module was pretty dense and not readily reusable. This also refactors that to break down the different authentication mechanisms into their own methods. Some structures were migrated to BinData, which is the current way of doing binary protocols in Metasploit. Moving these structures into bindata reduces the code to create what is now the
MsTdsLogin7structure from 4 different places (3 login methods and now the relay). TheUSE_WINDOWS_AUTHENToption has been removed because it's redundant with the newMssql::Authoption which is more explicit. Specs are included for the bindata structures, showing that they can be constructed and parsed.There's still an issue which predates this work where if the target MSSQL server requires encryption, the session creation will fail after authentication. This is tracked in #18745.
Verification
RHOSTSto target the MSSQL server.net useto trigger an authentication attempt to metasploit that can be relayed to the target.Demo