stihl не предоставил(а) никакой дополнительной информации.
Background
I was recently in a situation where I needed to pivot from a compromised windows endpoint to my target’s Entra tenancy. The usual go-to in this scenario is to extract the primary refresh token (PRT) from the endpoint via beacon (using BOFs like Для просмотра ссылки ВойдиDuring a quick chat, my good friend Для просмотра ссылки Войди
In short, the BOF works by leveraging the user already being authenticated to Entra via the browser. It starts by launching a new browser window and initiating an Для просмотра ссылки Войди
The BOF's approach has various advantages, one of them being that all requests originate from the end-user’s machine and IP address. However, an important caveat to note for this BOF is that the specified client ID must allow “Для просмотра ссылки Войди
Redirect URI
Unfortunately, because the redirect_uri parameter is set to localhost, it limits the number of client IDs that can be used with this technique - especially if you wanted to leverage the family of client ID (Для просмотра ссылки ВойдиSearching through the Для просмотра ссылки Войди
- Microsoft Azure CLI
- Microsoft Azure PowerShell,
- Visual Studio – Legacy
Microsoft’s Native Client Redirect URI
Microsoft provides a predefined redirect URI called the native client Для просмотра ссылки ВойдиTo get a better understanding of the authcode flow in action, check out JUMPSEC’s tool called Для просмотра ссылки Войди
Для просмотра ссылки Войди
JUMPSEC’s TokenSmith tool being used with the “authcode” functionality, generating an authorization code flow URL (Microsoft Teams client ID).
It occurred to me that the authorization code also resides in the window title. If we extracted it from there, it could allow us to use the native client redirect URI instead, giving us access to a much larger range of FOCIs and removing the restriction of only being able to use FOCIs that allow "Для просмотра ссылки Войди
Для просмотра ссылки Войди
Authorization code returned in URL and window title
There’s going to be multiple ways to do this, but the easiest to PoC I could come up with was extraction via GetWindowTextA API. With this approach, we could carry out authcode flows against a greater number of FOCIs - including our favourites like Teams, Copilot, Edge, etc. This can make a massive difference in terms of OPSEC.
I noted the following first-party FOCIs allow the “native client” redirect URI:
BOF or it didn’t happen
As a basic proof-of-concept, I threw together a BOF that does the following:- Opens a browser window to the authcode flow URL (for a client ID and scope)
- Extracts the returned code from the window title
- Uses the code to request and obtain the tokens
Код:
beacon> entra-authcode-flow <clientid> <scope>
You can find the BOF and usage instructions at my GitHub, Для просмотра ссылки Войди
Closing Thoughts
It goes without saying, but this is probably for edge-case scenarios only. In my eyes, obtaining the PRT is an easier and more reliable method for identity persistence. This was purely a concept that I wanted to try out, and I was pleased to see that it worked somewhat reliably for me and my team.Again, the most important benefit with this approach (for the red team) is that all authentication requests and token requests originate from the compromised endpoint. When paired with your favourite post-exploitation tools like Для просмотра ссылки Войди
Для просмотра ссылки Войди