DART CTF

A couple month ago I stumbled upon a challenge that was presented by Altered Security Unfortunately I lost all my previous documentation on how I did it and wasn't able to recover it. So let's do it again and dive into the world of Azure pentesting ;)

How Can You Start?

Fairly simple, just visit dartctf.enterprisesecurity.io and login using your googlemail address. Besides that, you may need a couple of additional tools.

Tools

NAME
DESCRIPTION
LINK
NAME
DESCRIPTION
LINK

Azure REST API reference

Reference to the Azure REST Api

Azure Pentesting

Hacktricks Collection of Azure Pentesting Tipps & Tricks

Flag 1 - To The Moon

After logging in we're presented with a URL to access the CTF and start our mission The DART Mission

Enumeration: Webpage

First, let's open the webpage and our devconsole. Browsing the page as intended and checking resources that have been loaded.

We can clearly see that a variables.css file has been loaded from GitHub and an image that is hosted on a Blob within Azure.

GitHub Repo

We've seen that variables.css is being loaded from GitHub, so let's check the repo and commits.

Browsing through the commits, we can spot our long awaited first flag and a logic app endpoint! https://prod-61.eastus.logic.azure.com:443/workflows/250827f3ebc54c368f85643619f38ce3/triggers/manual/paths/invoke/test?

Flag 2 - SAS, Blobs & APIs

Since the page has been fully enumerated and there's nothing else to be found, we should dive into Azure Blob Storage

SAS Token

Maybe you think that the URL looks a bit odd. That's the case because it contains a shared access signature (SAS) token. That token can be used to delegate access to certain resources within an Azure storage account.

Azure Blob Storage: Access Granted

To connect, we can utilize an application called Azure Storage-Explorer

Instead of using the full url, we'll only use a part of it to check if the token is wrongly scoped and we're able to access the whole container

https://tsarray.blob.core.windows.net/azure-webjobs-secrets/DART.jpg?sv=2021-12-02&ss=b&srt=sco&sp=rl&se=2025-05-01T19:00:19Z&st=2023-05-01T11:00:19Z&spr=https,http&sig=pMFZaRK7jfzs3GnvL1%2FoFss5g6XynaEV98wCh%2Bd68Kk%3D

Sure enough, it worked!

Azure Blob Storage: Digging Deeper

So what are we seeing here?

Folder: rosarray

This folder contains some json files which consist of keys that are encrypted and are no use for us. Luckily that's not all, we're also able to recover a functions 4.0 app endpoint

rosarray.azurewebsites.net

File: OSIRIX-REx.txt

That's an interesting file. When looking at the content, we get a string of characters that could be an GUID

6de8103e-049a-4f88-9abf-41099a79ca53

But there's also another function that's maybe available to us. We can check if there's any version history available.

Taking a look at the older version reveals another SAS Token that can maybe used on rosarray.azurewebsites.net

api-version=2018-07-01-preview&sp=%2Ftriggers%2Fmanual%2Frun&sv=1.0&sig=avLLG0xOCALGGT-7zmIJsddcUiL5o2GOijT4mPSA4JY

Fuzzing - Find API Endpoints

Opening https://prod-61.eastus.logic.azure.com:443/workflows/250827f3ebc54c368f85643619f38ce3/triggers/manual/paths/invoke/test? and appending the SAS Token we've found results in an error

So let's check if we can find any other API Endpoints

Sure enough, we're lucky and identify endpoints /debug & /action

/debug

When visiting the debug endpoint, we're presented a piece of code and Flag 2! We're going to "crack" that code in our next chapter

Flag 3 - Reversing & API

Decrypt: Reverse XOR

Remember the code found on /debug? Let's get it decrypted, easier than you might think

The encryption here is a simple XOR operation, which is a reversible operation. To decrypt the data, you would need to XOR it again with the same encryption key (Imp) to retrieve the original MyValue.

Decrypting it results in an Azure Function key 4YLHkGDuJGryZzbJhCZSyPEnl554oTU2U_lQDEl1h6YMAzFuLeZBDQ==

Accessing: Function App Endpoints

We discovered a list of function app endpoints when we started our journey. Let's try to use the key we've just found and check if we're able to access any endpoints.

By the way: Another piece to the puzzle was found on /action. This tells us how to use the code.

/api/Blanket

Blanket seems to be our target this time. Opening the page will display a cool message and Flag 3!

Flag 4 - More API Endpoints

Next up is Flag 4 which can be retrieved by visiting the /action endpoint we discovered earlier

/action

Action Endpoint contains a code that will be used to dive deeper into another flag and traverse further into Azure

Flag 5 - Following the Endpoints

Flag 5 is also pretty easy, we just have to follow the path

/api/Canister

We're able to construct the next url using code we've found on /action endpoint Opening the following URL will result in some json data that reveals Flag 5 and another function key including url

Flag 6 - Still APIs?!

/api/Deployer

Opening the url will result in an error, but we still got Flag 6 ;)

Flag 7 - SSRF

Maybe we're getting into Azure itself. Let's see how we can proceed ;)

/api/Deployer

When calling our /api/Deployer endpoint, we're getting a message that we're missing a required query string parameter

Adding the query parameter will result in an interesting error

That sounds like the function is relaying our request to an Endpoin we define JACKPOT ;) Smells like SSRF, which means we're able to contact the internal Metadata Endpoint!

Azure: Enumeration

Since we're now equipped with an access_token, it's time to start enumeration on azure!

A reference that might come in handy Azure REST API reference documentation | Microsoft Learn

To make this easier just dump the access_token in a variable

Subscription

Getting details about the subscription

Subscriptions - List - REST API (Azure Subscription | Microsoft Learn)

Resources in Subscription

Getting all resources in current subscription

Resources - List - REST API (Azure Resource Management) | Microsoft Learn

Looks like we have access to a storage account named coresat. Using our credentials, we're not able to move forward as they are for management.

Enumerate: Storage Account

First, we need to obtain a new token to access the storage account

Next, we can List Containers in our target storage account List Containers (REST API) - Azure Storage | Microsoft Learn

Okay... Our container is called datahandling. Let's see what is inside List Blobs (REST API) - Azure Storage | Microsoft Learn

Read Files: Storage Account

So we have two blobs: LORRI-Cert. Txt and Flag 7. Txt Time to get them Get Blob (REST API) - Azure Storage | Microsoft Learn

Flag 7.txt

LORRI-Cert.txt

When we try to get LORRI-Cert. Txt curl complains about "binary output". To fix that I save it the content to a file.

Flag 8 - Service Principal

I was guessing that LORRI-Cert. Txt was our next step to get to Flag 8. Decoding the base 64 reveals that it is some kind of certificate.

Using google, I found a way to login as a service principal using az-cli on linux that was using a certificate. That's where the string that we've found in xyz comes in play.

Get Tenant Details

We need the Tenant ID to craft our login command

Converting Cert

First, we have to decode the base 64 to get a PFX File.

Next up is converting it to a default pem file and removing the password

Logging in

Azure: Enumeration

Like before, we're going to find out what we can access.

![](attachments/az_keyvault_1 1.png)

Flag 8 - Found

Flag 9 - More Key Vault Fun

Flag 9 has something to do with the entry we were able to find in keyvault. The name looks like an application ID, so maybe we're able to recover the client secret

Decryption Using Encryption Keys

Since the entry I found is encrypted, I checked if I have access to any keys and sure I do. About keys - Azure Key Vault | Microsoft Learn

Decrypt Secret

There's an easy way to do that using the az cli utility. az keyvault key decrypt | Microsoft Learn

Loot

Login as New Service Principal

More Enumeration

And there's access to Flag 9 ;)

Final Flag - CosmoDB

As seen before we have access to a DocumentDB resource which is the name for a cosmos db

Unfortunately, we're unable to perform any kind of action on that resource except listing its configuration

If we try to access the document endpoint, we're shown an error message

So maybe we can use the "Ascenion" entry, which we were able to find using our new credentials

Decrypting should be straight forward, like we did during Flag 9.

It failed due to "BadParameter".

Maybe like with Storage Blobs, there's some kind of history that could help us?

So let's try to decrypt the secret again using another version

If you're lazy like me, just decode base 64 result in one go.

Cosmos DB: Access

Using that string, we're maybe able to access cosmos db by crafting a connection string

First, let's visit https://cosmos.azure.com/ where we can connect to a cosmos db using a connection string.

After signing in, we can explore the NOSQL API and look for items that are maybe of interest for us. Sure enough we will find the last flag

Last updated