Based on feedback in the comments on this answer, the situation is this:
There is an explicitly-created
BUILTIN\Administrators group login in SQL Server that has been denied
CONNECT to the database engine.
There is no other
sysadmin-level login available, including the
NT AUTHORITY\SYSTEM login that gets created by default.
SQL Server does not allow a user to disable the
BUILTIN\Administrators login, but it can still be denied
CONNECT. I consider this a bug, as it's obvious that the inability to disable the login outright was hard-coded into the engine to avoid scenarios like this.
I'm unable to get in after applying that permission.
You will have to either find a way to edit the contents of the
master database to get rid of the
DENY permission (totally unsupported, and at your own peril), reinstall the database engine from the installation media, or I suppose you could attempt to brute-force the
I don't believe you can simply rebuild
master as that requires connecting and authenticating against the database engine, which isn't available here.